PROGRAM SAMPLE

#include "TKHEADERS.h"
#include "TK_2AGPROFGMI.h"
#include "tkiofortdeclare.h"

RECORD /TKINFO/ granuleHandle2AGPROFGMI
RECORD /L2AGPROFGMI_S1/ GPROFGMI 

	PARAMETER( NANGLE=221 )

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

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

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

	do iscan=1,numOfScan
		status = TKreadScan( granuleHandle2AGPROFGMI, GPROFGMI )

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

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

                        ! surfacePrecipitation Read
                        surfacePrecipitation(iangle) = GPROFGMI.surfacePrecipitation(iangle)

                        ! print the value
                        IF(iscan .eq. 2001 .and. iangle .eq. 152 ) THEN
                             write(*,*) "scan=",iscan-1,",angle=",iangle-1
                             write(*,*) "lat=", lat(iangle), "lon=", lon(iangle)
                             write(*,*) "surfacePrecipitation=",surfacePrecipitation(iangle), "(mm/h)" 
                        ENDIF
                enddo
         enddo

	status = TKclose( granuleHandle2AGPROFGMI )
	STOP
END
	
