SINEOUT2.f95
PROGRAM SINEOUT2 ! ! Purpose: to output the angles 1, 2, 3 and 4 degrees, together with the ! the values of their sines, to the screen and to the file A:\ANGLSINE. ! IMPLICIT NONE DOUBLE PRECISION:: THETA1, THETA2, THETA3, THETA4 DOUBLE PRECISION:: SINE1, SINE2, SINE3, SINE4 DOUBLE PRECISION:: PI ! ! Define the angles: THETA1 = 1.D0 THETA2 = 2.D0 THETA3 = 3.D0 THETA4 = 4.D0 ! ! Calculate their sine. We'll use the intrinsic function SIN, which expects ! its argument to be expressed in radians, not in degrees. Hence, we convert ! the angles from degrees to radians by multiplying by the appropriate ! conversion factor. First, define pi. PI = 4.D0 * ATAN(1.D0) SINE1 = SIN(THETA1*PI/180.D0) SINE2 = SIN(THETA2*PI/180.D0) SINE3 = SIN(THETA3*PI/180.D0) SINE4 = SIN(THETA4*PI/180.D0) ! ! Now, display the results on the screen, in two columns. The D24.16 format ! descriptor ensures that all the significant digits are displayed. The ! angles vary from 1 to 4, so the format descriptor F6.1 is appropriate. ! The FORMAT statement is put at the end of the program, for clarity. WRITE(*,100)THETA1,SINE1 WRITE(*,100)THETA2,SINE2 WRITE(*,100)THETA3,SINE3 WRITE(*,100)THETA4,SINE4 ! ! Also, write the results on the file A:\ANGLSINE. First, open the file. ! OPEN(3,FILE='A:\ANGLSINE') OPEN(3,FILE='ANGLSINE') WRITE(3,100)THETA1,SINE1 WRITE(3,100)THETA2,SINE2 WRITE(3,100)THETA3,SINE3 WRITE(3,100)THETA4,SINE4 ! 100 FORMAT(1X,F6.1,2X,D24.16) ! END PROGRAM SINEOUT2