compiling a mod file

NMODL and the Channel Builder.
Post Reply
avracadavra
Posts: 3
Joined: Wed Nov 24, 2010 2:14 pm

compiling a mod file

Post by avracadavra »

Hi there,

when I compile the following code

Code: Select all


NEURON {
	ARTIFICIAL_CELL IntFire4_with_variable_weight
	RANGE taue, taui1, taui2, taum, e, i1, i2, m, weight_variability
	RANGE nself, nexcite, ninhibit
	GLOBAL eps
}

PARAMETER {
	taue = 5 (ms)
	taui1 = 10 (ms)
	taui2 = 20 (ms)
	taum = 50 (ms)
	ib = 0
	eps = 1e-6
	weight_variability = 0
}

ASSIGNED {
	e i1 i2 m
	enew i1new i2new mnew
	t0 (ms)
	nself nexcite ninhibit

	ke (1/ms) ki1 (1/ms) ki2 (1/ms) km (1/ms)
	ae (1/ms) ai1 (1/ms) ai2 (1/ms)
	be bi1 bi2
	a b
	delta_e		: Slight change in e
}

PROCEDURE newstates(d(ms)) {
	LOCAL ee, ei1, ei2, em
	
	ee = exp(-ke*d)
	ei1 = exp(-ki1*d)
	ei2= exp(-ki2*d)
	em = exp(-km*d)
	enew = e*ee
	i1new = i1*ei1
	i2new = i2*ei2 + bi1*i1*(ei2 - ei1)
	mnew = m*em
		+ be*e*(em - ee)
		+ (bi2*i2 + a*i1)*(em - ei2)
		- b*i1*(em - ei1)
}

FUNCTION M() {
	newstates(t - t0)
	M = mnew
}

FUNCTION E() {
	newstates(t - t0)
	E = enew
}

FUNCTION I() {
	newstates(t - t0)
	I = i2new
}

PROCEDURE update() {
	e = enew
	i1 = i1new
	i2 = i2new
	m = mnew
	t0 = t
}

PROCEDURE factors() {
	LOCAL tp
	: force all exponential solution ( no x*exp(-x) )
	: and force assertion for correctness of algorithm
	: i.e. taue is smallest and only one that is excitatory
	if (taue >= taui1) { taui1 = taue + .01 }
	if (taui1 >= taui2) { taui2 = taui1 + .01 }
	if (taui2 >= taum) { taum = taui2 + .01 }

	ke=1/taue  ki1=1/taui1  ki2=1/taui2  km=1/taum

	: normalize so the peak magnitude of m is 1 when single e of 1
	tp = log(km/ke)/(km - ke)
	be = 1/(exp(-km*tp) - exp(-ke*tp))
	ae = be*(ke - km)

	: normalize so the peak magnitude of i2 is 1 when single i of 1
	tp = log(ki2/ki1)/(ki2 - ki1)
	bi1 = 1/(exp(-ki2*tp) - exp(-ki1*tp))
	ai1 = bi1*(ki1 - ki2)

	: normalize so the peak magnitude of m is 1 when single i of 1
	: first set up enough so we can use newstates()
	e = 0
	i1 = 1
	i2 = 0
	m = 0
	bi2 = 1
	ai2 = bi2*(ki2 - km)
	a = bi2*bi1
	b = a*(ki2 - km)/(ki1 - km)
	:find the 0 of dm/dt
	tp = search()
	: now compute normalization factor and reset constants that depend on it
	newstates(tp)
	bi2 = 1/mnew
	ai2 = bi2*(ki2 - km)
	a = bi2*bi1
	b = a*(ki2 - km)/(ki1 - km)
	: now newstates(tp) should set mnew=1
	newstates(tp)
:	printf("INITIAL bi2=%g tp=%g mnew=%g\n", bi2, tp, mnew)
	i1 = 0
}

FUNCTION deriv(d(ms)) (/ms2) { : proportional, not exact derivative
	deriv = -km*(ki1 - ki2)*exp(-km*d)
		+ ki2*(ki1 - km)*exp(-ki2*d)
		- ki1*(ki2 - km)*exp(-ki1*d)
}

