program merger ! !******************************************************************************* ! !! MERGER merges two sorted files into a third. ! ! ! Usage: ! ! merger input1 input2 output ! ! Discussion: ! ! No check is made that the file is already sorted, and the program ! will become seriously confused if it is not. ! ! Duplicate entries are removed. ! ! Modified: ! ! 18 February 2002 ! ! Author: ! ! John Burkardt ! implicit none ! character ( len = 256 ) dict_file_name_1 character ( len = 256 ) dict_file_name_2 character ( len = 256 ) dict_file_name_3 integer iarg integer iargc integer ierror integer ilen integer ipxfargc integer n1 integer n2 integer n3 integer numarg ! call timestamp ( ) ! ! Count the number of command line arguments. ! ! Old style: ! numarg = iargc ( ) ! ! New style: ! ! numarg = ipxfargc ( ) ! ! Get the module name. ! if ( numarg < 3 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'MERGER - Not enough arguments!' write ( *, '(a)') ' Usage: merger infile1 infile2 outfile' stop end if iarg = 1 ! ! Old style: ! call getarg ( iarg, dict_file_name_1 ) ! ! New style: ! ! call pxfgetarg ( iarg, dict_file_name_1, ilen, ierror ) ! ! if ( ierror /= 0 ) then ! write ( *, '(a)' ) ' ' ! write ( *, '(a)' ) 'MERGER - Fatal error!' ! write ( *, '(a)' ) ' Unable to read command line argument #1.' ! stop ! end if iarg = 2 ! ! Old style: ! call getarg ( iarg, dict_file_name_2 ) ! ! New style: ! ! call pxfgetarg ( iarg, dict_file_name_2, ilen, ierror ) ! ! if ( ierror /= 0 ) then ! write ( *, '(a)' ) ' ' ! write ( *, '(a)' ) 'MERGER - Fatal error!' ! write ( *, '(a)' ) ' Unable to read command line argument #2.' ! stop ! end if iarg = 3 ! ! Old style: ! call getarg ( iarg, dict_file_name_3 ) ! ! New style: ! ! call pxfgetarg ( iarg, dict_file_name_3, ilen, ierror ) ! ! if ( ierror /= 0 ) then ! write ( *, '(a)' ) ' ' ! write ( *, '(a)' ) 'MERGER - Fatal error!' ! write ( *, '(a)' ) ' Unable to read command line argument #3.' ! stop ! end if call file_merge ( dict_file_name_1, dict_file_name_2, dict_file_name_3, & n1, n2, n3 ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'MERGER:' write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Words in file1: ', n1 write ( *, '(a,i8)' ) ' Words in file2: ', n2 write ( *, '(a,i8)' ) ' Words in file3: ', n3 write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Duplicates: ', n1 + n2 - n3 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'MERGER:' write ( *, '(a)' ) ' Normal end of execution.' stop end subroutine timestamp ( ) ! !******************************************************************************* ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! ! Example: ! ! May 31 2001 9:45:54.872 AM ! ! Modified: ! ! 31 May 2001 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none ! character ( len = 8 ) ampm integer d character ( len = 8 ) date 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 character ( len = 10 ) time integer values(8) integer y character ( len = 5 ) zone ! call date_and_time ( date, time, zone, 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 ( *, '(a,1x,i2,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & trim ( month(m) ), d, y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end