Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 8a7bb60

Browse files
committed
Read twice the global data to fill the global variables of coreneuron and the mod files
1 parent 43e881e commit 8a7bb60

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

coreneuron/apps/main1.cpp

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ void nrn_init_and_load_data(int argc,
185185
report_mem_usage("After MPI_Init");
186186
}
187187

188-
// initialise default coreneuron parameters
189-
initnrn();
190-
191-
// set global variables
192-
// precedence is: set by user, globals.dat, 34.0
193-
celsius = corenrn_param.celsius;
194-
195188
#if CORENEURON_ENABLE_GPU
196189
if (!corenrn_param.gpu && corenrn_param.cell_interleave_permute == 2) {
197190
fprintf(stderr,
@@ -218,9 +211,6 @@ void nrn_init_and_load_data(int argc,
218211
// full path of files.dat file
219212
std::string filesdat(corenrn_param.datpath + "/" + corenrn_param.filesdat);
220213

221-
// read the global variable names and set their values from globals.dat
222-
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
223-
224214
// set global variables for start time, timestep and temperature
225215
if (!corenrn_embedded) {
226216
t = checkPoints.restore_time();
@@ -236,6 +226,8 @@ void nrn_init_and_load_data(int argc,
236226

237227
rev_dt = (int) (1. / dt);
238228

229+
printf("CoreNEURON Global Vars before editing: second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
230+
239231
if (corenrn_param.celsius != -1000.) { // command line arg highest precedence
240232
celsius = corenrn_param.celsius;
241233
} else if (celsius == -1000.) { // not on command line and no celsius in globals.dat
@@ -247,6 +239,8 @@ void nrn_init_and_load_data(int argc,
247239
// for ispc backend
248240
ispc_celsius = celsius;
249241

242+
printf("CoreNEURON Global Vars after editing: second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
243+
250244
// create net_cvode instance
251245
mk_netcvode();
252246

@@ -514,9 +508,36 @@ extern "C" void mk_mech_init(int argc, char** argv) {
514508
out.close();
515509
}
516510

517-
// reads mechanism information from bbcore_mech.dat
511+
// Not working
512+
// initialise default coreneuron parameters
513+
initnrn();
514+
printf("CoreNEURON Global Vars after initnrn(): second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
518515

516+
// set global variables
517+
// precedence is: set by user, globals.dat, 34.0
518+
celsius = corenrn_param.celsius;
519+
printf("CoreNEURON Global Vars after corenrn_param: second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
520+
521+
// read the global variable names and set their values from globals.dat
522+
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
523+
printf("CoreNEURON Global Vars after set_globals(): second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
524+
525+
// reads mechanism information from bbcore_mech.dat
519526
mk_mech((corenrn_param.datpath).c_str());
527+
528+
// // Not working
529+
// // initialise default coreneuron parameters
530+
// initnrn();
531+
// printf("CoreNEURON Global Vars after initnrn(): second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
532+
533+
// // set global variables
534+
// // precedence is: set by user, globals.dat, 34.0
535+
// celsius = corenrn_param.celsius;
536+
// printf("CoreNEURON Global Vars after corenrn_param: second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
537+
538+
// // read the global variable names and set their values from globals.dat
539+
// set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
540+
// printf("CoreNEURON Global Vars after set_globals(): second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
520541
}
521542

522543
extern "C" int run_solve_core(int argc, char** argv) {
@@ -527,6 +548,12 @@ extern "C" int run_solve_core(int argc, char** argv) {
527548
std::vector<std::pair<std::string, int>> spikes_population_name_offset;
528549
bool reports_needs_finalize = false;
529550

551+
552+
// read the global variable names and set their values from globals.dat
553+
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
554+
printf("CoreNEURON Global Vars after set_globals(): second order=%d t=%g dt=%g rev_dt=%d celsius=%lf\n", secondorder, t, dt, rev_dt, celsius);
555+
556+
530557
if (!corenrn_param.is_quiet()) {
531558
report_mem_usage("After mk_mech");
532559
}

coreneuron/io/global_vars.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
6262
// will be processed before exit from loop.
6363
if (val) {
6464
N2V::iterator it = n2v->find(name);
65+
printf("Passing from NEURON %s %d %g\n", name, size, *val);
6566
if (it != n2v->end()) {
6667
if (size == 0) {
6768
nrn_assert(it->second.first == 0);

coreneuron/mechanism/eion.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,19 @@ void ion_reg(const char* name, double valence) {
109109
sprintf(buf[1], "%so0_%s", name, buf[0]);
110110
if (strcmp("na", name) == 0) {
111111
na_ion = mechtype;
112+
printf("Setting global_conci(na) to %lf and global_conco(na) to %lf\n", DEF_nai, DEF_nao);
112113
global_conci(mechtype) = DEF_nai;
113114
global_conco(mechtype) = DEF_nao;
114115
global_charge(mechtype) = 1.;
115116
} else if (strcmp("k", name) == 0) {
116117
k_ion = mechtype;
118+
printf("Setting global_conci(k) to %lf and global_conco(k) to %lf\n",DEF_ki, DEF_ko);
117119
global_conci(mechtype) = DEF_ki;
118120
global_conco(mechtype) = DEF_ko;
119121
global_charge(mechtype) = 1.;
120122
} else if (strcmp("ca", name) == 0) {
121123
ca_ion = mechtype;
124+
printf("Setting global_conci(ca) to %lf and global_conco(ca) to %lf\n", DEF_cai, DEF_cao);
122125
global_conci(mechtype) = DEF_cai;
123126
global_conco(mechtype) = DEF_cao;
124127
global_charge(mechtype) = 2.;

0 commit comments

Comments
 (0)