FUNCTION search() (ms) {
	LOCAL x, t1, t2
	: should only do this when tau's change
	: chord search
	: left side is 0 without slow km
	t1 = -log(ki1*(ki2 - km)/ki2/(ki1 - km))/(ki1 - ki2)
:printf("search greedy test t1=%g x1=%g\n", t1, deriv(t1))
	if (deriv(t1) < 0) { : but it failed so be conservative
		: and choose the peak location of i2
		t1 = log(ki1/ki2)/(ki1 - ki2)
	}
	: right side is 0 without fast ki1
	t2 = log(km*(ki1 - ki2)/ki2/(ki1 - km))/(km - ki2)
:printf("search  t1=%g x1=%g t2=%g x2=%g\n", t1, deriv(t1), t2, deriv(t2))
	: now do search
	while (t2 - t1 > 1e-6) {
		search = (t1+t2)/2
		x = deriv(search)
:printf("search=%g x=%g\n", search, x)
		if (x > 0) {
			t1 = search
		}else{
			t2 = search
		}
	}			
}

INITIAL {
	factors()
	e = 0
	i1 = 0
	i2 = 0
	m = 0
	t0 = t
	net_send(firetimebound(), 1)

	nself=0
	nexcite=0
	ninhibit=0
}

NET_RECEIVE (w) {
	newstates(t-t0)
	update()
	
	delta_e = (scop_random() - 0.5) * 2 * weight_variability
	
	
:printf("event %g t=%g e=%g i1=%g i2=%g m=%g\n", flag, t, e, i1, i2, m)
	if (m > 1-eps) { : time to fire
:printf("fire\n")
		net_event(t)
		m = 0
	}
	if (flag == 1) { :self event
		nself = nself + 1
		net_send(firetimebound(), 1)
	}else{
		if (w > 0) {
			nexcite = nexcite + 1
			e = e + w + delta_e
		}else{
			ninhibit = ninhibit + 1
			i1 = i1 + w + delta_e
		}
:printf("w=%g e=%g i1=%g\n", w, e, i1)
		net_move(firetimebound() + t)
	}
}

