! This program reads two data files and writes out paired values ! of wind velocity and direction for the same exact time ! It assumes that the files are in date/time order ! Example: ! sidebyside -f690070.org -g724916.org > ftord.out integer year(2), mo(2), day(2), hour(2), univtime(2), idx real dir(2), u(2) character*50 argv, name1, name2 ! function definition integer julday if (iargc() .gt. 0) then do i = 1, iargc() call getarg(i,argv) !command line help prompt if ((argv(2:2).eq.'?').or.(argv(2:2).eq.'h')) then write(*,*) 'Valid command line options:' write(*,*) '-? or -h Display this help screen' write(*,*) '-f' write(*,*) '-g' stop else if (argv(2:2) == 'f') then !First file name read(argv(3:),*) name1 else if (argv(2:2) == 'g') then !Second file name read(argv(3:),*) name2 end if end do endif open (1, file = name1) open (2, file = name2) ! read from both files read (1,*,end=300) year(1), mo(1), day(1), hour(1), dir(1), u(1) read (2,*,end=300) year(2), mo(2), day(2), hour(2), dir(2), u(2) ! calculate a single value for date and time univtime(1) = julday(day(1), mo(1), year(1))*24 + hour(1) univtime(2) = julday(day(2), mo(2), year(2))*24 + hour(2) do while (2 > 1) !only leave this loop when eof. ! index forward do while ( univtime(1) .lt. univtime(2) ) ! read first file until greater than or equal read (1,*,end=300) year(1), mo(1), day(1), hour(1), dir(1), u(1) univtime(1) = julday(day(1), mo(1), year(1))*24 + hour(1) end do do while ( univtime(2) .lt. univtime(1) ) ! read second file until greater than or equal read (2,*,end=300) year(2), mo(2), day(2), hour(2), dir(2), u(2) univtime(2) = julday(day(2), mo(2), year(2))*24 + hour(2) end do !write data when time is equal if( univtime(2) .eq. univtime(1) ) then write(*,35) year(1), mo(1), day(1), hour(1), univtime(1), dir(1), u(1), dir(2), u(2) 35 format(x,4i4,x,i12,x,4f6.1) ! read from both files read (1,*,end=300) year(1), mo(1), day(1), hour(1), dir(1), u(1) read (2,*,end=300) year(2), mo(2), day(2), hour(2), dir(2), u(2) ! calculate a single value for date and time univtime(1) = julday(day(1), mo(1), year(1))*24 + hour(1) univtime(2) = julday(day(2), mo(2), year(2))*24 + hour(2) end if end do 300 continue end