NMODL file in different folder

Particularly useful chunks of hoc and/or NMODL code. May be pedestrian or stunningly brilliant, may make you gasp or bring tears to your eyes, but always makes you think "I wish I had written that; I'm sure going to steal it."
Post Reply
Dradeliomecus
Posts: 5
Joined: Fri Jul 20, 2018 3:24 am

NMODL file in different folder

Post by Dradeliomecus »

Hi,

Is it possible to put all the NMODL files in a folder and tell hoc to go find the compiled nrnmech.dll in this folder?

And if it's possible, is it also possible to put them in 2 differents folders (like a folder "channels" and a folder "synapses") and tell hoc to look in these 2 folders?

Thanks.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NMODL file in different folder

Post by ted »

Yes, but it's rarely useful. How are you ever going to share your code with anyone else? "Oh, that'll never happen." Right.

KISS--if a model needs a particular set of mechanisms, put the necessary mod files in the same directory as the other files that the model uses. If you can't live with that, put the mod files into a subdirectory of the one that contains the other files that the model needs. Then execute
nrnivmodl subdirname.
Dradeliomecus
Posts: 5
Joined: Fri Jul 20, 2018 3:24 am

Re: NMODL file in different folder

Post by Dradeliomecus »

It's just that I have channels being used in different cells, and I'd like my folder architecture to be just one file (main hoc file) and subdirectories with "channels", "synapses", "cells"..., that way it'll be more understandable if I share my code and it'll be cleaner :)

How do you run nrnivmodl subdirname? That looks like what I'm looking for.

Thanks.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NMODL file in different folder

Post by ted »

Every elaborate strategy is perfectly natural and intuitive to its inventor, but appears to be idiosyncratic and obscure to everyone else.

Apropos of which, it seemed to me that
nrnivmodl subdirname
was about as obvious as the nose on anyone's face, but apparently not. Let me try again.

If the working directory contains a subdirectory foo, and foo contains NMODL files,
nrnivmodl foo
will compile the NMODL files in foo.
Dradeliomecus
Posts: 5
Joined: Fri Jul 20, 2018 3:24 am

Re: NMODL file in different folder

Post by Dradeliomecus »

Ok thanks.
So I guess my problem was actually that 'nrnivmodl' isn't recognized as a command, and what I want to do doesn't work with mknrndll.hoc.

I'll look into it, thank you for your help!
EDIT: It doesn't work on Windows: viewtopic.php?t=1909
RobinDS
Posts: 22
Joined: Mon Nov 04, 2019 12:17 pm

Re: NMODL file in different folder

Post by RobinDS »

I'm distributing models as part of a python package. During a post-install script I'd like to compile all of the mod files that are in a subfolder of the package, and I'd like NEURON to be able to find the resulting .dll from any folder on that machine. Right now it only seems to look in the current working directory where python is running. How can I change this?
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NMODL file in different folder

Post by ted »

RobinDS wrote: Fri Nov 15, 2019 11:16 am I'm distributing models as part of a python package. During a post-install script I'd like to compile all of the mod files that are in a subfolder of the package, and I'd like NEURON to be able to find the resulting .dll from any folder on that machine. Right now it only seems to look in the current working directory where python is running. How can I change this?
nrn_load_dll() with an appropriate path argument. Read about it https://www.neuron.yale.edu/neuron/stat ... n_load_dll
RobinDS
Posts: 22
Joined: Mon Nov 04, 2019 12:17 pm

Re: NMODL file in different folder

Post by RobinDS »

On Linux it generates a folder x86_64 and a file called a.out. How would I go about loading that?

The documentation mentions that nrn_load_dll works for Linux, but I don't see a dll file?
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: NMODL file in different folder

Post by ted »

RobinDS wrote: Wed Nov 20, 2019 3:35 pmOn Linux it generates a folder x86_64
. . .
The documentation mentions that nrn_load_dll works for Linux, but I don't see a dll file?
The file you want to load is x86_64/.libs/libnrnmech.so

You realize that, by doing this, you are writing code that will not work under MSWin or MacOS. And unless you use relative paths, it won't work on anybody else's Linux box either. Becomes a problem for collaborating with others, not to mention accumulating citations of whatever you publish. Of course, you can prevent OS-related problems by testing for OS and then using OS-specific paths, but then it's up to you to make sure that the tests and paths work. Diverts time and effort from productive activities.
RobinDS
Posts: 22
Joined: Mon Nov 04, 2019 12:17 pm

Re: NMODL file in different folder

Post by RobinDS »

These are software deployment basics, but thanks for the heads up. libnrnmech.so inside of the hidden .libs folder does the trick
Post Reply