1 /* dasioi.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* Table of constant values */
9 
10 static integer c__256 = 256;
11 
12 /* $Procedure      DASIOI ( DAS, Fortran I/O, integer ) */
dasioi_(char * action,integer * unit,integer * recno,integer * record,ftnlen action_len)13 /* Subroutine */ int dasioi_(char *action, integer *unit, integer *recno,
14 	integer *record, ftnlen action_len)
15 {
16     /* Builtin functions */
17     integer s_rdue(cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void),
18 	     s_wdue(cilist *), e_wdue(void);
19 
20     /* Local variables */
21     extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
22 	     ftnlen, ftnlen);
23     extern logical eqstr_(char *, char *, ftnlen, ftnlen);
24     extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
25 	    char *, ftnlen), chkout_(char *, ftnlen), setmsg_(char *, ftnlen);
26     integer iostat;
27     extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
28     extern logical return_(void);
29 
30     /* Fortran I/O blocks */
31     static cilist io___2 = { 1, 0, 1, 0, 0 };
32     static cilist io___3 = { 1, 0, 0, 0, 0 };
33 
34 
35 /* $ Abstract */
36 
37 /*     Perform Fortran reads and writes of DAS integer records. */
38 /*     This routine operates on DAS files having native binary */
39 /*     format. */
40 
41 /* $ Disclaimer */
42 
43 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
44 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
45 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
46 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
47 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
48 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
49 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
50 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
51 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
52 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
53 
54 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
55 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
56 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
57 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
58 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
59 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
60 
61 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
62 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
63 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
64 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
65 
66 /* $ Required_Reading */
67 
68 /*     DAS */
69 
70 /* $ Keywords */
71 
72 /*     DAS */
73 /*     FILES */
74 /*     UTILITY */
75 
76 /* $ Declarations */
77 /* $ Brief_I/O */
78 
79 /*     Variable  I/O  Description */
80 /*     --------  ---  -------------------------------------------------- */
81 /*     ACTION     I   Action to take (read or write). */
82 /*     UNIT       I   Fortran unit connected to DAS file. */
83 /*     RECNO      I   Number of record to read or write. */
84 /*     RECORD    I-O  DAS integer record. */
85 
86 /* $ Detailed_Input */
87 
88 /*     ACTION         is a character string specifying whether to read */
89 /*                    from or write to the specified DAS file.  Possible */
90 /*                    values are: */
91 
92 /*                       'READ' */
93 /*                       'WRITE' */
94 
95 /*                    Case and leading or trailing blanks are not */
96 /*                    significant. */
97 
98 
99 /*     UNIT           is the Fortran unit number connected to the DAS */
100 /*                    file that is to be read or written.  Given the */
101 /*                    handle of the DAS file, the unit number can be */
102 /*                    obtained using ZZDDHHLU. */
103 
104 /*     RECNO          is the Fortran record number of the record to be */
105 /*                    read or written. */
106 
107 /*     RECORD         is an integer array whose contents are to be */
108 /*                    written to record RECNO, if ACTION is WRITE. */
109 
110 /* $ Detailed_Output */
111 
112 /*     RECORD         is an integer array whose contents are to be */
113 /*                    set equal to those of record RECNO, if ACTION */
114 /*                    is READ. */
115 
116 /* $ Parameters */
117 
118 /*     NWI            is the number of elements in a DAS integer record. */
119 
120 /* $ Exceptions */
121 
122 /*     1)  If the value of ACTION is not recognized, the error */
123 /*         SPICE(UNRECOGNIZEDACTION) is signaled. */
124 
125 /*     2)  If a Fortran read error occurs, the error */
126 /*         SPICE(DASFILEREADFAILED) is signaled. */
127 
128 /*     3)  If a Fortran write error occurs, the error */
129 /*         SPICE(DASFILEWRITEFAILED) is signaled. */
130 
131 /* $ Files */
132 
133 /*     See the description of the argument UNIT in $Detailed_Input. */
134 
135 /* $ Particulars */
136 
137 /*     This routine may be used to write to and read from DAS files */
138 /*     having the native binary file format of the host system. The */
139 /*     routine ZZDASGDI should be used to read integer records from DAS */
140 /*     files that may have either native or non-native format. */
141 
142 /*     Normally, routines outside of SPICELIB will not need to call this */
143 /*     routine directly. Writes to DAS files should be performed using */
144 /*     the DASADx and DASUDx routines; reads should be performed using */
145 /*     the DASRDx routines. */
146 
147 /*     This routine centralizes I/O and the concomitant error handling */
148 /*     for DAS integer records. */
149 
150 /*     Although most DAS routines use file handles to identify DAS */
151 /*     files, this routine uses Fortran logical units for this purpose. */
152 /*     Using unit numbers allows the DASIOx routines to be called from */
153 /*     any DAS routine, including entry points of DASFM. */
154 
155 /* $ Examples */
156 
157 /*     1)  Read and print to the screen integer records number 10 */
158 /*         through 20 from the DAS file designated by HANDLE. */
159 
160 /*            INTEGER               RECORD ( NWI ) */
161 /*                           . */
162 /*                           . */
163 /*                           . */
164 
165 /*            CALL ZZDDHHLU ( HANDLE, 'DAS', .FALSE., UNIT ) */
166 /*            CALL DASHFN   ( HANDLE, NAME ) */
167 
168 /*            DO I = 1, 20 */
169 
170 /*               CALL DASIOI ( 'READ', UNIT, 10, RECORD ) */
171 
172 /*               LABEL = 'Contents of the # record in DAS file #: ' */
173 
174 /*               CALL REPMOT ( LABEL,  '#',  I,  'L',   LABEL ) */
175 /*               CALL REPMC  ( LABEL,  '#',      NAME,  LABEL ) */
176 
177 /*               WRITE (*,*) LABEL */
178 /*               WRITE (*,*) ' ' */
179 /*               WRITE (*,*) RECORD */
180 
181 /*            END DO */
182 
183 
184 
185 /*     2)  Write the contents of the array RECORD to record number */
186 /*         10 in the DAS file designated by HANDLE. */
187 
188 
189 /*            INTEGER               RECORD ( NWI ) */
190 
191 /*                           . */
192 /*                           . */
193 /*                           . */
194 
195 /*            CALL ZZDDHHLU ( HANDLE,  'DAS', .FALSE., UNIT   ) */
196 /*            CALL DASIOI   ( 'WRITE', UNIT,  10,      RECORD ) */
197 
198 
199 /* $ Restrictions */
200 
201 /*     1) This routine may be used only on DAS files having */
202 /*        the native binary file format of the host system. */
203 
204 /* $ Literature_References */
205 
206 /*     None. */
207 
208 /* $ Author_and_Institution */
209 
210 /*     N.J. Bachman   (JPL) */
211 /*     W.L. Taber     (JPL) */
212 
213 /* $ Version */
214 
215 /* -    SPICELIB Version 1.0.1, 05-FEB-2015 (NJB) */
216 
217 /*        Header was updated to refer to ZZDDHHLU. Restrictions section */
218 /*        was updated. */
219 
220 /* -    SPICELIB Version 1.0.0, 30-JUN-1992 (NJB) (WLT) */
221 
222 /* -& */
223 /* $ Index_Entries */
224 
225 /*     perform Fortran reads of integer records */
226 /*     perform Fortran writes of integer records */
227 /*     perform low-level I/O for DAS routines */
228 /* -& */
229 
230 /*     SPICELIB functions */
231 
232 
233 /*     Local variables */
234 
235 
236 /*     Use discovery check-in. */
237 
238     if (return_()) {
239 	return 0;
240     }
241     if (eqstr_(action, "READ", action_len, (ftnlen)4)) {
242 
243 /*        We're supposed to read the file. */
244 
245 	io___2.ciunit = *unit;
246 	io___2.cirec = *recno;
247 	iostat = s_rdue(&io___2);
248 	if (iostat != 0) {
249 	    goto L100001;
250 	}
251 	iostat = do_uio(&c__256, (char *)&record[0], (ftnlen)sizeof(integer));
252 	if (iostat != 0) {
253 	    goto L100001;
254 	}
255 	iostat = e_rdue();
256 L100001:
257 	if (iostat != 0) {
258 	    chkin_("DASIOI", (ftnlen)6);
259 	    setmsg_("Could not read DAS integer record. File = # Record numb"
260 		    "er = #. IOSTAT = #.", (ftnlen)74);
261 	    errfnm_("#", unit, (ftnlen)1);
262 	    errint_("#", recno, (ftnlen)1);
263 	    errint_("#", &iostat, (ftnlen)1);
264 	    sigerr_("SPICE(DASFILEREADFAILED)", (ftnlen)24);
265 	    chkout_("DASIOI", (ftnlen)6);
266 	    return 0;
267 	}
268     } else if (eqstr_(action, "WRITE", action_len, (ftnlen)5)) {
269 
270 /*        We're supposed to write to the file. */
271 
272 	io___3.ciunit = *unit;
273 	io___3.cirec = *recno;
274 	iostat = s_wdue(&io___3);
275 	if (iostat != 0) {
276 	    goto L100002;
277 	}
278 	iostat = do_uio(&c__256, (char *)&record[0], (ftnlen)sizeof(integer));
279 	if (iostat != 0) {
280 	    goto L100002;
281 	}
282 	iostat = e_wdue();
283 L100002:
284 	if (iostat != 0) {
285 	    chkin_("DASIOI", (ftnlen)6);
286 	    setmsg_("Could not write DAS integer record. File = # Record num"
287 		    "ber = #. IOSTAT = #.", (ftnlen)75);
288 	    errfnm_("#", unit, (ftnlen)1);
289 	    errint_("#", recno, (ftnlen)1);
290 	    errint_("#", &iostat, (ftnlen)1);
291 	    sigerr_("SPICE(DASFILEWRITEFAILED)", (ftnlen)25);
292 	    chkout_("DASIOI", (ftnlen)6);
293 	    return 0;
294 	}
295     } else {
296 
297 /*        The requested action is a little too weird. */
298 
299 	chkin_("DASIOI", (ftnlen)6);
300 	setmsg_("Action was #; should be READ or WRITE", (ftnlen)37);
301 	errch_("#", action, (ftnlen)1, action_len);
302 	sigerr_("SPICE(UNRECOGNIZEDACTION)", (ftnlen)25);
303 	chkout_("DASIOI", (ftnlen)6);
304 	return 0;
305     }
306     return 0;
307 } /* dasioi_ */
308 
309