## how to deal with "subscript out of range error" in printing out coordinate.

Anything that doesn't fit elsewhere.
Christine Chung
Posts: 13
Joined: Fri May 03, 2019 2:41 am

### how to deal with "subscript out of range error" in printing out coordinate.

Hi, I'm just beginner and undergraduate.
I'm using NEURON for my thesis for graduate paper.

What i am doing now is that print out coordinate info of each segment into txt.file with using interpxyz.hoc in extracellular_stim_and_rec.zip
But the problem is "subscript out of range error".

This is a part of my code

Code: Select all

``````proc grindaway() { local ii, nn, kk, xr

forall {

// get the data for the section
nn = n3d()
//print nn
//print secname()

xx = new Vector(nn)
yy = new Vector(nn)
zz = new Vector(nn)
length = new Vector(nn)

for ii = 0,nn-1 {
xx.x[ii] = x3d(ii)
yy.x[ii] = y3d(ii)
zz.x[ii] = z3d(ii)
length.x[ii] = arc3d(ii)
}
// to use Vector class's .interpolate()
// must first scale the independent variable
// i.e. normalize length along centroid
length.div(length.x[nn-1])

// initialize the destination "independent" vector
range = new Vector(nseg+2)
range.indgen(1/nseg)
range.sub(1/(2*nseg))
range.x[0]=0
range.x[nseg+1]=1

// length contains the normalized distances of the pt3d points
// along the centroid of the section.  These are spaced at
// irregular intervals.
// range contains the normalized distances of the nodes along the
// centroid of the section.  These are spaced at regular intervals.

xint = new Vector(nseg+2)
yint = new Vector(nseg+2)
zint = new Vector(nseg+2)

xint.interpolate(range, length, xx)
yint.interpolate(range, length, yy)
zint.interpolate(range, length, zz)

//print secname()
//print nseg

center_pt = new Vector(3)

//f.wopen("coordinate.txt")
//print range.size
//print xint.size

for ii = 1, nseg {

xr = range.x[ii]
center_pt.x[0] = xint.x[ii]
center_pt.x[1] = yint.x[ii]
center_pt.x[2] = zint.x[ii]
//print center_pt

//f.printf("%f %f %f \n",center_pt.x[0], center_pt.x[1], center_pt.x[2])

}

//f.close()

}
}
``````
And I found out that the parts causing error is this by chunking and executing.

Code: Select all

``````for ii = 1, nseg {

xr = range.x[ii]
center_pt.x[0] = xint.x[ii]
center_pt.x[1] = yint.x[ii]
center_pt.x[2] = zint.x[ii]
//print center_pt

//f.printf("%f %f %f \n",center_pt.x[0], center_pt.x[1], center_pt.x[2])

}
``````
This is the error message

C:\nrn73w64\bin64\nrniv.exe: subscript out of range x
..(omit).... near line 445
grindaway()
^
grindaway()
nrn_define_shape: soma first and last 3-d point at same (x,y)

How can I debug the error?
ted
Posts: 5814
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: how to deal with "subscript out of range error" in printing out coordinate.

Insert a series of print statements that report unique messages. Clearly the last message that is printed before the crash is located before the source of the error.
Christine Chung
Posts: 13
Joined: Fri May 03, 2019 2:41 am

### Re: how to deal with "subscript out of range error" in printing out coordinate.

Thank you for your response, Ted.
I had already used print statement and found out the location of the crash.

This loop is executed but stops and the error message "subscript out of range error" came out!

Code: Select all

``````for ii = 1, nseg {

xr = range.x[ii]
center_pt.x[0] = xint.x[ii]
center_pt.x[1] = yint.x[ii]
center_pt.x[2] = zint.x[ii]
//print center_pt

//f.printf("%f %f %f \n",center_pt.x[0], center_pt.x[1], center_pt.x[2])

}
``````
And, I changed the range of ii but it did not work.

What does cause the 'subscript out of range error?'
ted
Posts: 5814
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: how to deal with "subscript out of range error" in printing out coordinate.

I had already used print statement and found out the location of the crash.
No, you didn't. You localized the problem to a for loop. There are several statements in that for loop. Which statement is triggering the error message?
Christine Chung
Posts: 13
Joined: Fri May 03, 2019 2:41 am

### Re: how to deal with "subscript out of range error" in printing out coordinate.

Now I tried to print in a for loop like this.

Code: Select all

``````for ii = 1, nseg {

xr = range.x[ii]
printf("one")
print ii
center_pt.x[0] = xint.x[ii]
printf("two")
print ii
center_pt.x[1] = yint.x[ii]
printf("three")
print ii
center_pt.x[2] = zint.x[ii]
printf("four")
print ii
printf ("\n")
//print center_pt

//f.printf("%f %f %f \n",center_pt.x[0], center_pt.x[1], center_pt.x[2])

}
``````
And the result of execution is this.

