/* access dend1[13]  -- somatic recording site at 0.5    */
/* access dend1[232] -- dendritic recording site at 0.99 */

graphicson = 1    /* 1 graphics on, -1 graphics off */
lserroron = -1    /* compare simulation to real data if > 0 */
writeout = 0      /* equals 1 if output should be written to a file */

xopen("mystdrun.hoc")
xopen("ri21geo2.hoc")
xopen("ri21init.hoc")
xopen("ri21func.hoc")
nrnmainmenu()
tstop=400
lowv=-67
highv=-64
long=1
short=0
init_params()
if (graphicson>0) {
  newPlotV(lowv,highv)
}
read_expt_data()
init_pass()		/* initialize passive membrane */
if (qblock<1) {
  initq1()		/* initialize q conductance */
}		
/* initnakhh()	*/	/* initialize active HH Na/K conductances */
init()			/* initialize v and active states */
Vrestsoma=Vleak
Vrestdend=Vleak
if (qblock<1) {
  print "stabilizing"
  stabilize_cc(600,5)
}
somarawvec.play(&somarawv,vecdt)
dendrawvec.play(&dendrawv,vecdt)
somarawvec.play_remove()
dendrawvec.play_remove()
t=0
tstop=400
somarawvec.add(somaticv())
dendrawvec.add(dendriticv())
somarawvec.play(&somarawv,vecdt)
dendrawvec.play(&dendrawv,vecdt)
Vrestsoma=somaticv()
Vrestdend=dendriticv()

if (writeout>0) {
	somasimvec.record(&dend1[13].v(0.5))
	dendsimvec.record(&dend1[232].v(0.99))
}

/* send stim, delay, duration, tmax, dt */
if (long>0) {
	tstop=400
	somastep_cc_new(-0.05, 51.2, 201.2, 400, 0.5)
	graphItem.size(0,tstop,somaticv()-maxvsoma-0.2,dendriticv()+0.1)
}
if (short>0) {
	tstop=100
	somastep_cc_new(-2.0, 5.06, 1.008, 100, 0.1)
	graphItem.size(0,tstop,-80,-75)
}

if (writeout>0) {
	somaoutname = "ri21s1a.sim"
	dendoutname = "ri21d1a.sim"
	write_data()
}

printf("Input resistance = %f Mohms\n",rn)
printf("Max. voltage change at somatic electrode = %f mV\n\n",maxvsoma)
printf("Max. voltage change at dendritic electrode = %f mV\n\n",maxvdend)
printf("Attenuation = %f \n\n",maxvdend/maxvsoma)
wopen()

print"DONE\n"