def main(experiment_id, site, treatment, exp):

    GDAY_SPIN = "gday -s -p "
    GDAY = "gday -p "

    # dir names
    base_dir = os.path.dirname(os.getcwd())
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    shutil.copy(os.path.join(param_dir, "%s_%s_model_indust.cfg" % (experiment_id, site)),
                os.path.join(param_dir, "%s_%s_model_indust_adj_%s.cfg" % (experiment_id, site, exp)))

    itag = "%s_%s_model_indust_adj_%s" % (experiment_id, site, exp)
    otag = "%s_%s_simulation_%s" % (experiment_id, site, exp)
    mtag = "%s_met_data_%s_%s_co2.csv" % (site, treatment, exp)
    out_fn = "D1GDAY%s%s%s.csv" % (site, treatment.upper(), exp.upper())
    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)
    replace_dict = {
                     # files
                     "out_param_fname": "%s" % (out_param_fname),
                     "cfg_fname": "%s" % (cfg_fname),
                     "met_fname": "%s" % (met_fname),
                     "out_fname": "%s" % (out_fname),

                     # control
                     "print_options": "daily",

                    }
    ad.adjust_param_file(cfg_fname, replace_dict)
    os.system(GDAY + cfg_fname)

    # translate output names, units and make a nice CSV compliment with
    # experiment protocol 

    # add this directory to python search path so we can find the scripts!
    sys.path.append(os.path.join(base_dir, "scripts"))
    import translate_GDAY_output_to_EUCFACE_format as tr
    tr.translate_output(out_fname, met_fname)
def main(site, treatment):

    GDAY_SPIN = "./gday -s -p "
    GDAY = "./gday -p "

    # dir names
    base_dir = os.path.dirname(os.getcwd())
    param_dir = os.path.join(d, "params/Run1")
    met_dir = os.path.join(d, "met_data")
    run_dir = os.path.join(d, "outputs/Run1")

    shutil.copy(os.path.join(param_dir, "%s_model_spunup.cfg" % (site)),
                os.path.join(param_dir, "%s_model_transient.cfg" % (site)))

    itag = "%s_model_transient" % (site)
    otag = "%s_model_simulation_%s" % (site, treatment)
    mtag = "%s_met_forcing_transient_%s.csv" % (site, treatment)
    out_fn = "%s_transient_%s.csv" % (site, treatment.upper())
    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)

    replace_dict = {
        # files
        "out_param_fname": "%s" % (out_param_fname),
        "cfg_fname": "%s" % (cfg_fname),
        "met_fname": "%s" % (met_fname),
        "out_fname": "%s" % (out_fname),

        # control
        "print_options": "annual",
    }
    ad.adjust_param_file(cfg_fname, replace_dict)
    os.system(GDAY + cfg_fname)

    # add this directory to python search path so we can find the scripts!
    sys.path.append(os.path.join(d, "code/scripts"))
    import translate_GDAY_output_to_NCEAS_format as tr
def main(experiment_id,
         site,
         SPIN_UP=True,
         POST_INDUST=True,
         ELE_INITIALIZATION=True,
         ELE_SPINUP=True,
         ELE_EQUILIB=True):

    GDAY_SPIN = "./gday -s -p "
    GDAY = "./gday -p "

    # dir names
    base_param_name = "base_start_with_P"
    base_param_dir = "/Users/%s/Documents/Research/Projects/eucface/Git/GDAY/params" % (
        USER)
    base_dir = os.path.dirname(os.getcwd())
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                                                (experiment_id, site)))

        # Run model to equilibrium assuming forest, growing C pools from
        # effectively zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_data_amb_var_co2.csv" % (site)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # default C:N 25.
            # Canopy height = 22 m average of 6 plots at UWS, site_description_stuff/EucFACE_Plot_Summary.doc
            "activesoil": "0.001",
            "activesoiln": "0.00004",
            "activesoilp": "0.000002",
            "age": "100.0",
            "branch": "0.001",
            "branchn": "0.00004",
            "branchp": "0.000002",
            "cstore": "0.0",
            "nstore": "0.0",
            "pstore": "0.0",
            "inorgn": "0.0000",  # 0.00004
            "inorglabp": "0.0000",  # 0.00004
            "inorgsorbp": "0.0",
            "inorgssorbp": "0.0",
            "inorgoccp": "0.0",
            "inorgparp": "0.054",
            "metabsoil": "0.0",
            "metabsoiln": "0.0",
            "metabsoilp": "0.0",
            "metabsurf": "0.0",
            "metabsurfn": "0.0",
            "metabsurfp": "0.0",
            "passivesoil": "0.001",
            "passivesoiln": "0.0004",
            "passivesoilp": "0.000002",
            "prev_sma": "1.0",
            "root": "0.001",
            "croot": "0.0",  # don't simulate coarse roots
            "crootn": "0.0",  # don't simulate coarse roots
            "crootp": "0.0",  # don't simulate coarse roots
            "rootn": "0.00004",
            "rootp": "0.000002",
            "sapwood": "0.001",
            "shoot": "0.001",
            "shootn": "0.00004",
            "shootp": "0.000002",
            "slowsoil": "0.001",
            "slowsoiln": "0.00004",
            "slowsoilp": "0.000002",
            "stem": "0.001",
            "stemn": "0.00004",
            "stemp": "0.000002",
            "stemnimm": "0.00004",
            "stempimm": "0.000002",
            "stemnmob": "0.0",
            "stempmob": "0.0",
            "structsoil": "0.001",
            "structsoiln": "0.00004",
            "structsoilp": "0.000002",
            "structsurf": "0.001",
            "structsurfn": "0.00004",
            "structsurfp": "0.0000024",

            # parameters
            "resp_coeff": "0.2",
            "alpha_j":
            "0.308",  # Taking the theoretical maximum (from Belinda) 0.385 x 0.8 (leaf absorptance) = 0.308
            "intercep_frac": "0.15",
            "max_intercep_lai": "3.0",
            "latitude": "-33.61",
            "albedo": "0.2",
            "finesoil":
            "0.2",  # silt + clay fraction. Surface soil texture (upper 45 cm) for Clarenden sand: 80 +/- 8% sand, 9 +/- 5% silt, 11 +/- 3% clay
            "slamax":
            "5.1",  # current unit: m2 kg-1; original unit: 43.7 +/- 1.5 cm2 g 1 dry mass
            "sla":
            "5.1",  # current unit: m-2 kg-1; original unit: 43.7 +/-  1.5 cm2 g 1 dry mass
            "slazero":
            "5.1",  # current unit: m-2 kg-1; original unit: 43.7+/-  1.5 cm2 g 1 dry mass
            "lai_closed":
            "0.5",  # I am effectively turning this feature off by setting it so low
            "c_alloc_fmax": "0.45",  # 0.35
            "c_alloc_fmin": "0.05",  # 0.15
            "c_alloc_rmax": "0.45",  # 0.35
            "c_alloc_rmin": "0.05",  # 0.05
            "c_alloc_bmax": "0.1",  # 0.1
            "c_alloc_bmin": "0.1",  # 0.1
            "c_alloc_cmax": "0.0",  # turn off coarse roots!
            "biochemical_p_constant": "150.0",
            "fretrans": "0.5",
            "fretransp": "0.5",
            "rretrans": "0.0",
            "bretrans": "0.0",
            "wretrans": "0.7",
            "cretrans": "0.0",
            "crit_n_cost_of_p": "15.0",
            "ncwnewz": "0.003",  #New stem ring N:C at zero leaf N:C (mobile)
            "ncwnew": "0.003",  #New stem ring N:C at critical leaf N:C (mob)
            "ncwimmz": "0.003",  #Immobile stem N C at zero leaf N C
            "ncwimm": "0.003",  #Immobile stem N C at critical leaf N C
            "ncbnewz": "0.003",  #new branch N C at zero leaf N C
            "ncbnew": "0.003",  #new branch N C at critical leaf N C
            "nccnewz": "0.003",  #new coarse root N C at zero leaf N C
            "nccnew": "0.003",  #new coarse root N C at critical leaf N C
            "ncrfac": "0.8",
            "ncmaxfyoung": "0.04",
            "ncmaxfold": "0.04",
            "ncmaxr": "0.03",
            "retransmob": "0.0",
            "fdecay": "0.6",  # 18 mth turnover * 1/30
            "fdecaydry": "0.6",  # 18 mth turnover * 1/30
            "max_p_biochemical": "0.001",
            "rdecay": "0.6",
            "rdecaydry": "0.6",
            "crdecay": "0.00",  # turn off coarse roots!
            "bdecay": "0.1",  # no idea, assuming 50 years
            "wdecay": "0.1",  # no idea, assuming 50 years
            "watdecaydry": "0.0",
            "watdecaywet": "0.1",
            "ligshoot":
            "0.18",  # Based on white et al. 2000 #"0.145",   # assuming leaf and root same as DE word document
            "ligroot":
            "0.22",  # Based on white et al. 2000    # assuming leaf and root same as DE word document
            "rateuptake": "1.8",
            "rateloss": "0.05",  # was 0.1
            "topsoil_depth":
            "450.0",  # Not needed as I have supplied the root zone water and topsoil water available
            "rooting_depth":
            "2500.0",  # Not needed as I have supplied the root zone water and topsoil water available
            "wcapac_root":
            "300.0",  # [mm] (FC-WP)*rooting_depth. But using 2.0 m, site_description_stuff/EucFACE_Plot_Summary.doc
            "wcapac_topsoil":
            "67.5",  # [mm] (FC-WP)*rooting_depth. But using 0.45 m, site_description_stuff/EucFACE_Plot_Summary.doc
            "ctheta_topsoil": "0.65",  # Derive based on soil type loamy_sand
            "ntheta_topsoil": "8.0",  # Derive based on soil type loamy_sand
            "ctheta_root":
            "0.525",  # Derive based on soil type sandy_clay_loam
            "ntheta_root": "5.5",  # Derive based on soil type sandy_clay_loam
            "topsoil_type": "loamy_sand",
            "rootsoil_type": "sandy_clay_loam",
            "soil_order": "andisol",
            "ks": "0.5",
            "kp": "0.3",
            "krp": "0.00001",
            #"dz0v_dh": "0.1",
            #"z0h_z0m": "1.0",
            #"displace_ratio": "0.67",
            "dz0v_dh":
            "0.05",  # Using Value from JULES for TREE PFTs as I don't know what is best. However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
            "displace_ratio":
            "0.75",  # From Jones, pg 67, following Jarvis et al. 1976
            "z0h_z0m": "1.0",
            "g1":
            "3.8667",  # 3.8667 Fit by Me to Teresa's data 7th Nov 2013; or 2.78 from stomatal model
            #"jmaxna": "14.891",      #
            #"jmaxpa": "291.4305",    #
            #"jmaxnb": "99.497",      #
            #"jmaxpb": "99.949",      # 88.56
            #"vcmaxna": "10.453",     # 6.426
            #"vcmaxpa": "153.1748",
            #"vcmaxnb": "74.522",     # 60.526
            #"vcmaxpb": "57.242",     # 27.66
            "jmaxna":
            "49.930",  # forcing intercept to zero; if use all species df, 49.743
            "jmaxpa":
            "933.90",  # forcing intercept to zero; if use all species df, 842.46 
            "jmaxnb": "0.0",  # forcing intercept to zero
            "jmaxpb": "0.0",  # forcing intercept to zero
            "vcmaxna":
            "27.707",  # forcing intercept to zero; if use all species df, 27.627
            "vcmaxpa":
            "516.83",  # forcing intercept to zero; if use all species df, 468.76
            "vcmaxnb": "0.0",  # forcing intercept to zero
            "vcmaxpb": "0.0",  # forcing intercept to zero
            "measurement_temp":
            "25.0",  # parameters obtained at 22 not 25 degrees
            "heighto": "4.826",
            "htpower": "0.35",
            "height0": "5.0",
            "height1": "25.0",
            "leafsap0": "4000.0",  # "4000.0",
            "leafsap1": "2700.0",  # 2700
            "branch0": "5.61",
            "branch1": "0.346",
            "croot0": "0.34",
            "croot1": "0.84",
            "targ_sens": "0.5",
            "density": "800.0",  # 480
            "nf_min": "0.005",
            "nf_crit": "0.015",
            "sapturnover": "0.1",
            "p_atm_deposition":
            "0.000086",  # 1/4 of value from Table 4, Olander et al. 2005; Earth Interactions.
            "p_rate_par_weather":
            "0.0001",  # Calcualted so that weathering rate = atm deposition;
            "passpcmin": "0.005",
            "passpcmax": "0.05",
            "psecmnp": "0.000022",
            "pcbnew": "0.0003",
            "pcbnewz": "0.0003",
            "pccnew": "0.0003",
            "pccnewz": "0.0003",
            "pcmaxfold":
            "0.002",  # 0.0015 Table 3, Olander et al. 2005, Earth Interactions.
            "pcmaxfyoung": "0.002",
            "pcmaxr": "0.0006",
            "pcrfac": "0.8",
            "pcwimm": "0.00014",
            "pcwimmz": "0.00014",
            "pcwnew": "0.00014",
            "pcwnewz": "0.00014",
            "pf_crit": "0.002",
            "pf_min": "0.0002",
            "phmax": "7.6",
            "phmin": "5.0",
            "phtextmin": "0.000008",
            "phtextmax": "0.00015",
            "phtextslope": "0.00004",
            "pmax": "0.002",
            "pmin": "0.01",
            "pmin0": "0.0",
            "pmincrit": "2.0",
            "prateloss": "0.05",
            "prateuptake":
            "3.6",  # Fitted value to obtain balance between uptake N:P ratio and reasonable P labile pool
            "slowpcmin": "0.005",
            "slowpcmax": "0.011111",
            "soilph": "4.5",  # Olander et al., 2005, Earth Interactions.
            "sorpmx": "5.0",
            "sorpaf": "1.0",
            "structcp": "5500.0",
            "structratp": "0.0",

            # control
            "adjust_rtslow": "false",  # priming, off
            "alloc_model": "allometric",
            "assim_model": "mate",
            "calc_sw_params": "true",  #false=use fwp values, true=derive them
            "deciduous_model": "false",
            "disturbance": "false",
            "exudation": "false",
            "fixed_stem_nc": "true",
            "fixed_stem_pc": "true",
            "fixleafnc": "false",
            "fixleafpc": "false",
            "grazing": "false",
            "gs_model": "medlyn",
            "aci_relationship": "ellsworth",
            "model_optroot": "false",
            "modeljm": "1",
            "ncycle": "true",
            "pcycle": "false",
            "nuptake_model": "1",
            "puptake_model": "1",
            "triose_p": "false",
            "output_ascii": "true",
            "passiveconst": "false",
            "print_options": "end",
            "ps_pathway": "c3",
            "respiration_model": "fixed",
            "strfloat": "0",
            "strpfloat": "0",
            "sw_stress_model": "1",  # Sands and Landsberg
            "use_eff_nc": "0",
            "text_effect_p": "1",
            "water_stress": "true",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)

    if POST_INDUST == True:

        # copy spunup base files to make two new experiment files
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_spunup.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_amb_var_co2.csv" % (site)
        out_fn = "%s_amb_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    if POST_INDUST == True:

        # copy spunup base files to make two new experiment files
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_spunup.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_amb_var_co2.csv" % (site)
        out_fn = "%s_amb_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # elevated co2 initialization to store output
    if ELE_INITIALIZATION == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_indust.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_ele_initial" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "%s_ele_initial.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # elevated co2 initialization to store cfg
    if ELE_INITIALIZATION == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_indust.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_ele_initial" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "%s_ele_initial.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # elevated CO2 during spin up to store cfg file
    if ELE_SPINUP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir, "%s_%s_model_ele_initial.cfg" %
                         (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_ele_spinup.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_ele_spinup" % (experiment_id, site)
        otag = "%s_%s_model_ele_spunup" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "FACE_EUC_ele_spunup_%s%s.csv" % (site, treatment.upper())
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)

    # elevated co2 final equilibrium simulation
    if ELE_EQUILIB == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_ele_spunup.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_ele_equil.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_ele_equil" % (experiment_id, site)
        otag = "%s_%s_model_ele_final" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "%s_ele_final_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
