cdi_read_sst.f 1.19 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
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
      PROGRAM CDIREADSST

      IMPLICIT NONE

      INCLUDE 'cdi.inc'

      INTEGER nvals
      PARAMETER (nvals = 20480)

      INTEGER gridID, taxisID
      INTEGER vlistID, varID1, streamID, tsID
      INTEGER nmiss, status, vdate, vtime
      REAL*8 sst(nvals)

!      CALL cdiDebug(1)
!     Open the dataset
      streamID = streamOpenRead
     & ("/Users/m214003/data/icon_amip2sst_1870-2010.nc")
      IF ( streamID < 0 ) THEN
         WRITE(0,*) cdiStringError(streamID)
         STOP
      END IF

!     Get the variable list of the dataset
      vlistID = streamInqVlist(streamID)

!     Set the variable IDs
      varID1 = 0

!     Get the Time axis from the variable list
      taxisID = vlistInqTaxis(vlistID)

!     Loop over the first 10 time steps
      DO tsID = 0, 10
!        Inquire the time step
         status = streamInqTimestep(streamID, tsID)

!        Get the verification date and time
         vdate = taxisInqVdate(taxisID)
         vtime = taxisInqVtime(taxisID)

!        Read sst
         CALL streamReadVarSlice(streamID, varID1, 0, sst, nmiss)

         WRITE(*,*) vdate, minval(sst), maxval(sst)
      END DO

!     Close the input stream
      CALL streamClose(streamID)

      END