Run time error M6201:MATH-log domain error

In summary: Mark44 could not have helped you any further because you're not following the code. In summary, 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.
  • #1
MANJUNATH N M
3
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
  • #2
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.
 
  • #3
Thank you mark44.
But in the program i am taking log of T. see the program attached below.
 

Attachments

  • fort.txt
    611 bytes · Views: 306
  • #4
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
 
  • #5
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.
 
  • #6
THANK YOU MARK44, I eliminated log error. but now i am facing one more problem that is "array bound exceeded"
 

1. What does "Run time error M6201:MATH-log domain error" mean?

This error message indicates that there was an attempt to take the logarithm of a negative number or zero, which is mathematically undefined.

2. How can I fix a "Run time error M6201:MATH-log domain error"?

To fix this error, you need to ensure that the input values for the logarithm function are positive numbers. You can also use a conditional statement to check for negative or zero values before performing the calculation.

3. Why am I getting a "Run time error M6201:MATH-log domain error"?

This error can occur when the code attempts to perform a logarithm calculation on a negative or zero value, or if there is a mistake in the logic of the code that results in a negative or zero value being passed to the logarithm function.

4. Can a "Run time error M6201:MATH-log domain error" cause my program to crash?

Yes, if this error is not handled properly, it can lead to a program crash. It is important to handle this error by implementing proper error-checking and handling techniques.

5. How can I prevent a "Run time error M6201:MATH-log domain error" from occurring?

To prevent this error, you can use error-checking techniques to ensure that the input values for the logarithm function are positive numbers. You can also use proper logic and conditional statements to avoid passing negative or zero values to the logarithm function.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
903
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
808
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
805
  • Engineering and Comp Sci Homework Help
Replies
3
Views
794
Back
Top