> Hello:
>
> I have a little problem. An error message of
> Mathematica says:
> 'External evaluation error at instruction 7 ...'
> How does Mathematica count the instructions?
> Which is the 7th instruction?
>
> Thank-you
>
> Jesus ROJO
> --
The best way to interpret this message is to look inside of
the list of pseudo-code instructions generated by Compile.
The message indicates the position of the instruction where
something went wrong. Here is an example
In[6]:= f = Compile[{{x, _Integer}}, x + 10]
Out[6]= CompiledFunction[{x}, x + 10, -CompiledCode-]
In[7]:= f[2147483637]
Out[7]= 2147483647
In[8]:= f[2147483638]
CompiledFunction::cfn:
Numerical error encountered at instruction 4; proceeding with uncompiled
evaluation.
Out[8]= 2147483648
In this example, f[2147483637] works fine, because 10 + 2147483637
is representable as a machine integer (it is less than 2^32-1),
while f[f[2147483638] generates an error, because 10 + 2147483638
is too large to be represented as a machine integer.
This shows the pseudocode instructions returned by Compile.
In[9]:= InputForm[f]
Out[9]//InputForm=
CompiledFunction[{_Integer}, {0, 3, 0, 0},
{{1, 17}, {3, 1, 0}, {12, 10, 1}, {32, 0, 1, 2}, {7, 2}},
Function[{x}, x + 10]]
The list of pseudo-code instructions is the third element in this
result. Here is an analysis of those instructions.
In[11]:= f[[3]] //ColumnForm
Out[11]= {1, 17} (* verify the version *)
{3, 1, 0} (* load integer argument at position 1 into
integer register 0 *)
{12, 10, 1} (* load the integer constant 10 into integer
register 1 *)
{32, 0, 1, 2} (* add integer register 0 to integer register 1
and put the result in integer register 2 *)
{7, 2} (* return the result in integer register 2 *)
The error happens at the fourth instruction, {32, 0, 1, 2}, where
the argument is added to the constant 10.
It is somewhat easier to make sense of these messages if you have
the list of pseudo-code instructions handy. This list is available
in various technical reports (I am right now reading from the course
notes "Numerical Computatin in Mathematica" that Jerry Keiper and I
wrote for the 1992 Mathematica conferences).
In most cases, figuring out these messages by poring over lists of
pseudocode instructions is sort of tedious. It is usually easier
to look at the code and think deep thoughts about whether or not
the compiled program can be handled using machine-sized quantitites,
whether or not there are square roots of negative numbers, and so forth.
Dave Withoff
Research and Development
Wolfram Research