Writing data periodically throughout a simulation

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
pascal
Posts: 106
Joined: Thu Apr 26, 2012 11:51 am

Writing data periodically throughout a simulation

Post by pascal »

I recently wrote a block of code that outputs raster data periodically throughout a simulation, rather than all at once at the end:

Code: Select all

	fo = new File()
	{ fo.wopen("data/spikes.dat") } 
	t_curr = 0
	while (t_curr <= Tstop){
		print "Time = ",t_curr
		if(t_curr + t_seg <= Tstop) {
			{ pr.pnm.pcontinue(t_curr+t_seg)}
		} else {
			{pr.pnm.pcontinue(Tstop)}
		}
		for i=0, pr.pnm.spikevec.size-1 {
			fo.printf("%-10.6lf, %d\n", pr.pnm.spikevec.x[i], pr.pnm.idvec.x[i])
		}
		pr.pnm.spikevec.resize(0)
		pr.pnm.idvec.resize(0) 
		
		t_curr = t_curr + t_seg
	}
	{fo.close()}
This works, but I have a few basic questions:

1) Both pcontinue and psolve seem to work equivalently. Is there a difference that I should be aware of?
2) For some reason, I cannot name the file object anything I want. For example, when I tried to name it 'forast' instead of 'fo,' I received a syntax error. Any idea why this is?
3) This works on my laptop, but do I need to use 'gatherspikes' in order to ensure that this will also work in parallel?
pascal
Posts: 106
Joined: Thu Apr 26, 2012 11:51 am

Re: Writing data periodically throughout a simulation

Post by pascal »

I figured out the answer to question 2: I must declare the name of the file object with the command 'localobj forast'.
Post Reply