! This is a basic starting shell for your programs MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const ! ! Program to convert from rectangular to polar coordinates ! PROGRAM prog USE const IMPLICIT NONE REAL(KIND=dp) :: x,y,r,theta WRITE(*,*) 'Input x and y' READ(*,*) x,y ! NOTE: We need to have the proper angle (and not the principle angle) for ! the conversion the work correctly. Use the ATAN2 function. r = SQRT(x**2 + y**2) theta = ATAN2(y,x)*180/dpi WRITE(*,*) 'Polar coordinates = ',r,theta END PROGRAM prog !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Input x and y ! -1,1 ! Polar coordinates = 1.4142135623730951 135.00000000000000 ! ! Input x and y ! -4,-2 ! Polar coordinates = 4.4721359549995796 -153.43494882292202 ! Input x and y ! 0,-3 ! Polar coordinates = 3.0000000000000000 -90.000000000000000