def main(experiment_id, latitude, albedo, topsoil_type,
         rootsoil_type, finesoil, SPIN_UP=False, RUN_SIM=False):

    GDAY_SPIN = "gday -s -p "
    GDAY = "gday -p "

    # dir names
    base_param_name = "base_start"
    base_dir = os.getcwd()
    base_param_dir = "/Users/%s/src/c/gday/example/params" % (USER)
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "gday_met_files")
    run_dir = os.path.join(base_dir, "outputs")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_model_spinup.cfg" % \
                                                (experiment_id)))

        # Run model to equilibrium assuming forest, growing C pools from
        # effectively zero
        itag = "%s_model_spinup" % (experiment_id)
        otag = "%s_model_spunup" % (experiment_id)
        mtag = "%s.daily_spin.csv" % (experiment_id)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
                        # files
                        "out_param_fname": "%s" % (out_param_fname),
                        "cfg_fname": "%s" % (cfg_fname),
                        "met_fname": "%s" % (met_fname),
                        "out_fname": "%s" % (out_fname),

                        # state - default C:N 25.
                         "age": "0.0",
                         "canht": "20.0", # Made up
                         "activesoil": "0.001",
                         "activesoiln": "0.00004",
                         "age": "0.0",
                         "branch": "0.001",
                         "branchn": "0.00004",
                         "cstore": "0.001",
                         "inorgn": "0.00004",
                         "metabsoil": "0.0",
                         "metabsoiln": "0.0",
                         "metabsurf": "0.0",
                         "metabsurfn": "0.0",
                         "nstore": "0.00004",
                         "passivesoil": "0.001",
                         "passivesoiln": "0.0004",
                         "prev_sma": "-999.9",
                         "root": "0.001",
                         "root_depth": "-9999.9",
                         "rootn": "0.00004",
                         "sapwood": "0.001",
                         "shoot": "0.001",
                         "shootn": "0.00004",
                         "slowsoil": "0.001",
                         "slowsoiln": "0.00004",
                         "stem": "0.001",
                         "stemn": "0.00004",
                         "stemnimm": "0.00004",
                         "stemnmob": "0.0",
                         "structsoil": "0.001",
                         "structsoiln": "0.00004",
                         "structsurf": "0.001",
                         "structsurfn": "0.00004",
                         "croot": "0.0",   # don't simulate coarse roots
                         "crootn": "0.0",  # don't simulate coarse roots

                         # parameters
                         #"fix_lai": "3.0",
                         "latitude": "%f" % (latitude),
                         "albedo": "%f" % (albedo),
                         "finesoil": "%f" % (finesoil),
                         "intercep_frac": "0.15",
                         "max_intercep_lai": "3.0",
                         "slamax": "4.4",     # made up [m2 kg-1 DW]
                         "sla": "4.4",        # made up [m2 kg-1 DW]
                         "slazero": "4.4",    # made up [m2 kg-1 DW]
                         "cfracts": "0.5",
                         "lai_closed": "0.5",  # I am effectively turning this feature off by setting it so low

                         "c_alloc_fmax": "0.25",
                         "c_alloc_fmin": "0.25",
                         "c_alloc_rmax": "0.05",
                         "c_alloc_rmin": "0.05",
                         "c_alloc_bmax": "0.1",
                         "c_alloc_bmin": "0.1",
                         "c_alloc_cmax": "0.0", # turn off coarse roots!


                         #"c_alloc_fmax": "0.35",
                         #"c_alloc_fmin": "0.15",
                         #"c_alloc_rmax": "0.35",
                         #"c_alloc_rmin": "0.05",
                         #"c_alloc_bmax": "0.1",
                         #"c_alloc_bmin": "0.1",
                         #"c_alloc_cmax": "0.0", # turn off coarse roots!


                         "fretrans": "0.5",
                         "rretrans": "0.0",
                         "bretrans": "0.0",
                         "wretrans": "0.0",
                         "ncwnewz": "0.003",
                         "ncwnew": "0.003",
                         "ncwimmz": "0.003",
                         "ncwimm": "0.003",
                         "ncbnewz": "0.003",
                         "ncbnew": "0.003",
                         "ncrfac": "0.8",
                         "ncmaxfyoung": "0.04",
                         "ncmaxfold": "0.04",
                         "ncmaxr": "0.03",
                         "retransmob": "0.0",
                         "fdecay": "0.59988",      # Protocol  [years-1]
                         "fdecaydry": "0.59988",   # Protocol
                         "rdecay": "0.33333",      # Protocol
                         "rdecaydry": "0.33333",   # Protocol
                         "bdecay": "0.02",         # No data, assuming 50 years
                         "wdecay": "0.02",
                         "crdecay": "0.00",  # turn off coarse roots!
                         "watdecaydry": "0.0",
                         "watdecaywet": "0.1",
                         "ligshoot": "0.24",      # Based on White et al. 2000 for ENF
                         "ligroot": "0.22",       # Based on White et al. 2000
                         "rateuptake": "1.9",           # set somewhat (very) arbitarly to get an LAI ~ 4.
                         "rateloss": "0.3",

                         "topsoil_depth": "50.0",
                         "rooting_depth": "2000.0",
                         "topsoil_type": topsoil_type,
                         "rootsoil_type": rootsoil_type,
                         "ctheta_topsoil": "-999.9",     # Derive based on soil type
                         "ntheta_topsoil": "-999.9",     # Derive based on soil type
                         "ctheta_root": "-999.9",        # Derive based on soil type
                         "ntheta_root": "-999.9",        # Derive based on soil type
                         "measurement_temp": "25.0",
                         "dz0v_dh": "0.075", # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                         "displace_ratio": "0.78",
                         "g1": "2.74",


                         #"jmax": "60.0",
                         #"vcmax": "30.0",
                         "jmaxna": "60.0",
                         "jmaxnb": "0.0",
                         "vcmaxna": "30.0",
                         "vcmaxnb": "0.0",


                         "measurement_temp": "25.0",
                         "heighto": "4.826",
                         "htpower": "0.35",
                         "height0": "5.0",
                         "height1": "30.0",
                         "leafsap0": "4000.0",
                         "leafsap1": "2700.0",
                         "branch0": "5.61",
                         "branch1": "0.346",
                         "croot0": "0.34",
                         "croot1": "0.84",
                         "targ_sens": "0.5",
                         "density": "480.0",
                         "sapturnover": "0.1",

                         "prescribed_leaf_NC": "0.03",

                         # control
                         "adjust_rtslow": "false",  # priming, off
                         "alloc_model": "fixed",
                         "assim_model": "mate",
                         "calc_sw_params": "true",   #false=use fwp values, true=derive them
                         "deciduous_model": "false",
                         "disturbance": "false",
                         "exudation": "false",
                         "fixed_stem_nc": "true",
                         "fixleafnc": "false",
                         "fixed_lai": "false",
                         "grazing": "false",
                         "gs_model": "medlyn",
                         "model_optroot": "false",
                         "modeljm": "1",
                         "ncycle": "false",
                         "nuptake_model": "1",
                         "passiveconst": "false",
                         "print_options": "end",
                         "ps_pathway": "c3",
                         "respiration_model": "fixed",
                         "strfloat": "0",
                         "sw_stress_model": "1",  # Sands and Landsberg
                         "water_stress": "true",

        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)


    if RUN_SIM == True:

        # dir names
        param_dir = os.path.join(base_dir, "params")
        met_dir = os.path.join(base_dir, "gday_met_files")
        run_dir = os.path.join(base_dir, "outputs")

        if SPIN_UP == True:
            shutil.copy(os.path.join(param_dir, "%s_model_spunup.cfg" % (experiment_id)),
                        os.path.join(param_dir, "%s_model_spunup_adj.cfg" % (experiment_id)))

        itag = "%s_model_spunup_adj" % (experiment_id)
        otag = "%s_simulation" % (experiment_id)
        mtag = "%s.daily_run.csv" % (experiment_id)
        out_fn = "%s_simulation.csv" % (experiment_id)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {

                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),

                         # control
                         "print_options": "daily",
                         "sub_daily": "false",

                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
