def runVIC(dbname, options):
    """Driver function for performing a VIC forecast simulation"""
    startyear, startmonth, startday = map(
        int, options['forecast']['startdate'].split('-'))
    endyear, endmonth, endday = map(
        int, options['forecast']['enddate'].split('-'))
    # if date(endyear, endmonth, endday) > (date(startyear, startmonth, startday) + relativedelta(months=3)):
    #     print("WARNING! Forecast with lead time longer than 3 months requested. Exiting...")
    #     sys.exit()
    res = config.getResolution(options['forecast'])
    vicexe = "{0}/vicNl".format(rpath.bins)
    basin = config.getBasinFile(options['forecast'])
    saveto, savevars = config.getVICvariables(options)
    name = options['forecast']['name'].lower()
    nens = int(options['forecast']['ensemble size'])
    method = options['forecast']['method']
    name = options['forecast']['name'].lower()
    models = ensemble.Ensemble(nens, dbname, res, startyear,
                               startmonth, startday, endyear, endmonth, endday, name)
    if 'initialize' in options['vic'] and options['vic']['initialize'] in ['perturb', 'random']:
        init_method = options['vic']['initialize']
    else:
        init_method = "determ"  # default option to initialize the ensemble from the same state
    # override initializaton method if assimilation was requested
    if 'observations' in options['vic']:
        init_method = "random"
        models.initialize(options, basin, init_method, vicexe,
                          saveindb=True, saveto=saveto, saveargs=savevars, skipsave=-1)
        data, alat, alon, agid = assimilate(options, date(
            models.startyear, models.startmonth, models.startday), models)
        models.updateStateFiles(data, alat, alon, agid)
    else:
        models.initialize(options, basin, init_method, vicexe,
                          saveindb=True, saveto=saveto, saveargs=savevars)
    models.writeParamFiles()
    models.writeForcings(method, options)
    models.run(vicexe)
    models.setDates(startyear, startmonth, startday, endyear, endmonth, endday)
    models.save(saveto, savevars)
    for varname in savevars:
        raster.stddev(models.dbname, "{0}.{1}".format(
            models.name, varname))
    for e in range(nens):
        shutil.rmtree(models[e].model_path)
dataset/ETHPy150Open nasa/RHEAS/src/forecast.py/runVIC/original