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

Commit

Permalink
Fixed initialization of global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
iomaganaris committed Feb 25, 2022
1 parent 8c9a8db commit c3ec12d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
24 changes: 4 additions & 20 deletions coreneuron/apps/main1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,36 +508,21 @@ extern "C" void mk_mech_init(int argc, char** argv) {
out.close();
}

// Not working
// initialise default coreneuron parameters
initnrn();
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);

// set global variables
// precedence is: set by user, globals.dat, 34.0
celsius = corenrn_param.celsius;
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);

// read the global variable names and set their values from globals.dat
// some global variables need to be read before the ion_reg to initialize
// properly the in-built ion mechanisms
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
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);

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

// // Not working
// // initialise default coreneuron parameters
// initnrn();
// 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);

// // set global variables
// // precedence is: set by user, globals.dat, 34.0
// celsius = corenrn_param.celsius;
// 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);

// // read the global variable names and set their values from globals.dat
// set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
// 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);
}

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


// read the global variable names and set their values from globals.dat
// read agin the global variables to set the global variables defined by
// the mod files' mechanisms
set_globals(corenrn_param.datpath.c_str(), (corenrn_param.seed >= 0), corenrn_param.seed);
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);


if (!corenrn_param.is_quiet()) {
report_mem_usage("After mk_mech");
Expand Down
6 changes: 5 additions & 1 deletion coreneuron/io/global_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
}
}
}
if (static_cast<std::string>(name).find("ion") != std::string::npos) {
nrn_ion_init[name] = *val;
}
delete[] val;
val = nullptr;
}
Expand Down Expand Up @@ -116,7 +119,8 @@ void set_globals(const char* path, bool cli_global_seed, int cli_global_seed_val
if (it != n2v->end()) {
nrn_assert(it->second.first == 0);
*(it->second.second) = val;
} else if (static_cast<std::string>(name).find("ion") != std::string::npos) {
}
if (static_cast<std::string>(name).find("ion") != std::string::npos) {
nrn_ion_init[name] = val;
}
} else if (sscanf(line, "%[^[][%d]\n", name, &n) == 2) {
Expand Down

0 comments on commit c3ec12d

Please sign in to comment.