SIZE = COMM.Get_size()
RANK = COMM.Get_rank()

# load some neuron-interface files needed for the EPFL cell types
neuron.h.load_file("stdrun.hoc")
neuron.h.load_file("import3d.hoc")

# test mode (1 cell per pop, all-to-all connectivity)
TESTING = False

# Creating a NeuroTools.parameters.ParameterSet object for the main parameters
PSET = ParameterSet({})

# output file destination
if TESTING:
    PSET.OUTPUTPATH = 'example_parallel_network_output_testing'
else:
    PSET.OUTPUTPATH = 'example_parallel_network_output'

# input file paths
# PATHs to current cell-specific files and NMODL files
PSET.CWD = os.getcwd()
PSET.CELLPATH = 'hoc_combos_syn.1_0_10.allzips'
PSET.NMODL = 'hoc_combos_syn.1_0_10.allmods'

########################################################
# Simulation control
########################################################
PSET.dt = 2**-4  # simulation time step size (ms)
PSET.tstop = 1500.  # simulation duration (ms)
PSET.v_init = -77.  # membrane voltage(s) at t = 0 for all cells

# load some neuron-interface files needed for the EPFL cell types
neuron.h.load_file("stdrun.hoc")
neuron.h.load_file("import3d.hoc")


# test mode (1 cell per pop, all-to-all connectivity)
TESTING = False

# Creating a NeuroTools.parameters.ParameterSet object for the main parameters
PSET = ParameterSet({})

# output file destination
if TESTING:
    PSET.OUTPUTPATH = 'example_parallel_network_output_testing'
else:
    PSET.OUTPUTPATH = 'example_parallel_network_output'

# input file paths
# PATHs to current cell-specific files and NMODL files
PSET.CWD = os.getcwd()
PSET.CELLPATH = 'hoc_combos_syn.1_0_10.allzips'
PSET.NMODL = 'hoc_combos_syn.1_0_10.allmods'


########################################################
# Simulation control
########################################################
PSET.dt = 2**-4             # simulation time step size (ms)
PSET.tstop = 1500.          # simulation duration (ms)
                # scaling 1 with the population scaling variable, and recompute
                # the corresponding connection probability)
                PSET.connParams['connprob'][i][j] = \
                    1. - (1. - 1. / (N_pre * N_post)
                          )**(PSET.POPSCALING * np.log(
                              1. - PSET.connParams['connprob'][i][j]
                          ) / np.log(
                              1. - PSET.POPSCALING**2 / (N_pre * N_post)))
            if RANK == 0:
                print(string + ', C1={}, K1={}'.format(
                    PSET.connParams['connprob'][i][j],
                    np.log(1. - PSET.connParams['connprob'][i][j]) /
                    np.log(1. - 1. / (N_pre * N_post))))

    # file output destination
    PSET.OUTPUTPATH = os.path.join(OUTPUT, ps_id)

    # avoid same sequence of random numbers from numpy and neuron on each RANK,
    # e.g., in order to draw unique cell locations and random synapse
    # activation times
    np.random.seed(PSET.GLOBALSEED + RANK)

    # set up file destination
    if not os.path.isdir(PSET.OUTPUTPATH):
        if RANK == 0:
            os.mkdir(PSET.OUTPUTPATH)
    COMM.Barrier()

    if RANK == 0:
        parameters_time = time() - tic
        # open file object for writing