def main(experiment_id, site, SPIN_UP=True, POST_INDUST=True):

    GDAY_SPIN = "gday -s -p "
    GDAY = "gday -p "

    # dir names
    base_param_name = "base_start"
    base_dir = os.path.dirname(os.getcwd())

    # the base param file has been stored in the params directory, so this
    # link isn't necessary
    base_param_dir = "/Users/mdekauwe/src/c/gday/example/params"
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                                                (experiment_id, site)))

        # Run model to equilibrium assuming forest, growing C pools from
        # effectively zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_data_equilibrium_50_yrs.csv" % (site)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
                        # files
                        "out_param_fname": "%s" % (out_param_fname),
                        "cfg_fname": "%s" % (cfg_fname),
                        "met_fname": "%s" % (met_fname),
                        "out_fname": "%s" % (out_fname),

                        # default C:N 25.
                        # Canopy height = 22 m average of 6 plots at UWS, site_description_stuff/EucFACE_Plot_Summary.doc
                        "activesoil": "0.001",
                        "activesoiln": "0.00004",
                        "age": "0.0",
                        "branch": "0.001",
                        "branchn": "0.00004",
                        "cstore": "0.0",
                        "nstore": "0.0",
                        "inorgn": "0.00004",
                        "metabsoil": "0.0",
                        "metabsoiln": "0.0",
                        "metabsurf": "0.0",
                        "metabsurfn": "0.0",
                        "passivesoil": "0.001",
                        "passivesoiln": "0.0004",
                        "prev_sma": "1.0",
                        "root": "0.001",
                        "croot": "0.0",   # don't simulate coarse roots
                        "crootn": "0.0",  # don't simulate coarse roots
                        "rootn": "0.00004",
                        "sapwood": "0.001",
                        "shoot": "0.001",
                        "shootn": "0.00004",
                        "slowsoil": "0.001",
                        "slowsoiln": "0.00004",
                        "stem": "0.001",
                        "stemn": "0.00004",
                        "stemnimm": "0.00004",
                        "stemnmob": "0.0",
                        "structsoil": "0.001",
                        "structsoiln": "0.00004",
                        "structsurf": "0.001",
                        "structsurfn": "0.00004",

                        # parameters
                        "alpha_j": "0.308",  # Taking the theoretical maximum (from Belinda) 0.385 x 0.8 (leaf absorptance) = 0.308
                        "intercep_frac": "0.15",
                        "max_intercep_lai": "3.0",
                        "latitude": "-33.61",
                        "albedo": "0.2",
                        "finesoil": "0.2",   # silt + clay fraction. Surface soil texture (upper 45 cm) for Clarenden sand: 80 +/- 8% sand, 9 +/- 5% silt, 11 +/- 3% clay
                        "slamax": "4.37",    # 43.7 +/- 1.5 cm2 g 1 dry mass
                        "sla": "4.37",   # 43.7 +/-  1.5 cm2 g 1 dry mass
                        "slazero": "4.37",   # 43.7+/-  1.5 cm2 g 1 dry mass
                        "lai_closed": "0.5",  # I am effectively turning this feature off by setting it so low
                        "c_alloc_fmax": "0.35",
                        "c_alloc_fmin": "0.15",
                        "c_alloc_rmax": "0.35",
                        "c_alloc_rmin": "0.05",
                        "c_alloc_bmax": "0.1",
                        "c_alloc_bmin": "0.1",
                        "c_alloc_cmax": "0.0", # turn off coarse roots!
                        "fretrans": "0.5",
                        "rretrans": "0.0",
                        "bretrans": "0.0",
                        "wretrans": "0.0",
                        "cretrans": "0.0",
                        "ncwnewz": "0.003",          #New stem ring N:C at zero leaf N:C (mobile)
                        "ncwnew": "0.003",           #New stem ring N:C at critical leaf N:C (mob)
                        "ncwimmz": "0.003",          #Immobile stem N C at zero leaf N C
                        "ncwimm": "0.003",           #Immobile stem N C at critical leaf N C
                        "ncbnewz": "0.003",          #new branch N C at zero leaf N C
                        "ncbnew": "0.003",           #new branch N C at critical leaf N C
                        "nccnewz": "0.003",          #new coarse root N C at zero leaf N C
                        "nccnew": "0.003",           #new coarse root N C at critical leaf N C
                        "ncrfac": "0.8",
                        "ncmaxfyoung": "0.04",
                        "ncmaxfold": "0.04",
                        "ncmaxr": "0.03",
                        "retransmob": "0.0",
                        "fdecay": "0.6",   # 18 mth turnover * 1/30
                        "fdecaydry": "0.6", # 18 mth turnover * 1/30
                        "rdecay": "0.6",
                        "rdecaydry": "0.6",
                        "crdecay": "0.00",  # turn off coarse roots!
                        "bdecay": "0.02",  # no idea, assuming 50 years
                        "wdecay": "0.02",  # no idea, assuming 50 years
                        "watdecaydry": "0.0",
                        "watdecaywet": "0.1",
                        "ligshoot": "0.18", # Based on white et al. 2000 #"0.145",   # assuming leaf and root same as DE word document
                        "ligroot": "0.22",  # Based on white et al. 2000    # assuming leaf and root same as DE word document
                        "rateuptake": "4.0",
                        "rateloss": "0.1",  # was 0.1
                        "topsoil_depth": "450.0",    # Not needed as I have supplied the root zone water and topsoil water available
                        "rooting_depth": "2000.0",   # Not needed as I have supplied the root zone water and topsoil water available
                        "wcapac_root": "300.0",      # [mm] (FC-WP)*rooting_depth. But using 2.0 m, site_description_stuff/EucFACE_Plot_Summary.doc
                        "wcapac_topsoil": "67.5",    # [mm] (FC-WP)*rooting_depth. But using 0.45 m, site_description_stuff/EucFACE_Plot_Summary.doc
                        "ctheta_topsoil": "0.65",     # Derive based on soil type loamy_sand
                        "ntheta_topsoil": "8.0",     # Derive based on soil type loamy_sand
                        "ctheta_root": "0.525",      # Derive based on soil type sandy_clay_loam
                        "ntheta_root": "5.5",        # Derive based on soil type sandy_clay_loam
                        "topsoil_type": "loamy_sand",
                        "rootsoil_type": "sandy_clay_loam",
                        #"dz0v_dh": "0.1",
                        #"z0h_z0m": "1.0",
                        #"displace_ratio": "0.67",

                        "dz0v_dh": "0.05",         # Using Value from JULES for TREE PFTs as I don't know what is best. However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                        "displace_ratio": "0.75",  # From Jones, pg 67, following Jarvis et al. 1976
                        "z0h_z0m": "1.0",

                        "g1": "3.8667",     # Fit by Me to Teresa's data 7th Nov 2013
                        "jmaxna": "31.5",   # "jmaxna": "133.35",  # at 22 deg c
                        "jmaxnb": "0.0",      # "jmaxnb": "0.0",     # at 22 deg c
                        "vcmaxna": "15.6",   # "vcmaxna": "66.04",  # at 22 deg c
                        "vcmaxnb": "0.0",     # "vcmaxnb": "0.0",    # at 22 deg c
                        "measurement_temp": "22.0", # parameters obtained at 22 not 25 degrees
                        "heighto": "4.826",
                        "htpower": "0.35",
                        "height0": "5.0",
                        "height1": "25.0",
                        "leafsap0": "4000.0", #"4000.0",
                        "leafsap1": "2700.0", #2700
                        "branch0": "5.61",
                        "branch1": "0.346",
                        "croot0": "0.34",
                        "croot1": "0.84",
                        "targ_sens": "0.5",
                        "density": "480.0",
                        "nf_min": "0.005",
                        "nf_crit": "0.015",
                        "sapturnover": "0.1",

                        # control
                        "alloc_model": "allometric",
                        "assim_model": "mate",
                        "calc_sw_params": "true",   #false=use fwp values, true=derive them
                        "deciduous_model": "false",
                        "disturbance": "false",
                        "fixed_stem_nc": "true",
                        "fixleafnc": "false",
                        "grazing": "false",
                        "model_optroot": "false",
                        "modeljm": "1",
                        "ncycle": "true",
                        "nuptake_model": "2",
                        "output_ascii": "true",
                        "passiveconst": "false",
                        "print_options": "end",
                        "ps_pathway": "c3",
                        "respiration_model": "fixed",
                        "strfloat": "0",
                        "trans_model": "1",
                        "use_eff_nc": "0",
                        "use_leuning": "0",
                        "water_stress": "true",
                        "sw_stress_model": "1",  # Sands and Landsberg

        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)

    if POST_INDUST == True:

        # run for 260 odd years post industrial with increasing co2/ndep

        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_industrial_to_present_1750_2011.csv" % (site)
        out_fn = itag + "_indust.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),


                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
Exemple #6
0
def ambient_sim(experiment_id, site, treatment, ascii=True):

    GDAY_EXE = "../src/gday -p "

    # --- FILE PATHS, DIR NAMES ETC --- #
    #base_dir = os.getcwd()
    param_dir = "params"
    met_dir = "met_data"
    run_dir = "outputs"

    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag = "%s_%s_model_youngforest_%s" % (experiment_id, site, treatment)
    otag = "%s_%s_model_simulation_%s" % (experiment_id, site, treatment)
    mtag = "%s_met_data_%s_co2.csv" % (site, treatment)
    out_fn = "D1GDAY%s%s" + (".csv" if ascii else ".bin")
    #import pdb; pdb.set_trace()
    out_fn = out_fn % (site, treatment.upper())

    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)

    replace_dict = {
        "out_param_fname": "%s" % (out_param_fname),
        "cfg_fname": "%s" % (cfg_fname),
        "met_fname": "%s" % (met_fname),
        "out_fname": "%s" % (out_fname),

        # state
        "age": "12.0",

        # control
        "alloc_model": "allometric",
        "assim_model": "mate",
        "calc_sw_params": "True",  #0 uses fwp values, 1= derive them
        "deciduous_model": "false",
        "fixed_stem_nc": "true",
        "fixleafnc": "false",
        "grazing": "false",
        "model_optroot": "false",
        "modeljm": "2",
        "nuptake_model": "2",
        "output_ascii": str(ascii),
        "passiveconst": "false",
        "print_options": "daily",
        "ps_pathway": "c3",
        "respiration_model": "fixed",
        "strfloat": "0",
        "trans_model": "1",
        "use_eff_nc": "0",
        "use_leuning": "0",
        "water_stress": "true",
        "sw_stress_model": "1",  # Landsberg
    }
    ad.adjust_param_file(cfg_fname, replace_dict)

    # --- RUN THE MODEL --- #
    os.system(GDAY_EXE + cfg_fname)

    # translate output to NCEAS style output

    # add this directory to python search path so we can find the scripts!
    sys.path.append("scripts")
    import translate_GDAY_output_to_NCEAS_format as tr
    if ascii:
        tr.translate_output(out_fname, met_fname, binary=False)
    else:
        tr.translate_output(out_fname, met_fname, binary=True)
