text:
@ARTICLE{8362750,
author={Y. {Gan} and C. {Delimitrou}},
journal={IEEE Computer Architecture Letters},
title={The Architectural Implications of Cloud Microservices},
year={2018},
volume={17},
number={2},
pages={155-158},
keywords={cloud computing;computer centres;power aware computing;quality of service;quality of service;QoS;cloud microservices;open-source microservices;datacenter server design;end-to-end service;streaming service;movie renting;cloud utilization;architectural implications;Motion pictures;Servers;Electric breakdown;Videos;Quality of service;Open source software;Cloud computing;Super (very large) computers;distributed applications;application studies resulting in better multiple-processor systems},
doi={10.1109/LCA.2018.2839189},
ISSN={1556-6056},
month={July},}

repository: Wang-Xinkai/starter-academic

repo_name: Wang-Xinkai/starter-academic


text:
@Article{hess-2019-565,
AUTHOR = {Zuo, G. and Luo, J. and Wang, N. and Lian, Y. and He, X.},
TITLE = {Two-stage Variational Mode Decomposition and Support Vector Regression for Streamflow Forecasting},
JOURNAL = {Hydrology and Earth System Sciences Discussions},
VOLUME = {2019},
YEAR = {2019},
PAGES = {1--38},
URL = {https://www.hydrol-earth-syst-sci-discuss.net/hess-2019-565/},
DOI = {10.5194/hess-2019-565}
}

license: MIT

license_type: permissive

branch_name: refs/heads/master

extension: bib


text:
@article{DiegoTransfer2019,
  title = {Transfer entropy computation using the Perron-Frobenius operator},
  author = {Diego, David and Haaga, Kristian Agas\o{}ster and Hannisdal, Bjarte},
  journal = {Phys. Rev. E},
  volume = {99},
  issue = {4},
  pages = {042212},
  numpages = {17},
  year = {2019},
  month = {Apr},
  publisher = {American Physical Society},
  doi = {10.1103/PhysRevE.99.042212},
  url = {https://link.aps.org/doi/10.1103/PhysRevE.99.042212}
}

repository: earthsystemevolution/website

repo_name: earthsystemevolution/website

gha_license_id: MIT

gha_language: Jupyter Notebook


text:
package lockedresourcecontroller

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"strings"
	"sync"

	"github.com/go-logr/logr"
	"github.com/redhat-cop/operator-utils/pkg/util"
	"github.com/redhat-cop/operator-utils/pkg/util/apis"
	"github.com/redhat-cop/operator-utils/pkg/util/lockedresourcecontroller/lockedpatch"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/client-go/dynamic"
	"k8s.io/client-go/util/jsonpath"
	"k8s.io/client-go/util/workqueue"
	ctrl "sigs.k8s.io/controller-runtime"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/controller-runtime/pkg/controller"
	"sigs.k8s.io/controller-runtime/pkg/event"
	"sigs.k8s.io/controller-runtime/pkg/manager"
	"sigs.k8s.io/controller-runtime/pkg/predicate"
	"sigs.k8s.io/controller-runtime/pkg/reconcile"
	"sigs.k8s.io/controller-runtime/pkg/source"
	"sigs.k8s.io/yaml"
)

//LockedPatchReconciler is a reconciler that can enforce a LockedPatch
type LockedPatchReconciler struct {
	util.ReconcilerBase
	patch        lockedpatch.LockedPatch
	status       []metav1.Condition
	statusChange chan<- event.GenericEvent
	parentObject client.Object
	statusLock   sync.Mutex
	log          logr.Logger
}

//NewLockedPatchReconciler returns a new reconcile.Reconciler
func NewLockedPatchReconciler(mgr manager.Manager, patch lockedpatch.LockedPatch, statusChange chan<- event.GenericEvent, parentObject client.Object) (*LockedPatchReconciler, error) {

	// TODO create the object is it does not exists
	controllername := "patch-reconciler"

	reconciler := &LockedPatchReconciler{
		log:            ctrl.Log.WithName(controllername).WithName(apis.GetKeyShort(parentObject)).WithName(patch.GetKey()),
		ReconcilerBase: util.NewFromManager(mgr, mgr.GetEventRecorderFor(controllername+"_"+patch.GetKey())),
		patch:          patch,
		statusChange:   statusChange,
		parentObject:   parentObject,
		statusLock:     sync.Mutex{},
		status: []metav1.Condition([]metav1.Condition{{
			Type:               "Initializing",
			LastTransitionTime: metav1.Now(),
			Status:             metav1.ConditionTrue,
			ObservedGeneration: 0,
			Reason:             "ReconcilerManagerRestarting",
		}}),
	}

	controller, err := controller.New(controllername+"_"+patch.GetKey(), mgr, controller.Options{Reconciler: reconciler})
	if err != nil {
		return &LockedPatchReconciler{}, err
	}

	//create watcher for target
	gvk := getGVKfromReference(&patch.TargetObjectRef)
	groupVersion := schema.GroupVersion{Group: gvk.Group, Version: gvk.Version}
	obj := objectRefToRuntimeType(&patch.TargetObjectRef)
	mgr.GetScheme().AddKnownTypes(groupVersion, obj)

	err = controller.Watch(&source.Kind{Type: obj}, &enqueueRequestForPatch{
		reconcile.Request{
			NamespacedName: types.NamespacedName{
				Name:      patch.TargetObjectRef.Name,
				Namespace: patch.TargetObjectRef.Namespace,
			},
		},
	}, &referenceModifiedPredicate{
		ObjectReference: patch.TargetObjectRef,
	})
	if err != nil {
		return &LockedPatchReconciler{}, err
	}

	for _, sourceRef := range patch.SourceObjectRefs {
		gvk := getGVKfromReference(&patch.TargetObjectRef)
		groupVersion := schema.GroupVersion{Group: gvk.Group, Version: gvk.Version}
		obj := objectRefToRuntimeType(&patch.TargetObjectRef)
		mgr.GetScheme().AddKnownTypes(groupVersion, obj)
		err = controller.Watch(&source.Kind{Type: obj}, &enqueueRequestForPatch{
			reconcile.Request{
				NamespacedName: types.NamespacedName{
					Name:      sourceRef.Name,
					Namespace: sourceRef.Namespace,
				},
			},
		}, &referenceModifiedPredicate{
			ObjectReference: sourceRef,
		})
		if err != nil {
			return &LockedPatchReconciler{}, err
		}
	}

	return reconciler, nil
}

func getGVKfromReference(objref *corev1.ObjectReference) schema.GroupVersionKind {
	return schema.FromAPIVersionAndKind(objref.APIVersion, objref.Kind)
}

func objectRefToRuntimeType(objref *corev1.ObjectReference) client.Object {
	obj := &unstructured.Unstructured{}
	obj.SetKind(objref.Kind)
	obj.SetAPIVersion(objref.APIVersion)
	obj.SetNamespace(objref.Namespace)
	obj.SetName(objref.Name)
	return obj
}

type enqueueRequestForPatch struct {
	reconcile.Request
}

func (e *enqueueRequestForPatch) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) {
	q.Add(e.Request)
}

// Update implements EventHandler
func (e *enqueueRequestForPatch) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
	q.Add(e.Request)
}

// Delete implements EventHandler
func (e *enqueueRequestForPatch) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
	q.Add(e.Request)
}

// Generic implements EventHandler
func (e *enqueueRequestForPatch) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) {
	q.Add(e.Request)
}

type referenceModifiedPredicate struct {
	corev1.ObjectReference
	predicate.Funcs
}

// Update implements default UpdateEvent filter for validating resource version change
func (p *referenceModifiedPredicate) Update(e event.UpdateEvent) bool {
	if e.ObjectNew.GetName() == p.ObjectReference.Name && e.ObjectNew.GetNamespace() == p.ObjectReference.Namespace {
		return !compareObjectsWithoutIgnoredFields(e.ObjectNew, e.ObjectOld)
	}
	return false
}

func (p *referenceModifiedPredicate) Create(e event.CreateEvent) bool {
	if e.Object.GetName() == p.ObjectReference.Name && e.Object.GetNamespace() == p.ObjectReference.Namespace {
		return true
	}
	return false
}

func (p *referenceModifiedPredicate) Delete(e event.DeleteEvent) bool {
	// we ignore Delete events because if we loosing references there is no point in trying to recompute the patch
	return false
}

func (p *referenceModifiedPredicate) Generic(e event.GenericEvent) bool {
	// we ignore Generic events
	return false
}

// we ignore the fields of resourceVersion and managedFields
func compareObjectsWithoutIgnoredFields(changedObjSrc runtime.Object, originalObjSrc runtime.Object) bool {
	changedObj := changedObjSrc.DeepCopyObject().(*unstructured.Unstructured)
	originalObj := originalObjSrc.DeepCopyObject().(*unstructured.Unstructured)

	changedObj.SetManagedFields(nil)
	changedObj.SetResourceVersion("")
	originalObj.SetManagedFields(nil)
	originalObj.SetResourceVersion("")

	changedObjJSON, _ := json.Marshal(changedObj)
	originalObjJSON, _ := json.Marshal(originalObj)

	return (string(changedObjJSON) == string(originalObjJSON))
}

//Reconcile method
func (lpr *LockedPatchReconciler) Reconcile(context context.Context, request reconcile.Request) (reconcile.Result, error) {
	//gather all needed the objects
	targetObj, err := lpr.getReferecedObject(&lpr.patch.TargetObjectRef)
	if err != nil {
		lpr.log.Error(err, "unable to retrieve", "target", lpr.patch.TargetObjectRef)
		return lpr.manageErrorNoTarget(err)
	}
	sourceMaps := []interface{}{}
	for _, objref := range lpr.patch.SourceObjectRefs {
		sourceObj, err := lpr.getReferecedObject(&objref)
		if err != nil {
			lpr.log.Error(err, "unable to retrieve", "source", sourceObj)
			return lpr.manageError(targetObj, err)
		}
		sourceMap, err := lpr.getSubMapFromObject(sourceObj, objref.FieldPath)
		if err != nil {
			lpr.log.Error(err, "unable to retrieve", "field", objref.FieldPath, "from object", sourceObj)
			return lpr.manageError(targetObj, err)
		}
		sourceMaps = append(sourceMaps, sourceMap)
	}

	//compute the template
	var b bytes.Buffer
	err = lpr.patch.Template.Execute(&b, sourceMaps)
	if err != nil {
		lpr.log.Error(err, "unable to process ", "template ", lpr.patch.Template, "parameters", sourceMaps)
		return lpr.manageError(targetObj, err)
	}

	bb, err := yaml.YAMLToJSON(b.Bytes())

	if err != nil {
		lpr.log.Error(err, "unable to convert to json", "processed template", b.String())
		return lpr.manageError(targetObj, err)
	}

	patch := client.RawPatch(lpr.patch.PatchType, bb)

	err = lpr.GetClient().Patch(context, targetObj, patch)

	if err != nil {
		lpr.log.Error(err, "unable to apply ", "patch", patch, "on target", targetObj)
		return lpr.manageError(targetObj, err)
	}

	return lpr.manageSuccess(targetObj)
}

//GetKey return the patch no so unique identifier
func (lpr *LockedPatchReconciler) GetKey() string {
	return lpr.patch.GetKey()
}

func (lpr *LockedPatchReconciler) getReferecedObject(objref *corev1.ObjectReference) (*unstructured.Unstructured, error) {
	var ri dynamic.ResourceInterface
	res, err := lpr.getAPIReourceForGVK(schema.FromAPIVersionAndKind(objref.APIVersion, objref.Kind))
	if err != nil {
		lpr.log.Error(err, "unable to get resourceAPI ", "objectref", objref)
		return &unstructured.Unstructured{}, err
	}
	nri, err := lpr.GetDynamicClientOnAPIResource(res)
	if err != nil {
		lpr.log.Error(err, "unable to get dynamicClient on ", "resourceAPI", res)
		return &unstructured.Unstructured{}, err
	}
	if res.Namespaced {
		ri = nri.Namespace(objref.Namespace)
	} else {
		ri = nri
	}
	obj, err := ri.Get(context.TODO(), objref.Name, metav1.GetOptions{})
	if err != nil {
		lpr.log.Error(err, "unable to get referenced ", "object", objref)
		return &unstructured.Unstructured{}, err
	}
	return obj, nil
}

