"My mechanisms don't load!"

NMODL and the Channel Builder.
ted
Site Admin
Posts: 5107
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

"My mechanisms don't load!"

Post by ted » Wed Aug 11, 2010 10:30 am

Symptom:
NEURON exits with a syntax error that reports failure of an insert statement like

Code: Select all

. . . nrniv: syntax error
 in foo.hoc near line 2
 soma insert bar
              ^
or failure to create a new instance of a class, as in

Code: Select all

. . . nrniv: Bar is not a template
 in foo.hoc near line 4
 soma baz = new Bar(0.5)
                      ^
What this means:
The hoc code asked NEURON to use an unrecognized density mechanism ("distributed mechanism") or object class (point process or a class defined by a template).

Possible causes:
1. Typographical error in the name of the density mechanism or class.
2. Omission of hoc code that uses a template to define a class.
3. Failure to load the ses file for a Channel Builder that defines a density mechanism or point process.
4. The density mechanism or point process was defined by a mod file, but the mod file was not compiled, either because the user forgot to compile it, or because compilation failed.
5. The mod file was compiled successfully, but the compiled mechanism(s) did not load when NEURON started.

Diagnosis and treatment of causes 1 - 3 is generally straightforward and will not be discussed further. Failure to compile mod files under MSWin usually means badly broken NMODL code; the fix is highly case-specific and must be addressed on a case-by-case basis. Failure to compile under OS X, Linux, and UNIX most often means that the development tools and libraries have not been installed; the fix, which is to install the development tools and libraries, is OS-specific and has been discussed in multiple threads on this Forum.

