output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

# Initialise seeds and check their consistency with previously saved data

seed_gen = TrialSeedGenerator(o.master_seed)

if len(d['trials']) == 0:
    d['master_seed'] = o.master_seed
else:
    try:
        seed_gen.check_master_seed(d['master_seed'], o.master_seed)
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
oldNTrials = len(d['trials'])
################################################################################
for trial_idx in range(o.ntrials):
    print("\n\t\tStarting/appending to trial no. {0}\n".format(trial_idx))
    if trial_idx >= oldNTrials:  # Create new trial
        d['trials'].append({})
    trialOut = d['trials'][trial_idx]

    # Now check if there is data in the trial and append
    # Additionally, if data was saved but IvelVec missing, add it so that it
stateMonParams = {'start': o.time - o.stateMonDur}
nrec_spikes_e = None  # all neurons
nrec_spikes_i = o.nrec_spikes_i

output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
                                                   o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

seed_gen = TrialSeedGenerator(int(o.master_seed))
if len(d['trials']) == 0:
    d['master_seed'] = int(o.master_seed)
else:
    try:
        seed_gen.check_master_seed(d['master_seed'], int(o.master_seed))
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
stop = False
###############################################################################
for trial_idx in range(len(d['trials']), o.ntrials):
    print("\n\t\tStarting trial no. {0}\n".format(trial_idx))
    seed_gen.set_generators(trial_idx)
    d['invalidated'] = 1
    ei_net = BasicGridCellNetwork(
        o,
        simulationOpts=None,
        nrec_spikes=(nrec_spikes_e, nrec_spikes_i),
(o, args) = parser.parse_args()


output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir,
        o.fileNamePrefix, o.job_num)
d = DataStorage.open(output_fname, 'a')
if ("trials" not in d.keys()):
    d['trials'] = []

# Initialise seeds and check their consistency with previously saved data
seed_gen = TrialSeedGenerator(int(o.master_seed))
if len(d['trials']) == 0:
    d['master_seed'] = int(o.master_seed)
else:
    try:
        seed_gen.check_master_seed(d['master_seed'], int(o.master_seed))
    except ValueError as e:
        d.close()
        raise e

overalT = 0.
oldNTrials = len(d['trials'])
################################################################################
for trial_idx in range(o.ntrials):
    print("\n\t\tStarting/appending to trial no. {0}\n".format(trial_idx))
    if trial_idx >= oldNTrials:  # Create new trial
        d['trials'].append({})
    trialOut = d['trials'][trial_idx]

    # Now check if there is data in the trial and append
    # Additionally, if data was saved but IvelVec missing, add it so that it