def main(experiment_id,
         site,
         SPIN_UP=True,
         POST_INDUST=True,
         SPIN_UP_SIMS=True):

    GDAY_SPIN = "gday -s -p "
    GDAY = "gday -p "

    base_dir = os.path.dirname(os.getcwd())

    # dir names
    base_dir = "/Users/%s/src/c/gday/example/params" % (USER)
    param_dir = "params"
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                    (experiment_id, site)))

        # Run model to equilibrium assuming forest, growing C pools from effectively
        # zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_data_equilibrium_50_yrs.csv" % (site)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {

            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # state - default C:N 25.
            "age": "0.0",
            "canht":
            "17.0",  # Canopy height increased from 16m in 2001 to 18m in 2004 at Duke
            "activesoil": "0.001",
            "activesoiln": "0.00004",
            "age": "0.0",
            "branch": "0.001",
            "branchn": "0.00004",
            "cstore": "0.001",
            "inorgn": "0.00004",
            "metabsoil": "0.0",
            "metabsoiln": "0.0",
            "metabsurf": "0.0",
            "metabsurfn": "0.0",
            "nstore": "0.00004",
            "passivesoil": "0.001",
            "passivesoiln": "0.0004",
            "prev_sma": "-999.9",
            "root": "0.001",
            "root_depth": "-9999.9",
            "rootn": "0.00004",
            "sapwood": "0.001",
            "shoot": "0.001",
            "shootn": "0.00004",
            "slowsoil": "0.001",
            "slowsoiln": "0.00004",
            "stem": "0.001",
            "stemn": "0.00004",
            "stemnimm": "0.00004",
            "stemnmob": "0.0",
            "structsoil": "0.001",
            "structsoiln": "0.00004",
            "structsurf": "0.001",
            "structsurfn": "0.00004",
            "croot": "0.0",  # don't simulate coarse roots
            "crootn": "0.0",  # don't simulate coarse roots

            # parameters
            "latitude": "35.9",
            "intercep_frac": "0.15",
            "max_intercep_lai": "3.0",
            "albedo": "0.123",  # modis site avg
            "finesoil":
            "0.51",  # set based on silt+clay fractions of topsoil 0.42+0.09=0.5
            "slamax": "4.4",  # Protocol [m2 kg-1 DW]
            "sla": "4.4",  # Protocol [m2 kg-1 DW]
            "slazero": "4.4",  # Protocol [m2 kg-1 DW]
            "cfracts": "0.5",
            "lai_closed":
            "0.5",  # I am effectively turning this feature off by setting it so low

            #"c_alloc_fmax": "0.25",
            #"c_alloc_fmin": "0.25",
            #"c_alloc_rmax": "0.05",
            #"c_alloc_rmin": "0.05",
            #"c_alloc_bmax": "0.2",
            #"c_alloc_bmin": "0.2",

            #"c_alloc_fmax": "0.3",
            #"c_alloc_fmin": "0.3",
            #"c_alloc_rmax": "0.3",
            #"c_alloc_rmin": "0.3",
            #"c_alloc_bmax": "0.2",
            #"c_alloc_bmin": "0.2",
            #"c_alloc_cmax": "0.0", # turn off coarse roots!
            "c_alloc_fmax": "0.35",
            "c_alloc_fmin": "0.15",
            "c_alloc_rmax": "0.35",
            "c_alloc_rmin": "0.05",
            "c_alloc_bmax": "0.1",
            "c_alloc_bmin": "0.1",
            "c_alloc_cmax": "0.0",  # turn off coarse roots!
            "fretrans": "0.5",
            "rretrans": "0.0",
            "bretrans": "0.0",
            "wretrans": "0.0",
            "ncwnewz": "0.003",
            "ncwnew": "0.003",
            "ncwimmz": "0.003",
            "ncwimm": "0.003",
            "ncbnewz": "0.003",
            "ncbnew": "0.003",
            "ncrfac": "0.8",
            "ncmaxfyoung": "0.04",
            "ncmaxfold": "0.04",
            "ncmaxr": "0.03",
            "retransmob": "0.0",
            "fdecay": "0.59988",  # Protocol  [years-1]
            "fdecaydry": "0.59988",  # Protocol
            "rdecay": "0.33333",  # Protocol
            "rdecaydry": "0.33333",  # Protocol
            "bdecay": "0.02",  # No data, assuming 50 years
            "wdecay": "0.02",
            "crdecay": "0.00",  # turn off coarse roots!
            "watdecaydry": "0.0",
            "watdecaywet": "0.1",
            "ligshoot": "0.24",  # Based on White et al. 2000 for ENF
            "ligroot": "0.22",  # Based on White et al. 2000
            "rateuptake":
            "2.2",  # set somewhat (very) arbitarly to get an LAI ~ 4.
            "rateloss": "0.5",
            "wcapac_root":
            "96.75",  # [mm] (FC (m3/m-3)-WP (m3/m-3)) * rooting_depth (mm) using derived values and depth from protocol, 750 mm (FC=0.164 - WP=0.035)
            "wcapac_topsoil":
            "25.8",  # [mm] (FC (m3/m-3)-WP (m3/m-3)) * rooting_depth (mm) using derived values and depth from protocol, assuming 200 mm top soil following Corbeels 2005a (FC=0.164 - WP=0.035)
            "ctheta_topsoil": "0.5",  # Derive based on soil type clay_loam
            "ntheta_topsoil": "5.0",  # Derive based on soil type clay_loam
            "ctheta_root": "0.4",  # Derive based on soil type clay
            "ntheta_root": "3.0",  # Derive based on soil type clay
            "topsoil_type": "clay_loam",
            "rootsoil_type": "clay",
            "measurement_temp": "25.0",
            "dz0v_dh":
            "0.075",  # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
            "displace_ratio": "0.78",
            "g1": "2.74",

            #"jmaxna": "60.0",  # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
            #"jmaxnb": "0.0",   # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
            #"vcmaxna": "30.61",# Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
            #"vcmaxnb": "0.0",  # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
            "vcmaxna": "22.29",
            "vcmaxnb": "8.45",
            "jv_slope": "1.86",
            "jv_intercept": "0.0",
            "sapturnover": "0.1",
            "heighto": "4.826",
            "htpower": "0.35",
            "height0": "5.0",
            "height1": "20.0",
            "leafsap0": "8000.0",
            "leafsap1": "3060.0",  # Duke protocol
            "branch0": "5.61",
            "branch1": "0.346",
            "targ_sens": "0.5",
            "density": "420.0",

            # control
            "adjust_rtslow": "false",  # priming, off
            "alloc_model": "allometric",
            "assim_model": "mate",
            "calc_sw_params": "false",  #false=use fwp values, true=derive them
            "deciduous_model": "false",
            "disturbance": "false",
            "exudation": "false",
            "fixed_stem_nc": "true",
            "fixleafnc": "false",
            "grazing": "false",
            "gs_model": "medlyn",
            "model_optroot": "false",
            "modeljm": "2",
            "ncycle": "true",
            "nuptake_model": "2",
            "passiveconst": "false",
            "print_options": "end",
            "ps_pathway": "c3",
            "respiration_model": "fixed",
            "strfloat": "0",
            "sw_stress_model": "1",  # Sands and Landsberg
            "trans_model": "1",
            "use_eff_nc": "0",
            "use_leuning": "0",
            "water_stress": "true",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)

    if POST_INDUST == True:

        # run for 200 odd years post industrial with increasing co2/ndep
        # we are swapping forest params for grass params now
        # copy spunup base files to make two new experiment files
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_spunup.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_industrial_to_present_1850_1983.csv" % (site)
        out_fn = itag + "_indust.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # git stuff
            #"git_hash": str(git_revision),

            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # state - default C:N 25.
            "age": "0.0",
            "branch": "0.0",
            "branchn": "0.0",
            "canht": "0.79",  # Taken default C3grass value from JULES
            "cstore": "0.001",
            "nstore": "0.00004",
            "croot": "0.0",  # don't simulate coarse roots
            "crootn": "0.0",  # don't simulate coarse roots
            "root": "0.001",
            "rootn": "0.00004",
            "sapwood": "0.0",
            "shoot": "0.001",
            "shootn": "0.00004",
            "stem": "0.0",
            "stemn": "0.0",
            "stemnimm": "0.0",
            "stemnmob": "0.0",
            "nepsum": "0.0",
            "nppsum": "0.0",

            # parameters
            "ligshoot": "0.09",  # Smith et al. 2000, GRASS
            "ligroot": "0.22",  # Smith et al. 2000
            "age": "1.0",
            "slamax": "6.0",
            "sla": "6.0",
            "slazero": "6.0",
            "cfracts": "0.5",
            "lai_closed":
            "0.5",  # I am effectively turning this feature off by setting it so low
            "c_alloc_fmax": "0.8",
            "c_alloc_fmin": "0.2",
            "c_alloc_rmax": "0.8",
            "c_alloc_rmin": "0.2",
            "c_alloc_bmax": "0.0",
            "c_alloc_bmin": "0.0",
            "c_alloc_cmax": "0.0",  # turn off coarse roots!
            "fretrans": "0.4",
            "rretrans": "0.0",
            "bretrans": "0.0",
            "wretrans": "0.0",
            "ncwnewz": "0.0",
            "ncwnew": "0.0",
            "ncwimmz": "0.0",
            "ncwimm": "0.0",
            "ncbnewz": "0.0",
            "ncbnew": "0.0",
            "ncrfac": "0.7",
            "ncmaxfyoung": "0.035",
            "ncmaxfold": "0.035",
            "ncmaxr": "0.0287",
            "retransmob": "0.0",
            "fdecay": "1.0",
            "fdecaydry": "1.0",
            "rdecay": "1.0",
            "rdecaydry": "1.0",
            "bdecay": "0.0",
            "wdecay": "0.0",
            "watdecaydry": "0.0",
            "watdecaywet": "0.1",
            "crdecay": "0.00",  # turn off coarse roots!
            "dz0v_dh": "0.10",  # Taken default C3grass value from JULES
            "displace_ratio": "0.64",  #Jones 1992, pg. 67.
            "z0h_z0m":
            "1.0",  # Assume z0m = z0h, probably a big assumption [as z0h often < z0m.], see comment in code!!
            "jmaxna": "62.0",  # assuming j = v * 2
            "jmaxnb": "0.0",  # assuming no intercept
            "vcmaxna":
            "31.0",  # C3 grasses - CLM4 tech doc, table 8.2, Oleson et al 2010, page 176
            "vcmaxnb": "0.0",  # assuming no intercept

            # control
            "adjust_rtslow": "false",  # priming, off
            "alloc_model": "grasses",
            "assim_model": "mate",
            "calc_sw_params": "false",  #false=use fwp values, true=derive them
            "deciduous_model": "false",
            "disturbance": "false",
            "exudation": "false",
            "fixed_stem_nc": "true",
            "fixleafnc": "false",
            "grazing": "false",
            "gs_model": "medlyn",
            "model_optroot": "false",
            "modeljm": "1",
            "nuptake_model": "2",
            "ncycle": "true",
            "passiveconst": "false",
            "print_options": "end",
            "ps_pathway": "c3",
            "respiration_model": "fixed",
            "strfloat": "0",
            "sw_stress_model": "1",  # Sands and Landsberg
            "trans_model": "1",
            "use_eff_nc": "0",
            "use_leuning": "0",
            "water_stress": "true",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
Exemple #8
0
def ambient_sim(experiment_id, site, treatment, ascii=True):

    GDAY_EXE = "../src/gday -p "

    # --- FILE PATHS, DIR NAMES ETC --- #
    #base_dir = os.getcwd()
    param_dir    = "params"
    met_dir      = "met_data"
    run_dir      = "outputs"

    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag   = "%s_%s_model_youngforest_%s" % (experiment_id, site, treatment)
    otag   = "%s_%s_model_simulation_%s" % (experiment_id, site, treatment)
    mtag   = "%s_met_data_%s_co2.csv" % (site, treatment)
    out_fn = "D1GDAY%s%s" + (".csv" if ascii else ".bin")
    #import pdb; pdb.set_trace()
    out_fn = out_fn % (site, treatment.upper())

    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)

    replace_dict = {
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),

                         # state
                         "age": "12.0",


                         # control
                         "alloc_model": "allometric",
                         "assim_model": "mate",
                         "calc_sw_params": "True",   #0 uses fwp values, 1= derive them
                         "deciduous_model": "false",
                         "fixed_stem_nc": "true",
                         "fixleafnc": "false",
                         "grazing": "false",
                         "model_optroot": "false",
                         "modeljm": "2",
                         "nuptake_model": "2",
                         "output_ascii" : str(ascii),
                         "passiveconst": "false",
                         "print_options": "daily",
                         "ps_pathway": "c3",
                         "respiration_model": "fixed",
                         "strfloat": "0",
                         "trans_model": "1",
                         "use_eff_nc": "0",
                         "use_leuning": "0",
                         "water_stress": "true",
                         "sw_stress_model": "1",     # Landsberg
                    }
    ad.adjust_param_file(cfg_fname, replace_dict)

    # --- RUN THE MODEL --- #
    os.system(GDAY_EXE + cfg_fname)

    # translate output to NCEAS style output

    # add this directory to python search path so we can find the scripts!
    sys.path.append("scripts")
    import translate_GDAY_output_to_NCEAS_format as tr
    if ascii:
        tr.translate_output(out_fname, met_fname, binary=False)
    else:
        tr.translate_output(out_fname, met_fname, binary=True)
Exemple #9
0
def main(experiment_id, latitude, longitude, treatment, scheme):

    GDAY = "canopy_scaling -p "

    # dir names
    base_param_name = "base_start"
    base_dir = os.path.dirname(os.getcwd())
    base_param_dir = "../../params"

    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    # copy base files to make two new experiment files
    shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                os.path.join(param_dir, "%s_model_run.cfg" % \
                                                (experiment_id)))

    if scheme == "mate":
        sub_daily = "false"
        alpha_j = 0.26
    else:
        sub_daily = "true"
        alpha_j = 0.308

    itag = "%s_model_run" % (experiment_id)
    otag = "%s_simulation" % (experiment_id)
    mtag = "%s_%s.csv" % (scheme, treatment)

    out_fn = "%s_simulation.csv" % (experiment_id)
    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)

    out_fname = os.path.join(run_dir, out_fn)
    replace_dict = {

        # files
        "out_param_fname": "%s" % (out_param_fname),
        "cfg_fname": "%s" % (cfg_fname),
        "met_fname": "%s" % (met_fname),
        "out_fname": "%s" % (out_fname),
        "fix_lai": "1.2",
        #"alpha_j": "0.30588",
        "alpha_j": "%f" % (alpha_j),
        "max_intercep_lai": "3.0",
        "latitude": "%f" % (latitude),
        "longitude": "%f" % (longitude),
        "slamax": "4.37",  # 43.7 +/- 1.5 cm2 g 1 dry mass
        "sla": "4.37",  # 43.7 +/-  1.5 cm2 g 1 dry mass
        "slazero": "4.37",  # 43.7+/-  1.5 cm2 g 1 dry mass
        "lai_cover": "0.5",
        "kn": "0.3",
        "g1": "3.8667",  # Fit by Me to Teresa's data 7th Nov 2013
        "jmax": "55.0",  # 2.0 * vcmax
        "vcmax": "110.0",  # CABLE EBF
        "jmaxna": "110.0",
        "jmaxnb": "0.0",
        "vcmaxna": "55.0",
        "vcmaxnb": "0.0",
        "measurement_temp": "25.0",
        "prescribed_leaf_NC": "0.03",

        # control
        "assim_model": "mate",
        "fixed_lai": "true",
        "gs_model": "medlyn",
        "modeljm": "1",
        "ncycle": "false",
        "ps_pathway": "c3",
        "respiration_model": "fixed",
        "sub_daily": "%s" % (sub_daily),
        "sw_stress_model": "1",  # Sands and Landsberg
        "water_stress": "false",
    }
    ad.adjust_param_file(cfg_fname, replace_dict)
    ofname = " > outputs/%s_%s.csv" % (scheme, treatment)
    #print(cfg_fname)
    #os.system(GDAY + cfg_fname + ofname)
    os.system(GDAY + cfg_fname)
