section arrays in templates

Anything that doesn't fit elsewhere.
Post Reply
jaambros
Posts: 29
Joined: Tue Oct 04, 2005 3:29 pm
Location: Ohio University

section arrays in templates

Post by jaambros »

Hi all,
Any ideas on why the following examples don't work?

Thanks in advance,
Jose Ambros-Ingerson
PS. I'm running OSX 10.4.11 on Intel and G5

-------- example 1-------------

Code: Select all

begintemplate aT
  proc init(){
    create d1[2]
  }
  proc many(){
    create d1[20]
  }
endtemplate aT

objref a 
a = new aT()
a.many()

$ nrngui atest.hoc
NEURON -- Release 6.0.4 (1819) 2007-07-20
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html

/axon/d1/Users/jose/Software/bin/nrn-6.0/nrn/i686/bin/nrniv: Bus error See $NEURONHOME/lib/help/oc.help
 in atest.hoc near line 12
 a.many()
         ^
---------------- example 2 -------------

Code: Select all

create d1[2]
begintemplate aT
  external d1
  proc init(){
    create d1[2]
  }
  proc many(){
    create d1[40]
  }
endtemplate aT

objref a 
a = new aT()
$ nrngui atest.hoc
NEURON -- Release 6.0.4 (1819) 2007-07-20
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2007
See http://www.neuron.yale.edu/credits.html

/axon/d1/Users/jose/Software/bin/nrn-6.0/nrn/i686/bin/nrniv: Segmentation violation
 in atest.hoc near line 13
 a = new aT()
             ^
        aT[0].init()
Raj
Posts: 220
Joined: Thu Jun 09, 2005 1:09 pm
Location: Groningen, The Netherlands
Contact:

Post by Raj »

Try

Code: Select all

begintemplate aT

 create d1
 
  proc many(){
    create d1[20]
  }
endtemplate aT 
The information inside the functions is ignored when allocating space for an object of the class defined by the template, so you need to indicate outside a function but within the template that space for d1 should be allocated.
Post Reply