Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifort 64 bit & 32 bit compiler

dshetty
Beginner
1,419 Views

I have a doubt about ifort_64 compiler. I compiled and ran
program using ifort_64
[dshetty@rob ~]$ ifort_64 testd1.f
[dshetty@rob ~]$ ./a.out
1 2.225073858507201E-308
2 1.797693134862316E+308
3 1.110223024625157E-016
4 2.220446049250313E-016
5 0.301029995663981
0.000000000000000E+000
NaN
0.000000000000000E+000
0.000000000000000E+000
21404579840.0000


and when the same program compiled with ifort on the same machine

[dshetty@rob ~]$ ifort testd1.f
[dshetty@rob~]$ ./a.out
1 2.225073858507201E-308
2 1.797693134862316E+308
3 1.110223024625157E-016
4 2.220446049250313E-016
5 0.301029995663981
2.225073858507201E-308
1.797693134862316E+308
1.110223024625157E-016
2.220446049250313E-016
0.301029995663981


Is there anything wrong with the way I am running the code?


Below is the code :testd1.f



PROGRAM MAIN
double precision x(5)
x(1)=D1MACH(1)
x(2)=D1MACH(2)
x(3)=D1MACH(3)
x(4)=D1MACH(4)
x(5)=D1MACH(5)
WRITE(*,*)x(1)
WRITE(*,*)x(2)
WRITE(*,*)x(3)
WRITE(*,*)x(4)
WRITE(*,*)x(5)
END

!DECK D1MACH
DOUBLE PRECISION FUNCTION D1MACH (I)
IMPLICIT NONE
INTEGER :: I
DOUBLE PRECISION :: B, X
X = 1.0D0

B = RADIX(X)
SELECT CASE (I)
CASE (1)
D1MACH = B**(MINEXPONENT(X)-1) ! the smallest positive magnitude.
CASE (2)
D1MACH = HUGE(X) ! the largest magnitude.
CASE (3)
D1MACH = B**(-DIGITS(X)) ! the smallest relative spacing.
CASE (4)
D1MACH = B**(1-DIGITS(X)) ! the largest relative spacing.
CASE (5)
D1MACH = log10(B)
CASE DEFAULT
WRITE (*, FMT = 9000)
9000 FORMAT ('1ERROR 1 IN D1MACH - I OUT OF BOUNDS')
STOP
END SE LECT
write(*,*)I, D1MACH
RETURN


thanx

0 Kudos
2 Replies
Steven_L_Intel1
Employee
1,419 Views

This is an error in your program. You have not declared D1MACH as DOUBLE PRECISION in the caller.

Hint - always use IMPLICIT NONE to avoid such problems in the future.

0 Kudos
dshetty
Beginner
1,419 Views

Thanks

0 Kudos
Reply