func (lpr *LockedPatchReconciler) getSubMapFromObject(obj *unstructured.Unstructured, fieldPath string) (interface{}, error) {
	if fieldPath == "" {
		return obj.UnstructuredContent(), nil
	}

	jp := jsonpath.New("fieldPath:" + fieldPath)
	err := jp.Parse("{" + fieldPath + "}")
	if err != nil {
		lpr.log.Error(err, "unable to parse ", "fieldPath", fieldPath)
		return nil, err
	}

	values, err := jp.FindResults(obj.UnstructuredContent())
	if err != nil {
		lpr.log.Error(err, "unable to apply ", "jsonpath", jp, " to obj ", obj.UnstructuredContent())
		return nil, err
	}

	if len(values) > 0 && len(values[0]) > 0 {
		return values[0][0].Interface(), nil
	}

	return nil, errors.New("jsonpath returned empty result")
}

func (lpr *LockedPatchReconciler) getAPIReourceForGVK(gvk schema.GroupVersionKind) (metav1.APIResource, error) {
	res := metav1.APIResource{}
	discoveryClient, err := lpr.GetDiscoveryClient()
	if err != nil {
		lpr.log.Error(err, "unable to create discovery client")
		return res, err
	}
	resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
	if err != nil {
		lpr.log.Error(err, "unable to retrieve resouce list for:", "groupversion", gvk.GroupVersion().String())
		return res, err
	}
	for _, resource := range resList.APIResources {
		if resource.Kind == gvk.Kind && !strings.Contains(resource.Name, "/") {
			res = resource
			res.Namespaced = resource.Namespaced
			res.Group = gvk.Group
			res.Version = gvk.Version
			break
		}
	}
	return res, nil
}

func (lpr *LockedPatchReconciler) manageError(target *unstructured.Unstructured, err error) (reconcile.Result, error) {
	condition := metav1.Condition{
		Type:               apis.ReconcileError,
		LastTransitionTime: metav1.Now(),
		Message:            err.Error(),
		Reason:             apis.ReconcileErrorReason,
		Status:             metav1.ConditionTrue,
		ObservedGeneration: target.GetGeneration(),
	}
	lpr.setStatus(apis.AddOrReplaceCondition(condition, lpr.GetStatus()))
	return reconcile.Result{}, err
}

func (lpr *LockedPatchReconciler) manageErrorNoTarget(err error) (reconcile.Result, error) {
	condition := metav1.Condition{
		Type:               apis.ReconcileError,
		LastTransitionTime: metav1.Now(),
		Message:            err.Error(),
		Reason:             apis.ReconcileErrorReason,
		Status:             metav1.ConditionTrue,
		ObservedGeneration: 0,
	}
	lpr.setStatus(apis.AddOrReplaceCondition(condition, lpr.GetStatus()))
	return reconcile.Result{}, err
}

func (lpr *LockedPatchReconciler) manageSuccess(target *unstructured.Unstructured) (reconcile.Result, error) {
	condition := metav1.Condition{
		Type:               apis.ReconcileSuccess,
		LastTransitionTime: metav1.Now(),
		Reason:             apis.ReconcileSuccessReason,
		Status:             metav1.ConditionTrue,
		ObservedGeneration: target.GetGeneration(),
	}
	lpr.setStatus(apis.AddOrReplaceCondition(condition, lpr.GetStatus()))
	return reconcile.Result{}, nil
}

func (lpr *LockedPatchReconciler) setStatus(status []metav1.Condition) {
	lpr.statusLock.Lock()
	defer lpr.statusLock.Unlock()
	lpr.status = status
	if lpr.statusChange != nil {
		lpr.statusChange <- event.GenericEvent{
			Object: lpr.parentObject,
		}
	}
}

//GetStatus returns the status for this reconciler
func (lpr *LockedPatchReconciler) GetStatus() []metav1.Condition {
	lpr.statusLock.Lock()
	defer lpr.statusLock.Unlock()
	return lpr.status
}

repository: claudiumocanu/operator-utils

repo_name: claudiumocanu/operator-utils

extension: go


text:
% Extensive bib file for SUNDIALS
%
% Label convention:
%   One author:   first three letters of last name : two digit year
%   Two authors:  first two letters of last names : two digit year
%   More authors: first letter of last names : two digit year

%---------------------------------------------------------
% CURRENT SUNDIALS USER GUIDES
%---------------------------------------------------------

%
% ARKODE user guide
%
@techreport{arkode_ug,
author={Daniel R. Reynolds and David J. Gardner and Alan C. Hindmarsh
and Carol S. Woodward and Jean M. Sexton},
title={{User Documentation for ARKODE v5.6.0}},
institution={LLNL},
number={LLNL-SM-668082},
year        = 2023
}
%
% ARKODE examples
%
@techreport{arkode_ex,
author={Daniel R. Reynolds},
title={{Example Programs for ARKODE v5.6.0}},
institution={Southern Methodist University},
year        = 2023
}
%
% CVODE user guide
%
@techreport{cvode_ug,
author={A. C. Hindmarsh and R. Serban},
title={{User Documentation for CVODE v6.6.0}},
institution={LLNL},
number={UCRL-SM-208108},
year        = 2023
}
%
% CVODE examples
%
@techreport{cvode_ex,
author={A. C. Hindmarsh and R. Serban and D. R. Reynolds},
title={{Example Programs for CVODE v6.6.0}},
institution={LLNL},
note={UCRL-SM-208110},
year        = 2023
}
%
% CVODES user guide
%
@techreport{cvodes_ug,
author={A. C. Hindmarsh and R. Serban},
title={{User Documentation for CVODES v6.6.0}},
institution={LLNL},
note={UCRL-SM-208111},
year        = 2023
}
%
% CVODES examples
%
@techreport{cvodes_ex,
author={R. Serban and A. C. Hindmarsh},
title={{Example Programs for CVODES v6.6.0}},
institution={LLNL},
number={UCRL-SM-208115},
year        = 2023
}
%
% IDA user guide
%
@techreport{ida_ug,
author={A. C. Hindmarsh and R. Serban and A. Collier},
title={{User Documentation for IDA v6.6.0}},
institution={LLNL},
number={UCRL-SM-208112},
year        = 2023
}
%
% IDA examples
%
@techreport{ida_ex,
author={A. C. Hindmarsh and R. Serban and A. Collier},
title={{Example Programs for IDA v6.6.0}},
institution={LLNL},
number={UCRL-SM-208113},
year        = 2023
}
%
% IDAS user guide
%
@techreport{idas_ug,
author={R. Serban and C. Petra and A. C. Hindmarsh},
title={{User Documentation for IDAS v5.6.0}},
institution={LLNL},
number={UCRL-SM-234051},
year        = 2023
}
%
% IDAS examples
%
@techreport{idas_ex,
author={R. Serban and A. C. Hindmarsh},
title={{Example Programs for IDAS v5.6.0}},
institution={LLNL},
number={LLNL-TR-437091},
year        = 2023
}
%
% KINSOL user guide
%
@techreport{kinsol_ug,
author={A. M. Collier and A. C. Hindmarsh and R. Serban and C.S. Woodward},
title={{User Documentation for KINSOL v6.6.0}},
institution={LLNL},
number={UCRL-SM-208116},
year        = 2023
}
%
% KINSOL examples
%
@techreport{kinsol_ex,
author={A. M. Collier and R. Serban},
title={{Example Programs for KINSOL v6.6.0}},
institution={LLNL},
number={UCRL-SM-208114},
year        = 2023
}

%---------------------------------------------------------
% ORIGINAL USER GUIDES
%---------------------------------------------------------

%
% CVODE original report
%
@techreport{CoHi:94,
author={S. D. Cohen and A. C. Hindmarsh},
title={{CVODE User Guide}},
institution={LLNL},
number={UCRL-MA-118618},
month=sep, year=1994
}
%
% PVODE original report
%
@techreport{ByHi:98,
author={G. D. Byrne and A. C. Hindmarsh},
title={{User Documentation for PVODE, An ODE Solver for Parallel Computers}},
institution={LLNL},
number={UCRL-ID-130884},
month=may, year=1998
}
%
% IDA original report
%
@techreport{HiTa:99,
author={A. C. Hindmarsh and A. G. Taylor},
title={{User Documentation for \mbox{IDA}, a Differential-Algebraic Equation Solver
        for Sequential and Parallel Computers}},
institution={LLNL},
number={UCRL-MA-136910},
month=dec, year=1999
}
%
% KINSOL original report
%
@techreport{TaHi:98,
author={A. G. Taylor and A. C. Hindmarsh},
title={{User Documentation for KINSOL, A Nonlinear Solver for Sequential
        and Parallel Computers}},
institution={LLNL},
number={UCRL-ID-131185},
month=jul, year=1998
}

%---------------------------------------------------------
% Citations directly related to SUNDIALS solvers
%---------------------------------------------------------

%
% SUNDIALS ACM article
%
@article{HBGLSSW:05,
author={A. C. Hindmarsh and P. N. Brown and K. E. Grant and S. L. Lee
        and R. Serban and D. E. Shumaker and C. S. Woodward},
title={\mbox{SUNDIALS}, Suite of Nonlinear and Differential/Algebraic Equation Solvers},
journal={ACM Trans. Math. Softw.},
number={31},
pages = {363--396},
year=2005
}
%
% CVODES ASME article
%
@inproceedings{SeHi:05,
author={R. Serban and A. C. Hindmarsh},
title={\mbox{CVODES}, The Sensitivity-Enabled {ODE} Solver in \mbox{SUNDIALS}},
booktitle =  {Proceedings of the 5th International Conference on Multibody Systems,
Nonlinear Dynamics and Control},
publisher = {ASME},
address = {Long Beach, CA},
year=2005
}
%
% CVODE original article
%
@article{CoHi:96,
author={S. D. Cohen and A. C. Hindmarsh},
title={{\mbox{CVODE}, a Stiff/Nonstiff ODE Solver in C}},
journal={Computers in Physics},
volume={10(2)},
pages={138--143},
year=1996
}
%
% PVODE & IDA
%
@techreport{Hin:00,
author={A. C. Hindmarsh},
title={{The PVODE and IDA Algorithms}},
institution={LLNL},
number={UCRL-ID-141558},
month=dec, year=2000
}
%
% Report on PVODE and KINSOL
%
@techreport{HiTa:98,
author={A. C. Hindmarsh and A. G. Taylor},
title={{ PVODE and KINSOL: Parallel Software for Differential and Nonlinear Systems}},
institution={LLNL},
number={UCRL-ID-129739},
month=feb, year=1998
}
%
% SensPVODE user guide
%
@techreport{LHB:00,
author={S. L. Lee and A. C. Hindmarsh and P. N. Brown},
title={{User Documentation for \mbox{SensPVODE}, A Variant of {PVODE} for Sensitivity Analysis}},
institution={LLNL},
number={UCRL-MA-140211},
month=aug, year=2000
}
%
% SensIDA user guide
%
@techreport{LeHi:01,
author={S. L. Lee and A. C. Hindmarsh},
title={{User Documentation for \mbox{SensIDA}, A Variant of \mbox{IDA} for Sensitivity Analysis}},
institution={LLNL},
number={UCRL-MA-145712},
month=oct, year=2001
}
%
% SensKINSOL user guide
%
@techreport{GHT:03,
author={K. E. Grant and A. C. Hindmarsh and A. G. Taylor},
title={{User Documentation for SensKINSOL, a Variant of KINSOL for Sensitivity
        Analysis}},
institution={LLNL},
number={in preparation},
year=2003
}
%
% Problem test for PVODE
%
@techreport{Wit:96,
author={M. R. Wittman},
title={{Testing of PVODE, a Parallel ODE Solver}},
institution={LLNL},
number={UCRL-ID-125562},
month=aug, year=1996
}
%
% PVODE
%
@article{ByHi:99,
author={G. D. Byrne and A. C. Hindmarsh},
title={{PVODE, An ODE Solver for Parallel Computers}},
journal={Intl. J. High Perf. Comput. Apps.},
volume={13(4)},
pages={254--365},
year=1999
}

%---------------------------------------------------------
% Citations for solvers on which SUNDIALS is based
%---------------------------------------------------------

