File: readfields.f

package info (click to toggle)
hdf-eos4 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,960 kB
  • sloc: ansic: 43,570; sh: 11,324; fortran: 9,649; makefile: 261
file content (72 lines) | stat: -rw-r--r-- 1,345 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

c
c  In this example we will (1) open the "SwathFile" HDF file, (2) attach to
c  the "Swath1" swath, and (3) read data from the "Longitude" field.
c 


	program readfields

	integer            status, swrdfld, swrdattr, swdetach, swclose
	integer            start(2),stride(2),count(2), attr(4)
	integer*4          swfid, swid, swopen, swattach

	real*4         lng(10,20)
	
	integer DFACC_READ
	parameter (DFACC_READ=1)
	

c    
c     Open the HDF swath file, "SwathFile.hdf"
c 

	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)


	if (swfid .NE. -1) then

	   swid = swattach(swfid, "Swath1")

	   if (swid .NE. -1) then

	      
c     Read the entire Longitude field

	      start(1) = 0
	      start(2) = 0
	      stride(1) = 1
	      stride(2) = 1
	      count(1) = 10
	      count(2) = 20

	      status = swrdfld(swid, "Longitude", start, stride, count,
     1                         lng)

	      do i=1,20
		 do j=1,10
		    write(*,*)'i j Longitude ',i,j,lng(j,i)
		 enddo
	      enddo


c      Read Attribute	      
	      status = swrdattr(swid, "TestAttr", attr)
	      do i=1,4
		 write(*,*) 'Attribute Element', i, ':', attr(i)
	      enddo
	      
	      
	   endif
	endif
	
	status = swdetach(swid)
	status = swclose(swfid)

	stop
	end