PROGRAM SAMPLE


#include "TKHEADERS.h"
#include "TK_2ADPR.h"
#include "tkiofortdeclare.h"

RECORD /TKINFO/ granuleHandleL2DPR
RECORD /L2ADPR_SWATHS/ L2ADPR

	PARAMETER( NANGLE=49, NRANGE=176 )

	INTEGER status, numOfScan
	INTEGER iscan, iangle, irange
	CHARACTER*255 jobname, file

    REAL*8 lat(NANGLE), lon(NANGLE)
    REAL*4 precipRateESurface(NANGLE)
    REAL*4 precipWater(NRANGE,NANGLE)

	INTEGER*2 year, msec, dayOfYear
	BYTE month, dayOfMon, hour, min, sec
	REAL*8 secOfDay


	call getarg( 1, jobname )
	call getarg( 2, file )

! 	Open the file for reading.
	!status = TKopen( file, '2ADPR', TKREAD, 'HDF5', jobname, granuleHandleL2DPR, 0 )
        status = TKopen( file, '2ADPR', TKREAD, 'NETCDF4', jobname, granuleHandleL2DPR, 0 )
	IF ( status .NE. TK_SUCCESS ) THEN 
		status = TKmessage( granuleHandleL2DPR.jobname, TKERROR,'message to print' )
	ENDIF

	status = TKgetMetaInt( granuleHandleL2DPR, 'FS_SwathHeader', 'NumberScansGranule', numOfScan )

	do iscan=1,numOfScan
		status = TKreadScan( granuleHandleL2DPR, L2ADPR )

		! ScanTime Read
		year      = L2ADPR.FS.ScanTime.Year
		month     = L2ADPR.FS.ScanTime.Month
		dayOfMon  = L2ADPR.FS.ScanTime.DayOfMonth
		hour      = L2ADPR.FS.ScanTime.Hour
		min       = L2ADPR.FS.ScanTime.Minute
		sec       = L2ADPR.FS.ScanTime.Second
		msec      = L2ADPR.FS.ScanTime.MilliSecond
		dayOfYear = L2ADPR.FS.ScanTime.DayOfYear
		secOfDay  = L2ADPR.FS.ScanTime.SecondOfDay

		do iangle=1,NANGLE
            ! Latitude and Longitude Read
            lat(iangle)  = L2ADPR.FS.Latitude(iangle)
            lon(iangle)  = L2ADPR.FS.Longitude(iangle)

            ! precipRateESurface Read
            precipRateESurface(iangle) = L2ADPR.FS.SLV.precipRateESurface(iangle)

			do irange=1,NRANGE
                precipWater(irange, iangle) = L2ADPR.FS.SLV.precipWater(irange, iangle)
            enddo
            ! print the value
            IF(iscan .eq. 5211 .and. iangle .eq. 44 ) THEN
                write(*,*) "scan=",iscan-1,",angle=",iangle-1
                write(*,*) "lat=", lat(iangle), "lon=", lon(iangle)
                write(*,*) "precipRateESurface=",precipRateESurface(iangle), "(mm/hr)" 
                write(*,*) "precipWater(171,44)=", precipWater(171, iangle), "(g/m~3)"
            ENDIF
        enddo
    enddo

	status = TKclose( granuleHandleL2DPR )
	STOP
END
	
