This file is indexed.

/usr/share/ncarg/hluex/xyplot/xy14c.c is in libncarg-data 6.3.0-6build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/*
**      $Id: xy14c.c,v 1.7 2010-03-15 22:49:25 haley Exp $
*/
/***********************************************************************
*                                                                      *
*                Copyright (C)  1995                                   *
*        University Corporation for Atmospheric Research               *
*     The use of this Software is governed by a License Agreement      *
*                                                                      *
***********************************************************************/
/*
**  File:       xy14c.c
**
**  Author:     Fred Clare (converted to C by Mary Haley)
**          National Center for Atmospheric Research
**          PO 3000, Boulder, Colorado
**
**  Date:       Tue Sep 26 15:47:51 MDT 1995
**
** Description:  This example demonstrates the data manipulation
**               capabilities of the HLUS in conjunction with XyPlot.
**
**               This example is really meant to show the data manipulation
**               capabilities of NCL, since it does some array arithmetic
**               that you can't do in C or Fortran 77.        
*/

#include <stdio.h>
#include <math.h>
#include <ncarg/hlu/hlu.h>
#include <ncarg/hlu/ResList.h>
#include <ncarg/hlu/App.h>
#include <ncarg/hlu/NcgmWorkstation.h>
#include <ncarg/hlu/PSWorkstation.h>
#include <ncarg/hlu/PDFWorkstation.h>
#include <ncarg/hlu/CairoWorkstation.h>
#include <ncarg/hlu/XyPlot.h>
#include <ncarg/hlu/CoordArrays.h>

/*
 * Define temperature/rainfall data for a 25-hour period in
 * an NCL variable.  In a real-world NCL script these values
 * would probably be read in, either directly or as part of
 * a data file like a netCDF or HDF file.
 *
 * The temperature data is hourly data in degrees Celsius and
 * the rainfall data is hourly data in millimeters.
 */

float tr_data[2][25] = { { 9.00,  8.30,  7.40,  6.20,  5.60,  3.40,  2.70,  1.20,
			   3.70,  5.80,  5.90,  4.50,  7.40, 11.60, 10.40,  9.20,
			   7.80, 10.20, 12.10, 11.40,  9.00,  8.90,  8.50,  7.40,
			   6.60},
			 {0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,
			  0.00,  0.00,  0.00,  0.25,  0.63,  0.10,  0.00,  0.53,
			  3.75,  3.10,  0.52,  0.00,  0.00,  0.00,  0.00,  0.00,
			  0.00, 0.00}};

float yvalues[5] = {2.,1.,0.,-1.,-2.};
char *ylabels[5] = {"2~F33~s","~F33~s","~F22~MEAN","-~F33~s","-2~F33~s"};

#define NHOURS   25

