c This example shows how to read a data field and two geo-location c fields in HDF-EOS2 swath data. program read_fields_swath_MAC03S0 implicit none integer*4 swathfile1 integer*4 swath1 integer status integer*4 datafield1rank(32) integer*4 datafield1dimsize(32) integer*4 datafield1type(1) character*512 datafield1dimname integer*2 datafield1data(11,2030) integer*4 datafield1start(2) integer*4 datafield1stride(2) integer*4 datafield1edge(2) integer*4 geofield1rank(32) integer*4 geofield1dimsize(32) integer*4 geofield1type(1) character*512 geofield1dimname real*4 geofield1data(11,2030) integer*4 geofield1start(2) integer*4 geofield1stride(2) integer*4 geofield1edge(2) integer*4 geofield2rank(32) integer*4 geofield2dimsize(32) integer*4 geofield2type(1) character*512 geofield2dimname real*4 geofield2data(11,2030) integer*4 geofield2start(2) integer*4 geofield2stride(2) integer*4 geofield2edge(2) integer*4 i, j integer swrdfld, swfldinfo, swdetach, swclose external swrdfld, swfldinfo, swdetach, swclose integer*4 swopen, swattach external swopen, swattach integer*4 DFACC_READ parameter (DFACC_READ=1) c Open 'MAC03S0.A2006153.0000.002.2007098161727.hdf' using swath API swathfile1 = swopen('MAC03S0.A2006153.0000.002.2007098161727.hdf' $ , DFACC_READ) c Open a swath named 'MODIS_Swath_Type_GEO' swath1 = swattach(swathfile1, 'MODIS_Swath_Type_GEO') c Retrieve information about 'Height' datafield status = swfldinfo(swath1, 'Height', datafield1rank, $ datafield1dimsize, datafield1type, datafield1dimname) c Select necessary range of elements datafield1start(1) = 0 datafield1stride(1) = 1 datafield1edge(1) = 11 datafield1start(2) = 0 datafield1stride(2) = 1 datafield1edge(2) = 2030 c Read data from 'Height' status = swrdfld(swath1, 'Height', datafield1start, $ datafield1stride, datafield1edge, datafield1data) c Dump data from 'Height' do i = 1, 20 do j = 1, 2 write(*,*), datafield1data(j,i) enddo write(*,*) enddo c Retrieve information about 'Longitude' geolocation field status = swfldinfo(swath1, 'Longitude', geofield1rank, $ geofield1dimsize, geofield1type, geofield1dimname) c Select necessary range of elements geofield1start(1) = 0 geofield1stride(1) = 1 geofield1edge(1) = 11 geofield1start(2) = 0 geofield1stride(2) = 1 geofield1edge(2) = 2030 c Read data from 'Longitude' status = swrdfld(swath1, 'Longitude', geofield1start, $ geofield1stride, geofield1edge, geofield1data) c Dump data from 'Longitude' do i = 1, 20 do j = 1, 2 write(*,*), geofield1data(j,i) enddo write(*,*) enddo c Retrieve information about 'Latitude' geolocation field status = swfldinfo(swath1, 'Latitude', geofield2rank, $ geofield2dimsize, geofield2type, geofield2dimname) c Select necessary range of elements geofield2start(1) = 0 geofield2stride(1) = 1 geofield2edge(1) = 11 geofield2start(2) = 0 geofield2stride(2) = 1 geofield2edge(2) = 2030 c Read data from 'Latitude' status = swrdfld(swath1, 'Latitude', geofield2start, $ geofield2stride, geofield2edge, geofield2data) c Dump data from 'Latitude' do i = 1, 20 do j = 1, 2 write(*,*), geofield2data(j,i) enddo write(*,*) enddo c Close the swath named 'MODIS_Swath_Type_GEO' status = swdetach(swath1) c Close 'MAC03S0.A2006153.0000.002.2007098161727.hdf' status = swclose(swathfile1) end