Adding C code in a model file

NMODL and the Channel Builder.
Post Reply
roybens
Posts: 54
Joined: Fri Mar 14, 2008 7:57 am

Adding C code in a model file

Post by roybens »

Hello All,
For my simulation i need a RNG(Random Number Generator) which is not included in neuron (Levy Distribution). I wrote a mod file with the c code that will invoke the method gsl_ran_levy. the function gsl_ran_levy is part of the GSL Library located under usr/local/gsl.
After building the mod file with nrnivmodl, when i run nrniv i get the following error:
loading membrane mechanisms from x86_64/.libs/libnrnmech.so
dlopen failed -
x86_64/.libs/libnrnmech.so: undefined symbol: gsl_rng_default

I think i need to change the configuration that it will be referenced to the gsl library but i dont know how to do it under neuron
Can someone please help

The mod file:
levy.mod
NEURON {SUFFIX nothing}

VERBATIM
#include <stdio.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
/* all the c code needed for gsl_ran_levy here */
static gsl_rng* r;
static gsl_rng_type * T;
static double levy_wrapper(double c, double alpha) {
if (!r) {
T = gsl_rng_default;
r = gsl_rng_alloc (T);


}
return gsl_ran_levy(r, c, alpha);
}
ENDVERBATIM

FUNCTION levy(c, a) {
VERBATIM
_llevy = levy_wrapper(_lc,_la);
ENDVERBATIM
}
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Post by hines »

nrnivmodl needs to link against the gsl library. Use the nrnivmodl option -loadflags. Perhaps

Code: Select all

nrnivmodl -loadflags -lgsl
will work or perhaps you also need a -Lpath_to_gsl_library
Post Reply