Software Archive
Read-only legacy content
17060 Discussions

help! function call problem

Intel_C_Intel
Employee
288 Views
there is no difference between asd(), msd()
but why they print out different results?

thanks a lot.
a poor man

! result---------------------
1.23456001281738
0.000000000000000E+000

! code --------------------------------
program main
double precision time

time = asd()
print *, time
time = msd()
print *, time
end program main

double precision function asd()
asd = 1.23456
end function asd

double precision function msd()
msd = 1.23456
end function msd
0 Kudos
2 Replies
Intel_C_Intel
Employee
288 Views
there is no difference between asd(), msd() but why they print out different results? thanks a lot. a poor man

! result---------------------

1.23456001281738

0.000000000000000E+000

! code --------------------------------

program main

double precision time

time = asd()

print *, time

time = msd()

print *, time

end program main

double precision functionasd()

asd = 1.23456

end function asd


double precision function msd()

msd = 1.23456

end function msd
0 Kudos
Steven_L_Intel1
Employee
288 Views
You need to add:

double precision msd

to the main program. msd should also use:

msd = 1.23456D0

otherwise you are assigning a single precision value to a double precision variable.

Steve
0 Kudos
Reply