program main !*****************************************************************************80 ! !! abc_test() tests abc(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 27 April 2024 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ) a_in real ( kind = rk ) a_out real ( kind = rk ) b_in real ( kind = rk ) b_out real ( kind = rk ) c_in real ( kind = rk ) c_out interface subroutine abc ( a_in, b_in, c_in, a_out, b_out, c_out ) integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ), optional :: a_in real ( kind = rk ), optional :: a_out real ( kind = rk ), optional :: b_in real ( kind = rk ), optional :: b_out real ( kind = rk ), optional :: c_in real ( kind = rk ), optional :: c_out end subroutine end interface call timestamp ( ) write ( *, '(a)' ) '' write ( *, '(a)' ) 'abc_test():' write ( *, '(a)' ) ' Fortran90 version' write ( *, '(a)' ) ' Test abc(), with the interface:' write ( *, '(a)' ) ' abc(a_in=?,b_in=?,c_in=?,a_out=?,b_out=?,c_out=?)' call abc ( a_out = a_out, b_out = b_out, c_out = c_out ) write ( *, '(a)' ) '' write ( *, '(a)' ) ' Request current internal values.' write ( *, '(a)' ) ' Specify a_out=, b_out=, c_out=' write ( *, '(a,g14.6,a,g14.6,a,g14.6,a)' ) & ' abc( a_out =',a_out,', b_out = ',b_out,', c_out = ',c_out, ')' b_in = 19 c_in = 99 call abc ( b_in = b_in, c_in = c_in ) write ( *, '(a)' ) '' write ( *, '(a)' ) ' Change internal values of b and c' write ( *, '(a,g14.6,a,g14.6,a)' ) & ' abc( b_in = ',b_in, ' c_in = ',c_in, ')' a_in = 50 call abc ( a_in = a_in, b_out = b_out ) write ( *, '(a)' ) '' write ( *, '(a)' ) ' Change internal value of a_in, report value of b_out.' write ( *, '(a,g14.6,a,g14.6,a)' ) & ' abc( a_in = ', a_in,', b_out =', b_out, ')' call abc ( a_out = a_out, b_out = b_out, c_out = c_out ) write ( *, '(a)' ) '' write ( *, '(a)' ) ' Report all internal values.' write ( *, '(a,g14.6,a,g14.6,a,g14.6,a)' ) & ' abc( a_out =',a_out,', b_out = ',b_out,', c_out = ',c_out, ')' ! ! Terminate. ! write ( *, '(a)' ) '' write ( *, '(a)' ) 'abc_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) '' call timestamp ( ) return end subroutine timestamp ( ) !*****************************************************************************80 ! !! timestamp() prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) character ( len = 8 ) ampm integer d integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer n integer s integer values(8) integer y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(i2.2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end