PROGRAM Weeble
    USE double
    IMPLICIT NONE
    CHARACTER(LEN=50) :: input, output
    CHARACTER(LEN=8) :: data_char
    REAL(KIND=DP), DIMENSION(5) :: data_real
    INTEGER :: err, data_int

    WRITE (*, *) 'Type the input and output filenames'
    READ (*, *) input, output
    OPEN (11, FILE=TRIM(input), ACTION='read', &
        FORM='unformatted', IOSTAT=err)
    IF (err /= 0) THEN
        PRINT *, "Unable to open " // input
        STOP 1
    END IF
    OPEN (12, FILE=TRIM(output), ACTION='write', &
        FORM='unformatted', IOSTAT=err)
    IF (err /= 0) THEN
        PRINT *, "Unable to open " // output
        STOP 1
    END IF

! Error checking has been omitted for brevity from the following; it
! is best to check IOSTAT in all I/O statements, including CLOSE.

    READ (11) data_char, data_real, data_int
    WRITE (12) data_char, data_real, data_int
    CLOSE (11)
    CLOSE (12)
    
END PROGRAM Weeble
