Start NEURON and load MOD files

Anything that doesn't fit elsewhere.
Post Reply
stephanmg
Posts: 68
Joined: Tue Jul 03, 2012 4:40 am

Start NEURON and load MOD files

Post by stephanmg »

Dear Users,

I've come up with a question:

I need to start NEURON from let's say the directory /foo/bar/ but i have my mod files in /ext/dir/ - how would i load the mod files?

Please note, I'm using ivocmain for initializing NEURON in a custom cpp project.

Best regards and thanks in advance,
Stephan
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Start NEURON and load MOD files

Post by ted »

The location of the mod files isn't important; the location of the dll (OS X or MSWin) or special that is produced by compiling the mod files is what matters.

For example, suppose I use Linux and the foo.hoc or foo.py that I want NEURON to execute is in a directory called model1. I'd cd to model1, then in that directory I'd execute
nrnivmodl /ext/dir
which would compile the mod files that are in /ext/dir and produce an i686 or x86_64 subdirectory in model1 that contains a file called special. Staying in model1 and using nrngui or nrniv to execute foo.hoc or foo.py will make NEURON automatically discover and load the compiled mechanisms. If I then cd to some other directory, say model2, where there is a foo.hoc (or foo.py) that I want to use with the same compiled mechanisms, in model2 I could execute
model1/i686/special foo.hoc -
which would make NEURON load the compiled mechanisms and execute foo.hoc
or
model1/i686/special foo.hoc
which would make NEURON load the compiled mechanisms, execute foo.hoc, then exit.

If you're using MSWin or OS X, it should be sufficient to just run mknrndll in /ext/dir where the mod files are, and then copy the resulting nrnmech.dll file to wherever your foo.hoc or foo.py is located. Or you could leave the nrnmech.dll wherever you generated it, and just specify the path to it on the command line when you launch NEURON as an option to the -dll switch, like so
nrniv -dll /path/to/nrnmech.dll foo.hoc
with the optional - at the end if you don't want NEURON to exit immediately after it executes foo.hoc
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Start NEURON and load MOD files

Post by hines »

If you know where the shared library is, then you can load if from hoc using
nrn_load_dll("/where/the/shared/library/is/libnrnmech.so")
on a linux or mac machine that location is generally ./x86_64/.libs/libnrnmech.so
on mswin it is generally ./nrnmech.dll
stephanmg
Posts: 68
Joined: Tue Jul 03, 2012 4:40 am

Re: Start NEURON and load MOD files

Post by stephanmg »

Thanks, this helps a lot.

Best regards,
Stephan
Post Reply