%
% DASSL
%
@book{BCP:96,
author={K. E. Brenan and S. L. Campbell and L. R. Petzold},
title={{Numerical Solution of Initial-Value Problems in Differential-Algebraic Equations}},
publisher={SIAM},
address={Philadelphia, Pa},
year=1996
}
%
% VODE/EPISODE
%
@article{BBH:89,
author={P. N. Brown and G. D. Byrne and A. C. Hindmarsh},
title={{VODE, a Variable-Coefficient ODE Solver}},
journal={SIAM J. Sci. Stat. Comput.},
volume={10},
pages={1038--1051},
year=1989
}
%
% DASPK
%
@article{BHP:94,
author={P. N. Brown and A. C. Hindmarsh and L. R. Petzold},
title={{Using Krylov Methods in the Solution of Large-Scale Differential-Algebraic Systems}},
journal={SIAM J. Sci. Comput.},
volume={15},
pages={1467--1488},
year=1994
}
%
% DASPK3.0 description
%
@article{LiPe:99a,
author={S. Li and L. R. Petzold},
title={{Software and Algorithms for Sensitivity Analysis of Large-Scale
        Differential-Algebraic Systems}},
journal={Journal of Computational and Applied Mathematics},
volume={125},
pages={131-145},
year=2000
}
@techreport{LiPe:99b,
author={S. Li and L. R. Petzold},
title={{Design of New \mbox{DASPK} for Sensitivity Analysis}},
institution={Dept. of Computer Science, UCSB},
year=1999
}
%
% NKSOL
%
@article{BrSa:90,
author={P. N. Brown and Y. Saad},
title={{Hybrid Krylov Methods for Nonlinear Systems of Equations}},
journal={SIAM J. Sci. Stat. Comput.},
volume={11},
pages={450--481},
year=1990
}
%
% VODPK
%
@inproceedings{Byr:92,
author={G. D. Byrne},
title={{Pragmatic Experiments with Krylov Methods in the Stiff ODE Setting}},
booktitle={Computational Ordinary Differential Equations},
editor={Cash, J.R. and Gladwell, I.},
publisher={Oxford University Press},
address={Oxford},
pages={323--356},
year=1992
}
%
% LSODE report
%
@techreport{RaHi:94,
author={K. Radhakrishnan and A. C. Hindmarsh},
title={{Description and Use of LSODE, the Livermore Solver for
        Ordinary Differential Equations}},
institution={LLNL},
number={UCRL-ID-113855},
month={march},
year=1994
}

%---------------------------------------------------------
% Citations related to the methods used in SUNDIALS
%---------------------------------------------------------

