1 #include <../../nrnconf.h> 34 #define ASSERTfgets(a,b,c) nrn_assert(fgets(a,b,c) != 0) 35 #define ASSERTfread(a,b,c,d) nrn_assert(fread(a,b,c,d) == c) 36 #define ASSERTfwrite(a,b,c,d) nrn_assert(fwrite(a,b,c,d) == c) 84 bool check(
bool warn);
141 this_savestate->
tqcount(tq, i);
143 this_savestate->
tqsave(tq, i);
186 for (
int i=0;
i <
cnt; ++
i) {
193 for (
int i=0;
i <
cnt; ++
i) {
201 for (
int i=0;
i <
cnt; ++
i) {
213 for (
int i=0;
i <
cnt; ++
i) {
215 b = ss[
i].
root ? 1 : 0;
250 if (
ssi[im].offset < 0) {
269 fprintf(stderr,
"SaveState warning: %d sections exist but saved %d\n",
276 fprintf(stderr,
"SaveState warning: %d cells exist but saved %d\n",
294 for (
int isec=0; isec <
nsec_; ++isec) {
295 SecState& ss =
ss_[isec];
297 if (!sec->
prop || sec->
nnode != ss.nnode) {
300 fprintf(stderr,
"SaveState warning: saved section no longer exists\n");
302 fprintf(stderr,
"SaveState warning: %s has %d nodes but saved %d\n",
309 NodeState& ns = ss.ns[
inode];
313 for (p = nd->
prop; p; p = p->
next) {
319 fprintf(stderr,
"SaveState warning: \ 320 fewer mechanisms saved than exist at node %d of %s\n",
325 if (p->
type != ns.type[i]) {
327 fprintf(stderr,
"SaveState warning: mechanisms out of order at node %d of %s\n\ 328 saved %s but need %s\n",
337 fprintf(stderr,
"SaveState warning: more mechanisms saved than exist at node %d of %s\n",
346 fprintf(stderr,
"SaveState warning: Saved section and %s are not both root sections.\n",
363 for (p = nd->
prop; p; p = p->
next) {
369 fprintf(stderr,
"SaveState warning: \ 370 fewer mechanisms saved than exist at a root node\n");
376 fprintf(stderr,
"SaveState warning: mechanisms out of order at a rootnode\n\ 377 saved %s but need %s\n",
386 fprintf(stderr,
"SaveState warning: more mechanisms saved than exist at a rootnode\n");
396 fprintf(stderr,
"SaveState warning: different number of %s saved than exist.\n",
423 if (!
sec->parentsec) {
453 for (p = nd->
prop; p; p = p->
next) {
467 for (p = nd->
prop; p; p = p->
next) {
485 for (isec=0; isec <
nsec_; ++isec) {
526 for (i = 0; i <
nncs_; ++
i) {
542 for (i=0; i <
nprs_; ++
i) {
565 for (
int isec=0; isec <
nsec_; ++isec) {
587 for (i=0; i <
nprs_; ++
i) {
588 prs_[
i] = prl->item(i)->savestate_save();
604 for (p = nd->
prop; p; p = p->
next) {
611 if (type == EXTRACELL) {
612 for (
int i=0; i <
nlayer; ++
i) {
618 for (
int ip=
ssi[type].offset; ip <
max; ++ip) {
630 double* d = ml.
data[
i];
631 for (
int j=0;
j < sz; ++
j) {
641 "Stored state inconsistent with current neuron structure");
648 for (
int isec=0; isec <
nsec_; ++isec) {
666 if (type == 1) {
return; }
670 assert(nprs_ <= prl->count());
672 for (i = 0; i <
nprs_; ++
i) {
673 prs_[
i]->savestate_restore();
679 "This state requires Python to unpack.");
689 for (p = nd->
prop; p; p = p->
next) {
696 if (type == EXTRACELL) {
697 for (
int i=0; i <
nlayer; ++
i) {
703 for (
int ip=
ssi[type].offset; ip <
max; ++ip) {
715 double* d = ml.
data[
i];
716 for (
int j=0;
j < sz; ++
j) {
729 FILE* f = ocf->
file();
733 if (strcmp(buf,
"SaveState binary file version 6.0\n") != 0) {
734 if (strcmp(buf,
"SaveState binary file version 7.0\n") == 0) {
738 hoc_execerror(
"Bad SaveState binary file",
" Neither version 6.0 or 7.0");
746 sscanf(buf,
"%d %d\n", &nsec_, &
nroot_);
752 for (
int isec=0; isec <
nsec_; ++isec) {
783 sscanf(buf,
"%d\n", &n);
786 int nt = 0, nc = 0, ns = 0;
788 nrn_assert(sscanf(buf,
"%d %d %d\n", &nt, &nc, &ns) == 3);
797 sscanf(buf,
"%d\n", &
nprs_);
800 for (
int i=0; i <
nprs_; ++
i) {
816 }
catch (
const std::bad_alloc&
e) {
836 FILE* f = ocf->
file();
838 fprintf(f,
"SaveState binary file version %d.0\n", version);
842 for (
int isec=0; isec <
nsec_; ++isec) {
873 for (
int i=0; i <
nprs_; ++
i) {
875 prs_[
i]->savestate_write(f);
900 for (j=0; j <
n; ++
j) {
950 for (j=0; j <
n; ++
j) {
972 for (i=0; i <
n; ++
i) {
981 sscanf(buf,
"%d\n", &
nncs_);
986 for (i=0; i <
nncs_; ++
i) {
989 if (
ncs_[i].nstate) {
996 sscanf(buf,
"%d\n", &
npss_);
1012 sscanf(buf,
"%d\n", &n);
1018 for (i=0; i <
n; ++
i) {
1021 sscanf(buf,
"%d\n", &type);
1048 hoc_execerror(
"SaveState::readnet",
"Unimplemented DiscreteEvent type");
1059 for (i=0; i <
nncs_; ++
i) {
1061 if (
ncs_[i].nstate) {
1073 for (i=0; i <
n; ++
i) {
1082 fprintf(stderr,
"SaveState warning: There are %d NetCon but %d saved\n",
1097 fprintf(stderr,
"SaveState warning: %s is matched with NetCon[%d]\n",
1104 fprintf(stderr,
"SaveState warning: %s has %d weight states but saved %d\n",
1118 fprintf(stderr,
"SaveState warning: There are %d internal PreSyn but %d saved\n",
1234 ss->
write(f, close);
int var_type(Symbol *) const
void tqsave(const TQItem *, int)
size_t hoc_total_array_data(Symbol *s, Objectdata *obd)
double max(double a, double b)
#define ASSERTfread(a, b, c, d)
void allocnode(NodeState &, Node *)
static double sswrite(void *v)
static SaveState * this_savestate
#define ASSERTfwrite(a, b, c, d)
void fread_SecState(SecState *, int, FILE *)
struct Section * parentsec
void fwrite_SecState(SecState *, int, FILE *)
static double ssread(void *v)
ReceiveFunc * pnt_receive
#define ITERATE(itm, lst)
PlayRecList * net_cvode_instance_prl()
Symbol * hoc_lookup(const char *)
int prop_index(const Symbol *) const
TQueue * net_cvode_instance_event_queue(NrnThread *)
NetCvode * net_cvode_instance
char * hoc_object_name(Object *ob)
Represent main neuron object computed by single thread.
static DiscreteEvent * savestate_read(FILE *)
void(* ReceiveFunc)(Point_process *, double *, double)
static DiscreteEvent * savestate_read(FILE *)
check_obj_type(o, "SectionList")
static void * cons(Object *)
void(* nrnpy_store_savestate)(char **save_data, uint64_t *save_data_size)
void tqcount(const TQItem *, int)
#define BinaryMode(ocfile)
bool checkacell(ACellState &, int type, bool)
static DiscreteEvent * savestate_read(FILE *)
#define PlayRecordEventType
static DiscreteEvent * savestate_read(FILE *)
static DiscreteEvent * savestate_read(FILE *)
assert(isec==section_count)
void forall_callback(void(*)(const TQItem *, int))
static DiscreteEvent * savestate_read(FILE *)
static Member_func members[]
#define ASSERTfgets(a, b, c)
int const size_t const size_t n
void allocacell(ACellState &, int type)
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
const char * secname(Section *sec)
void savenode(NodeState &, Node *)
bool checknode(NodeState &, Node *, bool)
#define DiscreteEventType
void hoc_execerror(const char *, const char *)
#define ForAllSections(sec)
hoc_Item * net_cvode_instance_psl()
virtual void restore(int type)
void fwrite_NodeState(NodeState *, int, FILE *)
fprintf(stderr, "Don't know the location of params at %p\, pp)
virtual void unref() const
virtual void savestate_write(FILE *)
virtual void read(OcFile *, bool close)
static DiscreteEvent * savestate_read(FILE *)
static PlayRecordSave * savestate_read(FILE *)
virtual void write(OcFile *, bool close)
bool open(const char *filename, const char *type)
void section_ref(Section *)
static void destruct(void *v)
static DiscreteEvent * savestate_read(FILE *)
void restoreacell(ACellState &, int type)
void saveacell(ACellState &, int type)
short * nrn_is_artificial_
HocStruct cTemplate * ctemplate
virtual void savestate_restore(double deliverytime, NetCvode *)
for(int i=0, j=0;i< n_memb_func;++i) if(nrn_is_artificial_[i])
void section_unref(Section *)
void(* nrnpy_restore_savestate)(int64_t, char *)
Object ** hoc_objgetarg(int)
void restorenode(NodeState &, Node *)
double chkarg(int, double low, double high)
void fread_NodeState(NodeState *, int, FILE *)
static void tqcallback(const TQItem *tq, int i)
virtual DiscreteEvent * savestate_save()