PROGRAM SAMPLE


#include "TKHEADERS.h"
#include "TK_2HSLH.h"
#include "tkiofortdeclare.h"

RECORD /TKINFO/ granuleHandleL2HSLH
RECORD /L2HSLH_SWATH/ L2HSLH

	PARAMETER( NANGLE=49, NRANGE=80 )

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

    REAL*8 lat(NANGLE), lon(NANGLE)
    REAL*4 latentHeating(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, '2HSLH', TKREAD, 'HDF5', jobname, granuleHandleL2HSLH, 0 )
        status = TKopen( file, '2HSLH', TKREAD, 'NETCDF4', jobname, granuleHandleL2HSLH, 0 )
        IF ( status .NE. TK_SUCCESS ) THEN 
		status = TKmessage( granuleHandleL2HSLH.jobname, TKERROR,'message to print' )
	ENDIF

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

	do iscan=1,numOfScan
		status = TKreadScan( granuleHandleL2HSLH, L2HSLH )

		! ScanTime Read
		year      = L2HSLH.ScanTime.Year
		month     = L2HSLH.ScanTime.Month
		dayOfMon  = L2HSLH.ScanTime.DayOfMonth
		hour      = L2HSLH.ScanTime.Hour
		min       = L2HSLH.ScanTime.Minute

		do iangle=1,NANGLE

            ! Latitude and Longitude Read
            lat(iangle)  = L2HSLH.Latitude(iangle)
            lon(iangle)  = L2HSLH.Longitude(iangle)

            ! latentHeating Read
			do irange=1,NRANGE
                latentHeating(irange, iangle) = L2HSLH.latentHeating(irange, iangle)
!               write(*,*) iscan, iangle, irange, "precipRate = ", precipRate(irange, iangle)
            enddo

            ! print the value
            IF(iscan .eq. 161 .and. iangle .eq. 41 ) THEN
                write(*,*) "scan=",iscan-1,",angle=",iangle-1
                write(*,*) "lat=", lat(iangle), "lon=", lon(iangle)
                write(*,*) "latentHeating=",latentHeating(11,iangle), "(K/hr)" 
            ENDIF
        enddo
    enddo

	status = TKclose( granuleHandleL2HSLH )
	STOP
END
	
