program cylinder
implicit none
integer :: ierr
character(1) :: yn
real :: radius, height, area
real, parameter :: pi = 3.141592653589793
interactive_loop: do
write (*,*) 'Enter radius and height.'
read (*,*,iostat=ierr) radius,height
if (ierr /= 0) then
write(*,*) 'Error, invalid input.'
cycle interactive_loop
end if
area = 2 * pi * (radius**2 + radius*height)
write (*,'(1x,a7,f6.2,5x,a7,f6.2,5x,a5,f6.2)') &
'radius=',radius,'height=',height,'area=',area
yn = ' '
yn_loop: do
write(*,*) 'Perform another calculation? y[n]'
read(*,'(a1)') yn
if (yn=='y' .or. yn=='Y') exit yn_loop
if (yn=='n' .or. yn=='N' .or. yn==' ') exit interactive_loop
end do yn_loop
end do interactive_loop
end program cylinder