Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid use of ion variable in the CONSTANT block
* certain mod files use read/write ion variables from USEION statements in CONSTANT {} block * the generated code from such usage is not desired I believe. For example, cdp_spiny.mod from ModelDB model id 266799 has ```console NEURON { SUFFIX cdp4Nsp USEION ca READ cao, cai, ica WRITE cai RANGE ica_pmp,scale ... } ASSIGNED { diam (um) ica (mA/cm2) ica_pmp (mA/cm2) parea (um) : pump area per unit length cai (mM) } CONSTANT { cao = 2 (mM) } ``` In this example, the generated code doesn't set ion variable `cao` to 2 but declare a static variable `cao` with value 2 and that is not used anywhere: ```cpp #define ica _p[56] #define ica_columnindex 56 #define parea _p[57] #define parea_columnindex 57 #define cai _p[58] ... #define _ion_cao *_ppvar[0]._pval #define _ion_cai *_ppvar[1]._pval #define _ion_ica *_ppvar[2]._pval #define _style_ca *((int*)_ppvar[3]._pvoid) #define diam *_ppvar[4]._pval ... static double cao = 2; ... static void nrn_state(NrnThread* _nt, _Memb_list* _ml, int _type) { ... cao = _ion_cao; cai = _ion_cai; ica = _ion_ica; cai = _ion_cai; ... } ``` Note that `cao` variable used/updated here is not ion variable but static one defined in the file scope. I believe this is not what user "expected" here. * As we see this pattern in multiple mod files (including glia__dbbs_mod_collection__cdp5__CAM_GoC.mod mentioned in BlueBrain/nmodl#888), in this PR we disable declaring ion variables as CONSTANT. With this PR, we will get an error like: ```console $ ./bin/nocmodl /.../nmodldb/models/db/modeldb/266799/mod/cdp_spiny.mod ... cao used in USEION statement can not be re-declared in the CONSTANT block at line 299 in file /.../nmodldb/models/db/modeldb/266799/mod/cdp_spiny.mod ```
- Loading branch information