Page 1 of 1

nrnivmodl translation rules

Posted: Mon Jun 07, 2021 2:30 am
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.

Re: nrnivmodl translation rules

Posted: Mon Jun 07, 2021 10:33 am
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?

Re: nrnivmodl translation rules

Posted: Thu Jun 10, 2021 4:21 am
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.

Re: nrnivmodl translation rules

Posted: Thu Jun 10, 2021 10:03 am
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

Re: nrnivmodl translation rules

Posted: Thu Jun 10, 2021 5:15 pm
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.

Re: nrnivmodl translation rules

Posted: Fri Jun 11, 2021 12:30 am
by ted
Well, you can see the c code that is generated, so have at it.