1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Run time error M6201:MATH-log domain error

  1. Dec 28, 2011 #1
    hi all,
    i am getting the above problem while executing my fortran program. please help me how to fix it.

    thank
    MNM
     
  2. jcsd
  3. Dec 28, 2011 #2

    Mark44

    Staff: Mentor

    It would appear that your program is attempting to take the log of a number that is negative or zero.
     
  4. Dec 29, 2011 #3
    Thank you mark44.
    But in the program i am taking log of T. see the program attached below.
     

    Attached Files:

    • fort.txt
      fort.txt
      File size:
      611 bytes
      Views:
      48
  5. Dec 30, 2011 #4

    Mark44

    Staff: Mentor

    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 (Text):

    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
     
     
  6. Dec 30, 2011 #5

    Mark44

    Staff: Mentor

    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.
     
  7. Mar 6, 2012 #6
    THANK YOU MARK44, I eliminated log error. but now i am facing one more problem that is "array bound exceeded"
     
  8. Mar 6, 2012 #7

    Mark44

    Staff: Mentor

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Run time error M6201:MATH-log domain error
  1. Error checks (Replies: 1)

  2. VHDL errors (Replies: 1)

  3. Interpolation error. (Replies: 1)

Loading...