PROGRAM SAMPLE

#include "TKHEADERS.h"
#include "TK_3GSLH.h"
#include "tkiofortdeclare.h"

RECORD /TKINFO/ granuleHandle3GSLH
RECORD /L3GSLH_GRID/ L3GSLH

    PARAMETER( N_LAT=268, N_LON=720, N_LAY=80 )

	INTEGER status
	INTEGER st, rt, chn, lnL, ltL 
	CHARACTER*255 jobname, file

    REAL*4 allLHCndMean(N_LAT,N_LON,N_LAY)
    REAL*4 lat, lon

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

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

!   Grid data read
	status = TKreadGrid( granuleHandle3GSLH, L3GSLH )

    do ltL=1, N_LAT
        do lnL=1, N_LON
            do lay=1, N_LAY
                ! allLHCndMean Read
                allLHCndMean(ltL, lnL, lay) = L3GSLH.allLHCndMean(ltL, lnL, lay)

                ! print the value
                IF(lnL .eq. 621 .and. ltL .eq. 201 .and. lay .eq. 2 ) THEN
                    lat = (134.0/268.0) * (ltL-1) - 67.0 + (134.0/268.0/2)
                    lon = (360.0/720.0) * (lnL-1) - 180.0 + (360.0/72.0/2)
                    write(*,*) "lat=",lat,"lon=",lon
                    write(*,*) "lay=2 lnL=621 ltL=201 allLHCndMean=",allLHCndMean(ltL, lnL, lay), "(K/hr)" 
                ENDIF
            enddo
        enddo
    enddo

!   HDF file close
	status = TKclose( granuleHandle3GSLH )
	STOP
END
	
