I am trying to get a better understanding of the kind
specification, so I wrote the following program.
program main
implicit none
real(kind = selected_real_kind(1)) :: a1
real(kind = selected_real_kind(2)) :: a2
print *, "Kind = ", kind(a1), "Range = ", range(a1)
print *, "Kind = ", kind(a2), "Range = ", range(a2)
end program main
The program runs great. However, my question is not about kind
. My question is about using a do loop. I would like to make the program bigger, but I don't want to write out declaration and print statements over and over.
I don't think I have much choice on the declarations. I think I will have to write them out one at a time. Is that correct?
However, I do think there is a way to use a do loop for the print statements. Maybe something like this:
program main
implicit none
integer :: i
real(kind = selected_real_kind(1)) :: a1
real(kind = selected_real_kind(2)) :: a2
do i = 1, 2
print *, "Kind = ", kind(ai), "Range = ", range(ai)
end do
end program main
Any suggestions?