def main(experiment_id, site, SPIN_UP=True, POST_INDUST=True, ELE_INITIALIZATION=True, ELE_SPINUP=True, ELE_EQUILIB=True):

    GDAY_SPIN = "./gday -s -p "
    GDAY = "./gday -p "

    # dir names
    base_param_name = "base_start_with_P"
    base_param_dir = "/Users/%s/Documents/Research/Projects/Temperature_acclimation/Git/GDAY/params" % (USER)
    base_dir = os.path.dirname(os.getcwd())
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                                                (experiment_id, site)))

        # Run model to equilibrium assuming forest, growing C pools from
        # effectively zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_data_amb_var_co2.csv" % (site)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
                        # files
                        "out_param_fname": "%s" % (out_param_fname),
                        "cfg_fname": "%s" % (cfg_fname),
                        "met_fname": "%s" % (met_fname),
                        "out_fname": "%s" % (out_fname),

                        # default C:N 25.
                        # Canopy height = 22 m average of 6 plots at UWS, site_description_stuff/EucFACE_Plot_Summary.doc
                        "activesoil": "0.001",
                        "activesoiln": "0.00004",
                        "activesoilp": "0.000002",
                        "age": "100.0",
                        "branch": "0.001",
                        "branchn": "0.00004",
                        "branchp": "0.000002",
                        "cstore": "0.0",
                        "nstore": "0.0",
                        "pstore": "0.0",
                        "inorgn": "0.0000",     # 0.00004
                        "inorglabp": "0.0000",  # 0.00004
                        "inorgsorbp": "0.0",
                        "inorgssorbp": "0.0",
                        "inorgoccp": "0.0",
                        "inorgparp": "0.054",
                        "metabsoil": "0.0",
                        "metabsoiln": "0.0",
                        "metabsoilp": "0.0",
                        "metabsurf": "0.0",
                        "metabsurfn": "0.0",
                        "metabsurfp": "0.0",
                        "passivesoil": "0.001",
                        "passivesoiln": "0.0004",
                        "passivesoilp": "0.000002",
                        "prev_sma": "1.0",
                        "root": "0.001",
                        "croot": "0.0",   # don't simulate coarse roots
                        "crootn": "0.0",  # don't simulate coarse roots
                        "crootp": "0.0",  # don't simulate coarse roots
                        "rootn": "0.00004",
                        "rootp": "0.000002",
                        "sapwood": "0.001",
                        "shoot": "0.001",
                        "shootn": "0.00004",
                        "shootp": "0.000002",
                        "slowsoil": "0.001",
                        "slowsoiln": "0.00004",
                        "slowsoilp": "0.000002",
                        "stem": "0.001",
                        "stemn": "0.00004",
                        "stemp": "0.000002",
                        "stemnimm": "0.00004",
                        "stempimm": "0.000002",
                        "stemnmob": "0.0",
                        "stempmob": "0.0",
                        "structsoil": "0.001",
                        "structsoiln": "0.00004",
                        "structsoilp": "0.000002",
                        "structsurf": "0.001",
                        "structsurfn": "0.00004",
                        "structsurfp": "0.0000024",

                        # parameters
                        "resp_coeff": "0.2",      
                        "alpha_j": "0.308",  # Taking the theoretical maximum (from Belinda) 0.385 x 0.8 (leaf absorptance) = 0.308
                        "intercep_frac": "0.15",
                        "max_intercep_lai": "3.0",
                        "latitude": "-33.61",
                        "albedo": "0.2",
                        "finesoil": "0.2",   # silt + clay fraction. Surface soil texture (upper 45 cm) for Clarenden sand: 80 +/- 8% sand, 9 +/- 5% silt, 11 +/- 3% clay
                        "slamax": "5.1",    # current unit: m2 kg-1; original unit: 43.7 +/- 1.5 cm2 g 1 dry mass
                        "sla": "5.1",       # current unit: m-2 kg-1; original unit: 43.7 +/-  1.5 cm2 g 1 dry mass
                        "slazero": "5.1",   # current unit: m-2 kg-1; original unit: 43.7+/-  1.5 cm2 g 1 dry mass
                        "lai_closed": "0.5",  # I am effectively turning this feature off by setting it so low
                        "c_alloc_fmax": "0.45",  # 0.35
                        "c_alloc_fmin": "0.05",  # 0.15
                        "c_alloc_rmax": "0.45",  # 0.35
                        "c_alloc_rmin": "0.05",  # 0.05
                        "c_alloc_bmax": "0.1",   # 0.1
                        "c_alloc_bmin": "0.1",   # 0.1
                        "c_alloc_cmax": "0.0", # turn off coarse roots!
                        "biochemical_p_constant": "150.0",
                        "fretrans": "0.5",
                        "fretransp": "0.5",
                        "rretrans": "0.0",
                        "bretrans": "0.0",
                        "wretrans": "0.7",
                        "cretrans": "0.0",
                        "crit_n_cost_of_p": "15.0",
                        "ncwnewz": "0.003",          #New stem ring N:C at zero leaf N:C (mobile)
                        "ncwnew": "0.003",           #New stem ring N:C at critical leaf N:C (mob)
                        "ncwimmz": "0.003",          #Immobile stem N C at zero leaf N C
                        "ncwimm": "0.003",           #Immobile stem N C at critical leaf N C
                        "ncbnewz": "0.003",          #new branch N C at zero leaf N C
                        "ncbnew": "0.003",           #new branch N C at critical leaf N C
                        "nccnewz": "0.003",          #new coarse root N C at zero leaf N C
                        "nccnew": "0.003",           #new coarse root N C at critical leaf N C
                        "ncrfac": "0.8",
                        "ncmaxfyoung": "0.04",
                        "ncmaxfold": "0.04",
                        "ncmaxr": "0.03",
                        "retransmob": "0.0",
                        "fdecay": "0.6",    # 18 mth turnover * 1/30
                        "fdecaydry": "0.6", # 18 mth turnover * 1/30
                        "max_p_biochemical": "0.001",
                        "rdecay": "0.6",
                        "rdecaydry": "0.6",
                        "crdecay": "0.00",           # turn off coarse roots!
                        "bdecay": "0.1",            # no idea, assuming 50 years
                        "wdecay": "0.1",            # no idea, assuming 50 years
                        "watdecaydry": "0.0",
                        "watdecaywet": "0.1",
                        "ligshoot": "0.18",          # Based on white et al. 2000 #"0.145",   # assuming leaf and root same as DE word document
                        "ligroot": "0.22",           # Based on white et al. 2000    # assuming leaf and root same as DE word document
                        "rateuptake": "1.8",
                        "rateloss": "0.05",           # was 0.1
                        "topsoil_depth": "450.0",    # Not needed as I have supplied the root zone water and topsoil water available
                        "rooting_depth": "2500.0",   # Not needed as I have supplied the root zone water and topsoil water available
                        "wcapac_root": "300.0",      # [mm] (FC-WP)*rooting_depth. But using 2.0 m, site_description_stuff/EucFACE_Plot_Summary.doc
                        "wcapac_topsoil": "67.5",    # [mm] (FC-WP)*rooting_depth. But using 0.45 m, site_description_stuff/EucFACE_Plot_Summary.doc
                        "ctheta_topsoil": "0.65",     # Derive based on soil type loamy_sand
                        "ntheta_topsoil": "8.0",     # Derive based on soil type loamy_sand
                        "ctheta_root": "0.525",      # Derive based on soil type sandy_clay_loam
                        "ntheta_root": "5.5",        # Derive based on soil type sandy_clay_loam
                        "topsoil_type": "loamy_sand",
                        "rootsoil_type": "sandy_clay_loam",
                        "soil_order": "andisol",
                        "ks": "0.5",
                        "kp": "0.3",
                        "krp": "0.00001",
                        #"dz0v_dh": "0.1",
                        #"z0h_z0m": "1.0",
                        #"displace_ratio": "0.67",

                        "dz0v_dh": "0.05",         # Using Value from JULES for TREE PFTs as I don't know what is best. However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                        "displace_ratio": "0.75",  # From Jones, pg 67, following Jarvis et al. 1976
                        "z0h_z0m": "1.0",

                        "g1": "3.8667",          # 3.8667 Fit by Me to Teresa's data 7th Nov 2013; or 2.78 from stomatal model
                        #"jmaxna": "14.891",      # 
                        #"jmaxpa": "291.4305",    # 
                        #"jmaxnb": "99.497",      # 
                        #"jmaxpb": "99.949",      # 88.56  
                        #"vcmaxna": "10.453",     # 6.426
                        #"vcmaxpa": "153.1748",    
                        #"vcmaxnb": "74.522",     # 60.526
                        #"vcmaxpb": "57.242",     # 27.66
                        "jmaxna": "49.930",      # forcing intercept to zero; if use all species df, 49.743
                        "jmaxpa": "933.90",      # forcing intercept to zero; if use all species df, 842.46 
                        "jmaxnb": "0.0",         # forcing intercept to zero
                        "jmaxpb": "0.0",         # forcing intercept to zero
                        "vcmaxna": "27.707",     # forcing intercept to zero; if use all species df, 27.627
                        "vcmaxpa": "516.83",     # forcing intercept to zero; if use all species df, 468.76
                        "vcmaxnb": "0.0",        # forcing intercept to zero
                        "vcmaxpb": "0.0",        # forcing intercept to zero
                        "measurement_temp": "25.0", # parameters obtained at 22 not 25 degrees
                        "heighto": "4.826",
                        "htpower": "0.35",
                        "height0": "5.0",
                        "height1": "25.0",
                        "leafsap0": "4000.0",     # "4000.0",
                        "leafsap1": "2700.0",     # 2700
                        "branch0": "5.61",
                        "branch1": "0.346",
                        "croot0": "0.34",
                        "croot1": "0.84",
                        "targ_sens": "0.5",
                        "density": "800.0",       # 480
                        "nf_min": "0.005", 
                        "nf_crit": "0.015",
                        "sapturnover": "0.1",
                        "p_atm_deposition": "0.000086",   # 1/4 of value from Table 4, Olander et al. 2005; Earth Interactions.
                        "p_rate_par_weather": "0.0001", # Calcualted so that weathering rate = atm deposition;
                        "passpcmin": "0.005",
                        "passpcmax": "0.05",
                        "psecmnp": "0.000022",
                        "pcbnew": "0.0003",
                        "pcbnewz": "0.0003",
                        "pccnew": "0.0003",
                        "pccnewz": "0.0003",
                        "pcmaxfold": "0.002",    # 0.0015 Table 3, Olander et al. 2005, Earth Interactions.
                        "pcmaxfyoung": "0.002",
                        "pcmaxr": "0.0006",
                        "pcrfac": "0.8",
                        "pcwimm": "0.00014",
                        "pcwimmz": "0.00014",
                        "pcwnew": "0.00014",
                        "pcwnewz": "0.00014",
                        "pf_crit": "0.002",
                        "pf_min": "0.0002",
                        "phmax": "7.6",
                        "phmin": "5.0",
                        "phtextmin": "0.000008",
                        "phtextmax": "0.00015",
                        "phtextslope": "0.00004",
                        "pmax": "0.002",
                        "pmin": "0.01",
                        "pmin0": "0.0",
                        "pmincrit": "2.0",
                        "prateloss": "0.05",
                        "prateuptake": "3.6",    # Fitted value to obtain balance between uptake N:P ratio and reasonable P labile pool
                        "slowpcmin": "0.005",
                        "slowpcmax": "0.011111",
                        "soilph": "4.5",          # Olander et al., 2005, Earth Interactions.
                        "sorpmx": "5.0",
                        "sorpaf": "1.0",
                        "structcp": "5500.0",
                        "structratp": "0.0",

                        # control
                        "adjust_rtslow": "false",  # priming, off
                        "alloc_model": "allometric",
                        "assim_model": "mate",
                        "calc_sw_params": "true",   #false=use fwp values, true=derive them
                        "deciduous_model": "false",
                        "disturbance": "false",
                        "exudation": "false",
                        "fixed_stem_nc": "true",
                        "fixed_stem_pc": "true",
                        "fixleafnc": "false",
                        "fixleafpc": "false",
                        "grazing": "false",
                        "gs_model": "medlyn",
                        "aci_relationship": "ellsworth",
                        "model_optroot": "false",
                        "modeljm": "1",
                        "ncycle": "true",
                        "pcycle": "false",
                        "nuptake_model": "1",
                        "puptake_model": "1",
                        "triose_p": "false",
                        "output_ascii": "true",
                        "passiveconst": "false",
                        "print_options": "end",
                        "ps_pathway": "c3",
                        "respiration_model": "fixed",
                        "strfloat": "0",
                        "strpfloat": "0",
                        "sw_stress_model": "1",  # Sands and Landsberg
                        "use_eff_nc": "0",
                        "text_effect_p": "1",
                        "water_stress": "true",

        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)
        
        
    if POST_INDUST == True:

        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_amb_var_co2.csv" % (site)
        out_fn = "%s_amb_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
     
                         # control
                         "print_options": "end",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    if POST_INDUST == True:

        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_amb_var_co2.csv" % (site)
        out_fn = "%s_amb_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
     
                         # control
                         "print_options": "daily",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
    
    # elevated co2 initialization to store output 
    if ELE_INITIALIZATION == True:
        
        # copy last cfg file and make new one
        shutil.copy(os.path.join(param_dir, "%s_%s_model_indust.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_ele_initial" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "%s_ele_initial.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
    
                         # control
                         "print_options": "daily",
    
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
    
    # elevated co2 initialization to store cfg
    if ELE_INITIALIZATION == True:
        
        # copy last cfg file and make new one
        shutil.copy(os.path.join(param_dir, "%s_%s_model_indust.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_ele_initial" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "%s_ele_initial.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
    
                         # control
                         "print_options": "end",
    
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
    
    # elevated CO2 during spin up to store cfg file
    if ELE_SPINUP == True:
        
        # copy last cfg file and make new one
        shutil.copy(os.path.join(param_dir, "%s_%s_model_ele_initial.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_ele_spinup.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_ele_spinup" % (experiment_id, site)
        otag = "%s_%s_model_ele_spunup" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "FACE_EUC_ele_spunup_%s%s.csv" % (site, treatment.upper())
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
    
                         # control
                         "print_options": "end",
    
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)
    
    # elevated co2 final equilibrium simulation
    if ELE_EQUILIB == True:
        
        # copy last cfg file and make new one
        shutil.copy(os.path.join(param_dir, "%s_%s_model_ele_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_ele_equil.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_ele_equil" % (experiment_id, site)
        otag = "%s_%s_model_ele_final" % (experiment_id, site)
        mtag = "%s_met_data_%s_var_co2.csv" % (site, treatment)
        out_fn = "%s_ele_final_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
    
                         # control
                         "print_options": "daily",
    
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
Exemple #11
0
def main(site, SPIN_UP=True):

    GDAY_SPIN = "./gday -s -p "
    GDAY = "./gday -p "

    # dir names
    base_param_name = "base_start_with_P"
    base_dir = os.path.dirname(os.getcwd())
    base_param_dir = os.path.join(d, "code/example/params")
    param_dir = os.path.join(d, "params/Run1")
    run_dir = os.path.join(d, "outputs/Run1")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_model_spinup.cfg" % \
                    (site)))

        # Run model to equilibrium assuming forest, growing C pools from effectively
        # zero
        itag = "%s_model_spinup" % (site)
        otag = "%s_model_spunup" % (site)
        # mtag = "%s_met_forcing_transient_co2_amb.csv" % (site)
        out_fn = itag + "_equilib.csv"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        # met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         # "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),

                         # state - default C:N 25.
                         "shoot": "11.0",              # assuming total 10 g plant, 2 in leaf 
                         "shootn": "0.3",            # 0.0008 C:N = 25 
                         "shootp": "0.01",           # 0.00003 C:P = 680 
                         "stem": "1700.0",               # assuming total 10 g plant, 6 in stem
                         "stemn": "0.2",            # 0.0003 C:N = 200 
                         "stemp": "0.0005",          # 0.000018 C:P = 3333.33
                         "root": "3.0",               # assuming total 10 g plant, 2 in root
                         "rootn": "0.07",           # 0.00056 Root CN = leaf * 0.7 
                         "rootp": "0.002",          # 0.000021 Root CP = leaf * 0.7
                         "activesoil": "11.0",        # guess
                         "activesoiln": "0.7",    # C:N = 15
                         "activesoilp": "0.01",  # C:P = 800
                         "slowsoil": "170.0",          # guess
                         "slowsoiln": "8.0",       # C:N = 20
                         "slowsoilp": "0.08",     # C:P = 2000
                         "passivesoil": "180.0",        # analytical
                         "passivesoiln": "18.0",       # C:N = 10
                         "passivesoilp": "0.9",      # C:P = 200
                         "metabsoil": "0.00",          #
                         "metabsoiln": "0.0",          # C:N = 10 <-> 25
                         "metabsoilp": "0.0",          # C:P = 80 <-> 150
                         "metabsurf": "0.00",          #
                         "metabsurfn": "0.0",          # C:N = 10 <-> 25
                         "metabsurfp": "0.0",          # C:P = 80 <-> 150
                         "structsoil": "0.00",         # 
                         "structsoiln": "0.00000",     # C:N = 150 
                         "structsoilp": "0.000000",    # C:P = 500
                         "structsurf": "0.00",         # 
                         "structsurfn": "0.00000",     # C:N = 150
                         "structsurfp": "0.000000",    # C:P = 500
                         "inorgn": "0.016",         # annual input = 0.01 t/ha, monthly rate 
                         "inorgavlp": "0.0005",    # annual input = 0.0004 t/ha, monthly rate 
                         "inorgssorbp": "0.00009",         # 
                         "inorgoccp": "1.2",           # 
                         "inorgparp": "0.00003",           # annual input = 0.0004 t/ha, monthly rate 
                         "canht": "30.0",              # 
                         "sapwood": "0.01",            # initialize value, needed it for initialize alloc_stuffs

                         # parameters
                         "co2_in": "350.0",                    # spin-up value
                         "I0": "3000.0",                       # spin-up value, annual rate, unit MJ/m2/yr
                         "ndep_in": "0.005",                   # spin-up value, annual rate, unit t/ha/yr
                         "nfix_in": "0.005",                   # spin-up value, annual rate, unit t/ha/yr 
                         "pdep_in": "0.0004",                  # spin-up value, annual rate, unit t/ha/yr
                         "tsoil_in": "15.0",                   # spin-up value
                         "k1": "0.01",                         # rate from inorgavlp to inorgssorbp, adjustable    
                         "k2": "0.01",                         # rate from inorgssorbp to inorgavlp, adjustable
                         "k3": "0.05",                         # rate from inorgssorbp to inorgoccp, adjustable
                         "finesoil": "0.5",                    # match against analytical
                         "sla": "5.0",                         # match against analytical
                         "cfracts": "0.45",                    # match against analytical

                         "c_alloc_fmax": "0.2",                   # allocation to leaf, fixed
                         "c_alloc_fmin": "0.2",                   # allocation to leaf, fixed
                         "c_alloc_rmax": "0.2",                   # allocation to root, fixed
                         "c_alloc_rmin": "0.2",                   # allocation to root, fixed

                         "fdecay": "0.5",                      # /yr
                         "rdecay": "1.5",                      # /yr
                         "wdecay": "0.01",                     # /yr
                         "sapturnover": "0.1",                 # /yr

                         "fretransn": "0.5",                   # match against analytical
                         "fretransp": "0.6",                   # match against analytical
                         "rretrans": "0.0",                    #
                         "wretrans": "0.0",                    # 

                         "structcn": "200.0",                  # Commins and MCM uses 150
                         "structcp": "3333.33",                  # Literature suggests 500:62500
                         "metabcnmax": "25.0",                 # 
                         "metabcnmin": "10.0",                 # 
                         "metabcpmax": "150.0",                # 
                         "metabcpmin": "80.0",                 #
                         "ligshoot": "0.2",                    # match against analytical
                         "ligroot": "0.16",                    # match against analytical
                         
                         "height0": "5.0",
                         "height1": "30.0",
                         "heighto": "4.826",
                         "htpower": "0.35",
                         "density": "420.0",
                         "leafsap0": "8000.0",
                         "leafsap1": "3060.0",
                         "targ_sens": "0.5",

		             	 "actncmax": "0.066667",               # C:N = 15 
		            	 "actncmin": "0.066667",               # C:N = 15
		            	 "actpcmax": "0.00125",                # C:P = 800
		            	 "actpcmin": "0.00125",                # C:P = 800
		             	 "slowncmax": "0.05",                  # C:N = 20
		            	 "slowncmin": "0.05",                  # C:N = 20
                         "slowpcmin": "0.0005",                # C:P = 2000
                         "slowpcmax": "0.0005",                # C:P = 2000
                         "passncmax": "0.1",                   # C:N = 10
                         "passncmin": "0.1",                   # C:N = 10
                         "passpcmin": "0.005",                 # C:P = 200
                         "passpcmax": "0.005",                 # C:P = 200

                         "lue0": "2.8",                        # 2.8 for GPP, 1.4 for NPP
                         "cue": "0.5",                         # 

                         "ncmaxf": "0.05",                     # 0.05
                         "ncwnewz": "0.005",                   # C:N = 200, match analytical 
                         "ncrfac": "0.7",                      # match against analytical
                         "nref": "0.04",                       # N saturation threshold for photosynthesis
                         "pcmaxf": "0.005",                    # 
                         "pcwnewz": "0.0003",                  # C:P = 3333.33 match analytical
                         "pcrfac": "0.7",                      # match against analytical

                         "rateuptake": "0.96884",              # 0.96884 
                         "rateloss": "0.05",                   # match against analytical
                         "prateuptake": "1.9",             # 0.82395
                         "prateloss": "0.05",                  # match against analytical
                         "p_rate_par_weather": "1.0",          # Assumes all p_atm_dep into parent pool transfers into inorgavlp

                         "nuptakez": "0.01",                  #
                         "puptakez": "0.0004",                 # 

                         "passivesoilz": "26.8",               # 26.8 match against analytical
                         "passivesoilnz": "2.68",              # 2.68 match against analytical
                         "passivesoilpz": "0.134",             # 0.134 match against analytical

                         "num_years": "1",                     # no need to change 
                         "kr": "3.0",             # 0.5 t/ha in Dewar and McMurtrie 1996; the value of root carbon at which 50% of available N is taken up
                         "krp": "3.0",            # 0.00001; can set krp equals kr for consistency

                         "a0rhizo": "0.05",
                         "a1rhizo": "0.6",
                         "root_exu_CUE": "-999.99",
                         "prime_y": "0.0",
                         "prime_z": "0.0",
 
                         "nmin0": "0.0",                       # for variable som NC depend on inorgN
                         "nmincrit": "2.0",                    # for variable som NC depend on inorgN 
                         "pmin0": "0.0",                       # for variable som PC depend on inorgavlp
                         "pmincrit": "2.0",                    # for variable som PC depend on inorgavlp 

                         # control
                         "adjust_rtslow": "false",             # goes together with exudation
                         "alloc_model": "fixed",               # fixed and variable allocation pattern
                         "diagnosis": "false",
                         "exudation": "false",
                         "fixed_stem_nc": "false",
                         "fixed_stem_pc": "false",
                         "fixleafnc": "false",
                         "fixleafpc": "false",
                         "ncycle": "true",
                         "pcycle": "true",
                         "nuptake_model": "0",
                         "puptake_model": "0",
                         "print_options": "end",                # during spin up, set to end
                         "passiveconst": "false",
                         "respiration_model": "fixed",
                         "som_nc_calc": "fixed",
                         "som_pc_calc": "fixed",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)

        # add this directory to python search path so we can find the scripts!
        sys.path.append(os.path.join(d, "code/scripts"))
        import translate_GDAY_output_to_NCEAS_format as tr
def main(experiment_id, latitude, albedo, topsoil_type,
         rootsoil_type, finesoil, SPIN_UP=False, RUN_SIM=False):
    
    gday_exe = "@PATHTOGDAY@"
    GDAY_SPIN = gday_exe + " -s -p "
    GDAY = gday_exe + " -p "

    # dir names
    base_param_name = "base_start"
    base_dir = os.getcwd()
    base_param_dir = "@PATH_PARAMS@"
    param_dir = "@RUNDIR@"
    met_dir = "@SITE_MET@"
    run_dir = "@RUNDIR@"

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_model_spinup.cfg" % \
                                                (experiment_id)))

        # Run model to equilibrium assuming forest, growing C pools from
        # effectively zero
        itag = "%s_model_spinup" % (experiment_id)
        otag = "%s_model_spunup" % (experiment_id)
        mtag = "%s.daily_spin.csv" % (experiment_id)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
                        # files
                        "out_param_fname": "%s" % (out_param_fname),
                        "cfg_fname": "%s" % (cfg_fname),
                        "met_fname": "%s" % (met_fname),
                        "out_fname": "%s" % (out_fname),

                        # state - default C:N 25.
                         "age": "0.0",
                         "canht": "20.0", # Made up
                         "activesoil": "0.001",
                         "activesoiln": "0.00004",
                         "age": "0.0",
                         "branch": "0.001",
                         "branchn": "0.00004",
                         "cstore": "0.001",
                         "inorgn": "0.00004",
                         "metabsoil": "0.0",
                         "metabsoiln": "0.0",
                         "metabsurf": "0.0",
                         "metabsurfn": "0.0",
                         "nstore": "0.00004",
                         "passivesoil": "0.001",
                         "passivesoiln": "0.0004",
                         "prev_sma": "-999.9",
                         "root": "0.001",
                         "root_depth": "-9999.9",
                         "rootn": "0.00004",
                         "sapwood": "0.001",
                         "shoot": "0.001",
                         "shootn": "0.00004",
                         "slowsoil": "0.001",
                         "slowsoiln": "0.00004",
                         "stem": "0.001",
                         "stemn": "0.00004",
                         "stemnimm": "0.00004",
                         "stemnmob": "0.0",
                         "structsoil": "0.001",
                         "structsoiln": "0.00004",
                         "structsurf": "0.001",
                         "structsurfn": "0.00004",
                         "croot": "0.0",   # don't simulate coarse roots
                         "crootn": "0.0",  # don't simulate coarse roots

                         # parameters
                         #"fix_lai": "3.0",
                         "latitude": "%f" % (latitude),
                         "albedo": "%f" % (albedo),
                         "finesoil": "%f" % (finesoil),
                         "intercep_frac": "0.15",
                         "max_intercep_lai": "3.0",
                         "slamax": "4.4",     # made up [m2 kg-1 DW]
                         "sla": "4.4",        # made up [m2 kg-1 DW]
                         "slazero": "4.4",    # made up [m2 kg-1 DW]
                         "cfracts": "0.5",
                         "lai_closed": "0.5",  # I am effectively turning this feature off by setting it so low

                         "c_alloc_fmax": "0.25",
                         "c_alloc_fmin": "0.25",
                         "c_alloc_rmax": "0.05",
                         "c_alloc_rmin": "0.05",
                         "c_alloc_bmax": "0.1",
                         "c_alloc_bmin": "0.1",
                         "c_alloc_cmax": "0.0", # turn off coarse roots!


                         #"c_alloc_fmax": "0.35",
                         #"c_alloc_fmin": "0.15",
                         #"c_alloc_rmax": "0.35",
                         #"c_alloc_rmin": "0.05",
                         #"c_alloc_bmax": "0.1",
                         #"c_alloc_bmin": "0.1",
                         #"c_alloc_cmax": "0.0", # turn off coarse roots!


                         "fretrans": "0.5",
                         "rretrans": "0.0",
                         "bretrans": "0.0",
                         "wretrans": "0.0",
                         "ncwnewz": "0.003",
                         "ncwnew": "0.003",
                         "ncwimmz": "0.003",
                         "ncwimm": "0.003",
                         "ncbnewz": "0.003",
                         "ncbnew": "0.003",
                         "ncrfac": "0.8",
                         "ncmaxfyoung": "0.04",
                         "ncmaxfold": "0.04",
                         "ncmaxr": "0.03",
                         "retransmob": "0.0",
                         "fdecay": "0.59988",      # Protocol  [years-1]
                         "fdecaydry": "0.59988",   # Protocol
                         "rdecay": "0.33333",      # Protocol
                         "rdecaydry": "0.33333",   # Protocol
                         "bdecay": "0.02",         # No data, assuming 50 years
                         "wdecay": "0.02",
                         "crdecay": "0.00",  # turn off coarse roots!
                         "watdecaydry": "0.0",
                         "watdecaywet": "0.1",
                         "ligshoot": "0.24",      # Based on White et al. 2000 for ENF
                         "ligroot": "0.22",       # Based on White et al. 2000
                         "rateuptake": "1.9",           # set somewhat (very) arbitarly to get an LAI ~ 4.
                         "rateloss": "0.3",

                         "topsoil_depth": "50.0",
                         "rooting_depth": "2000.0",
                         "topsoil_type": topsoil_type,
                         "rootsoil_type": rootsoil_type,
                         "ctheta_topsoil": "-999.9",     # Derive based on soil type
                         "ntheta_topsoil": "-999.9",     # Derive based on soil type
                         "ctheta_root": "-999.9",        # Derive based on soil type
                         "ntheta_root": "-999.9",        # Derive based on soil type
                         "measurement_temp": "25.0",
                         "dz0v_dh": "0.075", # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                         "displace_ratio": "0.78",
                         "g1": "2.74",


                         #"jmax": "60.0",
                         #"vcmax": "30.0",
                         "jmaxna": "60.0",
                         "jmaxnb": "0.0",
                         "vcmaxna": "30.0",
                         "vcmaxnb": "0.0",


                         "measurement_temp": "25.0",
                         "heighto": "4.826",
                         "htpower": "0.35",
                         "height0": "5.0",
                         "height1": "30.0",
                         "leafsap0": "4000.0",
                         "leafsap1": "2700.0",
                         "branch0": "5.61",
                         "branch1": "0.346",
                         "croot0": "0.34",
                         "croot1": "0.84",
                         "targ_sens": "0.5",
                         "density": "480.0",
                         "sapturnover": "0.1",

                         "prescribed_leaf_NC": "0.03",

                         # control
                         "adjust_rtslow": "false",  # priming, off
                         "alloc_model": "fixed",
                         "assim_model": "mate",
                         "calc_sw_params": "true",   #false=use fwp values, true=derive them
                         "deciduous_model": "false",
                         "disturbance": "false",
                         "exudation": "false",
                         "fixed_stem_nc": "true",
                         "fixleafnc": "false",
                         "fixed_lai": "false",
                         "grazing": "false",
                         "gs_model": "medlyn",
                         "model_optroot": "false",
                         "modeljm": "1",
                         "ncycle": "false",
                         "nuptake_model": "1",
                         "passiveconst": "false",
                         "print_options": "end",
                         "ps_pathway": "c3",
                         "respiration_model": "fixed",
                         "strfloat": "0",
                         "sw_stress_model": "1",  # Sands and Landsberg
                         "water_stress": "true",

        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)


    if RUN_SIM == True:

        # dir names
        param_dir = os.path.join("@RUNDIR@")
        met_dir = os.path.join("@SITE_MET@")
        run_dir = os.path.join("@RUNDIR@")
        
        if SPIN_UP == True:
            shutil.copy(os.path.join(param_dir, "%s_model_spunup.cfg" % (experiment_id)),
                        os.path.join(param_dir, "%s_model_spunup_adj.cfg" % (experiment_id)))

        itag = "%s_model_spunup_adj" % (experiment_id)
        otag = "%s_simulation" % (experiment_id)
        mtag = "%s.daily_run.csv" % (experiment_id)
        out_fn = "%s_simulation.csv" % (experiment_id)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, "gday_out.csv")
        replace_dict = {

                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),

                         # control
                         "print_options": "daily",
                         "sub_daily": "false",

                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)
def main(experiment_id,
         site,
         SPIN_UP=True,
         POST_INDUST=True,
         OBS_DRY=True,
         OBS_WET=True,
         PRD_DRY_NOP=True,
         PRD_WET_NOP=True,
         PRD_DRY_MDP=True,
         PRD_WET_MDP=True,
         PRD_DRY_HIP=True,
         PRD_WET_HIP=True):

    GDAY_SPIN = "./gday -s -p "
    GDAY = "./gday -p "

    # dir names
    base_param_name = "base_start_with_P"
    base_param_dir = "/Users/%s/Documents/Research/Projects/EucFACE_Modeling/GDAY-EucFACE/GDAY/params" % (
        USER)
    base_dir = os.path.dirname(os.getcwd())
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")

    if SPIN_UP == True:

        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                                                (experiment_id, site)))

        # Run model to equilibrium assuming forest, growing C pools from
        # effectively zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_spinup_daily_50yrs.csv" % (site)
        out_fn = itag + "_equilib.out"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # default C:N 25.
            # Canopy height = 22 m average of 6 plots at UWS, site_description_stuff/EucFACE_Plot_Summary.doc
            "activesoil": "0.001",
            "activesoiln": "0.00004",
            "activesoilp": "0.000002",
            "age": "90.0",  # EucFACE parameter file
            "branch": "0.001",
            "branchn": "0.00004",
            "branchp": "0.000002",
            "cstore": "0.0",
            "nstore": "0.0",
            "pstore": "0.0",
            "inorgn": "0.0000",  # 0.00004
            "inorglabp": "0.0000",  # 0.00004
            "inorgsorbp": "0.0",
            "inorgssorbp": "0.0",
            "inorgoccp": "0.0",
            "inorgparp": "0.0",
            "fertilizerp": "0.0",  # Fertilizer P pool
            "metabsoil": "0.0",
            "metabsoiln": "0.0",
            "metabsoilp": "0.0",
            "metabsurf": "0.0",
            "metabsurfn": "0.0",
            "metabsurfp": "0.0",
            "passivesoil": "0.001",
            "passivesoiln": "0.0004",
            "passivesoilp": "0.000002",
            "prev_sma": "1.0",
            "root": "0.001",
            "croot": "0.0",  # don't simulate coarse roots
            "crootn": "0.0",  # don't simulate coarse roots
            "crootp": "0.0",  # don't simulate coarse roots
            "rootn": "0.00004",
            "rootp": "0.000002",
            "sapwood": "0.001",
            "shoot": "0.001",
            "shootn": "0.00004",
            "shootp": "0.000002",
            "slowsoil": "0.001",
            "slowsoiln": "0.00004",
            "slowsoilp": "0.000002",
            "stem": "0.001",
            "stemn": "0.00004",
            "stemp": "0.000002",
            "stemnimm": "0.00004",
            "stempimm": "0.000002",
            "stemnmob": "0.0",
            "stempmob": "0.0",
            "structsoil": "0.001",
            "structsoiln": "0.00004",
            "structsoilp": "0.000002",
            "structsurf": "0.001",
            "structsurfn": "0.00004",
            "structsurfp": "0.0000024",

            # parameters
            "resp_coeff":
            "0.9",  # controlling the rate of respiration and CUE. to be used when vary respiration flag is on. 
            "alpha_j":
            "0.308",  # Taking the theoretical maximum (from Belinda) 0.385 x 0.8 (leaf absorptance) = 0.308
            "intercep_frac": "0.15",
            "max_intercep_lai": "3.0",
            "latitude": "-33.61",  # EucFACE parameter file
            "albedo": "0.2",
            "slamax": "6.34",  # EucFACE parameter file
            "sla": "5.57",  # EucFACE parameter file
            "slazero": "5.57",  # EucFACE parameter file
            "lai_closed":
            "0.5",  # I am effectively turning this feature off by setting it so low
            "c_alloc_fmax": "0.48",  # EucFACE parameter file
            "c_alloc_fmin": "0.40",  # EucFACE parameter file
            "c_alloc_rmax": "0.26",  # EucFACE parameter file
            "c_alloc_rmin": "0.16",  # EucFACE parameter file
            "c_alloc_bmax": "0.05",  # guess
            "c_alloc_bmin": "0.05",  # guess
            "c_alloc_cmax": "0.0",  # turn off coarse roots!
            "cue": "0.35",  # cue
            "fretransn": "0.31",  # EucFACE parameter file
            "fretransp": "0.53",  # EucFACE parameter file
            "rretrans": "0.3",  # EucFACE parameter file
            "bretrans": "0.7",  # EucFACE parameter file
            "wretrans": "0.82",  # EucFACE parameter file
            "retransmob": "0.82",  # EucFACE parameter file
            "cretrans": "0.0",
            "ncwnewz": "0.008",  #New stem ring N:C at zero leaf N:C (mobile)
            "ncwnew": "0.008",  #New stem ring N:C at critical leaf N:C (mob)
            "ncwimmz": "0.008",  #Immobile stem N C at zero leaf N C
            "ncwimm": "0.008",  #Immobile stem N C at critical leaf N C
            "ncbnewz": "0.008",  #new branch N C at zero leaf N C
            "ncbnew": "0.008",  #new branch N C at critical leaf N C
            "nccnewz": "0.008",  #new coarse root N C at zero leaf N C
            "nccnew": "0.008",  #new coarse root N C at critical leaf N C
            "ncrfac": "0.8",
            "ncmaxfyoung": "0.5",
            "ncmaxfold": "0.05",
            "ncmaxr": "0.05",
            "fdecay": "1.1",  # foliage decay rate, guess parameter
            "fdecaydry": "1.1",  # foliage decay rate, guess parameter
            "rdecay": "0.9",  # EucFACE parameter file
            "rdecaydry": "0.9",  # as above
            "crdecay": "0.00",  # turn off coarse roots!
            "bdecay": "0.1",  # no idea, assuming 25 years
            "wdecay": "0.02",  # no idea, assuming 25 years
            "watdecaydry": "0.0",
            "watdecaywet": "0.1",
            "ligshoot": "0.15",  # EucFACE parameter file
            "ligroot": "0.2",  # Same as Medlyn 2016
            "rateuptake": "0.6",
            "rateloss": "0.02",  # guess value
            "topsoil_depth": "450.0",
            "rooting_depth": "11000.0",
            "topsoil_type": "loamy_sand",
            "rootsoil_type": "sandy_clay_loam",
            "fractup_soil":
            "0.5",  # fraction of transpiration from up of the soil
            "kn": "0.1",  # extinction coefficient for top canopy N 
            "kp": "0.1",  # extinction coefficient for top canopy P 
            "krp": "0.00001",
            "dz0v_dh":
            "0.05",  # Using Value from JULES for TREE PFTs as I don't know what is best. However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
            "displace_ratio":
            "0.75",  # From Jones, pg 67, following Jarvis et al. 1976
            "z0h_z0m": "1.0",
            # root exudation
            "a0rhizo": "0.01",
            "a1rhizo": "0.6",
            "prime_km": "0.3",
            "g1": "4.35",  # EucFACE parameter: 3.04 +- 1.31
            "jmaxna":
            "49.930",  # forcing intercept to zero; if use all species df, 49.743
            "jmaxpa":
            "933.90",  # forcing intercept to zero; if use all species df, 842.46 
            "jmaxnb": "0.0",  # forcing intercept to zero
            "jmaxpb": "0.0",  # forcing intercept to zero
            "vcmaxna":
            "27.707",  # forcing intercept to zero; if use all species df, 27.627
            "vcmaxpa":
            "516.83",  # forcing intercept to zero; if use all species df, 468.76
            "vcmaxnb": "0.0",  # forcing intercept to zero
            "vcmaxpb": "0.0",  # forcing intercept to zero
            "jmax": "162.91",  # EucFACE parameter file
            "vcmax": "92.85",  # EucFACE parameter file
            "measurement_temp":
            "25.0",  # parameters obtained at 22 not 25 degrees
            "heighto": "4.826",
            "htpower": "0.35",
            "height0": "5.0",
            "height1": "25.0",
            "leafsap0": "4000.0",  # "4000.0",
            "leafsap1": "2700.0",  # 2700
            "branch0": "5.61",
            "branch1": "0.346",
            "croot0": "0.34",
            "croot1": "0.84",
            "targ_sens": "0.5",
            "density": "492.0",  # EucFACE parameter file
            "nf_min": "0.005",
            "sapturnover": "0.1",  # guess value for EucFACE
            "p_rate_par_weather": "0.00004",  # 
            "p_rate_release_fertilizer":
            "1.0",  # 10 - 15 month release rate for slow-release fertilizer
            "rate_sorb_ssorb": "0.01",  # fitted value, reasonable for EucFACE
            "rate_ssorb_occ": "0.048",  # fitted value, reasonable for EucFACE
            # sorption calculation
            "smax":
            "0.01",  # convert to unit in t ha-1, Yang et al., 2016, GRL, Table S2 
            "ks":
            "0.006",  # convert to unit in t ha-1, Yang et al., 2016, GRL, Table S2 
            # biochemical P mineralization
            "biochemical_p_constant": "150.0",
            "max_p_biochemical": "0.001",
            "crit_n_cost_of_p": "15.0",
            "actncmax": "0.1",
            "actncmin": "0.006",
            "slowncmax": "0.006",
            "slowncmin": "0.0025",
            "passncmax": "0.0025",
            "passncmin": "0.001",
            "actpcmax": "0.01",  # empirical
            "actpcmin": "0.005",  # empirical
            "slowpcmax": "0.05",  # empirical
            "slowpcmin": "0.005",  # empirical
            "passpcmax": "0.0051",  # empirical
            "passpcmin": "0.0051",  # empirical
            "pcbnew": "0.00013",  # same as sapwood
            "pcbnewz": "0.00013",  # same as sapwood
            "pccnew": "0.00013",  # same as sapwood
            "pccnewz": "0.00013",  # same as sapwood
            "pcmaxfold": "0.01",  # EucFACE parameter file
            "pcmaxfyoung": "0.05",  # EucFACE parameter file
            "pcmaxr": "0.06",  # EucFACE parameter file
            "pcrfac": "0.8",
            "pcwimm": "0.00013",  # EucFACE parameter file
            "pcwimmz": "0.00013",  # EucFACE parameter file
            "pcwnew": "0.00013",  # EucFACE parameter file
            "pcwnewz": "0.00013",  # EucFACE parameter file
            "pf_min": "0.0002",
            # for calculate_p_ssorb_to_sorb function
            "finesoil": "0.2",  # EucFACE parameter file
            "phmin": "5.0",
            "phmax": "14.0",
            "soilph": "5.52",  # EucFACE parameter file
            "phtextmin": "0.000008",
            "phtextmax": "0.00015",
            "phtextslope": "0.00004",
            "psecmnp": "0.000022",
            # to determine soil SOM PC ratios
            "pmin0": "0.0",  # set to zero for now
            "pmincrit": "2.0",
            "prateloss": "0.05",  # set it to be the same as N rate loss
            "prateuptake":
            "0.9",  # Fitted value to obtain balance between uptake N:P ratio and reasonable P labile pool
            "puptakez": "0.002",  # EucFACE value
            "structcp": "5500.0",
            "structratp": "0.0",

            # control
            "adjust_rtslow": "true",  # priming, off
            "alloc_model": "fixed",
            "assim_model": "mate",
            "calc_sw_params": "true",  #false=use fwp values, true=derive them
            "deciduous_model": "false",
            "disturbance": "false",
            "exudation":
            "true",  # note that exudation not implemented in hourly model. 
            "fixed_stem_nc": "true",
            "fixed_stem_pc": "true",
            "fixleafnc": "false",
            "fixleafpc": "false",
            "grazing": "false",
            "gs_model": "medlyn",
            "aci_relationship": "walker",
            "model_optroot": "false",
            "modeljm": "1",
            "ncycle": "true",
            "pcycle": "true",
            "nuptake_model": "1",
            "puptake_model": "1",
            "triose_p": "false",
            "output_ascii": "true",
            "passiveconst": "false",
            "print_options": "end",
            "ps_pathway": "c3",
            "respiration_model": "vary",
            "strfloat": "0",
            "strpfloat": "0",
            "sw_stress_model": "1",
            "use_eff_nc": "0",
            "text_effect_p": "1",
            "water_stress": "true",
            "water_balance": "BUCKET",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY_SPIN + cfg_fname)

    if POST_INDUST == True:

        # copy spunup base files to make two new experiment files
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_spunup.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_historic_daily_1750_2011.csv" % (site)
        out_fn = "%s_amb_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    if POST_INDUST == True:

        # copy spunup base files to make two new experiment files
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_spunup.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_historic_daily_1750_2011.csv" % (site)
        out_fn = "%s_amb_equilib.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)

        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # observed (2011-2019) under dry condition: store output
    if OBS_DRY == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_indust.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_DRY_%s_2012_2019" % (experiment_id, site,
                                                 CO2_treatment)
        mtag = "%s_met_DRY_%s_daily_2012_2019.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_2012_2019.csv" % (site, CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # observed (2011-2019) under dry condition: store cfg
    if OBS_DRY == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_indust.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_DRY_%s_2012_2019" % (experiment_id, site,
                                                 CO2_treatment)
        mtag = "%s_met_DRY_%s_daily_2012_2019.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_2012_2019.csv" % (site, CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # predicted (2020-2069) under DRY and NOP condition: store output
    if PRD_DRY_NOP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_DRY_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_DRY_%s_NOP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_DRY_%s_NOP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_NOP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # predicted (2020-2069) under DRY and NOP condition: store cfg
    if PRD_DRY_NOP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_DRY_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_DRY_%s_NOP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_DRY_%s_NOP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_NOP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # predicted (2020-2069) under DRY and MDP condition: store output
    if PRD_DRY_MDP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_DRY_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_DRY_%s_MDP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_DRY_%s_MDP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_MDP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # predicted (2020-2069) under DRY and MDP condition: store cfg
    if PRD_DRY_MDP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_DRY_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_DRY_%s_MDP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_DRY_%s_MDP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_MDP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # predicted (2020-2069) under DRY and HIP condition: store output
    if PRD_DRY_HIP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_DRY_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_DRY_%s_HIP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_DRY_%s_HIP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_HIP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # predicted (2020-2069) under DRY and MDP condition: store cfg
    if PRD_DRY_HIP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_DRY_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_DRY_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_DRY_%s_HIP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_DRY_%s_HIP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_DRY_%s_HIP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # observed (2012-2019) under wet condition: store output
    if OBS_WET == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_indust.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_WET_%s_2012_2019" % (experiment_id, site,
                                                 CO2_treatment)
        mtag = "%s_met_WET_%s_daily_2012_2019.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_2012_2019.csv" % (site, CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # observed (2012-2019) under wet condition: store cfg
    if OBS_WET == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(param_dir,
                         "%s_%s_model_indust.cfg" % (experiment_id, site)),
            os.path.join(param_dir,
                         "%s_%s_model_indust_adj.cfg" % (experiment_id, site)))

        itag = "%s_%s_model_indust_adj" % (experiment_id, site)
        otag = "%s_%s_model_WET_%s_2012_2019" % (experiment_id, site,
                                                 CO2_treatment)
        mtag = "%s_met_WET_%s_daily_2012_2019.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_2012_2019.csv" % (site, CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # predicted (2020-2069) under WET and NOP condition: store output
    if PRD_WET_NOP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_WET_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_WET_%s_NOP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_WET_%s_NOP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_NOP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # predicted (2020-2069) under WET and NOP condition: store cfg
    if PRD_WET_NOP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_WET_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_WET_%s_NOP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_WET_%s_NOP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_NOP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # predicted (2020-2069) under WET and MDP condition: store output
    if PRD_WET_MDP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_WET_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_WET_%s_MDP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_WET_%s_MDP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_MDP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # predicted (2020-2069) under WET and MDP condition: store cfg
    if PRD_WET_MDP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_WET_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_WET_%s_MDP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_WET_%s_MDP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_MDP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

    # predicted (2020-2069) under WET and HIP condition: store output
    if PRD_WET_HIP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_WET_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_WET_%s_HIP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_WET_%s_HIP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_HIP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "daily",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)

        # translate output to EucFACE requested output
        #tr.translate_output(out_fname, met_fname)

    # predicted (2020-2069) under WET and MDP condition: store cfg
    if PRD_WET_HIP == True:

        # copy last cfg file and make new one
        shutil.copy(
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019.cfg" %
                (experiment_id, site, CO2_treatment)),
            os.path.join(
                param_dir, "%s_%s_model_WET_%s_2012_2019_adj.cfg" %
                (experiment_id, site, CO2_treatment)))

        itag = "%s_%s_model_WET_%s_2012_2019_adj" % (experiment_id, site,
                                                     CO2_treatment)
        otag = "%s_%s_model_WET_%s_HIP_2020_2069" % (experiment_id, site,
                                                     CO2_treatment)
        mtag = "%s_met_WET_%s_HIP_daily_2020_2069.csv" % (site, CO2_treatment)
        out_fn = "%s_simulated_WET_%s_HIP_2020_2069.csv" % (site,
                                                            CO2_treatment)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = {
            # files
            "out_param_fname": "%s" % (out_param_fname),
            "cfg_fname": "%s" % (cfg_fname),
            "met_fname": "%s" % (met_fname),
            "out_fname": "%s" % (out_fname),

            # control
            "print_options": "end",
        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        os.system(GDAY + cfg_fname)