0

Having an issue with an iterative function being run through a log10 function in Fortran.

program start
integer t, dt, range, rangestart
real*8 k1, k2, k, lognmdott, nmdott, interval

dt = 10
t = 0
range = 0
rangestart = 0
interval = 0

open(unit=1, file='accretion.txt', status='unknown')

do i = 1, 200000

 t=t+dt
 range = t-rangestart

 if (range .gt. 100 .and. range .le. 300) then
  k1 = log10(1.) - log10(0.001)
  k2 = log10(200.)

  k = k1/k2

  interval = interval + dt

  lognmdott = -k*(log10(interval))

  if (interval .eq. 200) then
   interval = 0
  endif

  nmdott = 10**lognmdott

  write(1,*) t, nmdott
 endif

close(1)
end

I was hoping to get the log10(interval) output for values between 10 and 200 in steps of 10. I actually get the error

'x' argument of 'log10' intrinsic at (1) must be REAL
awsc
  • 27
  • 1
  • Because you haven't declared `interval` it is implicitly an integer, so it is indeed an invalid argument to `log10`. You would detect this if you used `implicit none`. You should either declare the variable as real or convert its value to real for the argument. – francescalus Jan 28 '19 at 15:18
  • Sorry, I did declare it but forgot to add it in the question, I will edit. – awsc Jan 28 '19 at 15:25

0 Answers0