# Homework Help: Run-time error M6201: math -log: DOMAIN error

1. Jan 20, 2016

### js6201

Hi all,
I am facing the problem while executing my fortran (77) program.
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...ㅜㅜ...

1. The problem statement, all variables and given/known data
run-time error M6201: math -log: DOMAIN error

2. Relevant 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")

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)

& (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)

& (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)

& (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))

& (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: Jan 20, 2016
2. Jan 20, 2016

### SteamKing

Staff Emeritus
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.