! A simple interactive demo program ! ------------------------------------------------ ! Note the use of file units "fin" (Fortran input) ! and "fout" (Fortran output). These are aliases ! for the "5" and "6" Logical Unit Numbers (LUNs). ! These LUN asignments are not mentioned in any ! Fortran standard but are probably supported by ! all F90 compilers, for historical reasons. ! ! Input/Output is cumbersome in SEA because there ! is no Fortran builtin IO mechanism for derived ! types (unlike e.g. Pascal) and the IO statements ! cannot be overloaded. program test use sea_arithmetic ! Error analytic module type(sea_abs) :: x, y, z ! Declare our vars call sea_check_precise() ! Verify PRECISE reals exist call sea_read_abs(fin, x, "Enter |x,e|>: ") ! Input X call sea_read_abs(fin, y, "Enter |y,e|>: ") ! Input Y call sea_write_nl(fout) ! Write a newline call sea_write_txt_nl(fout, "# the input: ") ! Write a line of text call sea_write_entry(fout, "x = ", x, 5) ! Write number call sea_write_entry(fout, "y = ", y, 5) ! Write number call sea_write_nl(fout) ! Write a newline call sea_write_txt_nl(fout, "# z = x / x") ! Write a line of text z = x / x ! Error analytic division call sea_write_entry(fout, "x/x = ", z, 5) ! Write result call sea_write_nl(fout) ! Write a newline call sea_write_txt_nl(fout, "# z = x / y") ! Write a line of text z = x / y ! Error analytic division call sea_write_entry(fout, "x/y = ", z, 5) ! Write result call sea_write_nl(fout) ! Write a newline ! ! SEA_DEBUG = 1 ! Check SIN algorithm ! call sea_write_txt_nl(fout, "# trigo... ") ! Write a line of text z = sin(x) ! Error analytic sin(x) call sea_write_entry(fout, "sin(x) = ", z, 5) ! Write sin(x) z = cos(x) ! Error analytic cos(x) call sea_write_entry(fout, "cos(x) = ", z, 5) ! Write cos(x) z = tan(x) ! Error analytic tan(x) call sea_write_entry(fout, "tan(x) = ", z, 5) ! Write tan(x) z = alt_tan(x) ! Compute alt-tan(x) call sea_write_entry(fout, "alt-tan ", z, 5) ! Write alt-tan(x) call sea_write_nl(fout) ! Write a newline end program test