/usr/share/ncarg/hluex/basic/basic05f.f is in libncarg-data 6.4.0-9.
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 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | C
C $Id: basic05f.f,v 1.14 2010-03-15 22:49:23 haley Exp $
C
C***********************************************************************
C *
C Copyright (C) 1995 *
C University Corporation for Atmospheric Research *
C All Rights Reserved *
C *
C***********************************************************************
C
C File: basic05f.f
C
C Author: Tim Scheitlin (converted by Ed Stautler)
C National Center for Atmospheric Research
C PO 3000, Boulder, Colorado
C
C Date: Mon Mar 20 10:43:42 MST 1995
C
C Description: This example demonstrates how to read, display, and
C manipulate colormaps.
C
C The NG 4.x HLU software supports several different predefined
C colormaps of various sizes. This example demonstrates how to
C display each of those colormaps using the labelbar utility.
C This example also shows how to change entries in a colormap
C and create a completely new colormap.
C
external NhlFAppClass
external NhlFCairoWindowWorkstationClass
external NhlFNcgmWorkstationClass
external NhlFPSWorkstationClass
external NhlFPDFWorkstationClass
external NhlFCairoPSPDFWorkstationClass
external NhlFCairoImageWorkstationClass
external NhlFLabelBarClass
external NhlFTextItemClass
integer i, ierr
integer num_dims,len_dims(2)
integer appid,wks,lbar,rlist,glist,text
character*7 wks_type
character*3 colorindices(255)
real cmap(3,8)
real newcmap(3,100)
C
C Define the workstation type
C
wks_type = "x11"
C Initialize libraries and create a resource list.
call NhlFInitialize
call NhlFRLCreate(rlist,'SETRL')
call NhlFRLClear(rlist)
call NhlFCreate(appid,'appid',NhlFAppClass,0,rlist,ierr)
if (wks_type.eq."ncgm".or.wks_type.eq."NCGM") then
C
C Create an NCGM workstation.
C
call NhlFRLClear(rlist)
call NhlFRLSetstring(rlist,'wkMetaName','./basic05f.ncgm',ierr)
call NhlFCreate(wks,'wks',
1 NhlFNcgmWorkstationClass,0,rlist,ierr)
else if (wks_type.eq."x11".or.wks_type.eq."X11") then
C Create an XWorkstation object that uses the default colormap.
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkPause','True',ierr)
C Set color mode to private so that there is no contention for colors
C call NhlFRLSetString(rlist,'wkXColorMode','private',ierr)
call NhlFCreate(wks,'wks',
+ NhlFCairoWindowWorkstationClass,0,
1 rlist,ierr)
else if (wks_type.eq."oldps".or.wks_type.eq."OLDPS") then
C
C Create an older-style PostScript workstation.
C
call NhlFRLClear(rlist)
call NhlFRLSetstring(rlist,'wkPSFileName','./basic05f.ps',ierr)
call NhlFCreate(wks,'wks',
1 NhlFPSWorkstationClass,0,rlist,ierr)
else if (wks_type.eq."oldpdf".or.wks_type.eq."OLDPDF") then
C
C Create an older-style PDF workstation.
C
call NhlFRLClear(rlist)
call NhlFRLSetstring(rlist,'wkPDFFileName','./basic05f.pdf',
1 ierr)
call NhlFCreate(wks,'wks',
1 NhlFPDFWorkstationClass,0,rlist,ierr)
else if (wks_type.eq."pdf".or.wks_type.eq."PDF".or.
1 wks_type.eq."ps".or.wks_type.eq."PS") then
C
C Create a cairo PS/PDF object.
C
call NhlFRLClear(rlist)
call NhlFRLSetstring(rlist,'wkFileName','./basic05f',
1 ierr)
call NhlFRLSetstring(rlist,'wkFormat',wks_type,
1 ierr)
call NhlFCreate(wks,'wks',
1 NhlFCairoPSPDFWorkstationClass,0,rlist,ierr)
else if (wks_type.eq."png".or.wks_type.eq."PNG") then
C
C Create a cairo PNG object.
C
call NhlFRLClear(rlist)
call NhlFRLSetstring(rlist,'wkFileName','./basic05f',
1 ierr)
call NhlFRLSetstring(rlist,'wkFormat',wks_type,
1 ierr)
call NhlFCreate(wks,'wks',
1 NhlFCairoImageWorkstationClass,0,rlist,ierr)
endif
C Initialize labels for the colormap entries
do 100 i=1,255
write (colorindices(i),111) i
111 format (I3)
100 continue
C Create a labelbar object.
call NhlFRLClear(rlist)
C Assign the labels
call NhlFRLSetStringArray(rlist,'lbLabelStrings',
1 colorindices,232,ierr)
C Label every 5th entry
call NhlFRLSetInteger(rlist,'lbLabelStride',5,ierr)
C Single pattern used for fill
call NhlFRLSetString(rlist,'lbMonoFillPattern','True',ierr)
C Set fill pattern to solid
call NhlFRLSetString(rlist,'lbFillPattern','SolidFill',ierr)
C No lines between colors
call NhlFRLSetString(rlist,'lbBoxLinesOn','False',ierr)
C Display 255 entries
call NhlFRLSetInteger(rlist,'lbBoxCount',255,ierr)
C Turn off labelbar perimeter
call NhlFRLSetString(rlist,'lbPerimOn','False',ierr)
C Plot title
call NhlFRLSetString(rlist,'lbTitleString',
1 '(New) Default Colormap',ierr)
C Title font
call NhlFRLSetString(rlist,'lbTitleFont','Helvetica-bold',ierr)
C Label font
call NhlFRLSetString(rlist,'lbLabelFont','Helvetica',ierr)
C Set viewport to max size
call NhlFRLSetFloat(rlist,'vpXF',0.0,ierr)
call NhlFRLSetFloat(rlist,'vpYF',1.0,ierr)
call NhlFRLSetFloat(rlist,'vpHeightF',1.0,ierr)
call NhlFRLSetFloat(rlist,'vpWidthF',1.0,ierr)
call NhlFCreate(lbar,'lbar',NhlFLabelBarClass,wks,
1 rlist,ierr)
C Create a text label
call NhlFRLClear(rlist)
C Set the font
call NhlFRLSetString(rlist,'txFont','Helvetica-bold',ierr)
C Set position and height
call NhlFRLSetFloat(rlist,'txPosXF',.5,ierr)
call NhlFRLSetFloat(rlist,'txPosYF',.03,ierr)
call NhlFRLSetFloat(rlist,'txFontHeightF',.035,ierr)
C Set the function code to the "*" character so that the
C default function code character, the colon, can be used
C in the "txString" resource.
call NhlFRLSetString(rlist,'txFuncCode','*',ierr)
C Set the text value
call NhlFRLSetString(rlist,'txString','Note: Entry 0 is the backgr
$ound color',ierr)
call NhlFCreate(text,'text',NhlFtextItemClass,wks,
1 rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to the old default colormap
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','default',ierr)
call NhlFSetValues(wks,rlist,ierr)
call NhlFRLClear(rlist)
call NhlFRLSetInteger(rlist,'lbBoxCount',31,ierr)
call NhlFRLSetString(rlist,'lbTitleString',
1 '(Old) Default Colormap',ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','cyclic',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Cyclic Colormap',ierr)
C Label every entry
call NhlFRLSetInteger(rlist,'lbLabelStride',1,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',7,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','gscyclic',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Gscyclic Colormap',
$ ierr)
C Label every entry
call NhlFRLSetInteger(rlist,'lbLabelStride',1,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',7,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','gsltod',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Gsltod Colormap',
$ ierr)
C Label every other entry
call NhlFRLSetInteger(rlist,'lbLabelStride',2,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',32,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','gsdtol',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Gsdtol Colormap',
$ ierr)
C Label every other entry
call NhlFRLSetInteger(rlist,'lbLabelStride',2,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',32,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','uniform',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Uniform Colormap',
$ ierr)
C Label every 10th entry
call NhlFRLSetInteger(rlist,'lbLabelStride',10,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',112,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','temp1',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Temp1 Colormap',
$ ierr)
C Label every 5th entry
call NhlFRLSetInteger(rlist,'lbLabelStride',5,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',62,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','psgcap',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Psgcap Colormap',
$ ierr)
C Label every 15th entry
call NhlFRLSetInteger(rlist,'lbLabelStride',15,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',230,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C Change the colormap to one of the predefined colormaps
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','example',ierr)
call NhlFSetValues(wks,rlist,ierr)
C Change the labelbar title, annotation, and number of entries.
call NhlFRLClear(rlist)
C Labelbar title
call NhlFRLSetString(rlist,'lbTitleString','Example Colormap',
$ ierr)
C Label every 15th entry
call NhlFRLSetInteger(rlist,'lbLabelStride',10,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',114,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C This next example changes three entries in the colormap. Changing the
C first entry (colormap index 0) in the colormap, sets the background
C color for a plot. The second entry (color index 1) sets the foreground
C color for a plot.
C
C The colormap is stored in a 3xN variable where N is the length of
C the colormap. Each entry in the color map consists of a vector
C of 3 normalized red-green-blue color values.
C Assign gray scale colormap
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'wkColorMap','gscyclic',ierr)
call NhlFSetValues(wks,rlist,ierr)
num_dims = 2
len_dims(1) = 3
len_dims(2) = 8
call NhlFRLCreate(glist,'GETRL')
call NhlFRLClear(glist)
call NhlFRLGetMDFloatArray(glist,'wkColorMap',cmap,num_dims,
1 len_dims,ierr)
call NhlFGetValues(wks,glist,ierr)
C Change the first entry in the colormap array to blue, the
C second to green, and the fourth to red.
C Background color
cmap(1,1) = 0.0
cmap(2,1) = 0.0
cmap(3,1) = 1.0
C Foreground color
cmap(1,2) = 0.0
cmap(2,2) = 1.0
cmap(3,2) = 0.0
C Colormap entry 3
cmap(1,4) = 1.0
cmap(2,4) = 0.0
cmap(3,4) = 0.0
C Assign the new color map to the workstation object.
num_dims=2
len_dims(1)=3
len_dims(2)=8
call NhlFRLClear(rlist)
call NhlFRLSetMDFloatArray(rlist,'wkColorMap',cmap,
1 num_dims,len_dims,ierr)
call NhlFSetValues(wks,rlist,ierr)
C Add a different title.
call NhlFRLClear(rlist)
C Set the title
call NhlFRLSetString(rlist,'lbTitleString',
1 'Changing colormap entries',ierr)
C Label every entry
call NhlFRLSetInteger(rlist,'lbLabelStride',1,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',7,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Change the textual annotation at bottom of frame
call NhlFRLClear(rlist)
C Set the title for the labelbar
call NhlFRLSetString(rlist,'txString','Entry 0 (background) set to
$ Blue',ierr)
call NhlFSetValues(text,rlist,ierr)
C Draw and frame the labelbar.
call NhlFDraw(lbar,ierr)
call NhlFDraw(text,ierr)
call NhlFFrame(wks,ierr)
C This example demonstrates how to create and assign a new colormap.
C
C First we will initialize a new array with RGB entries. For this
C example we are choosing an arbitrary colormap size of 100.
C
C Assign new RGB values to each entry of the colormap.
C The first entry (background color) is black. The rest of
C the colormap is a smooth table that ranges from red to blue.
newcmap(1,1) = 0.
newcmap(2,1) = 0.
newcmap(3,1) = 0.
do 10, i=2,100
newcmap(1,i) = 1.-(i/100.)
newcmap(2,i) = i/100.
newcmap(3,i) = i/100.
10 continue
C Assign the new color map to the workstation object.
call NhlFRLClear(rlist)
num_dims=2
len_dims(1)=3
len_dims(2)=100
call NhlFRLSetMDFloatArray(rlist,'wkColorMap',newcmap,
1 num_dims,len_dims,ierr)
call NhlFSetValues(wks,rlist,ierr)
C Assign a new title.
call NhlFRLClear(rlist)
call NhlFRLSetString(rlist,'lbTitleString','New colormap',ierr)
C Label every 10th entry
call NhlFRLSetInteger(rlist,'lbLabelStride',10,ierr)
C Number of entries to display
call NhlFRLSetInteger(rlist,'lbBoxCount',99,ierr)
call NhlFSetValues(lbar,rlist,ierr)
C Draw and frame the labelbar
call NhlFDraw(lbar,ierr)
call NhlFFrame(wks,ierr)
C Cleanup
call NhlFDestroy(lbar,ierr)
call NhlFDestroy(text,ierr)
call NhlFDestroy(wks,ierr)
call NhlFClose
stop
end
|