Code: Select all

``````        1
one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one5
two5
three5
four5

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one5
two5
three5
four5

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one4
two4
three4
four4

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

one2
two2
three2
four2

one3
two3
three3
four3

one1
two1
three1
four1

C:\nrn73w64\bin64\nrniv.exe: subscript out of range x
in C:\Hyeyeon\Neuron\patdemo_r8\cells\demofig1_try_single_cell.hoc near line 456
grindaway()
^
``````
It seems that for loop stops on the way.
ted
Posts: 5814
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: how to deal with "subscript out of range error" in printing out coordinate.

Interesting result, but an essential clue is missing.

What to do for the next test?
1. Why so many "print ii" statements? Nothing inside the loop affects the value of ii, so you can get rid of all but the first "print ii" statement. And it would be a good idea to make that "print ii" statement be the first statement inside the for loop.
2. It would be good to confirm that execution fails inside the for loop. I know that you said that it does, but just to make sure, could you insert a
print "finished the for loop"
statement right after the loop's closing } ?
3. If the error _is_ generated in the for loop, it is essential to discover the name of the currently accessed section. You can do this by inserting a
print secname()
statement just before the
for ii = 1, nseg {
line.

Make those changes, and then let's see what the messages reveal.
Christine Chung
Posts: 13
Joined: Fri May 03, 2019 2:41 am

### Re: how to deal with "subscript out of range error" in printing out coordinate.

This is code which I put what you said-1.2.

Code: Select all

``````	for ii = 1, nseg {

print ii
xr = range.x[ii]
printf("one")

center_pt.x[0] = xint.x[ii]
printf("two")

center_pt.x[1] = yint.x[ii]
printf("three")

center_pt.x[2] = zint.x[ii]
printf("four")

printf ("\n")
//print center_pt

//f.printf("%f %f %f \n",center_pt.x[0], center_pt.x[1], center_pt.x[2])

}
printf("loop's closing \n")

//f.close()

}
``````

And it is the result

Code: Select all

``````1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
5
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
5
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
1
onetwothreefour
loop's closing
C:\nrn73w64\bin64\nrniv.exe: subscript out of range x
in C:\Hyeyeon\Neuron\patdemo_r7\demofig1_try_single_cell.hoc near line 459
grindaway()
^
grindaway()
nrn_define_shape: soma first and last 3-d point at same (x,y)
``````
Then, I inserted a print secname()

Code: Select all

`````` print secname()

for ii = 1, nseg {

print ii
xr = range.x[ii]
printf("one")

center_pt.x[0] = xint.x[ii]
printf("two")

center_pt.x[1] = yint.x[ii]
printf("three")

center_pt.x[2] = zint.x[ii]
printf("four")

printf ("\n")
//print center_pt

//f.printf("%f %f %f \n",center_pt.x[0], center_pt.x[1], center_pt.x[2])

}
printf("loop's closing \n")
``````
And This is the result after inserting secname()

Code: Select all

