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

Commit c3ec12d

Browse files
committed
Fixed initialization of global variables
1 parent 8c9a8db commit c3ec12d

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

coreneuron/apps/main1.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -508,36 +508,21 @@ extern "C" void mk_mech_init(int argc, char** argv) {
508508
out.close();
509509
}
510510

511-
// Not working
512511
// initialise default coreneuron parameters
513512
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);
515513

516514
// set global variables
517515
// precedence is: set by user, globals.dat, 34.0
518516
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);
520517

521518
// read the global variable names and set their values from globals.dat
519+
// some global variables need to be read before the ion_reg to initialize
520+
// properly the in-built ion mechanisms
522521
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);
524522

525523
// reads mechanism information from bbcore_mech.dat
526524
mk_mech((corenrn_param.datpath).c_str());
527525

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);
541526
}
542527

543528
extern "C" int run_solve_core(int argc, char** argv) {
@@ -549,10 +534,9 @@ extern "C" int run_solve_core(int argc, char** argv) {
549534
bool reports_needs_finalize = false;
550535

551536

552-
// read the global variable names and set their values from globals.dat
537+
// read agin the global variables to set the global variables defined by
538+
// the mod files' mechanisms
553539
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-
556540

557541
if (!corenrn_param.is_quiet()) {
558542
report_mem_usage("After mk_mech");

coreneuron/io/global_vars.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
7777
}
7878
}
7979
}
80+
if (static_cast<std::string>(name).find("ion") != std::string::npos) {
81+
nrn_ion_init[name] = *val;
82+
}
8083
delete[] val;
8184
val = nullptr;
8285
}
@@ -116,7 +119,8 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
116119
if (it != n2v->end()) {
117120
nrn_assert(it->second.first == 0);
118121
*(it->second.second) = val;
119-
} else if (static_cast<std::string>(name).find("ion") != std::string::npos) {
122+
}
123+
if (static_cast<std::string>(name).find("ion") != std::string::npos) {
120124
nrn_ion_init[name] = val;
121125
}
122126
} else if (sscanf(line, "%[^[][%d]\n", name, &n) == 2) {

0 commit comments

Comments
 (0)