// Main file for network of cells with coba (COnductance BAsed) synapses.

{load_file("nrngui.hoc")}  // GUI and runtime libraries
{load_file("cobacell.hoc")}  // defines CobaCell class

// Procedures that set up network architecture and performance reporting.
{load_file("../common/init.hoc")}

// Called by create_cells() in common/net.hoc
obfunc newcell() {
	return new CobaCell()
}

// Create the cells, then connect them.
create_net()  // in common/net.hoc
// Randomized spike trains driving excitatory synapses.
create_stim(run_random_low_start_, AMPA_GMAX)  // in common/netstim.hoc

// A few last items for performance reports, e.g. set up spike time recording, and,
// if in "demo" mode, create graph for raster plots, and panel with Stop button.
finish_setup()  // in common/init.hoc

// Parallel run to tstop.
prun()  // in common/perfrun.hoc

// Only the "master" cpu does this.
if (pc.id == 0) {print "RunTime: ", runtime}

// Up to this point, all CPUs have executed the same code,
// except for taking different branches depending on their value of pc.id,
// which ranges from 0 to pc.nhost-1.

// Gather performance statistics from each CPU.

// Only the master (pc.id == 0) returns from pc.runworker().
// All other CPUs ("workers") now wait for messages.
{pc.runworker()}

// Send requests to the workers and handle the results they send back.
collect_results()  // in common/init.hoc

// Send all workers a QUIT message; those NEURON processes exit.
// The master waits until all worker output has been transferred to it.
{pc.done()}

// Only the master executes code beyond this point; all others have exited.

// Times of all spikes, and consolidated performance report.
output_results()  // in common/perfrun.hoc