Run time error M6201:MATH-log domain error

  • Thread starter Thread starter MANJUNATH N M
  • Start date Start date
  • Tags Tags
    Domain Error Time
Click For Summary

Discussion Overview

The discussion revolves around a runtime error encountered in a Fortran program, specifically the M6201:MATH-log domain error. Participants explore potential causes and solutions related to taking logarithms of non-positive numbers, as well as subsequent issues related to array bounds.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant reports a runtime error while executing a Fortran program and seeks assistance.
  • Another participant suggests that the error may arise from attempting to take the logarithm of a negative or zero value.
  • A participant clarifies that the logarithm is being taken of the variable T, which may not be positive, and emphasizes the need for error handling in the code.
  • Code is provided for context, showing the structure of the function HP and its reliance on the variable T.
  • A participant expresses a general critique of Fortran code readability, noting issues with variable naming and formatting.
  • After addressing the log error, another participant mentions encountering a new issue related to "array bound exceeded."
  • A suggestion is made regarding the declaration of variables in common blocks, referencing external resources for clarification.

Areas of Agreement / Disagreement

Participants generally agree that the log domain error is likely due to taking the logarithm of a non-positive number. However, the discussion remains unresolved regarding the new issue of array bounds and the specifics of variable declarations.

Contextual Notes

There are limitations regarding the assumptions made about the values of T and the declarations of variables in common blocks, which may affect the program's execution.

MANJUNATH N M
Messages
3
Reaction score
0
hi all,
i am getting the above problem while executing my fortran program. please help me how to fix it.

thank
MNM
 
Physics news on Phys.org
MANJUNATH N M said:
hi all,
i am getting the above problem while executing my fortran program. please help me how to fix it.
It would appear that your program is attempting to take the log of a number that is negative or zero.
 
Thank you mark44.
But in the program i am taking log of T. see the program attached below.
 

Attachments

For the convenience of other readers, here's your code. As I already said, your program is attempting to take the log of a number that is not positive. There needs to be some code in this function to guard against an attempt to take the log of the parameter T when it is zero or negative.
Code:
C**********************************************************************************
		FUNCTION HP(T)
C**********************************************************************************
 	REAL KA,KP,KR,MC,MH,MO,NA,N,NADNAX,NMO,NP,NPO,NX,KRR
	COMMON/CHEM/KA,KP,KR,N(5),NA,NADNAX,NMO,NP,NPO,NX,RMR,KRR,
     #	MC,MH,MO,R,RLITAT,RMIX,Y,YCC,YMIN,PMOLWT
	COMMON/CPCOEF/CV,ACPF,BCPF,ACPA,BCPA,AL(5),AH(5),
     #	BL(5),BH(5),CL(5),CH(5)
	HP=0.
	IF(T.GT.1600.0) GO TO 20
	DO 1 I=1,5
1	HP=HP+N(I)*(AL(I)+BL(I)*T+CL(I)*ALOG(T))
	RETURN
20	DO 3 I=1,5
3	HP=HP+N(I)*(AH(I)+BH(I)*T+CH(I)*ALOG(T))
	RETURN
	END
 
Somewhat off topic...
I look at a lot of code samples in many different languages, but the ones in Fortran are usually the worst. They are typically nearly impossible to read with their terse variable names that convey almost no indication of what they're being used for, no or little whitespace, and no indentation to help the reader grasp the extent of loops.
 
THANK YOU MARK44, I eliminated log error. but now i am facing one more problem that is "array bound exceeded"
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
Replies
7
Views
3K
Replies
17
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
8K