***********************************************************************
* PROGRAM: COMBINE_REALTIME_FORECAST
* LANGUAGE: FORTRAN 77
*---------------------------------------------------------------------
* PURPOSE: Combines all 2x2 grids into one historical archive file
*           (1995 - present)
* USAGE: combine_realtime_forecast.Linux.exe ${1} ${2} ${3}
*---------------------------------------------------------------------
* INPUT FILES
*    ${1} - 2x2 gridded binary file for a single valid period
* OUTPUT FILES
*    ${2} - 2x2 gridded binary file containing all valid periods
*---------------------------------------------------------------------
* SUBROUTINES USED
*    NONE
* FUNCTIONS USED
*    NONE
*--------------------------------------------------------------------
* INPUT VARIABLES
*    INPUT - Input file name
*    KREC - record number that data will be written to in output file
*    OUTPUT - Output file name
* LOCAL VARIABLES
*    IREC - Record number in integer form
*    T - MATRIX TO STORE DATA 
*----------------------------------------------------------------*
* AUTHOR(S): MIKE HALPERT
*            SCOTT HANDEL
*--------------------------------------------------------------------
* DATE: APRIL 10, 2012
*--------------------------------------------------------------------
* MODIFICATIONS
*********************************************************************
       dimension t(36,19)
       character*4 krec
       character*300 input,output
*********************************************************************
* GET COMMAND LINE ARGUMENTS
*********************************************************************
       call getarg (1,input)
       call getarg (2,output)
       call getarg (3,krec)
*********************************************************************
* OPEN INPUT AND OUTPUT FILES
*********************************************************************
        open (11,file=input,access='direct',
     x   form='unformatted',recl=36*19*4,status='old')
        open (50,file=output,access='direct',
     x   form='unformatted',recl=36*19*4,status='unknown')
*********************************************************************
* CONVERT RECORD NUMBER COMMAND LINE ARGUMENT TO INTEGER
*********************************************************************
        read  (krec,'(i4)') irec
*********************************************************************
* READ INPUT DATA
*********************************************************************
        read(11,rec=1)t
*********************************************************************
* WRITE OUTPUT DATA
*********************************************************************
        write(50,rec=irec)t
        stop
        end
