Run-time error M6201: math -log: DOMAIN error

  • Thread starter Thread starter js6201
  • Start date Start date
  • Tags Tags
    Domain Error Log
Click For Summary
SUMMARY

The run-time error M6201 in the Fortran 77 program occurs due to the logarithm function receiving zero or negative values, despite the user's assertion that no such values exist. The program utilizes the 4th-order Runge-Kutta method to solve ordinary differential equations. To diagnose the issue, it is essential to insert WRITE statements before each LOG or DLOG function call to print the values being passed to these functions. Additionally, checking the input data for unexpected values is crucial, as the source of the error may stem from the input files.

PREREQUISITES
  • Understanding of Fortran 77 programming language
  • Familiarity with numerical methods, specifically the 4th-order Runge-Kutta method
  • Knowledge of logarithmic functions and their domain restrictions
  • Experience with debugging techniques in programming
NEXT STEPS
  • Implement WRITE statements to log values before each LOG and DLOG function call
  • Review input data files for potential zero or negative values
  • Learn about error handling in Fortran to manage run-time errors effectively
  • Explore debugging tools available for Fortran to streamline the troubleshooting process
USEFUL FOR

Fortran developers, numerical analysts, and anyone involved in solving ordinary differential equations using numerical methods will benefit from this discussion.

js6201
Messages
7
Reaction score
0
Hi all,
I am facing the problem while executing my fortran (77) program.
please help me how to fix it.
As I understood, the error means that the domain of log function has included zero values or negative values...But I could not understand...In my case... there are no zero or negative values...ㅜㅜ...

Homework Statement


run-time error M6201: math -log: DOMAIN error

Homework Equations


4th-order runge-kutta method
Ordinary differential equation

I attached the fortran source code below...
[ /CODE ]

Program Runge

REAL t, dt, dt2, beta, sd0
REAL k1(20000), k2(20000), k3(20000), k4(20000)
REAL D(20000), m1(20000), m2(20000), m3(20000), m4(20000)
REAL rat(20000), fc(20000)
integer i

open(unit=1,file="input",form="formatted",status="unknown")
read(1,*) n0d,t0,tf,gk,c
read(1,*) sd0,denp,kadot,kbdot,visB1

t=t0
dt=(tf-t0)/n0d
H=dt/6.d0
dfc=2000E-6
beta=dlog10(2.d0/3.d0)/log10(dfc/sd0)
D(1)=sd0
m1(1)=0.0
m2(1)=0.0
m3(1)=0.0
k1(1)=0.0
k2(1)=0.0
k3(1)=0.0
k4(1)=0.0
fc(1)=3.0*((D(1)/sd0)**beta)
rat(1)=beta*log(D(1)/sd0)+1

i=2

DO WHILE (i. le. n0d)

rat(i)=beta*log(D(i-1)/sd0)+1.0
fc(i)=3.0*(D(i-1)/sd0)**(beta)

k1(i)=(gk*(sd0**beta)/rat(i))*((kadot/3)*(c/denp)*((sd0)**
& (fc(i)-3))*(D(i-1)**(-fc(i)+4-beta))-(kbdot/3)*((visB1)**0.5)*
& (sd0**(-1.0+(1/3)*fc(i)))*(D(i-1)**(2-beta-fc(i)/3))*((D(i-1)
& -sd0)**1.0))

m1(i)=real(D(i-1)+k1(i)/2.0d0)

k2(i)=(gk*(sd0**beta)/rat(i))*((kadot/3)*(c/denp)*((sd0)**
& (fc(i)-3))*(m1(i)**(-fc(i)+4-beta))-(kbdot/3)*((visB1)**0.5)*
& (sd0**(-1.0+(1/3)*fc(i)))*(m1(i)**(2-beta-fc(i)/3))*((m1(i)
& -sd0)**1.0))

m2(i)=real(D(i-1)+k2(i)/2.0d0)

k3(i)=(gk*(sd0**beta)/rat(i))*((kadot/3)*(c/denp)*((sd0)**
& (fc(i)-3))*(m2(i)**(-fc(i)+4-beta))-(kbdot/3)*((visB1)**0.5)*
& (sd0**(-1.0+(1/3)*fc(i)))*(m2(i)**(2-beta-fc(i)/3))*((m2(i)
& -sd0)**1.0))

m3(i)=real(D(i-1)+k3(i))

k4(i)=(gk*(sd0**beta)/rat(i))*((kadot/3)*(c/denp)*((sd0)**
& (fc(i)-3))*(m3(i)**(-fc(i)+4-beta))-(kbdot/3)*((visB1)**0.5)*
& (sd0**(-1.0+(1/3)*fc(i)))*(m3(i)**(2-beta-fc(i)/3))*((m3(i)
& -sd0)**1.0))

D(i)=real(D(i-1)+H*(k1(i)+2*(k2(i)+k3(i))+k4(i)))

open(unit=1000,file="flocsize",form="formatted",status="unknown")
open(unit=2000,file="result",form="formatted",status="unknown")

write(1000,*) t, m1(i), m2(i), m3(i), D(i)
write(2000,*) i, k1(i), k2(i), k3(i), k4(i)
write(*,*) i, D(i)

i=i+1
t=t+dt

END DO
END
 
Last edited:
Physics news on Phys.org
When posting source code, please use [ CODE ] [ /CODE ] tags (without the spaces) to enclose the code to preserve the original spacing.

You may think you have no zeros or negative values, but your code disagrees. You are reading input data from files, so it's impossible to tell where the problem might be occurring.

The best I can recommend is that you inserts WRITE statements in your code before each line where a LOG or DLOG function is executed and print out the values of the arguments being supplied to these functions.

When reporting errors, compilers and runt-time units sometimes include line numbers where the error occurred. It's always helpful to include this information with any request for help.
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
9K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K