Ouzen
February 17, 2022, 8:09pm
#1
I have a problem with dividing 1/10, i set the value as real number , here is the code
program test1
implicit none
real :: ne,mn,dt,pw
mn=1.0e0!multiplied number
dt=1.0e0
ne=10.0e0
pw=-1
dt=1/10
print *, dt
end program test1
also when i try to do 10*exp(pw), where pw is -1 i dont get 0.1
Integer division (both numerator and denominator integers) in Fortran truncates, so
print*,1/10
gives 0.
You could write instead
dt = 1/10.0
2 Likes
msz59
February 17, 2022, 8:34pm
#3
10*exp(pw) does not mean 10 to the pw
power but 10 times (e
to the pw
power), where e
is the Euler’s constant (2.718281…). To raise 10 to some power, use 10**pw
1 Like