! dp2_to_dd.f90
!
! K. Myneni, 16 Sep 2026
!
! Convert a pair of double precision (DP) numbers to
! a double double precision (DD) number and display
! the DD number in scientific notation. The program
! also displays the input DP numbers in  scientific 
! notation and their hex values.
!
! Build:
!   $ gfortran -O3 -o dp2_to_dd dp2_to_dd.f90 ddmodule.o ddfuna.o ddfune.o second.o
!
! Build assumes you have built the Fortran ddfun-v04 package using the
!   shell script gnu-complib-dd.scr
! The script will generate the .o files for linking to the program below.
!
! Revisions:
!   2026-09-18 km; directly set the two DP numbers of a DD variable
!
program dp2todd
        use ddmodule
        implicit none
        real (ddknd) a(2)
        type (dd_real) t1, t2
        print *, 'Enter a pair of double precision (DP) numbers:'
        read(*, '(D28.16,D28.16)') a(1), a(2)
        print *, 'The two DP numbers are:'
        write(*,'(E30.17,2X,E30.17)') a(1), a(2)
        print *, 'The two DP hex values are:'
        write(*, '(Z16,2X,Z16)') a(1), a(2)
        print *, 'The double double (DD) value of the pair is:'
        ! t1 = ddreal(a(1))
        ! t2 = ddreal(a(2))
        ! t1 = t1 + t2
        t1%ddr(1) = a(1)
        t1%ddr(2) = a(2)
        call ddwrite(6,40,32,t1)
end program dp2todd

