@@ -60,6 +60,15 @@ double nrn_ion_charge(int type) {
6060 return global_charge (type);
6161}
6262
63+ std::unordered_map<std::string, double > nrn_ion_init = {
64+ {" nai0_na_ion" , DEF_nai},
65+ {" nao0_na_ion" , DEF_nao},
66+ {" ki0_k_ion" , DEF_ki},
67+ {" ko0_k_ion" , DEF_ko},
68+ {" cai0_ca_ion" , DEF_cai},
69+ {" cao0_ca_ion" , DEF_cao},
70+ };
71+
6372void ion_reg (const char * name, double valence) {
6473 char buf[7 ][50 ];
6574#define VAL_SENTINAL -10000 .
@@ -109,22 +118,30 @@ void ion_reg(const char* name, double valence) {
109118 sprintf (buf[1 ], " %so0_%s" , name, buf[0 ]);
110119 if (strcmp (" na" , name) == 0 ) {
111120 na_ion = mechtype;
112- global_conci (mechtype) = DEF_nai ;
113- global_conco (mechtype) = DEF_nao ;
121+ global_conci (mechtype) = nrn_ion_init[ " nai0_na_ion " ] ;
122+ global_conco (mechtype) = nrn_ion_init[ " nao0_na_ion " ] ;
114123 global_charge (mechtype) = 1 .;
115124 } else if (strcmp (" k" , name) == 0 ) {
116125 k_ion = mechtype;
117- global_conci (mechtype) = DEF_ki ;
118- global_conco (mechtype) = DEF_ko ;
126+ global_conci (mechtype) = nrn_ion_init[ " ki0_k_ion " ] ;
127+ global_conco (mechtype) = nrn_ion_init[ " ko0_k_ion " ] ;
119128 global_charge (mechtype) = 1 .;
120129 } else if (strcmp (" ca" , name) == 0 ) {
121130 ca_ion = mechtype;
122- global_conci (mechtype) = DEF_cai ;
123- global_conco (mechtype) = DEF_cao ;
131+ global_conci (mechtype) = nrn_ion_init[ " cai0_ca_ion " ] ;
132+ global_conco (mechtype) = nrn_ion_init[ " cao0_ca_ion " ] ;
124133 global_charge (mechtype) = 2 .;
125134 } else {
126- global_conci (mechtype) = DEF_ioni;
127- global_conco (mechtype) = DEF_iono;
135+ if (nrn_ion_init[static_cast <std::string>(buf[0 ])]) {
136+ global_conci (mechtype) = nrn_ion_init[static_cast <std::string>(buf[0 ])];
137+ } else {
138+ global_conci (mechtype) = DEF_ioni;
139+ }
140+ if (nrn_ion_init[static_cast <std::string>(buf[1 ])]) {
141+ global_conco (mechtype) = nrn_ion_init[static_cast <std::string>(buf[0 ])];
142+ } else {
143+ global_conco (mechtype) = DEF_iono;
144+ }
128145 global_charge (mechtype) = VAL_SENTINAL;
129146 }
130147 }
@@ -275,6 +292,7 @@ void nrn_cur_ion(NrnThread* nt, Memb_list* ml, int type) {
275292 for (int _iml = 0 ; _iml < _cntml_actual; ++_iml) {
276293 dcurdv = 0 .;
277294 cur = 0 .;
295+ // printf("nrn_cur_ion %d iontype[%d] %d\n", type, _iml, iontype);
278296 if (iontype & 0100 ) {
279297 erev = nrn_nernst (conci, conco, charge, celsius);
280298 }
@@ -295,10 +313,10 @@ void nrn_init_ion(NrnThread* nt, Memb_list* ml, int type) {
295313 return ;
296314 }
297315
298- /* printf("ion_init %s\n", memb_func[type].sym->name);*/
299316 int _cntml_padded = ml->_nodecount_padded ;
300317 pd = ml->data ;
301318 ppd = ml->pdata ;
319+ printf (" nrn_init_ion %d %s conci %lf conco %lf charge %lf celsius %lf\n " , type, nrn_get_mechname (type), conci0, conco0, charge, celsius);
302320 // There was no async(...) clause in the initial OpenACC implementation, so
303321 // no `nowait` clause has been added to the OpenMP implementation. TODO:
304322 // verify if this can be made asynchronous or if there is a strong reason it
0 commit comments