nrnivmodl translation rules

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
itaru
Posts: 27
Joined: Wed Jan 29, 2020 10:15 pm
Contact:

nrnivmodl translation rules

Post by itaru »

Hi,
Is there documentation to explain how mod files are translated into C files?
I've been using today's master branch of NEURON.
ted
Site Admin
Posts: 5935
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: nrnivmodl translation rules

Post by ted »

Are you just trying to figure out how to write NMODL code that does something useful, or are you actually interested in the process that translates NMODL statements into C code?
itaru
Posts: 27
Joined: Wed Jan 29, 2020 10:15 pm
Contact:

Re: nrnivmodl translation rules

Post by itaru »

latter; those translated C codes still look to me not human readable in my humble opinion.
I'd like to know the process so I can write clearer .mod files.
ted
Site Admin
Posts: 5935
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: nrnivmodl translation rules

Post by ted »

those translated C codes still look to me not human readable in my humble opinion.
Your humble opinion is mostly correct. Those c files are computer generated, and they're not intended to be human readable. Bits and pieces of them can be understood for very specific purposes, if and when absolutely necessary, but it's almost never necessary to do that.

If your goal is to "write clearer .mod files" then you're going about it the wrong way. To learn how to write better C code does one read the generated assembly language code?

Instead, learn NMODL's syntax from the perspective of "how do I implement a synapse or artificial spiking cell, or a biophysical mechanism like an ion channel or pump?" To learn about using NMODL to implement synapses and artificial spiking cells see chapter 10 of the NEURON book; to learn about how to use it to implement biophysical mechanisms, see chapter 9. If you don't have the book, here are preprints of these chapters:
https://www.neuron.yale.edu/ftp/ted/boo ... xedref.pdf
https://www.neuron.yale.edu/ftp/ted/boo ... xedref.pdf
itaru
Posts: 27
Joined: Wed Jan 29, 2020 10:15 pm
Contact:

Re: nrnivmodl translation rules

Post by itaru »

Sure Ted I will re-read the NEURON Book's relevant chapters; sometimes even as an end-user I'd like to really see the C code can generate an optimized piece of code.
ted
Site Admin
Posts: 5935
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: nrnivmodl translation rules

Post by ted »

Well, you can see the c code that is generated, so have at it.
Post Reply