%
% General ODE/DAE
%
@book{AsPe:98,
author={U. M. Ascher and L. R. Petzold},
title={{Computer Methods for Ordinary Differential Equations and
        Differential-Algebraic Equations}},
publisher={SIAM},
address={Philadelphia, Pa},
year={1998}
}
@book{HWN:87,
author={E. Hairer and S. P. Norsett and G. Wanner},
title={{Solving Ordinary Differential Equations I}},
publisher={Springer-Verlag},
address={Berlin},
year=1987
}
@book{HaWa:91,
author={E. Hairer and G. Wanner},
title={{Solving Ordinary Differential Equations II, Stiff and Differential-Algebraic Problems}},
publisher={Springer-Verlag},
address={Berlin},
year=1991
}
@article{GGL:85,
author={C.W. Gear and B. Leimkuhler and G.K. Gupta},
title={{Automatic Integration of Euler-Lagrange Equations with Constraints}},
journal={J. Comput. Appl. Math.},
volume={12/13},
pages={77--90},
year=1985
}
%
% LMM articles
%
@article{BrHi:89,
author={P. N. Brown and A. C. Hindmarsh},
title={{Reduced Storage Matrix Methods in Stiff ODE Systems}},
journal={J. Appl. Math. \& Comp.},
volume={31},
pages={49--91},
year=1989
}
@article{ByHi:75,
author={G. D. Byrne and A. C. Hindmarsh},
title={{A Polyalgorithm for the Numerical Solution of Ordinary
Differential Equations}},
journal={ACM Trans. Math. Softw.},
volume={1},
pages={71--96},
year=1975
}
@article{JaSD:80,
author={K. R. Jackson and R. Sacks-Davis},
title={{An Alternative Implementation of Variable Step-Size Multistep
Formulas for Stiff ODEs}},
journal={ACM Trans. Math. Softw.},
volume={6},
pages={295--318},
year=1980
}
%
% BDF Stability Limit Detection
%
@inproceedings{Hin:92,
author={A. C. Hindmarsh},
title={{Detecting Stability Barriers in BDF Solvers}},
booktitle={Computational Ordinary Differential Equations},
editor={{J.R. Cash and I. Gladwell}},
publisher={Oxford University Press},
address={Oxford},
pages={87--96},
year=1992
}
@article{Hin:95,
author={A. C. Hindmarsh},
title={{Avoiding BDF Stability Barriers in the MOL
        Solution of Advection-Dominated Problems}},
journal={Appl. Num. Math.},
volume={17},
pages={311--318},
year=1995
}
%
% Projection methods for IVPs with constraints
%
@article{eich1993convergence,
  title={Convergence results for a coordinate projection method applied to mechanical systems with algebraic constraints},
  author={Eich, Edda},
  journal={SIAM Journal on Numerical Analysis},
  volume={30},
  number={5},
  pages={1467--1482},
  year={1993},
  publisher={SIAM}
}
@article{shampine1999conservation,
  title={Conservation laws and the numerical solution of ODEs, II},
  author={Shampine, LF},
  journal={Computers \& Mathematics with Applications},
  volume={38},
  number={2},
  pages={61--72},
  year={1999},
  publisher={Elsevier}
}
%
% Consistent initialization for DAE
%
@article{BHP:98,
author={P. N. Brown and A. C. Hindmarsh and L. R. Petzold},
title={{Consistent Initial Condition Calculation for Differential-Algebraic Systems}},
journal={SIAM J. Sci. Comput.},
volume={19},
pages={1495--1512},
year=1998
}
%
% Rootfinding
%
@techreport{HeSh:80,
author={K. L. Hiebert and L. F. Shampine},
title={{Implicitly Defined Output Points for Solutions of ODEs}},
institution={Sandia National Laboratories},
number={SAND80-0180},
month=feb, year=1980
}
%
% DAE Adjoint sensitivity
%
@article{CLPS:03,
author={Y. Cao and S. Li and L. R. Petzold and R. Serban},
title={{Adjoint Sensitivity Analysis for Differential-Algebraic Equations:
           The Adjoint {DAE} System and its Numerical Solution}},
journal = {SIAM J. Sci. Comput.},
volume  = {24(3)},
pages   = {1076--1089},
year    = 2003
}
%
% 2nd order sensitivity analysis
%
@article{OzBa:05,
author = {D.B. Ozyurt and P.I. Barton},
title={Cheap second order directional derivatives of stiff {ODE} embedded functionals},
journal={SIAM J. of Sci. Comp.},
volume={ 26(5)},
pages={1725--1743},
year=2005
}
%
% Staggered direct method for forward sensitivity
%
@article{CaSt:85,
author={M. Caracotsios and W. E. Stewart},
title={{Sensitivity Analysis of Initial Value Problems with
        Mixed ODEs and Algebraic Equations}},
journal={Computers and Chemical Engineering},
volume={9},
pages={359-365},
year=1985
}
%
% Simultaneous corrector method for forward sensitivity
%
@article{MaPe:97,
author={T. Maly and L. R. Petzold},
title={{Numerical Methods and Software for Sensitivity
        Analysis of Differential-Algebraic Systems}},
journal={Applied Numerical Mathematics},
volume={20},
pages={57-79},
year=1997
}
%
% Staggered corrector method for forward sensitivity
%
@article{FTB:97,
author={W. F. Feehery and J. E. Tolsma and P. I. Barton},
title={{Efficient Sensitivity Analysis of Large-Scale Differential-Algebraic Systems}},
journal={Applied Numer. Math.},
volume={25(1)},
pages={41--54},
year=1997
}
%
% Linear algebra
%
@book{GoVL:96,
author={G. H. Golub and C. F. Van Loan},
title={{Matrix computations}},
publisher={The Johns Hopkins University Press},
address={Baltimore, Md},
year=1996
}
%
% GMRES
%
@article{SaSc:86,
author={Y. Saad and M. H. Schultz},
title={{GMRES: A Generalized Minimal Residual
        Algorithm for Solving Nonsymmetric Linear Systems}},
journal={SIAM J. Sci. Stat. Comp.},
volume={7},
pages={856--869},
year=1986
}
%
% FGMRES
%
@article{Saa:93,
  author = {Saad, Y.},
  title = {A flexible inner-outer preconditioned {GMRES} algorithm},
  doi = {http://dx.doi.org/10.1137/0914028},
  journal = {SIAM J. Sci. Comput.},
  number = {2},
  pages = {461--469},
  publisher = {Society for Industrial and Applied Mathematics},
  address = {Philadelphia, PA, USA},
  volume = {14},
  year = 1993
}
%
% Bi-CGStab
%
@article{Van:92,
author={H. A. Van Der Vorst},
title={{Bi-CGSTAB: A Fast and Smoothly Converging Variant
        of Bi-CG for the Solution of Nonsymmetric Linear Systems}},
journal={SIAM J. Sci. Stat. Comp.},
volume={13},
pages={631--644},
year=1992
}
%
% TFQMR
%
@article{Fre:93,
author={R. W. Freund},
title={{A Transpose-Free Quasi-Minimal Residual Algorithm
        for Non-Hermitian Linear Systems}},
journal={SIAM J. Sci. Comp.},
volume={14},
pages={470--482},
year=1993
}
%
% PCG
%
@article{HeSt:52,
author={M. R. Hestenes and E. Stiefel},
title={{Methods of Conjugate Gradients for Solving Linear Systems}},
journal={J. Research of the National Bureau of Standards},
volume={49},
number={6},
pages={409--436},
year=1952
}
%
% KLU
%
@article{DaPa:10,
  title={Algorithm 907: {KLU}, a direct sparse solver for circuit simulation problems},
  author={Davis, T. A. and P. N. Ekanathan},
  journal={ACM Trans. Math. Softw.},
  volume={37},
  number={3},
  year={2010},
  publisher={ACM}
}
@Misc{KLU_site,
  title = {{KLU Sparse Matrix Factorization Library}},
  howpublished = {http://faculty.cse.tamu.edu/davis/suitesparse.html},
}
%
% SuperLU_MT
%
@article{Li:05,
    AUTHOR = {X. S. Li},
    TITLE = {An Overview of {SuperLU}: Algorithms, Implementation,
             and User Interface},
    journal = {{ACM} Trans. Math. Softw.},
    volume = {31},
    number = {3},
    month = {September},
    year = {2005},
    pages = {302--325},
}
@article{DGL:99,
    author  = {J. W. Demmel and J. R. Gilbert and X. S. Li},
    title   = {An Asynchronous Parallel Supernodal Algorithm for
                 Sparse Gaussian Elimination},
    journal = {SIAM J. Matrix Analysis and Applications},
    volume  = {20},
    number  = {4},
    pages   = {915--952},
    year    = {1999}
}
@Misc{SuperLUMT_site,
  title =        {{SuperLU\_MT Threaded Sparse Matrix Factorization Library}},
  howpublished = {http://crd-legacy.lbl.gov/~xiaoye/SuperLU/},
}
%
% SuperLU_DIST
%
@article{GDL:07,
  Author = {Laura Grigori and James W. Demmel and Xiaoye S. Li},
  Title = {Parallel Symbolic Factorization for Sparse {LU} with
      Static Pivoting},
  journal = {SIAM J. Scientific Computing},
  volume = {29},
  number = {3},
  pages = {1289-1314},
  year = {2007}
}
@article{LD:03,
     author = {Xiaoye S. Li and James W. Demmel},
     title = {{SuperLU\_DIST}: A Scalable Distributed-Memory Sparse Direct
              Solver for Unsymmetric Linear Systems},
     journal = {ACM Trans. Mathematical Software},
     month = {June},
     volume = {29},
     number = {2},
     pages = {110-140},
     year = {2003}
}
@techreport{SLUUG:99,
     AUTHOR = {X.S. Li and J.W. Demmel and J.R. Gilbert and L. Grigori and M. Shao and
          I. Yamazaki},
     INSTITUTION = {Lawrence Berkeley National Laboratory},
     NUMBER = {LBNL-44289},
     TITLE = {{SuperLU Users' Guide}},
     MONTH = {September},
     YEAR = {1999},
     NOTE = "\url{http://crd.lbl.gov/~xiaoye/SuperLU/}.
             Last update: August 2011"
}
@Misc{SuperLUDIST_site,
  title =        {{SuperLU\_DIST Parallel Sparse Matrix Factorization Library}},
  howpublished = {http://crd-legacy.lbl.gov/~xiaoye/SuperLU/},
}
%
% ADIFOR
%
@article{BCCGH:92,
author={C. Bischof and A. Carle and G. Corliss and A. Griewank and P. Hovland},
title={{ADIFOR - Generating Derivative Codes from Fortran Programs}},
journal={Scientific Programming},
volume={1},
pages= {11-29},
year=1992
}
%
% TAMC: reverse automatic differentiation (Fortran)
%
@article{GiKa:98,
author={R. Giering and T. Kaminski},
title={{Recipes for Adjoint Code Construction}},
journal={ACM Transactions on Mathematical Software},
volume={24(4)},
pages={437-474},
year=1998
}
%
% TAPENADE
%
@techreport{tapenade:04,
title = {TAPENADE 2.1 user's guide},
author = {L. Hasco{\''e}t and V Pascual},
typdoc = {Technical report},
number = {300},
institution = {INRIA},
year = {2004},
url = {http://hal.inria.fr/inria-00069880},
}
%
% ADOLC
%
@article{adolc:96,
 author = {Andreas Griewank and David Juedes and Jean Utke},
 title = {Algorithm 755: {ADOL-C}: a package for the automatic differentiation of algorithms written in C/C++},
 journal = {ACM Trans. Math. Softw.},
 volume = {22},
 number = {2},
 year = {1996},
 issn = {0098-3500},
 pages = {131--167},
 doi = {http://doi.acm.org/10.1145/229473.229474},
 publisher = {ACM},
 address = {New York, NY, USA},
 }

%---------------------------------------------------------
%---------------------------------------------------------

@article{ACR:79,
author={U. M. Ascher and J. Christiansen and R. D. Russel},
title={{A Collocation Solver for Mixed Order Systems of Boundary
        Value Problems}},
journal={Math. Comp.},
volume={33},
pages={659-679},
year={1979}
}
@book{AMR:95,
author={U. M. Ascher and R. M. Mattheij and R. D. Russell},
title={{Numerical solution of Boundary Value Problems for Ordinary
        Differential Equations}},
publisher={SIAM},
address={Philadelphia, Pa},
year=1995
}
@article{AsPe:93,
author={U. M. Ascher and L. R. Petzold},
title={{Stability of Computational Methods for Constrained Dynamics Systems}},
journal={SIAM J. Sci. Comput.},
volume={14(1)},
year={1993}
}

@article{Bal:96a,
author={K. Balla},
title={{Linear Subspaces for Linear DAEs of Index 1}},
journal={Computers Math. Applic.},
volume={32(4/5)},
pages={81--86},
year=1996
}
@article{Bal:96b,
author={K. Balla},
title={{Boundary Conditions and their Transfer for
        Differential Algebraic Equations of Index 1}},
journal={Computers Math. Applic.},
volume={31(10)},
pages={1--5},
year=1996
}
@article{BaMa:96,
author={K. Balla and R. M{\"a}rz},
title={{Transfer of Boundary Conditions for DAEs of Index 1}},
journal={SIAM J. Numer. Anal.},
volume={33(6)},
pages={2318--2332},
year=1996
}
@article{BaMa:00,
author={K. Balla and R. M{\"a}rz},
title={{An Unified Approach to Linear Differential Algebraic
        Equations and their Adjoint Equations}},
journal={Institute of Mathematics Technical Report, Humboldt University, Berlin},
year=2000
}
@article{BaMa:99,
author={K. Balla and R. M{\"a}rz},
title={{Linear Differential Algebraic Equations of Index 1
        and their Adjoint Equations}},
journal={Results in Mathematics},
volume={37},
pages={13-35},
year=2000
}
%
%
%
@Book{Ber:95,
author={D. P. Bertsekas},
title={{Nonlinear Programming}},
publisher={Athena Scientific},
address={Belmont, Massachusetts},
year=1995
}

%
%
%
@article{BGW:03,
author={P. N. Brown and K. E. Grant and C. S. Woodward},
title={{On the Calculation of Uncertainties for 3-D Time-Dependent Neutral Particle Transport}},
journal={J. of Comp. Phys.},
volume={submitted},
pages={},
year=2003
}

%
% PVODE for BOUT equations
%
@article{RXH:02,
author={T. D. Rognlien and X. Q. Xu and A. C. Hindmarsh},
title={{Application of Parallel Implicit Methods to Edge-Plasma
        Numerical Simulations}},
journal = {Journal of Computational Physics},
volume = {175},
pages = {249-268},
year = 2002
}
%
% Forward sensitivity analysis, radiation diffusion
%
@unpublished{LWG:03,
author={S. L. Lee and C. S. Woodward and F. Graziani},
title={{Analyzing Radiation Diffusion using Time-Dependent
        Sensitivity-Based Techniques}},
journal = {Journal of Computational Physics},
note = {To appear in J. on Comp. Phys.},
year = 2003
}
%
% Adjoint sensitivity
%
@article{Cac:81a,
author={D. G. Cacuci},
title={{Sensitivity Theory for Nonlinear Systems. I.
        Nonlinear Functional Analysis Approach}},
journal={J. Math. Phys.},
volume={22(12)},
pages={2794-2802},
year=1981
}
%
% Adjoint sensitivity
%
@article{Cac:81b,
author={D. G. Cacuci},
title={{Sensitivity Theory for Nonlinear Systems. II.
        Extension to Additional Classes of Responses}},
journal={J. Math. Phys.},
volume={22(12)},
pages={2803-2812},
year=1981
}

@article{CBT:91,
author={S. L. Campbell and N. K. Bichols and W. J. Terrel},
title={{Duality, Observability and Controllability for Linear Time-Varying Systems}},
journal={Circuits, Systems, Signal Process},
volume={10(4)},
pages={455--470},
year=1991
}

@book{CoLe:55,
author={E. A. Coddington and N. Levinson},
title={{Theory of Ordinary Differential Equations}},
publisher={McGraw-Hill},
address={New York},
year=1955
}

%
%
%
@Article{Den:81,
author={J. E. {Dennis Jr.} and D. M. Gay and R. E. Welsch},
title={{An Adaptive Nonlinear Least-Squares Algorithm}},
journal={ACM Transactions on Mathematical Software},
volume={7(3)} ,
pages={348-368},
year=1981
}
%
%
%
@article{DiEi:99,
author={L. Dieci and T. Eirola},
title={{On Smooth Decompositions of Matrices}},
journal={SIAM J. Matrix Anal. Appl.},
volume={20(4)},
pages={800--819},
year=1999
}
@article{Err:97,
author={R. M. Errico},
title={{What is an adjoint model?}},
journal={Bulletin of the American Meteorological Society},
volume={78(11)},
pages={2577-2591},
year=1997
}

@article{GhBa:97,
author={O. Ghattas and J. H. Bark},
title={{Optimal Control of Two- and Three-Dimensional Incompressible
        Navier-Stokes Flows}},
journal = {Journal of Computational Physics},
volume = {136},
pages = {231-244},
year = 1997
}

@article{GiPi:97,
author={M. B. Giles and N. A. Pierce},
title={{Adjoint Equations in CFD: Duality, Boundary Conditions and Solution Behavior}},
journal={AIAA Paper 97-1850},
volume={AIAA, New York},
year=1997
}
@article{GJLPS:98,
author={P. E. Gill and L. O. Jay and M. W. Leonard and L. R. Petzold and V. Sharma},
title={{An SQP Method for the Optimal Control of Large-Scale Dynamical Systems}},
journal={J. Comp. Appl. Math.},
volume={20},
pages={197-213},
year=2000
}

@article{HMM:98,
author={M. Hanke and E. I. Macana and R. M{\"a}rz},
title={{On Asymptotics in Case of Linear Index-2 Differential-Algebraic
        Equations}},
journal={SIAM J. Numer. Anal.},
volume={35},
pages={1326--1346},
year=1998
}

%
%
@book{Kel:68,
author={H. B. Keller},
title={{Numerical methods for two-point boundary-value problems}},
publisher={Blaisdel},
address={Waltham, Ma},
year=1968
}
@article{KBYPT:97,
author={D. Knapp and V. Barocas and K. Yoo and L. R. Petzold and R. Tranquillo},
title={{Rheology of Reconstituted Type I Collagen Gel in Confined Compression}},
journal={J. Rheology},
volume={41},
pages={971--993},
year=1997
}

@inproceedings{LeHo:01,
author={{S. L. Lee. and P. D. Hovland}},
title={{Sensitivity Analysis using Parallel {ODE} Solvers and Automatic Differentiation in C:
SensPVODE and ADIC}},
booktitle={Automatic Differentiation of Algorithms: From Simulation to Optimization},
editors={George Corliss, Christele Faure, Andreas Griewank, Laurent Hascoet, and Uwe Naumann},
publisher={Springer-Verlag},
address={New York},
pages={223--229},
year=2001
}

%
%
%
@inproceedings{KKPR:01,
author={S. Kohn and G. Kumfert and J. Painter and C. Ribbens},
title={{Divorcing Language Dependencies from a Scientific Software Library}},
booktitle={10th SIAM Conference on Parallel Processing},
address={Portsmouth, VA},
month={March},
year=2001
}
%
%
%
@article{Lew:98,
author={R. M. Lewis},
title={{Numerical Computation of Sensitivities and the
        Adjoint Approach}},
journal={ICASE technical report},
volume={97-61},
year=1997
}
%
% Neutron Transport
%
@book{LeMi:93,
author={E. E. Lewis and W. F. Miller},
title={{Computational Methods of Neutron Transport}},
publisher={American Nuclear Society},
address={La Grange Park, IL},
year=1993
}

%
% Comparison of methods for forward sensitivity
%
@article{LPZ:99,
author={S. Li and L. R. Petzold and W. Zhu},
title={{Sensitivity Analysis of Differential-Algebraic Equations: A Comparison of Methods
        on a Special Problem}},
journal={Applied Num. Math.},
volume={32},
pages={161--174},
year=2000
}
@article{Mac:99a,
author={L. Machiels},
title={{A Posteriori Finite Element Output Bounds for Discontinuous Galerkin Discretizations
        of Parabolic Problems}},
journal={Lawrence Livermore National Laboratory technical report},
volume={UCRL-JC-136614},
year=1999
}
@article{MaMaPa:99,
author={L. Machiels and Y. Maday and A. T. Patera},
title={{Output Bounds for Reduced-Order Approximations of Elliptic Partial
        Differential Equations}},
journal={MIT technical report},
volume={FML 99-5-1},
year=1999
}
%
% Adjoint equations (formal approach)
%
@book{MAS:96,
author={G. I. Marchuk and V. I. Agoshkov and V. P. Shutyaev},
title={{Adjoint Equations and Perturbation Algorithms}},
publisher={CRC Press},
address={Boca Raton, Fl},
year=1996
}

@article{Mar:00,
author={R. M{\"a}rz},
title={{Differential Algebraic Systems Anew}},
journal={Institute of Mathematics Technical Report, Humboldt University, Berlin},
year=2000
}
%
% Radiation Hydrodynamics
%
@book{Pom:73,
author={G. C. Pomraning},
title={{"The Equations of Radiation Hydrodynamics"}},
publisher={Pergamon Press},
address={Oxford},
year=1973
}

%
% Optimal control w/ forward sensitivities (cooptFM application)
%
@article{RKSP:00,
author={L. L. Raja and R. J. Kee and R. Serban and L. R. Petzold},
title={{Computational Algorithm for Dynamic Optimization of Chemical Vapor
        Deposition Processes in Stagnation Flow Reactors}},
journal={J. Electrochemical Soc.},
volume={147(7)},
pages={2718--2726},
year=2000
}

%
% Halo orbit paper
%
@article{SKLMPRW:02,
author={R. Serban and W. S. Koon and M. Lo and J. Marsden and L. R. Petzold and S. D. Ross and R. Wilson},
title={{Halo Orbit Mission Correction Maneuvers Using Optimal Control}},
journal={Automatica},
volume={38(4)},
pages={571--583},
year=2002
}
%
% cooptAM paper
%
@article{SLP:03,
author={R. Serban and S. Li and L. R. Petzold},
title={{Adaptive Algorithms for Optimal Control of Time-Dependent Partial
        Differential-Algebraic Equation Systems}},
journal={Int. J. Numer. Math. Eng.},
volume={57},
pages={1457--1569},
year=2003
}
%
% cooptFM description
%
@article{SePe:01,
author={R. Serban and L. R. Petzold},
title={{{COOPT} - A Software Package for Optimal Control of Large-Scale
        Differential-Algebraic Equation Systems}},
journal={J. Math. Comp. Sim.},
volume={56(2)},
pages={187--203},
year=2001
}
%
% ODE BVP adjoint sensitivity analysis
%
@article{SePe:02,
author={R. Serban and L. R. Petzold},
title={{Efficient Computation of Sensitivities for Ordinary Differential
        Equation Boundary Value Problems}},
journal={SIAM J. Num. An.},
volume={40(1)},
pages={220--232},
year=2002
}

%
%
%
@inproceedings{WGM:02,
author={C. S. Woodward and K. E. Grant and R. Maxwell},
title={{Applications of Sensitivity Analysis to Uncertainty Quantification for Variably Saturated Flow}},
booktitle={Computational Methods in Water Resources},
editor={{S. M. Hassanizadeh and R. J. Schotting and W. G. Gray and G. F. Pinder}},
publisher={Elsevier},
address={Amsterdam},
pages={73--80},
year=2002
}
%
% Inexact Newton Methods
%
@book{DeSc:96,
author={J. E. Dennis and R. B. Schnabel},
title={{Numerical Methods for Unconstrained Optimization and Nonlinear Equations}},
publisher={SIAM},
address={Philadelphia},
year=1996
}
@article{EiWa:96,
author={S. C. Eisenstat and H. F. Walker},
title={{Choosing the Forcing Terms in an Inexact Newton Method}},
journal={SIAM J. Sci. Comput.},
volume={17},
pages={16--32},
year=1996
}
@Article{EiWa:94,
author = {S. C. Eisenstat and H. F. Walker},
title = {{Globally Convergent Inexact {N}ewton Methods}},
journal = {SIAM J. Optimization},
volume = {4},
pages = {393-422},
year = {1994}
}
@Article{DES:82,
author = {R. S. Dembo and S. C. Eisenstat and T. Steihaug},
title = {{Inexact {N}ewton Methods}},
journal = {SIAM J. Numer. Anal.},
volume = {19},
pages = {400-408},
year = 1982
}
@Article{Bro:87,
author = {P. N. Brown},
title = {{A local convergence theory for combined inexact-{N}ewton/finite
          difference projection methods}},
journal = {SIAM J. Numer. Anal.},
volume = {24},
number = {2},
pages = {407--434},
year = 1987,
}
@book{Kel:95,
author = {C. T. Kelley},
title = {Iterative Methods for Solving Linear and Nonlinear Equations},
publisher = {SIAM},
address = {Philadelphia},
year = 1995
}
%
%
%
@Article{BrWo:01,
  author =      {P.~N.~Brown and C.~S.~Woodward},
  title =       {{Preconditioning Strategies for Fully Implicit Radiation
                 Diffusion with Material-Energy Transfer}},
  journal =     {SIAM J. Sci. Comput.},
  volume =       23,
  number =       2,
  pages =       {499--516},
  year =         2001
}
@Article{JoWo:01,
  author =      {J.~E.~Jones and C.~S.~Woodward},
  title =       {{{N}ewton-{K}rylov-Multigrid Solvers for Large-Scale,
                 Highly Heterogeneous, Variably Saturated Flow Problems}},
  journal =     {Advances in Water Resources},
  month =       jul,
  pages =       {763--774},
  year =        2001,
  volume =      24
}
@inproceedings{Woo:98,
  author =      {C.~S.~Woodward},
  title =       {{A {N}ewton-{K}rylov-Multigrid Solver for Variably Saturated
                 Flow Problems}},
  booktitle =   {Proc. of the Twelfth International Conference on
                 Computational Methods in Water Resources},
  publisher =   {Computational Mechanics Publications},
  volume =      {2},
  address =     {Southampton},
  pages =       {609--616},
  year =        1998
}

%
% Citations for IDA examples
%

@inproceedings{Rob:66,
author={H. H. Robertson},
title = {The solution of a set of reaction rate equations},
booktitle={Numerical analysis: an introduction},
editor={J. Walsh},
publisher={Academ. Press},
pages={178--182},
year=1966
}

@article{Bro:86,
author={Peter N. Brown},
title={Decay to uniform states in food webs},
journal={SIAM J. Appl. Math.},
volume={46},
pages={376--392},
year=1986
}

%
% Citations for KINSOL examples
%
@book{FlPa:99,
author={C. Floudas and P. Pardalos and
C. Adjiman and W. Esposito and Z. Gumus and
S. Harding and J. Klepeis and C. Meyer and C. Schweiger},
title={Handbook of Test Problems in Local and Global Optimization},
publisher={Kluwer Academic Publishers},
address={Dordrecht},
year={1999}
}

@book{Frank-Kam:55,
 author = {D. A. Frank-Kamenetskii and N. Thon},
 publisher = {Princeton University Press},
 title = {Diffusion and Heat Exchange in Chemical Kinetics},
 year = {1955}
}

%
% Citations for Picard, Anderson, Broyden
%
@Article{Walker-Ni09,
  author =       {H. F. Walker and P. Ni},
  title =        {{A}nderson Acceleration for Fixed-Point Iterations},
  year =         {2011},
  key =          {Walker-Ni09},
  journal =      {SIAM Jour. Num. Anal.},
  volume =       {49},
  number =       {4},
  pages =        {1715--1735}
}

@Article{Anderson65,
  author =       {D. G. Anderson},
  title =        {Iterative
    Procedures for Nonlinear Integral Equations},
  journal =      {J. Assoc. Comput. Machinery},
  year =         {1965},
  key =          {Anderson65},
  volume =       {12},
  pages =        {547-560}
}

@Article{Broyden65,
 author =       {C. G. Broyden},
 title =        {A class of methods for solving nonlinear simultaneous equations},
 journal =      {Math. Comp.},
 year =         {1965},
 key =          {Broyden65},
 volume =       {19},
 pages =        {577-593}
}

@Article{Fang-Saad09,
 author =       {H. Fang and Y. Saad},
 title =        {Two classes of secant methods for nonlinear acceleration},
 journal =      {Numer. Linear Algebra Appl.},
 year =         {2009},
 key =          {Fang-Saad09},
 volume =       {16},
 pages =        {197-221}
}

@Article{LWWY11,
  author =       {P. A. Lott and H. F. Walker and C. S. Woodward and U. M. Yang},
  title =        {An Accelerated {P}icard Method for Nonlinear Systems Related to Variably Saturated Flow},
  journal =      {Adv. Wat. Resour.},
  volume =       {38},
  pages =        {92--101},
  year =         {2012},
  key =          {LWWY11}
}

@Book{Ortega-Rheinbolt00,
  author =       {J.~M.~Ortega and W.~C.~Rheinbolt},
  title =        {Iterative solution of nonlinear equations in several variables},
  year =         {2000},
  publisher =    {SIAM},
  address =      {Philadelphia},
  note =         {Originally published in 1970 by Academic Press}
}

%
% HYPRE references
%
@techreport{hypre_um,
  title={Hypre user's manual},
  author={Falgout, R and Yang, UM},
  institution={LLNL},
  year={2015}
}

%
% MAGMA references
%
@article{magma_ref,
  title     = {{Towards dense linear algebra for hybrid GPU accelerated manycore systems}},
  author    = {Stanimire Tomov and Jack Dongarra and Marc Baboulin},
  booktitle = {Parallel Matrix Algorithms and Applications},
  doi       = {10.1016/j.parco.2009.12.005},
  issn      = {0167-8191},
  journal   = {Parallel Computing},
  month     = jun,
  number    = {5-6},
  pages     = {232--240},
  posted-at = {2010-12-17 09:48:58},
  priority  = {2},
  volume    = {36},
  year      = {2010}
}

%
% PETSc references
%
@TechReport{petsc-user-ref,
  Author = {Satish Balay and Shrirang Abhyankar and Mark F. Adams and Jed Brown and Peter Brune
            and Kris Buschelman and Lisandro Dalcin and Victor Eijkhout and William D. Gropp
            and Dinesh Kaushik and Matthew G. Knepley
            and Lois Curfman McInnes and Karl Rupp and Barry F. Smith
            and Stefano Zampini and Hong Zhang},
  Title = {{PETS}c Users Manual},
  Number = {ANL-95/11 - Revision 3.12},
  Institution = {Argonne National Laboratory},
  Year = {2019}
}

@Misc{petsc-web-page,
  author = {Satish Balay and Shrirang Abhyankar and Mark~F. Adams and Jed Brown and Peter Brune
            and Kris Buschelman and Lisandro Dalcin and Victor Eijkhout and William~D. Gropp
            and Dinesh Kaushik and Matthew~G. Knepley
            and Lois Curfman McInnes and Karl Rupp and Barry~F. Smith
            and Stefano Zampini and Hong Zhang and Hong Zhang},
  title =  {{PETS}c {W}eb page},
  url =    {http://www.mcs.anl.gov/petsc},
  howpublished = {\url{http://www.mcs.anl.gov/petsc}},
  year = {2016}
}

%
% CUDA references
%

@book{cheng2014professional,
  title={Professional Cuda C Programming},
  author={Cheng, John and Grossman, Max and McKercher, Ty},
  year={2014},
  publisher={John Wiley \& Sons}
}

@techreport{nvidia2017samples,
  title={CUDA Samples: Reference Manual},
  author={NVidia, CUDA},
  year={2017},
  institution={TRM-06704-001 v8}
}

@Misc{cuda_site,
  title = {{NVIDIA CUDA Programming Guide}},
  howpublished = {https://docs.nvidia.com/cuda/index.html}
}

@Misc{cuSOLVER_site,
  title = {{NVIDIA cuSOLVER Programming Guide}},
  howpublished = {https://docs.nvidia.com/cuda/cusolver/index.html}
}

@Misc{cuSPARSE_site,
  title = {{NVIDIA cuSPARSE Programming Guide}},
  howpublished = {https://docs.nvidia.com/cuda/cusparse/index.html}
}

%
% ROCm/HIP references
%

@Misc{rocm_site,
  title = {{AMD ROCm Documentation}},
  howpublished = {https://rocmdocs.amd.com/en/latest/index.html}
}

%
% oneAPI references
%

@Misc{oneAPI_site,
  title = {{Intel oneAPI Programming Guide}},
  howpublished = {https://software.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top.html}
}

%
% RAJA references
%

@TechReport{raja,
 author = {R. D. Hornung and J. A. Keasler},
 title = {The RAJA Poratability Layer: Overview and Status},
 institution = {Lawrence Livermore National Laboratory},
 year = {2014},
 OPTkey = {},
 OPTtype = {},
 number = {LLNL-TR-661403},
 OPTaddress = {},
 OPTmonth = {September},
 OPTnote = {},
 OPTannote = {},
 OPTurl = {},
 OPTurldate = {},
 OPTlastchecked = {},
 OPTdoi = {},
 OPTisbn = {},
 OPTissn = {},
 OPTlocalfile = {},
 OPTabstract = {},
 OPTkeywords = {},
}

%
% Trilinos references
%

@techreport{Trilinos-Overview,
title = "{An Overview of Trilinos}",
author = "Michael Heroux and Roscoe Bartlett and Vicki Howle Robert Hoekstra and Jonathan Hu and Tamara Kolda and Richard Lehoucq and Kevin Long and Roger Pawlowski and Eric Phipps and Andrew Salinger and Heidi Thornquist and Ray Tuminaro and James Willenbring and Alan Williams ",
institution = "Sandia National Laboratories",
number = "SAND2003-2927",
year = 2003}

@techreport{hoemmen2015tpetra,
  title={Tpetra Project Overview.},
  author={Hoemmen, Mark Frederick},
  year={2015},
  institution={Sandia National Lab.(SNL-NM), Albuquerque, NM (United States)}
}

%
% SWIG Fortran references
%

@article{Swig-Fortran,
author    = {Seth R. Johnson and
              Andrey Prokopenko and
              Katherine J. Evans},
title     = {Automated Fortran-C++ Bindings for Large-Scale Scientific Applications},
journal   = {},
volume    = {arXiv:1904.02546 [cs]},
year      = {2019},
url       = {http://arxiv.org/abs/1904.02546},
archivePrefix = {arXiv},
eprint    = {1904.02546},
timestamp = {Wed, 24 Apr 2019 12:21:25 +0200},
biburl    = {https://dblp.org/rec/bib/journals/corr/abs-1904-02546},
bibsource = {dblp computer science bibliography, https://dblp.org}
}

%
% Using an alternative function in Jacobian-vector products
%

@article{dorr2010numerical,
  title={A numerical algorithm for the solution of a phase-field model of polycrystalline materials},
  author={Dorr, M.R. and Fattebert, J.-L. and Wickett, M.E. and Belak, J.F. and Turchi, P.E.A.},
  journal={Journal of Computational Physics},
  volume={229},
  number={3},
  pages={626--641},
  year={2010},
  publisher={Elsevier}
}

%
% MAGMA linear solvers
%

@Misc{magma_site,
  title = {{MAGMA: Matrix Algebra on GPU and Multicore Architectures}},
  howpublished = {https://icl.utk.edu/magma/index.html}
}

%
% Low synchronization orthogonalization routines
%

@article{lowSyncGMRES,
  title = {Low synchronization Gram-Schmidt and GMRES algorithms},
  author = {Swirydowicz, Kasia and Langou, Julien and Ananthan, Shreyas and Yang, Ulrike and Thomas, Stephen},
  journal = {Numerical Linear Algebra with Applications},
  year = {2020},
  month = {02}
}

@inproceedings{hernandez2005parallel,
  title={A Parallel Variant of the Gram-Schmidt Process with Reorthogonalization.},
  author={Hern{\'a}ndez, Vicente and Rom{\'a}n, Jos{\'e} E and Tom{\'a}s, Andr{\'e}s},
  booktitle={PARCO},
  pages={221--228},
  year={2005}
}

%
% Kokkos
%

@article{trott2022kokkos,
  author  = {Trott, Christian R. and Lebrun-Grandi\'e, Damien and Arndt, Daniel and Ciesko, Jan and Dang, Vinh and Ellingwood, Nathan and Gayatri, Rahulkumar and Harvey, Evan and Hollman, Daisy S. and Ibanez, Dan and Liber, Nevin and Madsen, Jonathan and Miles, Jeff and Poliakoff, David and Powell, Amy and Rajamanickam, Sivasankaran and Simberg, Mikael and Sunderland, Dan and Turcksin, Bruno and Wilke, Jeremiah},
  journal = {IEEE Transactions on Parallel and Distributed Systems},
  title   = {Kokkos 3: Programming Model Extensions for the Exascale Era},
  year    = {2022},
  volume  = {33},
  number  = {4},
  pages   = {805-817},
  doi     = {10.1109/TPDS.2021.3097283}
}

@article{trott2021kokkos,
  author  = {Trott, Christian and Berger-Vergiat, Luc and Poliakoff, David and Rajamanickam, Sivasankaran and Lebrun-Grandie, Damien and Madsen, Jonathan and Al Awar, Nader and Gligoric, Milos and Shipman, Galen and Womeldorff, Geoff},
  journal = {Computing in Science Engineering},
  title   = {The Kokkos EcoSystem: Comprehensive Performance Portability for High Performance Computing},
  year    = {2021},
  volume  = {23},
  number  = {5},
  pages   = {10-18},
  doi     = {10.1109/MCSE.2021.3098509}
  }

@article{edwards2014kokkos,
  author  = {H. Carter Edwards and Christian R. Trott and Daniel Sunderland},
  title   = {Kokkos: Enabling manycore performance portability through polymorphic memory access patterns},
  journal = {Journal of Parallel and Distributed Computing},
  volume  = {74},
  number  = {12},
  pages   = {3202-3216},
  year    = {2014},
  issn    = {0743-7315},
  doi     = {10.1016/j.jpdc.2014.07.003}
}

repository: LLNL/sundials

repo_name: LLNL/sundials

branch_name: refs/heads/main

gha_language: C


text:
//此源码被清华学神尹成大魔王专业翻译分析并修改
//尹成QQ77025077
//尹成微信18510341407
//尹成所在QQ群721929980
//尹成邮箱 yinc13@mails.tsinghua.edu.cn
//尹成毕业于清华大学,微软区块链领域全球最有价值专家
//https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
//版权所有（c）2015-2016 BTCSuite开发者
//此源代码的使用由ISC控制
//可以在许可文件中找到的许可证。

/*
此测试文件是ffldb包的一部分，而不是ffldb-u测试
包装，使其能够连接内部构件，以正确测试
不可能或不能通过公共接口可靠地进行测试。
仅在运行测试时导出函数。
**/

package ffldb

import "github.com/btcsuite/btcd/database"

//tstrunwithmaxblockfilesize以允许的最大值运行传递的函数
//数据库的文件大小设置为提供的值。将设置该值
//完成后返回原值。
func TstRunWithMaxBlockFileSize(idb database.DB, size uint32, fn func()) {
	ffldb := idb.(*db)
	origSize := ffldb.store.maxBlockFileSize

	ffldb.store.maxBlockFileSize = size
	fn()
	ffldb.store.maxBlockFileSize = origSize
}

license: ISC

repository: eriday/golang-bitcoin-chinese

repo_name: eriday/golang-bitcoin-chinese

gha_license_id: ISC


text:
#
# Activate component packaging
#

if(CPACK_GENERATOR MATCHES "DEB")
   set(CPACK_DEB_COMPONENT_INSTALL "ON")
endif()

#
# Choose grouping way
#
#set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE)
#set(CPACK_COMPONENTS_GROUPING)
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)

# overriding previous descriptions
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY           "main description")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION    "applications_description")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION         "headers_description")
# libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY
unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION)

extension: in


text:
package models

type DocumentBaseConfig struct {
	Entity
	Name           string                            `json:"name"`
	FilenamePrefix string                            `json:"filenamePrefix"`
	FilenameSuffix string                            `json:"filenameSuffix"`
	DocumentNumber string                            `json:"documentNumber"`
	Global         bool                              `json:"global"`
	DocumentTypeID string                            `json:"documentTypeId"`
	LogoID         string                            `json:"logoId"`
	config         []string                          `json:"config"`
	salesChannels  []*DocumentBaseConfigSalesChannel `json:"salesChannels"`
	DocumentType   *DocumentType                     `json:"documentType"`
	Logo           *MediaEntity                      `json:"logo"`
}


text:
# © 2018 Joseph Cameron - All Rights Reserved

cmake_minimum_required(VERSION 3.9 FATAL_ERROR)

include_guard(DIRECTORY)

#================================================================================================
# Projects
#================================================================================================
set(JFC_LIBRARY_PROJECT_TEMPLATE_ABSOLUTE_PATH    ${CMAKE_CURRENT_LIST_DIR}/library_project_template.cmake.in)
set(JFC_EXECUTABLE_PROJECT_TEMPLATE_ABSOLUTE_PATH ${CMAKE_CURRENT_LIST_DIR}/executable_project_template.cmake.in)

# TODO: Simplify implementation: make use of jfc_parse_arguments
# Generates a library or executable project.
# See the options in the _required* sets below
# See the output formats in the *_PROJECT_TEMPLATE_ABSOLUTE_PATHs above
# Example usage:
#   jfc_project(executable
#       NAME MyExecutable
#       SOURCE_LIST
#           ${CMAKE_CURRENT_SOURCE_DIR}/main.c
#   )
function(jfc_project aType) # library | executable
    if (EXISTS "${CMAKE_BINARY_DIR}/${NAME_value}.cmake") # is BIN dir really the safest thing to rely on for build script gen skip?
        jfc_log(WARN ${TAG} "${NAME_value} already exists! skipping...")

        #TODO: verion assert: if exists & commit hash is different then halt
        #jfc_git("rev-parse HEAD")
        #jfc_log(WARN ${TAG} "${OUTPUT}")
    else()
        set(TAG "project")

        set(_required_simple_fields
            "NAME"                        # name of the project
            "VERSION"                     # version of the project (no enforced foramt)
            "DESCRIPTION"                 # description of the project
            "C++_STANDARD"                # minimum ISO language standard required by the C++ compiler.
            "C_STANDARD"                  # minimum ISO language standard required by the C compiler.
        )
        set(_optional_simple_fields
            ""
        )
        set(_required_list_fields
            "SOURCE_LIST"                 # list of source files
        )
        set(_optional_list_fields
            "PRIVATE_INCLUDE_DIRECTORIES" # Header paths hidden from downstream projects (internal use only)
            "PUBLIC_INCLUDE_DIRECTORIES"  # Header paths accessible (and needed) by downstream projects
            "LIBRARIES"                   # binary lib files needed by this project (and therefore downstream projects)
            "DEPENDENCIES"                # list of projects that must be built before this one                            IMPLEMENTED but NOT IDEAL IMPLEMETION.
        )

        macro(_library_project)
            list(APPEND _required_simple_fields
                "TYPE"                    # STATIC | DYNAMIC
            )
            set(_project_template_absolute_path "${JFC_LIBRARY_PROJECT_TEMPLATE_ABSOLUTE_PATH}")

            #[[jfc_parse_arguments(${ARGV} # Not begin used.. should change to this instead of the by-hand stuff below. The fact that this cannot be dropped in as a replacement shows there is something wrong with jfc_parse_args implementation. I need a test framework.
                REQUIRED_SINGLE_VALUES ${_required_simple_fields}
                SINGLE_VALUES          ${_optional_simple_fields}
                REQUIRED_LISTS         ${_required_list_fields}
                LISTS                  ${_optional_list_fields}
            )]]

            #jfc_print_all_variables()

            #jfc_log(STATUS ${TAG} "== Current project: ${NAME} ==")

            _jfc_project_implementation()
        endmacro()

        macro(_executable_project)
            list(APPEND _optional_list_fields
                "EXECUTABLE_PARAMETERS"   # list of params. see cmake built in function add_executable
            )
            set(_project_template_absolute_path "${JFC_EXECUTABLE_PROJECT_TEMPLATE_ABSOLUTE_PATH}")

            _jfc_project_implementation()
        endmacro()

        macro(_jfc_project_implementation)
            list(APPEND _all_simple_fields ${_required_simple_fields} ${_optional_simple_fields})
            list(APPEND _all_list_fields   ${_required_list_fields}   ${_optional_list_fields})
            list(APPEND _all_fields        ${_all_simple_fields}      ${_all_list_fields})

            set(_parse_mode "PARSE_SIMPLE_FIELDS") # PARSE_SIMPLE_FIELDS | any member of _all_list_fields

            macro(_pop_front)
                list(REMOVE_AT ARGV 0)
                list(LENGTH ARGV _s)
            endmacro()

            list(LENGTH ARGV _s)
            while(_s GREATER 0)
                list(LENGTH ARGV _s)
                list(GET ARGV 0 _item)

                if (_parse_mode STREQUAL "PARSE_SIMPLE_FIELDS")
                    list(FIND _required_simple_fields ${_item} _item_is_a_required_field)
                    if (_item_is_a_required_field GREATER_EQUAL 0)
                        if (${_s} GREATER 1)
                            list(GET ARGV 1 _value)

                            list(FIND _all_fields ${_value} _value_is_a_field)
                            if (_value_is_a_field GREATER_EQUAL 0)
                                jfc_log(FATAL_ERROR ${TAG} "The field ${_item} requires a value")
                            endif()

                            set("${_item}_value" ${_value})

                            _pop_front()
                        else()
                            jfc_log(FATAL_ERROR ${TAG} "${ARGV${_found_index}} requires a value")
                        endif()
                    else()
                        list(FIND _all_list_fields ${_item} _item_is_a_list_field)
                        if (_item_is_a_list_field GREATER_EQUAL 0)
                            set(_parse_mode ${_item})
                        else()
                            jfc_log(FATAL_ERROR ${TAG} "\"${_item}\" is a value without a field!")
                        endif()
                    endif()

                    _pop_front()
                else() # Parsing a list field
                    list(FIND _all_fields ${_item} _item_is_a_field)
                    if (_item_is_a_field GREATER_EQUAL 0)
                        set(_parse_mode "PARSE_SIMPLE_FIELDS")
                    else()
                        list(APPEND "${_parse_mode}" "${_item}")

                        _pop_front()
                    endif()
                endif()
            endwhile()

            foreach(_field ${_required_simple_fields})
                if ("${${_field}_value}" STREQUAL "")
                    jfc_log(FATAL_ERROR ${TAG} "${_field} is a required field")
                endif()
            endforeach()

            foreach(list ${_required_list_fields})
                set (list_values ${list})
                list(LENGTH ${list_values} _s)

                if ("${_s}" EQUAL 0)
                    jfc_log(FATAL_ERROR ${TAG} "${list} is a required list field and is missing or has no entries")
                endif()
            endforeach()

            foreach(list ${_all_list_fields})
                set (list_values ${list})
                list(LENGTH ${list_values} _s)

                set(_i "0")
                while(${_i} LESS ${_s})
                    list(GET "${list_values}" ${_i} value)

                    if (NOT ${list}_value)
                        set(${list}_value "${value}")
                    else()
                        string(CONCAT ${list}_value "${${list}_value}\n\t" "${value}")
                    endif()

                    MATH(EXPR _i "${_i}+1")
                endwhile()
            endforeach()

            if (TARGET "${NAME_value}")
                #jfc_log(STATUS ${TAG} "Skipping duplicate project \"${NAME_value}\"")
            else()
                jfc_log(STATUS ${TAG} "Generating project \"${NAME_value}\", dir: ${CMAKE_CURRENT_LIST_FILE}")

                configure_file(${_project_template_absolute_path} "${CMAKE_BINARY_DIR}/${NAME_value}.cmake" @ONLY)

                include("${CMAKE_BINARY_DIR}/${NAME_value}.cmake")

                list(LENGTH DEPENDENCIES_value _dep_len)

                # Appends dependencies.. This is ok but would prer to append to the cmake file
                # TODO: This should be added to the generated doc before the include ^. This makes issues around malformed projects easier to detect.
                # TODO: source list should be optional, should be appended as are deps below
                if (NOT "${_dep_len}" EQUAL 0)
                    jfc_log(STATUS ${TAG} "dependencies: ${DEPENDENCIES}")
                    add_dependencies(${PROJECT_NAME} ${DEPENDENCIES})
                else()
                    jfc_log(WARN ${TAG} "no dependencies")
                endif()

                # Promoting project variables
                set(PROJECT_NAME       "${PROJECT_NAME}"       PARENT_SCOPE) # Project vars must be promoted to be accessible in call scope. They are being "returned" in a saner language
                set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}" PARENT_SCOPE)

            endif()
        endmacro()

        list(REMOVE_AT ARGV 0)

        if ("${aType}" STREQUAL "library")
            _library_project("${ARGV}")
        elseif ("${aType}" STREQUAL "executable")
            _executable_project("${ARGV}")
        else()
            jfc_log(FATAL_ERROR ${TAG} "jfc_project unrecognized type: ${aType}. Must be library | executable")
        endif()
    endif()
endfunction()

repository: jfcameron/jfc-cmake

repo_name: jfcameron/jfc-cmake

gha_language: CMake

extension: cmake


text:
%% This BibTeX bibliography file was created using BibDesk.
%% http://bibdesk.sourceforge.net/

%% Created for Molly at 2019-09-05 20:35:10 -0400

%% Saved with string encoding Unicode (UTF-8)

@article{R-metafor,
	Author = {Wolfgang Viechtbauer},
	Date-Added = {2018-03-05 15:53:01 +0000},
	Date-Modified = {2018-03-05 15:53:01 +0000},
	Journal = {Journal of Statistical Software},
	Number = {3},
	Pages = {1--48},
	Title = {Conducting meta-analyses in {R} with the {metafor} package},
	Url = {http://www.jstatsoft.org/v36/i03/},
	Volume = {36},
	Year = {2010},
	Bdsk-Url-1 = {http://www.jstatsoft.org/v36/i03/}}

@manual{R-base,
	Address = {Vienna, Austria},
	Author = {{R Core Team}},
	Organization = {R Foundation for Statistical Computing},
	Title = {R: A Language and Environment for Statistical Computing},
	Url = {https://www.R-project.org/},
	Year = {2017},
	Bdsk-Url-1 = {https://www.R-project.org/}}

@manual{R-bindrcpp,
	Author = {Kirill M{\"u}ller},
	Note = {R package version 0.2},
	Title = {bindrcpp: An 'Rcpp' Interface to Active Bindings},
	Url = {https://CRAN.R-project.org/package=bindrcpp},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=bindrcpp}}

@manual{R-broom,
	Author = {David Robinson},
	Note = {R package version 0.4.3},
	Title = {broom: Convert Statistical Analysis Objects into Tidy Data Frames},
	Url = {https://CRAN.R-project.org/package=broom},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=broom}}

@manual{R-dplyr,
	Author = {Hadley Wickham and Romain Francois and Lionel Henry and Kirill M{\"u}ller},
	Note = {R package version 0.7.4},
	Title = {dplyr: A Grammar of Data Manipulation},
	Url = {https://CRAN.R-project.org/package=dplyr},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=dplyr}}

@manual{R-feather,
	Author = {Hadley Wickham},
	Note = {R package version 0.3.1},
	Title = {feather: R Bindings to the Feather 'API'},
	Url = {https://CRAN.R-project.org/package=feather},
	Year = {2016},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=feather}}

@manual{R-forcats,
	Author = {Hadley Wickham},
	Note = {R package version 0.2.0},
	Title = {forcats: Tools for Working with Categorical Variables (Factors)},
	Url = {https://CRAN.R-project.org/package=forcats},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=forcats}}

@book{R-ggplot2,
	Author = {Hadley Wickham},
	Isbn = {978-3-319-24277-4},
	Publisher = {Springer-Verlag New York},
	Title = {ggplot2: Elegant Graphics for Data Analysis},
	Url = {http://ggplot2.org},
	Year = {2016},
	Bdsk-Url-1 = {http://ggplot2.org}}

@manual{R-ggthemes,
	Author = {Jeffrey B. Arnold},
	Note = {R package version 3.4.0},
	Title = {ggthemes: Extra Themes, Scales and Geoms for 'ggplot2'},
	Url = {https://CRAN.R-project.org/package=ggthemes},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=ggthemes}}

@manual{R-kableExtra,
	Author = {Hao Zhu},
	Note = {R package version 0.6.1},
	Title = {kableExtra: Construct Complex Table with 'kable' and Pipe Syntax},
	Url = {https://CRAN.R-project.org/package=kableExtra},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=kableExtra}}

@book{R-knitr,
	Address = {Boca Raton, Florida},
	Author = {Yihui Xie},
	Edition = {2nd},
	Note = {ISBN 978-1498716963},
	Publisher = {Chapman and Hall/CRC},
	Title = {Dynamic Documents with {R} and knitr},
	Url = {https://yihui.name/knitr/},
	Year = {2015},
	Bdsk-Url-1 = {https://yihui.name/knitr/}}

@manual{R-langcog,
	Author = {Mika Braginsky and Dan Yurovsky and Michael Frank},
	Note = {R package version 0.1.9001},
	Title = {langcog: Language and Cognition Lab Things},
	Url = {http://github.com/langcog/langcog},
	Bdsk-Url-1 = {http://github.com/langcog/langcog}}

@article{R-lme4,
	Author = {Douglas Bates and Martin M{\"a}chler and Ben Bolker and Steve Walker},
	Doi = {10.18637/jss.v067.i01},
	Journal = {Journal of Statistical Software},
	Number = {1},
	Pages = {1--48},
	Title = {Fitting Linear Mixed-Effects Models Using {lme4}},
	Volume = {67},
	Year = {2015},
	Bdsk-Url-1 = {http://dx.doi.org/10.18637/jss.v067.i01}}

@manual{R-Matrix,
	Author = {Douglas Bates and Martin Maechler},
	Note = {R package version 1.2-12},
	Title = {Matrix: Sparse and Dense Matrix Classes and Methods},
	Url = {https://CRAN.R-project.org/package=Matrix},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=Matrix}}

@manual{R-papaja,
	Author = {Frederik Aust and Marius Barth},
	Note = {R package version 0.1.0.9492},
	Title = {{papaja}: {Create} {APA} manuscripts with {R Markdown}},
	Url = {https://github.com/crsh/papaja},
	Year = {2017},
	Bdsk-Url-1 = {https://github.com/crsh/papaja}}

@manual{R-purrr,
	Author = {Lionel Henry and Hadley Wickham},
	Note = {R package version 0.2.4},
	Title = {purrr: Functional Programming Tools},
	Url = {https://CRAN.R-project.org/package=purrr},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=purrr}}

@manual{R-readr,
	Author = {Hadley Wickham and Jim Hester and Romain Francois},
	Note = {R package version 1.1.1},
	Title = {readr: Read Rectangular Text Data},
	Url = {https://CRAN.R-project.org/package=readr},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=readr}}

@manual{R-stringr,
	Author = {Hadley Wickham},
	Note = {R package version 1.2.0},
	Title = {stringr: Simple, Consistent Wrappers for Common String Operations},
	Url = {https://CRAN.R-project.org/package=stringr},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=stringr}}

@manual{R-tibble,
	Author = {Kirill M{\"u}ller and Hadley Wickham},
	Note = {R package version 1.4.2},
	Title = {tibble: Simple Data Frames},
	Url = {https://CRAN.R-project.org/package=tibble},
	Year = {2018},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=tibble}}

@manual{R-tidyr,
	Author = {Hadley Wickham and Lionel Henry},
	Note = {R package version 0.7.2},
	Title = {tidyr: Easily Tidy Data with 'spread()' and 'gather()' Functions},
	Url = {https://CRAN.R-project.org/package=tidyr},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=tidyr}}

@manual{R-tidyverse,
	Author = {Hadley Wickham},
	Note = {R package version 1.2.1},
	Title = {tidyverse: Easily Install and Load the 'Tidyverse'},
	Url = {https://CRAN.R-project.org/package=tidyverse},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=tidyverse}}

@manual{R-compute.es,
	Author = {A. C. Del Re},
	Journal = {R Package},
	Title = {compute.es: Compute Effect Sizes},
	Url = {http://cran.r-project.org/web/packages/compute.es},
	Year = {2013},
	Bdsk-Url-1 = {http://cran.r-project.org/web/packages/compute.es}}

@manual{R-ggrepel,
	Author = {Kamil Slowikowski},
	Note = {R package version 0.8.0},
	Title = {ggrepel: Automatically Position Non-Overlapping Text Labels with 'ggplot2'},
	Url = {https://CRAN.R-project.org/package=ggrepel},
	Year = {2018},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=ggrepel}}

@manual{R-pander,
	Author = {Gergely Dar{\'o}czi and Roman Tsegelskyi},
	Note = {R package version 0.6.2},
	Title = {pander: An R 'Pandoc' Writer},
	Url = {https://CRAN.R-project.org/package=pander},
	Year = {2018},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=pander}}

@manual{R-citr,
	Author = {Frederik Aust},
	Note = {R package version 0.2.0},
	Title = {citr: 'RStudio' Add-in to Insert Markdown Citations},
	Url = {https://CRAN.R-project.org/package=citr},
	Year = {2016},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=citr}}

@manual{R-here,
	Author = {Kirill M{\"u}ller},
	Note = {R package version 0.1},
	Title = {here: A Simpler Way to Find Your Files},
	Url = {https://CRAN.R-project.org/package=here},
	Year = {2017},
	Bdsk-Url-1 = {https://CRAN.R-project.org/package=here}}


text:
DESCRIPTION = "ST Telematics application"
SECTION = "extras"
LICENSE = "GPLv2+ & LGPLv2.1+"
PR = "r0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

TELEMATICS_INSTALL = "/opt/demo/telematics"
TELEMATICS_BASE_FLDR = "${S}/rootfs"
TELEMATICS_WWW = "www"
TELEMATICS_WWW_sta1385 = "www-1385"
inherit externalsrc systemd

#DEPENDS = "gnuplot"

EXTERNALSRC_pn-telematics ?= "${ST_LOCAL_SRC}carproc-app/telematics"

FILES_${PN} = "${bindir}/telematics"
FILES_${PN} += "${bindir}/socket_redirect.bin"
FILES_${PN} += "${bindir}/start_telematics.sh"
FILES_${PN} += "${TELEMATICS_INSTALL}"
FILES_${PN} += "/var/www"
FILES_${PN} += "/lib"
FILES_${PN} += "${sysconfdir}/udhcpd.conf"
FILES_${PN} += "${sysconfdir}/hostapd.mrvl.conf"
FILES_${PN} += "${sysconfdir}/me909-datacall"
FILES_${PN} += "${sysconfdir}/syslog.conf"

SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"

#Enable systemd service to start
SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','telematics.service','',d)}"
SYSTEMD_SERVICE_${PN} += " ${@bb.utils.contains('DISTRO_FEATURES','systemd','startchime.service','',d)}"
SYSTEMD_SERVICE_${PN} += " ${@bb.utils.contains('DISTRO_FEATURES','systemd','wifi-hotspot.service','',d)}"

EXTRA_CFLAGS = "-Os -Wall -DDEBUG"
EXTRA_LDFLAGS = " -lpthread "

do_compile() {
	${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} ${CFLAGS} ${LDFLAGS} ${S}/telematics.c -o telematics
	${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} ${CFLAGS} ${LDFLAGS} ${S}/socket_redirect.c -o socket_redirect.bin
}

do_install() {
	install -d ${D}${bindir}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/start_telematics.sh ${D}${bindir}
	install -m 0777 ${B}/telematics ${D}${bindir}
	install -m 0777 ${B}/socket_redirect.bin ${D}${bindir}

	install -d ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/kill_audio.sh ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/papcall-le910 ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/papcall-he910 ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/papcall-me909u ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/papcall-ue910 ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/setup.sh ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/sta1195html.sh ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/timetofix.sh ${D}${TELEMATICS_INSTALL}
	install -m 0755 ${TELEMATICS_BASE_FLDR}/telematics.ini ${D}${TELEMATICS_INSTALL}
	install -d ${D}${TELEMATICS_INSTALL}/audio
	install -m 0666 ${TELEMATICS_BASE_FLDR}/audio/* ${D}${TELEMATICS_INSTALL}/audio
	install -m 0777 ${TELEMATICS_BASE_FLDR}/startchime.sh ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/alsastart.up ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/modem_audio.sh ${D}${TELEMATICS_INSTALL}
# Wifi Hotspot installation
	install -m 0777 ${TELEMATICS_BASE_FLDR}/hotspot.sh ${D}${TELEMATICS_INSTALL}
#	install -m 0777 ${TELEMATICS_BASE_FLDR}/monitor_demo.sh ${D}${TELEMATICS_INSTALL}
	install -m 0777 ${TELEMATICS_BASE_FLDR}/modem_pinctrl.sh ${D}${TELEMATICS_INSTALL}
	install -d ${D}${sysconfdir}
	install -m 0755 ${TELEMATICS_BASE_FLDR}/udhcpd.conf ${D}${sysconfdir}
	install -m 0755 ${TELEMATICS_BASE_FLDR}/hostapd.mrvl.conf ${D}${sysconfdir}
	install -m 0755 ${TELEMATICS_BASE_FLDR}/me909-datacall ${D}${sysconfdir}
#Disable for now, require gnuplot, which requires X11 !
#	install -m 0777 ${TELEMATICS_BASE_FLDR}/plot_accel ${D}${TELEMATICS_INSTALL}
	install -d ${D}/var/www
	install -m 0666 ${TELEMATICS_BASE_FLDR}/${TELEMATICS_WWW}/* ${D}/var/www
#Install systemd service
	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
		install -d ${D}${systemd_unitdir}/system
		install -m 644 ${TELEMATICS_BASE_FLDR}/*.service ${D}/${systemd_unitdir}/system
	fi
}

extension: bb


text:
@article{Ratelle-2018-Implementation,
    title = "Implementation of human biomonitoring in the Dehcho region of the Northwest Territories, Canada (2016{--}2017)",
    author = "Ratelle, Myl{\`e}ne  and
      Skinner, Kelly  and
      Laird, Matthew J.  and
      Majowicz, Shannon  and
      Brandow, Danielle  and
      Packull-McCormick, Sara  and
      Bouchard, Mich{\`e}le  and
      Dieme, Denis  and
      Stark, Ken D.  and
      Henao, Juan Jose Aristizabal  and
      Hanning, Rhona  and
      Laird, Brian D.",
    journal = "Archives of Public Health, Volume 76, Issue 1",
    volume = "76",
    number = "1",
    year = "2018",
    publisher = "Springer Science and Business Media LLC",
    url = "https://aclanthology.org/G18-107001",
    doi = "10.1186/s13690-018-0318-9",
    abstract = "Human biomonitoring represents an important tool for health risk assessment, supporting the characterization of contaminant exposure and nutrient status. In communities where country foods (locally harvested foods: land animals, fish, birds, plants) are integrated in the daily diet, as is the case in remote northern regions where food security is a challenge, such foods can potentially be a significant route of contaminant exposure. To assess this issue, a biomonitoring project was implemented among Dene/M{\'e}tis communities of the Dehcho region of the Northwest Territories, Canada.Participants completed dietary surveys (i.e., a food frequency questionnaire and 24-h recall) to estimate food consumption patterns as well as a Health Messages Survey to evaluate the awareness and perception of contaminants and consumption notices. Biological sampling of hair, urine and blood was conducted. Toxic metals (e.g., mercury, lead, cadmium), essential metals (e.g., copper, nickel, zinc), fatty acids, and persistent organic pollutants (POPs) were measured in samples.The levels of contaminants in blood, hair and urine for the majority of participants were below the available guidance values for mercury, cadmium, lead and uranium. However, from the 279 participants, approximately 2{\%} were invited to provide follow up samples, mainly for elevated mercury level. Also, at the population level, blood lead (GM: 11 μg/L) and blood cadmium (GM: 0.53 μg/L) were slightly above the Canadian Health Measures Survey data. Therefore, although country foods occasionally contain elevated levels of particular contaminants, human exposures to these metals remained similar to those seen in the Canadian general population. In addition, dietary data showed the importance and diversity of country foods across participating communities, with the consumption of an average of 5.1{\%} of total calories from wild-harvested country foods.This project completed in the Mackenzie Valley of the Northwest Territories fills a data gap across other biomonitoring studies in Canada as it integrates community results, will support stakeholders in the development of public health strategies, and will inform environmental health issue prioritization.",
}

repository: gwf-uwaterloo/gwf-publications

repo_name: gwf-uwaterloo/gwf-publications

gha_language: Python


text:
@misc{Soebadi2017,
 abstract = {Introduction Stem cells for sexual disorders are steadily being introduced into clinical trials. Two conditions of importance are the main target for this line of treatment, especially when regarding the wide array of translational and basic science highlighting the potential advantages of regenerative therapy: erectile dysfunction (ED) and more recently Peyronie disease (PD). Cellular therapy offers a treatment modality that might reverse disease progression. It would be used in a curative setting, in contrast to other pharmaceutical agents that are currently available. Aim To review basic preclinical studies and recent clinical trials of stem cells on ED and PD. Methods A search of the medical literature for the following terms was performed using PubMed: stem cells, cellular therapy, erectile dysfunction, Peyronie's disease, and clinical trial. Main Outcome Measures A non-systematic narrative review and critical reflection on preclinical and clinical studies administering stem cells for ED and PD in animal models and human subjects. Results Numerous studies have confirmed the beneficial functional effects of stem cell injection in established animal models on ED and PD. Various stem cell types have been adopted, from embryonic to adult mesenchymal cell types. Each cell type offers distinctive advantages and disadvantages. Diverse administrations of stem cells were investigated, with insignificant variability in the ultimate results. Stem cells appear to have a pronounced paracrine effect, rather than the classic engraftment and differentiation hypothesis. Phase 1 clinical trials using stem cells have not reported any severe adverse events in animals. However, these results cannot be extrapolated to draw any conclusions about efficacy in human patients. Conclusion Stem cells have an established efficacy in preclinical studies and early clinical trials. Studies are currently being published demonstrating the safety of intrapenile injection of autologous bone marrow- and adipose tissue-derived stem cells. Soebadi MA, Milenkovic U, Weyne E, et al. Stem Cells in Male Sexual Dysfunction: Are We Getting Somewhere? Sex Med Rev 2017;5:222–235.},
 author = {Soebadi, Mohammad Ayodhia and Milenkovic, Uros and Weyne, Emmanuel and Castiglione, Fabio and Albersen, Maarten},
 booktitle = {Sexual Medicine Reviews},
 doi = {10.1016/j.sxmr.2016.11.002},
 file = {:Volumes/JetYodi/Mendeley folder/Soebadi et al/Sexual Medicine Reviews/Soebadi et al. - 2017.pdf:pdf},
 issn = {20500521},
 keywords = {Cavernous Nerve Injury,Erectile Dysfunction,Peyronie Disease,Progenitor Cells,Sexual Dysfunction,Stem Cells},
 number = {2},
 pages = {222--235},
 title = {Stem Cells in Male Sexual Dysfunction: Are We Getting Somewhere?},
 url = {http://www.scopus.com/inward/record.url?eid=2-s2.0-85009350698&partnerID=MN8TOARS},
 volume = {5},
 year = {2017}
}

repository: gruenekaefer/starter-academic

repo_name: gruenekaefer/starter-academic


text:
package main

import (
	"easyNmon/internal"
	"flag"
	"fmt"
	"github.com/gin-gonic/gin"
	"net"
	"net/http"
	"os"
	"os/exec"
	"path/filepath"
	"strconv"
	"strings"
	"time"
)

var (
	// 版本号
	Version = "<Version>"
	// 构建时间
	BuildTime = "<BuildTime>"
)

func main() {
	os.MkdirAll("./report", 777)
	ip := ""
	netaddr, _ := net.InterfaceAddrs()
	networkIp, _ := netaddr[1].(*net.IPNet)
	if !networkIp.IP.IsLoopback() && networkIp.IP.To4() != nil {
		ip = networkIp.IP.String()
	}

	version := flag.Bool("v", false, "显示版本号")
	port := flag.String("p", "9999", "默认监听端口9999,自定义端口加 -p 端口号\n设置端口示例：./monitor -p 9999")
	flag.Bool("web管理页面", false, "浏览器访问http://"+ip+":9999")
	flag.Bool("启动监控", false, "参数n的值：name 生成报告的文件名\n参数t的值：time 监控时长，单位分钟\n\tget_url示例：http://"+ip+":9999/start?n=test&t=30")
	flag.Bool("停止所有监控任务", false, "等同于kill掉nmon进程\nget_url示例：http://"+ip+":9999/stop")
	flag.Bool("查看报告", false, "浏览器访问：http://"+ip+":9999/report，也可通过web管理页面入口查看")
	flag.Bool("退出程序", false, "关闭自身，结束monitor进程\nget_url示例：http://"+ip+":9999/close")

	wd := flag.String("wd", *internal.WorkingDirectory, "指定当前工作路径")
	flag.Parse()
	if *wd != "" {
		internal.WorkingDirectory = wd
	}

	flag.Parse()

	if *version {
		fmt.Println("Version: " + Version)
		fmt.Println("BuildTime: " + BuildTime)
		return
	}

	fmt.Println("访问web管理页面 : http://" + ip + ":" + *port)
	fmt.Println("启动监控接口示例: http://" + ip + ":" + *port + "/start?n=testname&t=30")
	fmt.Println("停止所有监控接口: http://" + ip + ":" + *port + "/stop")
	fmt.Println("浏览器查看报告 :  http://" + ip + ":" + *port + "/report")
	fmt.Println("结束monitor进程:  http://" + ip + ":" + *port + "/close")

	gin.SetMode(gin.ReleaseMode)
	r := gin.Default()

	// 首页
	r.LoadHTMLGlob("web/index.html")
	r.Static("/js", "web/js")
	r.Static("/fonts", "web/fonts")
	r.Static("/chart", "web/chart")
	r.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.html", gin.H{})
	})
	// 浏览报告
	r.GET("/report/*name", func(c *gin.Context) {
		name := c.Param("name")
		if len(name) > 15 && strings.Count(name, "/") < 3 {
			runame := name[:len(name)-15]
			// exec.Command("/bin/bash", "-c", "cd report"+name+"&&./toHtml.sh "+runame[1:]).Run()
			nmonReport := internal.GetNmonReport(filepath.Join(*internal.WorkingDirectory, "report", name, runame[1:]))
			if nmonReport != nil {
				nmonReport.ScriptName = runame[1:]
				internal.GenIndexPage(nmonReport, filepath.Join(*internal.WorkingDirectory, "report", name))
			}
		}
		c.Request.URL.Path = "/reports" + name
		defer r.HandleContext(c)
	})
	r.StaticFS("/reports/", http.Dir("report"))

	r.GET("/start", start)
	r.GET("/close", close)
	r.GET("/stop", stop)

	r.Run(":" + *port) // listen and serve on 0.0.0.0:8080
}

func start(c *gin.Context) { // 格式 ?n=name&t=time 其中&后可为空 默认30分钟
	name := c.DefaultQuery("n", "name")  // 取name值
	timeStr := c.DefaultQuery("t", "30") // 取执行时间,单位分钟

	filename := name + time.Now().Format("20060102150405")

	go func() {
		exec.Command("/bin/bash", "-c", "cp -rf templet report/"+filename).Run()
		exec.Command("/bin/bash", "-c", "./nmon -f -t -s "+timeStr+" -c 60 -m report/"+filename+" -F "+name).Run()
		t, _ := strconv.Atoi(timeStr)
		time.Sleep(time.Second * time.Duration(t*60+2))
		// exec.Command("/bin/bash", "-c", "cd report/"+filename+" &&./toHtml.sh "+name).Run()
		nmonReport := internal.GetNmonReport(filepath.Join(*internal.WorkingDirectory, "report", filename, name))
		if nmonReport != nil {
			nmonReport.ScriptName = name
			internal.GenIndexPage(nmonReport, filepath.Join(*internal.WorkingDirectory, "report", filename))
		}
	}()
	c.JSON(http.StatusOK, gin.H{
		"status":  http.StatusOK,
		"message": string("已执行" + name + "场景监控，测试时长 " + timeStr + " 分钟"),
	})
}

func close(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"status":  http.StatusOK,
		"message": "已结束EasyNmon服务!",
	})
	go func() {
		exec.Command("/bin/bash", "-c", "cd report/&&for i in `ls`;do cd $PWD/$i;if [ \"`ls index.html`\" != \"index.html\" ];then ./toHtml.sh \"`ls|grep -v js|grep -v templet|grep -v toHtml.sh`\"; fi;cd ..;done").Run()
		time.Sleep(time.Second * 2)
		defer os.Exit(0)
	}()
}

func stop(c *gin.Context) {
	exec.Command("/bin/bash", "-c", "ps -ef|grep nmon|grep -v grep|awk {'print $2'}|xargs kill -9").Start()
	exec.Command("/bin/bash", "-c", "cd report/&&for i in `ls`;do cd $PWD/$i;if [ \"`ls index.html`\" != \"index.html\" ];then ./toHtml.sh \"`ls|grep -v js|grep -v templet|grep -v toHtml.sh`\"; fi;cd ..;done").Run()
	c.JSON(http.StatusOK, gin.H{
		"status":  http.StatusOK,
		"message": "已结束所有服务器监控任务!",
	})
}

repository: roboytim/easyNmon

repo_name: roboytim/easyNmon