``````a1_1
1
onetwothreefour
loop's closing
a1_11
1
onetwothreefour
loop's closing
a1_111
1
onetwothreefour
loop's closing
a1_1111
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a1_1112
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a1_112
1
onetwothreefour
loop's closing
a1_1121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a1_1122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a1_12
1
onetwothreefour
loop's closing
a1_121
1
onetwothreefour
loop's closing
a1_1211
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a1_1212
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a1_122
1
onetwothreefour
loop's closing
a1_1221
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a1_1222
1
onetwothreefour
loop's closing
a1_12221
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a1_12222
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_1
1
onetwothreefour
loop's closing
a2_11
1
onetwothreefour
loop's closing
a2_111
1
onetwothreefour
loop's closing
a2_1111
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_1112
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
5
onetwothreefour
loop's closing
a2_112
1
onetwothreefour
loop's closing
a2_1121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_1122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_12
1
onetwothreefour
loop's closing
a2_121
1
onetwothreefour
loop's closing
a2_1211
1
onetwothreefour
loop's closing
a2_12111
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_121111
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_121112
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_12112
1
onetwothreefour
loop's closing
a2_121121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_1211211
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_1211212
1
onetwothreefour
loop's closing
a2_12112121
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_12112122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_121122
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_1212
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_12121
1
onetwothreefour
loop's closing
a2_121211
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_121212
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_12122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_122
1
onetwothreefour
loop's closing
a2_1221
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_12211
1
onetwothreefour
loop's closing
a2_12212
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_1222
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a2_12221
1
onetwothreefour
2
onetwothreefour
loop's closing
a2_12222
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a3_1
1
onetwothreefour
loop's closing
a3_11
1
onetwothreefour
loop's closing
a3_111
1
onetwothreefour
loop's closing
a3_1111
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a3_1112
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_11121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a3_11122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a3_112
1
onetwothreefour
loop's closing
a3_1121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a3_1122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a3_12
1
onetwothreefour
loop's closing
a3_121
1
onetwothreefour
loop's closing
a3_1211
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a3_1212
1
onetwothreefour
loop's closing
a3_12121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a3_12122
1
onetwothreefour
loop's closing
a3_121221
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a3_121222
1
onetwothreefour
loop's closing
a3_1212221
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_1212222
1
onetwothreefour
loop's closing
a3_12122221
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
5
onetwothreefour
loop's closing
a3_12122222
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_121222221
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_1212222211
1
onetwothreefour
loop's closing
a3_12122222111
1
onetwothreefour
loop's closing
a3_12122222112
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_1212222212
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_121222222
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_1212222221
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_1212222222
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_12122222221
1
onetwothreefour
loop's closing
a3_12122222222
1
onetwothreefour
loop's closing
a3_122
1
onetwothreefour
loop's closing
a3_1221
1
onetwothreefour
loop's closing
a3_12211
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_12212
1
onetwothreefour
2
onetwothreefour
loop's closing
a3_1222
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a4_1
1
onetwothreefour
loop's closing
a4_11
1
onetwothreefour
loop's closing
a4_111
1
onetwothreefour
loop's closing
a4_1111
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a4_1112
1
onetwothreefour
loop's closing
a4_11121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a4_11122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a4_112
1
onetwothreefour
loop's closing
a4_1121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a4_1122
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a4_12
1
onetwothreefour
loop's closing
a4_121
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
4
onetwothreefour
loop's closing
a4_122
1
onetwothreefour
loop's closing
a4_1221
1
onetwothreefour
loop's closing
a4_1222
1
onetwothreefour
loop's closing
a4_12221
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
a4_12222
1
onetwothreefour
2
onetwothreefour
3
onetwothreefour
loop's closing
soma
1
onetwothreefour
loop's closing
``````
ted
Posts: 5814
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: how to deal with "subscript out of range error" in printing out coordinate.

And This is the result after inserting secname()
Do you see any error messages in that? If you don't, does that mean the problem went away?
Christine Chung
Posts: 13
Joined: Fri May 03, 2019 2:41 am

### Re: how to deal with "subscript out of range error" in printing out coordinate.

oh, I didn't copy all the result. The error was still happened.
And I found out that when I print secname and nn in front of for loop,

Code: Select all

``printf("%s: %d \n", secname(), nn)``
The axon part's outcome is zero.
ted
Posts: 5814
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: how to deal with "subscript out of range error" in printing out coordinate.

I didn't copy all the result. The error was still happened.
Would you like to share the last, say, 10 lines or so of the output? I ask because those lines are likely to contain a useful clue to the problem you encountered.
Christine Chung
Posts: 13
Joined: Fri May 03, 2019 2:41 am

### Re: how to deal with "subscript out of range error" in printing out coordinate.

umm.. I found the error! exactly
In code, without any function I made or loop, I put only

Code: Select all

``forall {printf("%s: %d \n", secname(), n3d())}``

Then, the result looks axon did not have its coordination.

Code: Select all

