Re: problem with very small numbers - g95 versus gfortran



On May 28, 11:01 pm, "James Van Buskirk" <not_va...@xxxxxxxxxxx>
wrote:
"James Van Buskirk" <not_va...@xxxxxxxxxxx> wrote in messagenews:ZNidnfL7Zs7Jl6PVnZ2dnUVZ_vCdnZ2d@xxxxxxxxxxxxxx

Just for fun, tell me what g95 does with the following:

And for even more fun, this experiment tempting overflow:

C:\gcc_mingw64a\test\denormal>type mega.f90
program mega
   real(4) x4
   real(8) x8
   real(10) x10
   real pi

   pi = 4*atan(1.0)

   x4 = 2
   x4 = log(huge(x4))+log(x4)*1.1
   write(*,*) cos(complex(pi/4,x4))
   x4 = log(huge(x4))
   write(*,*) cos(complex(pi/4,x4))

   x8 = 2
   x8 = log(huge(x8))+log(x8)*1.1
   write(*,*) cos(complex(pi/4,x8))
   x8 = log(huge(x8))
   write(*,*) cos(complex(pi/4,x8))

   x10 = 2
   x10 = log(huge(x10))+log(x10)*1.1
   write(*,*) cos(complex(pi/4,x10))
   x10 = log(huge(x10))
   write(*,*) cos(complex(pi/4,x10))
   write(*,*) huge(x4)
   write(*,*) huge(x8)
   write(*,*) huge(x10)
end program mega

C:\gcc_mingw64a\test\denormal>x86_64-pc-mingw32-gfortran mega.f90 -omega

C:\gcc_mingw64a\test\denormal>mega
 (      +Infinity,      -Infinity)
 ( 1.20308013E+38,-1.20308013E+38)
 (                +Infinity,                -Infinity)
 ( 6.35580489185754273E+307,-6.35580516967861561E+307)
 (                    +Infinity,                    -Infinity)
 ( 4.20633594885755398476E+4931,-4.20633613272234874657E+4931)
  3.40282347E+38
  1.79769313486231571E+308
  1.18973149535723176502E+4932

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end

OK. Here it goes on g95:

C:\Users\epc\temp>g95 mega.f90
In file mega.f90:25

write(*,*) cos(complex(pi/4,x10))
1
In file mega.f90:19

write(*,*) cos(complex(pi/4,x8))
2
Warning (155): Inconsistent types (REAL(10)/REAL(8)) in actual
argument lists at
(1) and (2)
In file mega.f90:25

write(*,*) cos(complex(pi/4,x10))
1
In file mega.f90:17

write(*,*) cos(complex(pi/4,x8))
2
Warning (155): Inconsistent types (REAL(10)/REAL(8)) in actual
argument lists at
(1) and (2)
In file mega.f90:25

write(*,*) cos(complex(pi/4,x10))
1
In file mega.f90:13

write(*,*) cos(complex(pi/4,x4))
2
Warning (155): Inconsistent types (REAL(10)/REAL(4)) in actual
argument lists at
(1) and (2)
In file mega.f90:25

write(*,*) cos(complex(pi/4,x10))
1
In file mega.f90:11

write(*,*) cos(complex(pi/4,x4))
2
Warning (155): Inconsistent types (REAL(10)/REAL(4)) in actual
argument lists at
(1) and (2)
C:\Users\epc\AppData\Local\Temp/ccErGX8Q.o:mega.f90:(.text+0xb0):
undefined refe
rence to `complex_'
C:\Users\epc\AppData\Local\Temp/ccErGX8Q.o:mega.f90:(.text+0x164):
undefined ref
erence to `complex_'
C:\Users\epc\AppData\Local\Temp/ccErGX8Q.o:mega.f90:(.text+0x252):
undefined ref
erence to `complex_'
C:\Users\epc\AppData\Local\Temp/ccErGX8Q.o:mega.f90:(.text+0x311):
undefined ref
erence to `complex_'
C:\Users\epc\AppData\Local\Temp/ccErGX8Q.o:mega.f90:(.text+0x403):
undefined ref
erence to `complex_'
C:\Users\epc\AppData\Local\Temp/ccErGX8Q.o:mega.f90:(.text+0x4cd):
more undefine
d references to `complex_' follow

C:\Users\epc\temp>

??????????

- e

.