FUNCTION firetimebound() (ms) {
	LOCAL slope
	slope = -km*m + ae*e + ai2*i2
	if (slope <= 1e-9) {
		firetimebound = 1e9
	}else{
		firetimebound = (1 - m)/slope
	}
}
I get the following error messages:
IntFire4_with_variab#2E2754.mod
IntFire4_with_variab#2E2754.mod
"/Applications/NEURON-7.2/nrn/share/nrn/libtool" --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I"/Applications/NEURON-7.2/nrn/include/nrn" -I"/Applications/NEURON-7.2/nrn/umac/lib" -arch ppc -arch i386 -c -o IntFire4_with_variab#2E2754.lo `test -f 'IntFire4_with_variab#2E2754.c' || echo '/'`IntFire4_with_variab#2E2754.c
XIntFire4_with_variab#2E2754.lo
libtool: compile: libobj name `IntFire4_with_variab#2E2754.lo' may not contain shell special characters.
gcc -DHAVE_CONFIG_H -I. -I.. -I/Applications/NEURON-7.2/nrn/include/nrn -I/Applications/NEURON-7.2/nrn/umac/lib -arch ppc -arch i386 -c "IntFire4_with_variab#2E2754.c" -fno-common -DPIC -o .libs/IntFire4_with_variab#2E2754.o
IntFire4_with_variab#2E2754.c:223: error: stray '#' in program
IntFire4_with_variab#2E2754.c:223:24: error: invalid suffix "_reg" on floating constant
IntFire4_with_variab#2E2754.c:223: error: syntax error before numeric constant
IntFire4_with_variab#2E2754.c:225: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:226: error: non-static declaration of '_pointtype' follows static declaration
IntFire4_with_variab#2E2754.c:87: error: previous declaration of '_pointtype' was here
IntFire4_with_variab#2E2754.c:230: error: initializer element is not constant
IntFire4_with_variab#2E2754.c:230: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:231: error: non-static declaration of '_mechtype' follows static declaration
IntFire4_with_variab#2E2754.c:84: error: previous declaration of '_mechtype' was here
IntFire4_with_variab#2E2754.c:231: error: initializer element is not constant
IntFire4_with_variab#2E2754.c:231: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:232: error: syntax error before numeric constant
IntFire4_with_variab#2E2754.c:232: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:233: error: syntax error before numeric constant
IntFire4_with_variab#2E2754.c:233: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:234: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:234: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:235: error: variable-size type declared outside of any function
IntFire4_with_variab#2E2754.c:235: error: variable-sized object may not be initialized
IntFire4_with_variab#2E2754.c:235: error: conflicting types for 'pnt_receive'
IntFire4_with_variab#2E2754.c:221: error: previous declaration of 'pnt_receive' was here
IntFire4_with_variab#2E2754.c:235: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:236: error: variable-size type declared outside of any function
IntFire4_with_variab#2E2754.c:236: error: variable-sized object may not be initialized
IntFire4_with_variab#2E2754.c:236: error: conflicting types for 'pnt_receive_size'
IntFire4_with_variab#2E2754.c:222: error: previous declaration of 'pnt_receive_size' was here
IntFire4_with_variab#2E2754.c:236: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:237: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:237: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:238: error: syntax error before string constant
IntFire4_with_variab#2E2754.c:238: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:239: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:239: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:240: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:240: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:241: error: syntax error before '}' token
IntFire4_with_variab#2E2754.c:223: error: stray '#' in program
IntFire4_with_variab#2E2754.c:223:24: error: invalid suffix "_reg" on floating constant
IntFire4_with_variab#2E2754.c:223: error: syntax error before numeric constant
IntFire4_with_variab#2E2754.c:225: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:226: error: non-static declaration of '_pointtype' follows static declaration
IntFire4_with_variab#2E2754.c:87: error: previous declaration of '_pointtype' was here
IntFire4_with_variab#2E2754.c:230: error: initializer element is not constant
IntFire4_with_variab#2E2754.c:230: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:231: error: non-static declaration of '_mechtype' follows static declaration
IntFire4_with_variab#2E2754.c:84: error: previous declaration of '_mechtype' was here
IntFire4_with_variab#2E2754.c:231: error: initializer element is not constant
IntFire4_with_variab#2E2754.c:231: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:232: error: syntax error before numeric constant
IntFire4_with_variab#2E2754.c:232: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:233: error: syntax error before numeric constant
IntFire4_with_variab#2E2754.c:233: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:234: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:234: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:235: error: variable-size type declared outside of any function
IntFire4_with_variab#2E2754.c:235: error: variable-sized object may not be initialized
IntFire4_with_variab#2E2754.c:235: error: conflicting types for 'pnt_receive'
IntFire4_with_variab#2E2754.c:221: error: previous declaration of 'pnt_receive' was here
IntFire4_with_variab#2E2754.c:235: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:236: error: variable-size type declared outside of any function
IntFire4_with_variab#2E2754.c:236: error: variable-sized object may not be initialized
IntFire4_with_variab#2E2754.c:236: error: conflicting types for 'pnt_receive_size'
IntFire4_with_variab#2E2754.c:222: error: previous declaration of 'pnt_receive_size' was here
IntFire4_with_variab#2E2754.c:236: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:237: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:237: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:238: error: syntax error before string constant
IntFire4_with_variab#2E2754.c:238: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:239: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:239: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:240: warning: parameter names (without types) in function declaration
IntFire4_with_variab#2E2754.c:240: warning: data definition has no type or storage class
IntFire4_with_variab#2E2754.c:241: error: syntax error before '}' token
lipo: can't figure out the architecture type of: /var/folders/uN/uNOGWHHuHjCOcQulNjnr1k+++TI/-Tmp-//cc5XokLO.out
make: *** [IntFire4_with_variab#2E2754.lo] Error 1
Press 'return' key to close
But when I compile it on windows there is no trouble. I have no idea what to do to fix this.

Also, I clearly want to incorporate random variability into the weight. Is there are better way to do this? Is scop_random a good choice? Any suggestions would be welcome. Thanks!
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: compiling a mod file

Post by ted »

I don't see any error messages at all when compiling under Linux. I wonder if somehow what you posted on the Forum differs from the file contents on your Mac? If you email the file to me
ted dot carnevale at yale dot edu
I'll try it again.

Two comments about the addition of random weight variation.
1. First, a question--are you sure you want excitatory and inhibitory weight to fluctuate by identical amounts?
2. Second, it would be best to use the Random class with MCellRan4 as discussed in the thread
random number generation and thread safety
especially the comment by hines
http://www.neuron.yale.edu/phpBB/viewto ... ndom#p8110
Post Reply