``````loading membrane mechanisms from nrnmech.dll
ca.mod cad.mod kca.mod km.mod kv.mod na.mod
1
0
1
1
1
a1_1: 3
a1_11: 5
a1_111: 8
a1_1111: 59
a1_1112: 55
a1_112: 7
a1_1121: 44
a1_1122: 58
a1_12: 6
a1_121: 14
a1_1211: 50
a1_1212: 53
a1_122: 6
a1_1221: 50
a1_1222: 14
a1_12221: 52
a1_12222: 50
a2_1: 8
a2_11: 9
a2_111: 11
a2_1111: 46
a2_1112: 82
a2_112: 17
a2_1121: 42
a2_1122: 55
a2_12: 14
a2_121: 8
a2_1211: 13
a2_12111: 41
a2_121111: 53
a2_121112: 32
a2_12112: 7
a2_121121: 41
a2_1211211: 19
a2_1211212: 11
a2_12112121: 24
a2_12112122: 47
a2_121122: 42
a2_1212: 38
a2_12121: 6
a2_121211: 36
a2_121212: 33
a2_12122: 40
a2_122: 10
a2_1221: 19
a2_12211: 17
a2_12212: 22
a2_1222: 35
a2_12221: 23
a2_12222: 31
a3_1: 7
a3_11: 15
a3_111: 16
a3_1111: 71
a3_1112: 29
a3_11121: 41
a3_11122: 39
a3_112: 6
a3_1121: 51
a3_1122: 52
a3_12: 6
a3_121: 7
a3_1211: 64
a3_1212: 12
a3_12121: 45
a3_12122: 5
a3_121221: 60
a3_121222: 24
a3_1212221: 42
a3_1212222: 21
a3_12122221: 75
a3_12122222: 25
a3_121222221: 23
a3_1212222211: 12
a3_12122222111: 7
a3_12122222112: 19
a3_1212222212: 28
a3_121222222: 33
a3_1212222221: 19
a3_1212222222: 36
a3_12122222221: 8
a3_12122222222: 5
a3_122: 7
a3_1221: 18
a3_12211: 34
a3_12212: 46
a3_1222: 64
a4_1: 8
a4_11: 3
a4_111: 10
a4_1111: 58
a4_1112: 6
a4_11121: 54
a4_11122: 41
a4_112: 17
a4_1121: 58
a4_1122: 64
a4_12: 12
a4_121: 64
a4_122: 6
a4_1221: 16
a4_1222: 6
a4_12221: 44
a4_12222: 43
soma: 2
iseg: 0
hill: 0
myelin[0]: 0
myelin[1]: 0
myelin[2]: 0
myelin[3]: 0
myelin[4]: 0
node[0]: 0
node[1]: 0
node[2]: 0
node[3]: 0
node[4]: 0
nrn_define_shape: soma first and last 3-d point at same (x,y)``````
But when I write down same code in execution window ( I mean nrniv.exe,pop-up window after execution of code), the result looks normal!

Code: Select all

``````oc>forall {printf("%s: %d \n", secname(), n3d())}
a1_1: 3
a1_11: 5
a1_111: 8
a1_1111: 59
a1_1112: 55
a1_112: 7
a1_1121: 44
a1_1122: 58
a1_12: 6
a1_121: 14
a1_1211: 50
a1_1212: 53
a1_122: 6
a1_1221: 50
a1_1222: 14
a1_12221: 52
a1_12222: 50
a2_1: 8
a2_11: 9
a2_111: 11
a2_1111: 46
a2_1112: 82
a2_112: 17
a2_1121: 42
a2_1122: 55
a2_12: 14
a2_121: 8
a2_1211: 13
a2_12111: 41
a2_121111: 53
a2_121112: 32
a2_12112: 7
a2_121121: 41
a2_1211211: 19
a2_1211212: 11
a2_12112121: 24
a2_12112122: 47
a2_121122: 42
a2_1212: 38
a2_12121: 6
a2_121211: 36
a2_121212: 33
a2_12122: 40
a2_122: 10
a2_1221: 19
a2_12211: 17
a2_12212: 22
a2_1222: 35
a2_12221: 23
a2_12222: 31
a3_1: 7
a3_11: 15
a3_111: 16
a3_1111: 71
a3_1112: 29
a3_11121: 41
a3_11122: 39
a3_112: 6
a3_1121: 51
a3_1122: 52
a3_12: 6
a3_121: 7
a3_1211: 64
a3_1212: 12
a3_12121: 45
a3_12122: 5
a3_121221: 60
a3_121222: 24
a3_1212221: 42
a3_1212222: 21
a3_12122221: 75
a3_12122222: 25
a3_121222221: 23
a3_1212222211: 12
a3_12122222111: 7
a3_12122222112: 19
a3_1212222212: 28
a3_121222222: 33
a3_1212222221: 19
a3_1212222222: 36
a3_12122222221: 8
a3_12122222222: 5
a3_122: 7
a3_1221: 18
a3_12211: 34
a3_12212: 46
a3_1222: 64
a4_1: 8
a4_11: 3
a4_111: 10
a4_1111: 58
a4_1112: 6
a4_11121: 54
a4_11122: 41
a4_112: 17
a4_1121: 58
a4_1122: 64
a4_12: 12
a4_121: 64
a4_122: 6
a4_1221: 16
a4_1222: 6
a4_12221: 44
a4_12222: 43
soma: 2
iseg: 7
hill: 7
myelin[0]: 7
myelin[1]: 7
myelin[2]: 7
myelin[3]: 7
myelin[4]: 7
node[0]: 3
node[1]: 3
node[2]: 3
node[3]: 3
node[4]: 3
oc> ``````
I thought that this situation invoke the out of range error.
But I cannot understand difference between printing same thing in code and in cmd window
ted