int main()
{
    int appid, work_id, plotid, dataid, dataspec;
    int srlist, i, j;
    float x_array[NHOURS], y_array[NHOURS];
    float x_array2[5], y_array2[5];
    float t_mean, std_dev, mm2inch = 1./25.4;
/*
 * Default is to display output to an X workstation
 */
    char const *wks_type = "x11";
/*
 * Initialize the HLU library.
 */
    NhlInitialize();
    srlist = NhlRLCreate(NhlSETRL);
/*
 * Create Application object.
 */
    NhlRLClear(srlist);
    NhlRLSetString(srlist,NhlNappDefaultParent,"True");
    NhlRLSetString(srlist,NhlNappUsrDir,"./");
    NhlCreate(&appid,"xy14",NhlappClass,NhlDEFAULT_APP,srlist);

    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
/*
 * Create a meta file object.
 */
        NhlRLClear(srlist);
        NhlRLSetString(srlist,NhlNwkMetaName,"./xy14c.ncgm");
        NhlCreate(&work_id,"xy14Work",NhlncgmWorkstationClass,
                  NhlDEFAULT_APP,srlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
/*
 * Create an X11 workstation.
 */
        NhlRLClear(srlist);
        NhlRLSetInteger(srlist,NhlNwkPause,True);
        NhlCreate(&work_id,"xy14Work",NhlcairoWindowWorkstationClass,
              NhlDEFAULT_APP,srlist);
    }
    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
/*
 * Create an older-style PostScript workstation.
 */
        NhlRLClear(srlist);
        NhlRLSetString(srlist,NhlNwkPSFileName,"./xy14c.ps");
        NhlCreate(&work_id,"xy14Work",NhlpsWorkstationClass,
                  NhlDEFAULT_APP,srlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
/*
 * Create an older-style PDF workstation.
 */
        NhlRLClear(srlist);
        NhlRLSetString(srlist,NhlNwkPDFFileName,"./xy14c.pdf");
        NhlCreate(&work_id,"xy14Work",NhlpdfWorkstationClass,
                  NhlDEFAULT_APP,srlist);
    }
    else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
             !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
/*
 * Create a cairo PS/PDF workstation.
 */
        NhlRLClear(srlist);
        NhlRLSetString(srlist,NhlNwkFileName,"./xy14c");
        NhlRLSetString(srlist,NhlNwkFormat, (char*)wks_type);
        NhlCreate(&work_id,"xy14Work",NhlcairoDocumentWorkstationClass,
                  NhlDEFAULT_APP,srlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
/*
 * Create a cairo PNG workstation.
 */
        NhlRLClear(srlist);
        NhlRLSetString(srlist,NhlNwkFileName,"./xy14c");
        NhlRLSetString(srlist,NhlNwkFormat, (char*)wks_type);
        NhlCreate(&work_id,"xy14Work",NhlcairoImageWorkstationClass,
                  NhlDEFAULT_APP,srlist);
    }
/*
 * Create X-axis values and convert data to Fahrenheit.
 */
    for( i = 0; i < NHOURS; i++ ) {
        x_array[i] = (float)i;
        y_array[i] = (9./5.)*tr_data[0][i]+32.;
    }
/*
 * Picture 1:
 *
 * Convert the temperatures to degrees Fahrenheit and plot as an XyPlot
 * object in the X11 window.  Note the usage of NCL algebraic operators
 * and array selection capabilities.
 */
    NhlRLClear(srlist);
    NhlRLSetFloatArray(srlist,NhlNcaXArray,x_array,NHOURS);
    NhlRLSetFloatArray(srlist,NhlNcaYArray,y_array,NHOURS);
    NhlCreate(&dataid,"xyData",NhlcoordArraysClass,appid,srlist);

    NhlRLClear(srlist);
    NhlRLSetInteger(srlist,NhlNxyCoordData, dataid);
/*
 * X-axis resources
 */
    NhlRLSetString(srlist,NhlNtmXBMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmXBTickStartF, 0.);
    NhlRLSetFloat(srlist,NhlNtmXBTickEndF, 24.);
    NhlRLSetFloat(srlist,NhlNtmXBTickSpacingF, 4.);
    NhlRLSetInteger(srlist,NhlNtmXBLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmXBLabelFontHeightF, 0.024);
/*
 * Y-axis resources.  The title precision is changed to "2" so that integer
 * values will be used (the temperatures are in a range requiring only
 * two digits).
 */
    NhlRLSetString(srlist,NhlNtmYLMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmYLTickStartF, 30.);
    NhlRLSetFloat(srlist,NhlNtmYLTickEndF, 60.);
    NhlRLSetFloat(srlist,NhlNtmYLTickSpacingF, 5.);
    NhlRLSetString(srlist,NhlNtmYLAutoPrecision, "False");
    NhlRLSetInteger(srlist,NhlNtmYLPrecision, 2);
    NhlRLSetInteger(srlist,NhlNtmYLLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmYLLabelFontHeightF, 0.024);
    NhlRLSetInteger(srlist,NhlNtmYLMinorPerMajor, 4);
/*
 * Specify the Y-axis range precisely.
 */
    NhlRLSetFloat(srlist,NhlNtrYMinF, 30.);
    NhlRLSetFloat(srlist,NhlNtrYMaxF, 60.);
/*
 * Supply titles
 */
    NhlRLSetInteger(srlist,NhlNtiMainFont, 26);
    NhlRLSetFloat(srlist,NhlNtiMainFontHeightF, .03);
    NhlRLSetString(srlist,NhlNtiMainString, "Hourly Temperatures");
    NhlRLSetInteger(srlist,NhlNtiXAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiXAxisString, "Hours Since Midnight");
    NhlRLSetInteger(srlist,NhlNtiYAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiYAxisString, "Temperature (degrees F)");
    NhlCreate(&plotid,"XyPlot",NhlxyPlotClass,work_id,srlist);

    NhlDraw(plotid);
    NhlFrame(work_id);
/*
 * Picture 2:
 *
 * Convert the rainfall data to inches and plot in the X11 window. 
 * (In NCL, note how easy it is to select the rainfall data from the
 * original two-dimensional data array.
 */
    for( i = 0; i < NHOURS; i++ ) y_array[i] = mm2inch*tr_data[1][i];
    NhlRLClear(srlist);
    NhlRLSetFloatArray(srlist,NhlNcaXArray,x_array,NHOURS);
    NhlRLSetFloatArray(srlist,NhlNcaYArray,y_array,NHOURS);
    NhlCreate(&dataid,"xyData",NhlcoordArraysClass,appid,srlist);

    NhlRLClear(srlist);
    NhlRLSetInteger(srlist,NhlNxyCoordData, dataid);
/*
 * X-axis resources
 */
    NhlRLSetString(srlist,NhlNtmXBMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmXBTickStartF, 0.);
    NhlRLSetFloat(srlist,NhlNtmXBTickEndF, 24.);
    NhlRLSetFloat(srlist,NhlNtmXBTickSpacingF, 4.);
    NhlRLSetInteger(srlist,NhlNtmXBLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmXBLabelFontHeightF, 0.024);
/*
 * Y-axis resources.
 */
    NhlRLSetString(srlist,NhlNtmYLMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmYLTickStartF, 0.);
    NhlRLSetFloat(srlist,NhlNtmYLTickEndF, 0.15);
    NhlRLSetFloat(srlist,NhlNtmYLTickSpacingF, 0.03);
    NhlRLSetString(srlist,NhlNtmYLAutoPrecision, "False");
    NhlRLSetInteger(srlist,NhlNtmYLPrecision, 2);
    NhlRLSetInteger(srlist,NhlNtmYLLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmYLLabelFontHeightF, 0.024);
    NhlRLSetInteger(srlist,NhlNtmYLMinorPerMajor, 4);
/*
 * Specify the Y-axis range precisely.
 */
    NhlRLSetFloat(srlist,NhlNtrYMinF, 0.);
    NhlRLSetFloat(srlist,NhlNtrYMaxF, 0.15);
/*
 * Supply titles
 */
    NhlRLSetInteger(srlist,NhlNtiMainFont, 26);
    NhlRLSetFloat(srlist,NhlNtiMainFontHeightF, .03);
    NhlRLSetString(srlist,NhlNtiMainString, "Hourly Rainfall");
    NhlRLSetInteger(srlist,NhlNtiXAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiXAxisString, "Hours Since Midnight");
    NhlRLSetInteger(srlist,NhlNtiYAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiYAxisString, "Rainfall in Inches");
    NhlCreate(&plotid,"XyPlot",NhlxyPlotClass,work_id,srlist);
    NhlDraw(plotid);
    NhlFrame(work_id);
/*
 * Picture 3:
 *
 * For each hourly temperature reading, plot the number of standard
 * deviations from the mean the reading represents.  (In NCL, note the
 * use of the NCL exponentiation operator (^) and the sqrt function.)
 */
    t_mean = 0.;
    for( i = 0; i < NHOURS; i++ )  t_mean = t_mean+(9./5.)*tr_data[0][i]+32.;
    t_mean = t_mean/NHOURS;
    std_dev = 0.;
    for( i = 0; i < NHOURS; i++ ) {
         std_dev = std_dev+pow( ((9./5.)*tr_data[0][i]+32.) - t_mean,2.);
     }
    std_dev = sqrt(std_dev/(NHOURS-1));
    for( i = 0; i < NHOURS; i++ ) {
        y_array[i] = ((9./5.)*tr_data[0][i]+32. - t_mean)/std_dev;
    }
    NhlRLClear(srlist);
    NhlRLSetFloatArray(srlist,NhlNcaXArray,x_array,NHOURS);
    NhlRLSetFloatArray(srlist,NhlNcaYArray,y_array,NHOURS);
    NhlCreate(&dataid,"xyData",NhlcoordArraysClass,appid,srlist);

    NhlRLClear(srlist);
/*
 * X-axis resources
 */
    NhlRLSetString(srlist,NhlNtmXBMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmXBTickStartF, 0.);
    NhlRLSetFloat(srlist,NhlNtmXBTickEndF, 24.);
    NhlRLSetFloat(srlist,NhlNtmXBTickSpacingF, 4.);
    NhlRLSetInteger(srlist,NhlNtmXBLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmXBLabelFontHeightF, 0.024);
/*
 * Y-axis resources.
 */
    NhlRLSetString(srlist,NhlNtmYLMode, "EXPLICIT");
    NhlRLSetFloatArray(srlist,NhlNtmYLValues, yvalues,5);
    NhlRLSetStringArray(srlist,NhlNtmYLLabels, ylabels,5);
    NhlRLSetFloat(srlist,NhlNtmYLTickSpacingF, 1.);
    NhlRLSetInteger(srlist,NhlNtmYLLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmYLLabelFontHeightF, 0.024);
    NhlRLSetString(srlist,NhlNtmYMajorGrid, "True");
    NhlRLSetString(srlist,NhlNtmYLMinorOn, "False");
    NhlRLSetString(srlist,NhlNtmYRMinorOn, "False");
/*
 * Specify the Y-axis range precisely.
 */
    NhlRLSetFloat(srlist,NhlNtrYMinF, -2.5);
    NhlRLSetFloat(srlist,NhlNtrYMaxF, 2.5);
/*
 * Supply titles
 */
    NhlRLSetInteger(srlist,NhlNtiMainFont, 26);
    NhlRLSetFloat(srlist,NhlNtiMainFontHeightF, .03);
    NhlRLSetString(srlist,NhlNtiMainString, "Temperature Deviations From Mean");
    NhlRLSetInteger(srlist,NhlNtiXAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiXAxisString, "Hours Since Midnight");
    NhlRLSetString(srlist,NhlNtiYAxisString, "Deviations");
    NhlRLSetInteger(srlist,NhlNtiYAxisFont, 22);
    NhlCreate(&plotid,"XyPlot",NhlxyPlotClass,work_id,srlist);
/*
 * Specify the use of filled circle markers.
 */
    dataspec = NhlAddData(plotid,"xyCoordData",dataid);

    NhlRLClear(srlist);
    NhlRLSetString(srlist,NhlNxyMarkLineMode, "MARKERS");
    NhlRLSetString(srlist,NhlNxyMonoMarkLineMode, "True");
    NhlRLSetInteger(srlist,NhlNxyMarker, 16);
    NhlRLSetString(srlist,NhlNxyMonoMarkerSize, "True");
    NhlRLSetFloat(srlist,NhlNxyMarkerSizeF, .02);
    NhlSetValues(dataspec,srlist);
    NhlDraw(plotid);
    NhlFrame(work_id);
/*
 * Picture 4:
 *
 * (In Ncl, this section illustrate the use of being able to easily pick
 * out subsections of data arrays.
 */
    j = 0;
    for( i = 2; i < NHOURS; i+=6 ) {
        x_array2[j] = x_array[i];
        y_array2[j++] = (9./5.)*tr_data[0][i]+32.;
    }
    NhlRLClear(srlist);
    NhlRLSetFloatArray(srlist,NhlNcaXArray,x_array2,j);
    NhlRLSetFloatArray(srlist,NhlNcaYArray,y_array2,j);
    NhlCreate(&dataid,"xyData",NhlcoordArraysClass,appid,srlist);

    NhlRLClear(srlist);
    NhlRLSetInteger(srlist,NhlNxyCoordData,dataid);
/*
 * X-axis resources 
 */
    NhlRLSetString(srlist,NhlNtmXBMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmXBTickStartF, 2.);
    NhlRLSetFloat(srlist,NhlNtmXBTickEndF, 22.);
    NhlRLSetFloat(srlist,NhlNtmXBTickSpacingF, 6.);
    NhlRLSetInteger(srlist,NhlNtmXBLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmXBLabelFontHeightF, 0.024);
    NhlRLSetInteger(srlist,NhlNtmXBMinorPerMajor, 0);
/*
 * Y-axis resources.
 */
    NhlRLSetString(srlist,NhlNtmYLMode, "MANUAL");
    NhlRLSetFloat(srlist,NhlNtmYLTickStartF, 30.);
    NhlRLSetFloat(srlist,NhlNtmYLTickEndF, 60.);
    NhlRLSetFloat(srlist,NhlNtmYLTickSpacingF, 5.);
    NhlRLSetString(srlist,NhlNtmYLAutoPrecision, "False");
    NhlRLSetInteger(srlist,NhlNtmYLPrecision, 2);
    NhlRLSetInteger(srlist,NhlNtmYLLabelFont, 22);
    NhlRLSetFloat(srlist,NhlNtmYLLabelFontHeightF, 0.024);
    NhlRLSetInteger(srlist,NhlNtmYLMinorPerMajor, 4);
/*
 * Specify the Y-axis range precisely.
 */
    NhlRLSetFloat(srlist,NhlNtrYMinF, 30.);
    NhlRLSetFloat(srlist,NhlNtrYMaxF, 60.);
/*
 * Supply titles
 */
    NhlRLSetInteger(srlist,NhlNtiMainFont, 26);
    NhlRLSetString(srlist,NhlNtiMainString, "Temperatures at Six Hour Intervals");
    NhlRLSetFloat(srlist,NhlNtiMainFontHeightF, .03);
    NhlRLSetInteger(srlist,NhlNtiXAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiXAxisString, "Hours Since Midnight");
    NhlRLSetInteger(srlist,NhlNtiYAxisFont, 22);
    NhlRLSetString(srlist,NhlNtiYAxisString, "Temperature (degrees F)");
    NhlCreate(&plotid,"XyPlot",NhlxyPlotClass,work_id,srlist);

    NhlDraw(plotid);
    NhlFrame(work_id);
/*
 * NhlDestroy destroys the given id and all of its children.
 */
    NhlDestroy(appid);
    NhlRLDestroy(srlist);
/*
 * Restores state.
 */
    NhlClose();
    exit(0);
}