PROGRAM SAMPLE

#include "TKHEADERS.h"
#include "TK_1BKu.h"
#include "tkiofortdeclare.h"

RECORD /TKINFO/ granuleHandle1BKu
RECORD /L1BKu_FS/ L1BKu

	PARAMETER( NANGLE=49, NRANGE=260 )

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

    REAL*8 lat(NANGLE), lon(NANGLE)
	INTEGER*2 noisePower(NANGLE), echoPower(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, '1BKu', TKREAD, 'HDF5', jobname, granuleHandle1BKu, 0 )
        status = TKopen( file, '1BKu', TKREAD, 'NETCDF4', jobname, granuleHandle1BKu, 0 )
        IF ( status .NE. TK_SUCCESS ) THEN 
		status = TKmessage( granuleHandle1BKu.jobname, TKERROR,'message to print' )
	ENDIF

	status = TKgetMetaInt( granuleHandle1BKu, 'SwathHeader', 'NumberScansGranule', numOfScan )

	do iscan=1,numOfScan
		status = TKreadScan( granuleHandle1BKu, L1BKu )

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

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

            ! noisePower Read
            noisePower(iangle) = L1BKu.Receiver.noisePower(iangle)                                

            ! echoPower Read
        	do irange=1,NRANGE
                echoPower(irange, iangle) = L1BKu.Receiver.echoPower(irange, iangle)
            enddo

            ! print the value
            IF(iscan .eq. 3947 .and. iangle .eq. 20 ) THEN
                write(*,*) "scan=",iscan-1,",angle=",iangle-1
                write(*,*) "lat=", lat(iangle), "lon=", lon(iangle)
                write(*,*) "echoPower(260)=",echoPower(260,iangle) 
                write(*,*) "noisePower=",noisePower(iangle) 
            ENDIF
        enddo
    enddo

    ! Close HDF5 file.
	status = TKclose( granuleHandle1BKu )
	STOP
END
	
