PROGRAM SAMPLE

#include "TKHEADERS.h"
#include "TK_3HSLH.h"
#include "tkiofortdeclare.h"

RECORD /TKINFO/ granuleHandle3HSLH
RECORD /L3HSLH_GRID/ L3HSLH

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

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

    REAL*4 LHCndMean(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, '3HSLH', TKREAD, 'HDF5', jobname, granuleHandle3HSLH, 0 )
    status = TKopen( file, '3HSLH', TKREAD, 'NETCDF4', jobname, granuleHandle3HSLH, 0 )
    IF ( status .NE. TK_SUCCESS ) THEN 
        status = TKmessage( granuleHandle3HSLH.jobname, TKERROR,'message to print' )
    ENDIF

!   Grid data read
    status = TKreadGrid( granuleHandle3HSLH, L3HSLH )

    do ltL=1, N_LAT
        do lnL=1, N_LON
            do lay=1, N_LAY
                ! LHCndMean Read
                LHCndMean(ltL, lnL, lay) = L3HSLH.LHCndMean(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/720.0/2)
                    write(*,*) "lat=",lat,"lon=",lon
                    write(*,*) "lay=2 lnL=621 ltL=201 LHCndMean=",LHCndMean(ltL, lnL, lay), "(K/hr)" 
                ENDIF
            enddo
        enddo
    enddo

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