In my parallel model, I am trying to record the time while i record some time-dependent variables. I can record and save those variables correctly, but the recording of time gives all zero to the recording vector.
There is nothing incorrect about the code fragment you copied. I tested it with
the neurondemo after selecting the HH demo, then pressing Init&Run and seeing that
TRec.printf() printed the times every .1 interval. Some things that can go wrong in
context are
not doing a run()
doing something that calls finitialize() after the run and before saving/printing TRec
unreferencing TRec somehow (recreating it, for example)
and a few other obscure ways. Check first if your fragment works in the neurondemo
context.
If you continue to have difficulty, try changing the record statement to record without
specifying the time interval. If the time now starts getting recorded into TVec
(every time step), is .1 a multiple of dt? Since you wish to record t every .1 ms,
there is no real reason to record it, instead, you can record the other variables at
TRec.indgen(0, tstop, SaveDataDt) and use a second arg of TRec in those
record statements.
You're right. That demonstrates a bug. t is not being updated during
pc.psolve()
That bug came into existence when threads were introduced. Each thread
has its own time variable ->_t and the thread 0 time does not get copied to
the hoc variable, 't', during pc.psolve in many circumstances. The fix would be
to edit nrn/src/nrnoc/fadvance.c: nrn_fixed_step_group and copythe last
line in that function
t = nrn_threads[0]._t;
to the last statement of the various while loops
or else just fill the TVec explicity using indgen.
I'm going to consider other ways of mirroring t and the thread 0 _t
or may consider it as a specific problem of Vector.record(&t) and specially
record the thread 0 time.
I've done some further looking into the problem and realize that the reason for
TVec.record(&t, DT) not working in the thread version is that recording the time
needs a special implementation and that was done only for TVec.record(&t)
and not for the DT and tvec second arg variants. So TVec.record(&t) works
for all methods, threads, parallel mpi because of its special implementation
as a TVecRecord class in nrn/src/nrncvode/vrecitem.h but there is
no corresponding TVecRecordDiscrete or TVecRecordDt variants as there is for
YVecRecord
VecRecordDiscrete
VecRecordDt
From one point of view, it does not seem worthwhile to add the implmentations since
recording time at specific times seems pointless. One either already has the time in a vector
or else it is tvec.indgen(0, tstop, DT). However in this case I should at least add a specific
error message. I guess the