-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmrrec.f
74 lines (74 loc) · 1.96 KB
/
dmrrec.f
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
73
74
SUBROUTINE DM_RREC ( iflno, irec, ircpnt, iflerr, iret )
C************************************************************************
C* DM_RREC *
C* *
C* This subroutine reads a data record from a file. *
C* *
C* DM_RREC ( IFLNO, IREC, IRCPNT, IFLERR, IRET ) *
C* *
C* Input parameters: *
C* IFLNO INTEGER File number *
C* IREC INTEGER Record number *
C* *
C* Output parameters: *
C* IRCPNT INTEGER Pointer to record in cache *
C* IFLERR INTEGER GEMPAK file error number *
C* IRET INTEGER Return code *
C* 0 = normal return *
C* -6 = write error *
C* -7 = read error *
C** *
C* Log: *
C* M. desJardins/GSFC 6/86 *
C* M. desJardins/GSFC 3/87 Added write for records replaced *
C* M. desJardins/GSFC 11/87 Initialize iflerr *
C************************************************************************
INCLUDE 'GEMPRM.PRM'
INCLUDE 'GMBDTA.CMN'
INCLUDE 'dmcmn.cmn'
C------------------------------------------------------------------------
iret = 0
iflerr = 0
C
C* Check for data already in cache.
C
ircpnt = 0
knt = 1
DO WHILE ( (ircpnt .eq. 0) .and. (knt .le. MCACHE) )
IF ((kcflno (knt) .eq. iflno) .and. (kcrecn (knt) .eq. irec))
+ ircpnt = knt
knt = knt + 1
END DO
IF ( ircpnt .ne. 0 ) RETURN
C
C* Get the next record in the cache.
C
CALL DM_NXTC ( ircpnt, ier )
C
C* Read requested data record. Check first to see if this is
C* a shared file.
C
IF ( kshare ( iflno ) ) THEN
CALL FL_RSHR ( lundm (iflno), irec, MBLKSZ,
+ kcdata (1,kclast), iflerr )
ELSE
CALL FL_READ ( lundm (iflno), irec, MBLKSZ,
+ kcdata (1,kclast), iflerr )
END IF
C
C* In case of error, blank out record.
C
IF ( iflerr .ne. 0 ) THEN
iret = -7
DO i = 1, MBLKSZ
kcdata ( i, ircpnt ) = 0
END DO
END IF
C
C* Update file number and record number in cache.
C
kcflno ( ircpnt ) = iflno
kcrecn ( ircpnt ) = irec
C*
RETURN
END