Failure to load compiled mechanisms occurs rarely, and when it does, it is typically in the context of programs that are organized so as to place mod files in one or more directories that are different from the directories that contain the hoc and ses files. Sometimes it can be useful to break programs into multiple files that are distributed over elaborate directory structures (for a good example of how to do this properly, see the NEURON code for Brette et al. 2007 http://senselab.med.yale.edu/modeldb/Sh ... odel=83319), but most often the result is obfuscating complexity that interferes with program use, debugging, and maintentance.

But failure to load compiled mechanisms can also have much simpler causes. For example, suppose you're in a directory where you successfully compiled some mod files, and you execute this command:
nrngui foo.hoc
where foo.hoc is the name of a hoc file in that directory. NEURON will start, read the compiled mechanisms, and then it will read and execute the statements in foo.hoc. So far, so good. Now suppose you try this instead:
nrniv foo.hoc
NEURON will start, but it won't load the compiled mechanisms. Instead, it will immediately start reading and executing the statements in foo.hoc. If any of those statements needs one of the compiled mechanisms, you're going to get an error message, because NEURON won't know anything about the compiled mechanisms.

"But I can fix that by putting a nrn_load_dll() statement in my hoc file, right?"

Sure you can, but the statement will be OS-specific. On a 32 bit Linux machine, it would be
nrn_load_dll("i686/.libs/libnrnmech.so.0")
But under 64 bit Linux it would have to be
nrn_load_dll("x86_64/.libs/libnrnmech.so.0")
and under MSWin it would be
nrn_load_dll("nrnmech.dll")
So why bother? Just use
nrngui foo.hoc
and you won't have to worry about all these OS-specific details.

"But I don't want the GUI."

Fine. Start neuron like this:
nrngui -nogui foo.hoc

GraeGreene
Posts: 3
Joined: Thu Dec 31, 2009 10:03 am

Re: "My mechanisms don't load!"

Post by GraeGreene » Sun Aug 22, 2010 5:38 am

Hello,

I'm new to NEURON and I'm having trouble with a .mod file that compiled properly but doesn't load. So my stupid question of the day is: do I need to do anything after the .mod file compiles (such as move it, rename it, or something of the sort)? When I run the code that uses it, I get "ASyn is not a template."

Pertinent info: I'm running NEURON 7.1 on Mac OS X Snow Leopard, installed with the standard .dmg from the downloads page. I compiled by running nrnivmodl from the directory that contains the .mod file.

I'm also having trouble compiling a different mod file, but I'll make a new thread for that.

Any assistance would be greatly appreciated. Many thanks in advance.

*edit* I just noticed that when I run nrngui after compiling, it says:

Code: Select all

loading membrane mechanisms from /Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so
dlopen failed - 
dlopen(/Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so, 2): Symbol not found: __AlphaSyn_reg
  Referenced from: /Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so
  Expected in: flat namespace
 in /Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so

But I still don't know what it means. Thanks again!

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

Re: "My mechanisms don't load!"

Post by ted » Sun Aug 22, 2010 10:15 am

GraeGreene wrote:do I need to do anything after the .mod file compiles (such as move it, rename it, or something of the sort)?
No.
When I run the code that uses it, I get "ASyn is not a template."
Not surprising, given this message:

Code: Select all

loading membrane mechanisms from /Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so
dlopen failed - 
dlopen(/Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so, 2): Symbol not found: __AlphaSyn_reg
  Referenced from: /Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so
  Expected in: flat namespace
 in /Users/mgmacleod8/ProgrammingProjects/NEURON/SixToTwo/Code/umac/.libs/libnrnmech.so
which strongly suggests some problem during compilation of a mod file that tries to define something called AlphaSyn.

When you try to execute your hoc file, what does NEURON print right after its banner (i.e. right after the message that tells the version information)?

stil
Posts: 28
Joined: Thu Jul 01, 2010 8:47 am
Location: Mulhouse - France

Re: "My mechanisms don't load!"

Post by stil » Wed Jun 06, 2012 12:17 pm

Hello,

I've had such a problem (dlopen failed) on a fresh install of ubuntu, when my tests were situated on a ntfs partition.

I modified the /etc/fstab file so that the partition is mounted with full rights (umask=000), and execution authorized (exec option)

Code: Select all

# Partitions Windows - NTFS
 UUID="X4XXCAXX428AC64B"	/media/DATA	 ntfs-3g 	rw,user,auto,gid=100,uid=1000,nls=utf8,umask=000,exec	0  0
hope it will help.
Arnaud.

JMGomes

Re: "My mechanisms don't load!"

Post by JMGomes » Fri Nov 29, 2013 12:54 pm

Dear NEURON users and contributors,

I'm dealing with a similar problem. Running NEURON 7.3 on Mac OS 10.9, my Upstates.mod file compiles fine (Successfully created x86_64/special), with a mechanism also called Upstates (no typo also in the hoc file). But I keep running into this:

Code: Select all

/Applications/NEURON-7.3/nrn/x86_64/bin/nrniv: Upstates is not a template
 in /Users/Gus/Travail/These/Scripts/Neuron/dcjm.hoc near line 31
     soma syn = new Upstates(0.5)
                                ^
I'm clearly in the 5th case of the uppermost post.

This is quite frustrating since I'm able to run similar sets of files that were compiled on other computers/configs/galaxies. Furthermore, the problem is the same in Linux Mint 15 that I've installed as guest: flawless compiling, but inability to load the mechanism.

I exhausted all the possible help that I was able to understand (as a tenacious beginner: forums, manuals, google), so any suggestion is welcome.
If needed I can provide files or more info.

Thanks in advance.

hines
Site Admin
Posts: 1459
Joined: Wed May 18, 2005 3:32 pm

Re: "My mechanisms don't load!"

Post by hines » Fri Nov 29, 2013 9:03 pm

Can you successfully launcn neurondemo, select the "Release" demo, and see results with "Init&Run".

If so, when you launch in preparation for using Upstates, is Upstates.mod listed as one of the "Additional mechanisms from files"

if not, can you start a terminal window, navigate to the folder containing Upstates.mod and is there a file called
x86_64/.libs/libnrnmech.so

If so can you launch x86_64/special from the terminal window and is Upstates.mod listed as one of the "Additional mechanisms from files"

If all this fails, you might start from
http://www.neuron.yale.edu/ftp/neuron/v ... y1.1.0.dmg
and let me know if that works.

JMGomes

Re: "My mechanisms don't load!"

Post by JMGomes » Sat Nov 30, 2013 8:19 pm

Can you successfully launcn neurondemo, select the "Release" demo, and see results with "Init&Run".
Yes. Displaying nice colourful curvy curves.

Upstates.mod is not an "Additional mechanisms from files" when launching the associated .hoc file calling for Upstates. (Am I understanding this right? Just compiling the .mod file and then launching the .hoc with nrngui, with the -Py_NoSiteFlag option to avoid a "no module named site" error.)

The libnrnmech.so is indeed present, launching "special" brings up the hope:

Code: Select all

loading membrane mechanisms from /Users/.../Neuron/x86_64/.libs/libnrnmech.so
Additional mechanisms from files
 Upstates.mod

Then:

Code: Select all

load_file("/Users/Gus/Travail/These/Scripts/Neuron/dcjm.hoc")
... Huzza!

Thanks a lot for being so quick and helpful even during the weekend. Such dedication in support is really amazing!
Last edited by JMGomes on Sun Dec 01, 2013 5:58 am, edited 1 time in total.

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

Re: "My mechanisms don't load!"

Post by ted » Sat Nov 30, 2013 10:02 pm

JMGomes wrote:

Code: Select all

oc>load_file("/Users/.../dcjm.hoc")
	1 
/Applications/NEURON-7.3/nrn/x86_64/bin/nrniv: Iclamp is not a template[/quote]This is correct--NEURON doesn't know anything about Iclamp. Perhaps you meant to type IClamp?

JMGomes

Re: "My mechanisms don't load!"

Post by JMGomes » Sun Dec 01, 2013 6:00 am

Indeed, my bad.
Deleted this in the previous post to make the solution clearer to future generations.

hines
Site Admin
Posts: 1459
Joined: Wed May 18, 2005 3:32 pm

Re: "My mechanisms don't load!"

Post by hines » Sun Dec 01, 2013 10:09 am

Upstates.mod is not an "Additional mechanisms from files" when launching the associated .hoc file calling for Upstates.
(Am I understanding this right? Just compiling the .mod file and then launching the .hoc with nrngui...
You are supposed to be able to double click the .hoc file if the mod files are in the same folder and that folder was dragged
onto the mknrndll icon. I'm not sure that dragging the hoc file onto the nrngui icon works properly in the sense of starting in the
folder containing the hoc file. (you can check by executing from hoc the statement "getcwd()" without the quotes after launch).

With regard to
... with the -Py_NoSiteFlag option to avoid a "no module named site" error.
I must admit to a good deal of puzzlement over the whole constellation of "no module named site" problems. I have no found a general solution yet, perhaps due to site.py and descendents being
in different places in different python installations. Anyway, the NoSiteFlag work around is a kind of last resort. On maveriks with canopy, the last part of the log message at
http://www.neuron.yale.edu/hg/neuron/nr ... 0f78755a30
gives the LD_LIBRARY_PATH and PYTHONHOME I needed to avoid the problem. Perhaps something analogous would avoid your "site" problem.

santana_loren9
Posts: 12
Joined: Thu Oct 19, 2017 6:42 pm

Re: "My mechanisms don't load!"

Post by santana_loren9 » Mon Dec 04, 2017 8:11 pm

Dear all,

I've read a couple of the forums regarding this topic, yet I cannot fix my code. I am receiving the error
/Applications/NEURON-7.5/nrn/x86_64/bin/nrniv: syntax error
in snc_compensation.hoc near line 12
insert leak_dop
^
as others have mentioned.

I have a hoc file in the same folder as the mod files. This is the code:

Code: Select all

load_file("nrngui.hoc") 
nrn_load_dll("nrnmech.dll")

create soma
access soma

soma {
   nseg = 1
   L = 15
   diam = 15
   Ra = 70
   insert leak_dop
    	gbar_leak_dop = 5e-06
    	e_leak_dop = -45
   insert nahh
    	gbar_nahh = 0.01

}

v_init = -68
celsius = 35
cvode.active(0)
proc init() {
	finitialize(v_init)
}
tstop = 10000

run()
Before dragging the hoc code to nrngui, I drag the mod files to mknrndll. A folder called x86_64 is made with files titled:
libnrnmech.la
special
mod_func.lo
nahh.lo
nahh.c
mod_func.c
nahh.mod
leak_dop.lo
lead_dop.c
leak_dop.mod

I checked for spelling errors and I don't have any. When I run the hoc code without nahh insert (only leak_dop), I do not get any error messages and can plot voltage.

Can someone tell me what I am doing incorrectly?
Thank you.

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

Re: "My mechanisms don't load!"

Post by ted » Mon Dec 04, 2017 10:09 pm

1. Does this

"I drag the mod files to mknrndll."

mean that you dragged the folder that contained the mod files onto mknrndll?

2. Is the x86_64 folder in the same folder that contains your mod files and your hoc file?

3. Use a plain text editor to create a text file called hello.hoc that contains the following statement:

print "hello"

Put hello.hoc in the same folder that contains your mod files. Double click on hello.hoc (or drag and drop hello.hoc onto nrngui, if you prefer)and tell me exactly what NEURON prints to the terminal.


Miscellaneous comments that have nothing to do with the problem you are experiencing:
1. You won't need a
nrn_load_dll() statement if your hoc file is located in the same folder as the mod files and the x86_64 folder generated by mknrndll.
2. Don't use cvode.active() to turn adaptive integration on or off. Instead use cvode_active() with a 1 or 0 argument, respectively. Why? cvode_active() is part of NEURON's run control system. In addition to turning adaptive integration on or off, it also does many other important things, including ensuring that updates of current- and state-axis graphs are plotted at time t, rather than being offset by +- dt/2 (the times at which ionic conductances and currents, respectively, are second order accurate when Crank-Nicholson integration is used).

santana_loren9
Posts: 12
Joined: Thu Oct 19, 2017 6:42 pm

Re: "My mechanisms don't load!"

Post by santana_loren9 » Mon Dec 04, 2017 11:03 pm

Hi Ted,

Thank you for getting back to me. When I said I drag the mod files to mknrndll, I mean that I dragged each individual mod file and new files kept being added to the x86_64 folder.

The x86_64 folder is in the same folder that contains my hoc and mod files. Also, I'll add that my hoc and mod files are in the same folder, not separate.

When I create a hello.hoc file and drag it to nrngui, I get the following:
-e
NEURON -- VERSION 7.5 master (6b4c19f) 2017-09-25
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from /Users/lorensantana/Desktop/snc_compensation/x86_64/.libs/libnrnmech.so
Additional mechanisms from files
nahh.mod
hello
oc>
Thank you for the additional comments.

santana_loren9
Posts: 12
Joined: Thu Oct 19, 2017 6:42 pm

Re: "My mechanisms don't load!"

Post by santana_loren9 » Mon Dec 04, 2017 11:43 pm

Also, based on your last comment, I dragged the whole folder instead of each file individually and now I'm not getting the error message. Is that the error? Should I be okay from now on?
I got the following message when I run a hoc file:
-e
NEURON -- VERSION 7.5 master (6b4c19f) 2017-09-25
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from /Users/lorensantana/Desktop/snc_compensation/x86_64/.libs/libnrnmech.so
Additional mechanisms from files
Ca.mod CaDiffuse2.mod CaDiffuse3.mod CaHandler2.mod bk_dop.mod cal_dop.mod cap_dop.mod hcn_siegelbaum.mod kcnq_hh.mod kir2_dop.mod kv1_gp.mod kv2_hh.mod kv2_simplehh.mod kv4hh.mod leak_dop.mod nahh.mod sk_dop.mod vramp.mod
0
oc>

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

Re: "My mechanisms don't load!"

Post by ted » Tue Dec 05, 2017 12:26 am

You figured it out. Drag and drop one mod file onto mknrndll, and you get a library that contains one compiled mechanism. Drag and drop another mod file, and you overwrite what you previously had with a library that contains a different compiled mechanism. Drag and drop the whole folder of mod files, and the library contains multiple compiled mechanisms. The messages printed by NEURON when it starts will tell you what compiled mechanisms are in the library. Looks like you have a bunch of mod files in that folder, and your library contains many mechanisms.

Post Reply