Skip to content
Permalink
Browse files

section.rangevar[i] = expr sets the rangevar aray item to a constant

over the section.

Tagging along is some information that may help build from sources on
mswin using msys2.
  • Loading branch information...
nrnhines committed Feb 12, 2018
1 parent 4e5aee6 commit d9be9278dbda0b374124c99380fe53d189abf570
Showing with 78 additions and 5 deletions.
  1. +1 −1 mingw_files/mingwnotes
  2. +54 −0 mingw_files/msys2
  3. +23 −4 src/nrnpython/nrnpy_nrn.cpp
@@ -1,6 +1,6 @@
http://www.symscape.com/configure-msmpi-for-mingw-w64

Installed msmpisdk.msi and MsMpiSetup.exe in c:\ms-mpi (version 7.1)
Installed msmpisdk.msi and MsMpiSetup.exe in c:\ms-mpi (version 9.0)
Change Bin, Lib, Include to bin, lib, include
cp c:/Windows/System32/msmpi.dll c:/ms-mpi/lib/x64
cp c:/Windows/SysWoW64/msmpi.dll c:/ms-mpi/lib/x86 #optional
@@ -0,0 +1,54 @@
msys2.org
download x86_64 installer and follow instructions. i.e.
run the installer
tick the "run MSYS now" at end
in the terminal ---
pacman -Syu
close msysw terminal and open any msys2 terminal again from start menu.
pacman -Su #until no further installations
pacman -S git
pacman -S zip unzip

after installing from above
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
(I chose default=all for the first group and '3' for the toolchain)

for complete mpi see mingw_notes
for more or less complete python
pacman -S mingw64/mingw-w64-x86_64-python3-scipy #python 3.6.4
pacman -S mingw64/mingw-w64-x86_64-cython

if you wish to eventually build a setup.exe, then search for nsis installer
and install the nullsoft nsis installer.

in $HOME/neuron

git clone http://nrnhines@github.com/nrnhines/iv
git clone http://nrnhines@github.com/nrnhines/nrn

cd $HOME/neuron/iv
sh build.sh
./configure --prefix=`pwd`
make
make install

cd $HOME/neuron/nrn
sh build.sh

mkdir $HOME/neuron/nrnwinobj
cd $HOME/neuron/nrnwinobj
../nrn/configure --prefix=`pwd` -with-nrnpython=dynamic \
--with-pyexe=python3 --with-paranrn=dynamic \
MPICC=x86_64-w64-mingw32-gcc MPICXX=x86_64-w64-mingw32-g++ \
CFLAGS='-DMSMPI_NO_SAL -I/c/ms-mpi/include' \
LIBS='-L/c/ms-mpi/lib/x64 -lmsmpi' \
--host=x86_64-w64-mingw32

make # may do configure over again
#probably should edit nrn/src/mswin/batch/instalmingw.sh and change
#'if true ; then # false means skip marshaling of html'
#to 'if false ;'
make mswin

c:/nrn/tmp needed by bash.exe
export PATH=/mingw/bin:$PATH
@@ -46,6 +46,7 @@ typedef struct {
PyObject_HEAD NPySegObj* pyseg_;
Symbol* sym_;
int isptr_;
int attr_from_sec_; // so section.xraxial[0] = e assigns to all segments.
} NPyRangeVar;

static PyTypeObject* psection_type;
@@ -313,6 +314,7 @@ static PyObject* NPyRangeVar_new(PyTypeObject* type, PyObject* args,
self->pyseg_ = NULL;
self->sym_ = NULL;
self->isptr_ = 0;
self->attr_from_sec_ = 0;
}
return (PyObject*)self;
}
@@ -998,6 +1000,7 @@ static PyObject* section_getattro(NPySecObj* self, PyObject* pyname) {
r->pyseg_->x_ = 0.5;
r->sym_ = sym;
r->isptr_ = 0;
r->attr_from_sec_ = 1;
result = (PyObject*)r;
} else {
int err;
@@ -1225,6 +1228,7 @@ static PyObject* segment_getattro(NPySegObj* self, PyObject* pyname) {
Py_INCREF(r->pyseg_);
r->sym_ = sym;
r->isptr_ = 0;
r->attr_from_sec_ = 0;
result = (PyObject*)r;
} else {
int err;
@@ -1251,6 +1255,7 @@ static PyObject* segment_getattro(NPySegObj* self, PyObject* pyname) {
Py_INCREF(r->pyseg_);
r->sym_ = sym;
r->isptr_ = 1;
r->attr_from_sec_ = 0;
result = (PyObject*)r;
} else {
int err;
@@ -1378,6 +1383,7 @@ static PyObject* mech_getattro(NPyMechObj* self, PyObject* pyname) {
Py_INCREF(r->pyseg_);
r->sym_ = sym;
r->isptr_ = isptr;
r->attr_from_sec_ = 0;
result = (PyObject*)r;
} else {
double* px = np.prop_pval(sym, 0);
@@ -1508,10 +1514,22 @@ static int rv_setitem(PyObject* self, Py_ssize_t ix, PyObject* value) {
rv_noexist(r->pyseg_->pysec_->sec_, r->sym_->name, r->pyseg_->x_, err);
return -1;
}
d += ix;
if (!PyArg_Parse(value, "d", d)) {
PyErr_SetString(PyExc_ValueError, "bad value");
return -1;
if (r->attr_from_sec_) {
// the range variable array is from a section not a segment and so
// assignment is over the entire section.
double x;
if (!PyArg_Parse(value, "d", &x)) {
PyErr_SetString(PyExc_ValueError, "bad value");
return -1;
}
hoc_pushx(double(ix));
nrn_rangeconst(r->pyseg_->pysec_->sec_, r->sym_, &x, 0);
}else{
d += ix;
if (!PyArg_Parse(value, "d", d)) {
PyErr_SetString(PyExc_ValueError, "bad value");
return -1;
}
}
if (r->sym_->u.rng.type == EXTRACELL && r->sym_->u.rng.index == 0) {
diam_changed = 1;
@@ -1640,6 +1658,7 @@ static void rangevars_add(Symbol* sym) {
// printf("%s\n", sym->name);
r->sym_ = sym;
r->isptr_ = 0;
r->attr_from_sec_ = 0;
PyDict_SetItemString(rangevars_, sym->name, (PyObject*)r);
}

0 comments on commit d9be927

Please sign in to comment.
You can’t perform that action at this time.