Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to trace run-time error M6201: MATH 2

Status
Not open for further replies.

amagrammer

Technical User
Nov 26, 2009
16
DE
hi, Folks,

I am trying to debug a program. When I run my executable, the console window will keep telling me that
Code:
run-time error M6201:MATH
- sqrt:DOMAIN error
line       source
unknown    unknown

At the same time. A breakpoint will be shown:
Code:
 =>77038B2E   int         3

I don't know what this means. It seems to me that some inappropriate(maybe nagative here) argument has been passed to function sqrt. But I don't call function sqrt explicitly in my program. It must be called by some other subroutine. I don't know where this occurs and how I can fix this. I need Ideas and suggestions from you guys! Thank you.
 
It is obviously an Intel based machine - int 3 is the breakpoint interrupt. Questions are

1) Linux or Windows
2) What sort of IDEs/debuggers do you have access to
3) Which compiler are you using
 
Just noticed from a previous thread that you're on Linux. You could try pstack. If you're using the debug version, it may tell you which routine is calling which all the way until it reaches the routine you're calling.
 
Hi, xwb,
thank you for the reply. I use Compaq Fortran Compiler 6.6 on the Windows Vista system. I am not sure what IDEs/debugger I use. How can I check this?
 
Normally CVF is installed with Visual Studio 6 but VS6 doesn't work very well on Vista. Do you have CVF installed standalone or integrated into Visual Studio?

How do you build your programs - do you use an IDE or do you do it from the cmd prompt or do you use a makefile?
 
hi, xwb,

You are right. CVF seems to be unstable on Vista. Sometimes when I start Developer Studio, a Microsoft Visual C++ runtime error occurs right away. So, I guess my CVF is integrated into Visual Studio.
I build programs in an IDE and don't use makefiles.
 
I haven't got a VS6 installation anywhere so I'm just doing this from memory.

1) When it hits the breakpoint and asks you if you wish to attach a debugger, click yes, choose VS.
2) You will probably have to click through a few windows before it breaks inside VS.
3) Inside VS. It will probably stop at some assembler instruction unless you have the .pdb file in the same directory as the .exe.
4) Click Debug/Windows/Callstack or Debug/Callstack. This will tell you where the crash was and who called who.

You could also just run it from the IDE by pressing F5. It may be faster getting to the breakpoint from there. If you need to supply parameters to the program, put them in Settings/Debugging
 
Hi, xwb,
thanks for getting back to me. What happens here is the following. As it hits breakpoint it says
Code:
Compaq Visual Fortran
!User breakpoint called from code at 0x77b18b2e OK?

I have no choice but to confirm "OK". Then the line
Code:
77B18B2E int 3
is pointed.

I wasn't offered to choose a debugger. Only in the lower left corner there is a "Context:" drop-down. There are a few things I don't understand like "KERNEL32!772ad0e9()" or "CARBONPRICE_SP!_FF_puterr". carbonprice_sp.f90 is btw my source file.

If I strike F5(GO) again, runtime exits. Do I have to do some pre-configurations to have any debugger choice?

 
I don't have CVF6: only IVF7 and IVF11 its sucessor.

kernel32 is deep in the depths of some I/O routine
!_FF_puterr is an error printing routine.

At a guess, the thing in the lower left corner is your stack. That should roughly tell you where it is going wrong. I think if you click on an item in the context drop down, it might take you to the code, if it can find it.
 
I followed down the stack. I came to two lines in my source file. The first line is
Code:
	CALL D03RAF(NPDE,TS,TOUT,DT,XMIN,XMAX,YMIN,YMAX,NX,NY,TOLS,&
	 TOLT,PDEF1,BNDRY1,PDEIV1,MONIT1,OPTI,OPTR,RWK,&	
	 LENRWK,IWK,LENIWK,LWK,LENLWK,ITRACE,IND,IFAIL)
which calls a NAG subroutine. And the other is
Code:
	CALL EX1
which calls an external subroutine named EX1. I have no clue how these two lines could cause MATH sqrt error...
 
Whenever I've gotten something strange like that, it is normally, these are caused by real*8 being passed in as real*4 or vice-versa. It basically ends up as the sqrt of a -ve or illegal number. Worth checking the parameters and the array sizes against the specification for D03RAF.
 
As xwb said, you probably passed to the subroutine D03RAF a wrong argument which was elsewhere internal by calling of sqrt() interpreted as a negative number. When you doesn't have a source of D03RAF and the subroutine is not compiled with the debug option, then you cannot trace the error with a debugger.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top