<commit_before>#include "pihm.h"

void BgcSpinup (pihm_struct pihm, N_Vector CV_Y, void *cvode_mem)
{
    int             i;
    int             spinyears = 0;
    int             first_spin_cycle = 1;
    int             steady;
    double          metyears;

    metyears =
        (pihm->ctrl.endtime - pihm->ctrl.starttime) / DAYINSEC / 365;

    do
    {
        PIHMprintf (VL_NORMAL, "Spinup year: %6d\n", spinyears + 1);

        ResetSpinupStat (pihm->elem);

        for (i = 0; i < pihm->ctrl.nstep; i++)
        {
            PIHM (pihm, cvode_mem, CV_Y, pihm->ctrl.tout[i],
                pihm->ctrl.tout[i + 1]);
        }

        /* Reset solver parameters */
        SetCVodeParam (pihm, cvode_mem, CV_Y);

        spinyears += metyears;

        steady = CheckBgcSS (pihm->elem, pihm->siteinfo.area,first_spin_cycle,
            pihm->ctrl.endtime - pihm->ctrl.starttime, spinyears);

        first_spin_cycle = 0;
    } while (spinyears < pihm->ctrl.maxspinyears && steady == 0);
}

void ResetSpinupStat (elem_struct *elem)
{
    int             i;

    for (i = 0; i < nelem; i++)
    {
        elem[i].spinup.soilc = 0.0;
        elem[i].spinup.totalc = 0.0;
    }
}

int CheckBgcSS (elem_struct *elem, double total_area, int first_cycle,
    int totalt, int spinyears)
{
    int             i;
    double          t1;<commit_msg>BGC spinpu continues after reaches steady state<commit_after>#include "pihm.h"

void BgcSpinup (pihm_struct pihm, N_Vector CV_Y, void *cvode_mem)
{
    int             i;
    int             spinyears = 0;
    int             first_spin_cycle = 1;
    int             steady;
    double          metyears;

    metyears =
        (pihm->ctrl.endtime - pihm->ctrl.starttime) / DAYINSEC / 365;

    do
    {
        PIHMprintf (VL_NORMAL, "Spinup year: %6d\n", spinyears + 1);

        ResetSpinupStat (pihm->elem);

        for (i = 0; i < pihm->ctrl.nstep; i++)
        {
            PIHM (pihm, cvode_mem, CV_Y, pihm->ctrl.tout[i],
                pihm->ctrl.tout[i + 1]);
        }

        /* Reset solver parameters */
        SetCVodeParam (pihm, cvode_mem, CV_Y);

        spinyears += metyears;

        steady = CheckBgcSS (pihm->elem, pihm->siteinfo.area,first_spin_cycle,
            pihm->ctrl.endtime - pihm->ctrl.starttime, spinyears);

        first_spin_cycle = 0;
    } while (spinyears < pihm->ctrl.maxspinyears);
}

void ResetSpinupStat (elem_struct *elem)
{
    int             i;

    for (i = 0; i < nelem; i++)
    {
        elem[i].spinup.soilc = 0.0;
        elem[i].spinup.totalc = 0.0;
    }
}

int CheckBgcSS (elem_struct *elem, double total_area, int first_cycle,
    int totalt, int spinyears)
{
    int             i;
    double          t1;
{'fraction_non_alphanumeric': 0.12192434814542784, 'fraction_numerical': 0.012118986412045538, 'mean_word_length': 1.8169596690796277, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '728413', 'n_tokens_mistral': 1048, 'n_tokens_neox': 971, 'n_words': 213}