def run_simulation(vtype, sim_obj):
    '''Run a simulation.

    Returns True if all went well, else False.
    '''
    
    # untar the object
    tar_path = os.path.join(Local_Data_Directory, sim_obj)
    log.info('Untarring %s in directory %s ...'
             % (tar_path, Local_Data_Directory))
    untar_file(tar_path, target_dir=Local_Data_Directory)

    # modify project.py template
    log.debug("Creating '%s' version of project.py" % vtype)
    fd = open('project_template.py', 'r')
    project = fd.readlines()
    fd.close()

    new_project = []
    for line in project:
        new_project.append(line.replace('#!SETUP!#', vtype.lower()))
            
    fd = open('project.py', 'w')
    fd.write(''.join(new_project))
    fd.close()
    
    # import new project.py
    import project

    # run the simulation, produce SWW file
    log.info('Running the simulation ...')
    cmd = 'python run_model.py > %s' % RUNMODEL_STDOUT
    log.debug("run_simulation: doing '%s'" % cmd)
    res = os.system(cmd)
    log.debug("run_simulation: res=%d" % res)

    # 'unimport' project.py
    del project

    # check result
    if res != 0:
        log.critical('Simulation failed, check log')

    return res == 0
        log.critical("Can't refresh via the internet and you don't have the "
                     "required files.")
        log.critical('Terminating the validation.')
        log.critical('')
        log.critical('If you get the missing files from %s' % DATA_FILES_URL)
        log.critical('then you can try to run the validation again.  Put the '
                     'files into the directory')
        log.critical("%s." % Local_Data_Directory)
        sys.exit(10)

# now untar mandatory objects
for obj in Mandatory_Data_Objects:
    tar_path = os.path.join(Local_Data_Directory, obj)
    log.info('Untarring %s in directory %s ...'
             % (tar_path, Local_Data_Directory))
    untar_file(tar_path, target_dir=Local_Data_Directory)

# set required environment variables
set_environment()

## 6/6/2013 -- Removed this code, as purpose now is just to get data
## now run what simulations we can and check output is as expected

#for odo in Optional_Data_Objects:
#    start_time = time.time()
#
#    _, vtype, _ = odo.rsplit('.', 2)
#    vtype = vtype.lower()
#    log.critical('#' * 72)
#    log.critical('Running Patong "%s" validation ...' % vtype)
#    if run_simulation(vtype, odo):