Figure F horizontal color slice and contour slice of the pressure together with the map of

the HIRLAM domain

Figure F iso surface of the wind at knots together with the orography of the HIRLAM domain

APPENDIX F EXAMPLE IMAGES

Figure F contour surface of a D eld without handle and a D eld with handle

Figure F legenda of the temp erature

App endix F

Example Images

Figure F vertical color surface of the temp erature together with the orography of the

HIRLAM domain

APPENDIX E VOGL IMPLEMENTATION DETAILS

Note This routine do esnt yet work in the VISD distribution of VOGL It is prob

ably obsolete as the line style is not device dep endent any more The linestyle

must b e used when scan converting lines

For full details the reader is referred to the X driver The le Xc contains the complete

sp ecication of a VOGL device driver

E VOGL DEVICE DRIVER STRUCTURE

Note This routine is not available in the original VOGL distribution

It is the resp onsibility of the device to approximate bit color when a frame

buer of only bits is available

DEV mapcolorint LUTindex int r int g int b

Changes a colormap index to a given RGB value

DEV fontchar fontfile

Sets up a hardware font This should also set vdevicehwidth and vdevicehheight

which are the width and height of the current hardware font in pixels VOGL assumes

that hardware text is of a xed width

DEV charchar c

Prints a character of hardware text This routine must do any neccessary moving to

make sure the current drawing p osition on the device is correct and it must leave the

device in graphics mo de

stringchar s DEV

Prints a string of hardware text This routine must do any neccessary moving to make

sure the current drawing p osition on the device is correct and it must leave the device

in graphics mo de

DEV fillint n int x int y

Draws lled p olygons devices which do not supp ort this should just do an outline

Note This routine is obsolete in the VISD distribution of VOGL It is never called

but included to retain backward compatibility

backbuf DEV

Initializes double buering by selecting the back drawing buer and p erforming any

other initializations If no double buering is supp orted then should b e returned

Note The double buering used is in fact pseudodouble buering Drawing is done

is a backbuer which is copied into the front buer when requested

DEV swapbuf

Swaps the front and back buer What it really do es in most device drivers is copy the

back buer into the front buer

frontbuf DEV

Switches drawing into the front drawing buer

DEV setlwint w

Sets the line width

Note This routine do esnt yet work in the VISD distribution of VOGL It is prob

ably obsolete as the line width is not device dep endent any more The linewidth

must b e used when scan converting lines

DEV setlsint lss

Sets the line style of line drawings

APPENDIX E VOGL IMPLEMENTATION DETAILS

There must also b e a function in the device driver to copy the device driver structure in

the global used device entry This function must b e called conditionally from driversc

as should the device name print statement the device are printed if VOGL is used but no

device is set

The nineteen functions required for a complete device driver are

DEV init

Device initialization routine A routine which enables graphics on the device sets the

default color map and sets vdevicemaxSxy and vdeviceminSxy to the window

size in pixels

Note In the VISD distribution of VOGL this routine also initializes the palette to

colors distributed in the RGB space when the frame buer is only bits

exit DEV

Do es the necessary cleaning up to allow VOGL to exit leaving the device in a usable

form

DEV drawint x int y

Draws a line from the current device p osition to a p oint x y in vogle device co ords

note these assume that is the b ottom left hand corner This routine must up date

the current device p osition

Note This routine is obsolete in the VISD distribution of VOGL It is never called

but included to retain backward compatability

DEV pointint x int y

Draws a single pixel in the current device color

Note This function is not available in the original VOGL distribution

DEV getkey

Gets a single character of input from a device capable of providing it

DEV locatorint wx int wy

Returns the mouse p osition for the device in VOGL device co ordinates returned in the

arguments and returns a bit pattern giving which buttons were down at the time of

the call

DEV clear

Clears the current viewp ort to the current background color

DEV colorint LUTindex

Changes the current device color to the sp ecied LUT index

DEV RGBcolorint r int g int b

Changes the current device color to the sp ecied RGB value

E VOGL DEVICE DRIVER STRUCTURE

void lmbindshort target short index

lmbind binds one of the eleven light controlling resource of the GL to a resource dened

by lmdef target can b e one of MATERIAL BACKMATERIAL LIGHT or LMODEL

void shademodellong model

Sets the mo del Two shading mo dels are supp orted FLAT and GOURAUD

long getsmvoid

Returns the current shading mo del The value returned can b e either FLAT or GOURAUD

E Depthcueing functions

Private functions

void calc depthcueVertex v

Calculates the color of the given vertex v using the Screen Zco ordinate of v and the

current RGB and Zrange

Public functions

void depthcueint onoff

Turns depthcueing on or o If onoff is zero depthcueing is turned o Otherwise it

is turned on

void lRGBrangeshort rmingminbminrmaxgmaxbmaxlong znearzfar

Sp ecied the RGB color and Z range to b e used for depthcueing The values rmax

gmax and bmax are mapp ed to znear

E VOGL device driver structure

VOGL device drivers contain the following information

 Three character p ointers giving

The name of the device

The name for the small hardware font

The name for the large hardware font

 function p ointers giving the functionality of the device If a device is not capable

of some function eg color changing a noop function should b e provided which has a

return value of

APPENDIX E VOGL IMPLEMENTATION DETAILS

COLOR RGB color commands will set the current color If a color is the last LMC

thing sent b efore a vertex the vertex is colored If a normal is the last thing sent

b efore a vertex the vertex will b e lighted LMC COLOR is the default mo de

LMC EMISSION RGB color commands will set the EMISSION color prop erty of

the current material

AMBIENT RGB color commands will set the AMBIENT color prop erty of LMC

the current material

LMC DIFFUSE RGB color commands will set the DIFFUSE color prop erty of

the current material Alpha the fourth color comp onent sp ecied by RGB color

commands will set the ALPHA prop erty of the current material

LMC SPECULAR RGB color commands will set the SPECULAR color prop erty

of the current material

LMC AD RGB color commands will set the DIFFUSE and AMBIENT color prop

erty of the current material Alpha the fourth color comp onent sp ecied by RGB

color commands will set the ALPHA prop erty of the current material

NULL RGB color commands will b e ignored LMC

IMPORTANT lmcolor do es NOT change the data structures holding the material

denitions but is provided to supp ort fast changes to the current material without

changing the denition of the currently b ound material Thus lmcolor changes are lost

whenever a new material is b ound only the MATERIAL prop erties can b e changed not

those of the BACKMATERIAL

void nlentypetype normal

These functions are named identical as the color functions prexed with an n instead

of an c and are used to sp ecify vertex normals len can currently only b e type can b e

s short i longd double or f oat Vertex normals must b e normalized in order

for the shading calculation to b e meaningful b ecause the dot pro duct of the vectors is

used as a measure of the angle b etween the vectors See also the function nmode

void nmodelong mode

Tell the GL when normal vectors must b e normalized mode can b e

 NAUTO normalize vectors only when the current Mo delView matrix is not orthonor

mal

 NNORMALIZE always normalize vectors disregarding the current Mo delView ma

trix

Even in hardware renormalization can have an adverse eect on the p erformance

void lmdefshort deftype short index short np float props

Denes or mo dies a material light source or lighting mo del deftype can b e one of

DEFMATERIAL DEFLIGHT and DEFLMODEL index is the index of the resource to dene

or mo dify each resource typ e has an unique array of denitions np is the numb er

of entries in the props array props contains the various attributes appropriate to the

typ e of resource The kinds of attributes available for each resource typ e were listed in section

E VOGL ENHANCEMENTS

void ccallshort r short g short b short a

Generic color pro cessing functions All public RGB color functions call this function

The arguments are clipp ed to a limit of Then dep ending on the color mode see

section the current color is set or a sp ecic material characteristic is set

Public functions

void cpackunsigned long argb

Sp ecify a true red green blue color using the packed ARGB format the color com

p onents are packed into one unsigned long as xAARRGGBB The A comp onent is

the alpha transparency comp onent and is currently not used in VOGL

void RGBcolorshort r short g short b

Equal to cpack only sp ecies no alpha comp onent and red green and blue separately

void clentypetype colors

These are various color sp ecication functions which all take a vector an array as input

len determines the length of the vector exp ected and can b e array contains red

green and blue values or alpha comp onent also included type determines the

typ e of the array and can b e s short i long or f oat Colors are clipp ed to a

maximum of If the oat variant of the function is used values are exp ected to b e

in the range For the other functions the range is

E Lighting functions

The following functions are implemented for GL lighting supp ort

Private functions

void calc shadeVertex v

Calculates color of vertex v The supplied Vertex struct should contain the trans

formed vertex p osition in Eye co ordinates When lighting is on the color is calculated

using the vertex normal and lighting mo del Otherwise the vertex is colored using the

current color

void init lightmodulevoid

Initializes the light mo dule by binding all eleven lighting controlling resources to zero

The shading mo del lighting and normalization mo des are also initialize d

Public functions

void lmcolorlong mode

Sp ecies the color mo de The color mo de determines the eect of color commands like

cpack and the c calls The following color mo des are p ossible

APPENDIX E VOGL IMPLEMENTATION DETAILS

Private functions

zbuftype WtoSzVector v

Returns the Screen Zco ordinate of the Vector v which must b e in Clip co ordinates

int zbuffer condition Scoord x Scoord y zbuftype z

Eight zbuer test functions which all return TRUE and up date the Zbuer if condition

is TRUE which can b e never less equal lequal greater notequal gequal and always

Selection of the functions is done by zfunction which sets a function p ointer to

one of the eight functions a case statement is probably to o slow b ecause the selected

function must b e called for every pixel in every geometry

swapbuffersvoid void zbuffer

Swaps the Zbuers only when doublebuering is supp orted and activated

Public functions

void zbufferBoolean onoff

Turns Zbuering on or o

void zfunctionint type

Sp ecies one of eight Zbuer comparison functions that determine if a pixel must b e up

dated or not Possible values for type are ZF NEVER ZF LESS ZF EQUAL ZF LEQUAL

GREATER ZF NOTEQUAL ZF GEQUAL and ZF ALWAYS For instance if ZF LESS is cho ZF

sen a pixel is up dated if the Zvalue of the incoming pixel is less than the existing Zvalue

in the Zbuer

void lsetdepthunsigned long near unsigned long far

Sets the range of Zbuer values that values in clip co ordinates are mapp ed to

void zclearunsigned long zfar

Clears the Zbuer to the sp ecied value

void czclearunsigned long color unsigned long zfar

Clears b oth the Zbuer and the color frame buer This function has b een provided by

the GL b ecause clearing b oth buers at once can often b e done in hardare faster than

clearing the buers separately using the functions clear and zclear This is not

the case in VOGL

E RGB color functions

Since VOGL only supp orted colormap mo de the following functions had to b e implemented

in order to enable the sp ecication of RGB colors

Private functions

App endix E

VOGL implementation details

This app endix describ es the enhancements made to VOGL and the structure of VOGL device

drivers Of the private functions only the most imp ortant are discussed The reader is referred

to the source co de for further detail The public functions are all discussed

E VOGL enhancements

The list of typedefs of VOGL have b een extended with the following new typedefs

 zbuftype This is the typ e used for each entry in the Zbuer It can b e changed

but then also the define for MAXZ must b e changed MAXZ represents the maximum

numb er that ts in the typ e zbuftype

 Vertex This is a structure which holds information ab out vertices It contains the

following memb ers

v vertex p osition in Ob ject co ordinates as sp ecied by the user

eye vertex p osition in Eye co ordinates

clip vertex p osition in Slip co ordinates

sx vertex x p osition in Screen co ordinates

sy vertex y p osition in Screen co ordinates

sz vertex z p osition in Screen co ordinates

r g b a vertex color and transparency when in RGB mo de

color vertex color when in colormap mo de currently not used

E Zbuer functions

The following functions have b een implemented to supp ort Zbuering

APPENDIX D VISD MODIFICATIONS

D VOGL RELATED MODIFICATIONS

vslice is altered it is of course necessary to change When the interface of extract

all the function calls as well The changed vertical slice routine is not enough however

to visualize wind slices correctly The wind vectors are scaled with a constant factor

in the function calc hwind and calc vwind The scaling must b e changed when

pressure levels are used

hwind and calc vwind calc

 Change the scale factor for the W comp onent of the wind

D VOGL related mo dications

In order to use VOGL with visd the following mo dications must b e made

xh

 In xh the VOGL include le voglh must b e included

graphicsc

The graphics mo dule contains all D graphics library sp ecic co de Each function in the

graphics mo dule contains system sp ecic parts for the various graphics libraries used by VIS

D In order to use VISD with VOGL some functions must b e extended with a co de section

sp ecic to VOGL while other functions can use the same co de as the SGI and IBM systems

do es The last co de sections are enclosed by sgi or ibm or VOGL prepro cessor statements

and can b e easily identied Function which are dierent for VOGL with resp ect to the SGI

are

 init graphics Initialization is split in a system sp ecic part and a VOGL sp ecic

part The rst part initialize s the variables ScreenWidth and ScreenHeight to the size

of the screen and the second part sets variables which indicate the functionality that

is available in VOGL such as High Quality rendering and screendo or transparency

 make window This function creates the D window and initializes the graphics mo dule

VOGL must b e instructed to use the window created in this function This is done by

calling the X driver sp ecic function vo xt window Furthermore VOGL do esnt

supp ort screendo or transparency which do esnt have to b e initialized

color Sets the current color and transparency The latter is not set for VOGL  set

 polytrinorm Due to strangeness in the IBM hardware it is necessary to break

p olytriangle strips into individual triangles and test to make sure the normal vectors

are correct Also triangles with zero area must b e culled out Apparently VOGL

suers from the same b ehaviour b ecause the same precautions are necessary when

using VOGL

 Other changes are necessary to disable calls to transparency functions

APPENDIX D VISD MODIFICATIONS

gridc

old grid read

LEVELS  Set the LevelType variable to HEIGHT

read new grid

LEVELS  Set the LevelType variable to HEIGHT

Note that in the function read varNL grid the LevelTyp e is read from the le This

is not conditional the leveltyp e is always available in this typ e les ID x

load dataset grid

 Dep ending on the leveltyp e read from the le or set to the default value ini

tialize the variable pairs BottomCoordinate TopCoordinate and BottomBound

TopBound to the appropriate values For height levels the co ordinate pairs are

equal ie BottomCoordinate BottomBound equals the height of level and

TopCoordinate TopBound equals the height of level MaxNL For pressure

levels BottomBound must b e set to instead and TopBound to MaxNL A warning is

LEVELS is used instead printed if an unknown leveltyp e is encountered and HEIGHT

get grid value

 Implementation of the same typ e interp olation as describ ed in section

renderc

draw box

 When real domain b ounds must b e printed near the b ox corners use the variables

BottomCoordinate and TopCoordinate instead of the variables BottomBound and

TopBound used previously

slice tick draw

 Use BottomCoordinate and TopCoordinate to calculate the level values to place

at slice ticks

workc

extract hslice

 Use linear interp olation for HEIGHT LEVELS and other levels default When

LEVELS however interp olation must b e p erformed using LevelType is PRESSURE

the log of the level pressures The pressure of the level to extract is calculated using

linear interp olation b etween the two adjoining levels and the resulting pressure is

used to calculate new interp olation fractions as describ ed in section

extract vslice

 Logarithmic interp olation of vertical slices is currently not yet implemented but

the places are marked where mo dications must b e made A metho d that can b e

used is describ ed in section

D LOGARITHMIC INTERPOLATION MODIFICATIONS

D Logarithmic interp olation mo dications

The C prepro cessor statements have the following form

ifdef LEVELTYPES

newcode

else

oldcode

endif

A new global variable int LevelType is declared to contain the leveltyp e of the data Cur

rently LevelType can have the following values

HEIGHT LEVELS Metres are used as unit of the vertical co ordinateThis is the default

leveltyp e and used for old COMP les VISD should b ehave as b efore for data dened

at height levels

PRESSURE LEVELS Pascal is used as unit of the vertical co ordinate If data with

this leveltyp e is visualized vertical interp olation is p erformed using the logarithm of

the vertical pressure co ordinate

Furthermore b ecause the vertical co ordinate stored in the Height array do esnt have to

b e the height of the levels in metres anymore these values cant b e used for scaling of the

top ography Two new variables are used BottomCoordinate and TopCoordinate represent

the b ottom and top of the domain in units of the vertical co ordinate The already existing

variables BottomBound and TopBound represent the top and b ottom of the domain in kilome

tres The rst pair of variables is used to calculate values to place at slice ticks ie the real

vertical co ordinates The second pair of variables is used to scale the height of the top ography

etc to the correct height

The following changes have b een made to visd

globalsh

 Declare variables

extern int LevelType

extern float BottomCoordinate

TopCoordinate

and prepro cessor constants

LEVELS HEIGHT

PRESSURE LEVELS

globalsc

Idem as globalsh but only the variables and without the extern class

APPENDIX D VISD MODIFICATIONS

static int compressisovertsvx vy vz

cvx cvy cvz verts numlev

int numlev

This function is obsolete and only changed to preserve consistency

hslice extract

 New interface for extract hslice

static float extracthslice grid level colmajor numlev

int numlev

where numlev is the numb er of levels of the parameter for which to extract a slice

It is used as an upp er b ound for the level to extract

hslice calc

 Mo died function call to extract hslice passing the extra parameter NLparm

vslice calc

 Set the numb er of rows in the vertical slice to the numb er of levels of the parameter

calc chslice

hslice passing the extra parameter NLparm  Mo died function call to extract

cvslice calc

 Set the numb er of rows in the vertical slice to the numb er of levels of the parameter

calc hwindslice

hslice passing the extra parameter WindNL  Mo died function call to extract

for U V and W

 Calculate the Zco ordinate of the horizontal wind slice using WindNL

calc vwindslice

 Set the numb er of rows in the vertical slice to the numb er of windlevels WindNL

calc traj

 Convert from grid to graphics co ordinates using WindNL and check if WindNL is zero

D D FIELDS MODIFICATIONS

 The new slice p osition is scaled using MaxNL but clipp ed to the extra parameter

maxlevel

move vslice

vslice  New interface for move

static int movevslicenumlevels

curx cury rc rc corner

int numlevels

where numlevels is a new input parameter and holds the numb er of levels of the

parameter for which a vertical slice is moved

 Set the numb er of levels of the vertical slice to move to the supplied value numlevels

move slice

hslice and move vslice with the new supplied parameter times  Call move

tra jc

trace

 Set ql the vertical b ox dimensions to the numb er of levels of the wind parameters

WindNL

workc

calc surface

march with the correct numb er of levels NLparm  Call main

 Pass an extra parameter to compress iso verts The numb er of levels must b e

used in that function to scale the Zco ordinates of the calculated isosurface

iso verts compress

 New interface for compress iso verts

static int compressisovertsvx vy vz vpts

cvx cvy cvz verts numlev

int numlev

where numlev holds the numb er of levels of the parameter for which the isosurface

generated must b e compressed If numlev is one a warning is given This should

never o ccur b ecause isosurfaces cannot b e calculated for singlelevel elds

compress iso verts

 New interface for compress iso verts

APPENDIX D VISD MODIFICATIONS

chslices draw

 If a horizontal color slice is drawn for a singlelevel eld initialize the Zco ordinate

of the slice to Zmax instead of doing the division which will b e a division by zero

 Disable the drawing of slice ticks for singlelevel elds color slices

draw hwind

 If a horizontal wind slice is drawn for a singlelevel eld initialize the Zco ordinate

of the slice to Zmax instead of doing the division which will b e a division by zero

 Disable the drawing of slice ticks for singlelevel elds wind slices

draw slice tick

 Calculate the slice tick Zp osition from MaxNL and make sure that MaxNL is greater

than MaxNL could b e if only singlelevel elds are in the data set

 Idem as ab ove now to calculate the slice tick level value

savec

save

 Calculate the correct numb er of bytes to save using NLip

 Write the correct numb er of ga gb and grid values using NLip

restore

 Read the correct numb er of ga gb and grid values using NLip

slicec

to hslice distance

 Calculate the normalized slice level using MaxNL and check if MaxNL is greater than

one

find nearest slice

 Skip singlelevel eld slices when searching for the slice nearest to a given cursor

p osition These slices have no slice tick so they cant b e moved

 Do the same for color slices

 Do the same for wind slices

move hslice

 A new interface

static int movehslicecurx cury level corner maxlevel

int maxlevel

with a new variable which holds the upp er b ound on the slice movement

D D FIELDS MODIFICATIONS

 Use NLip instead of Nl as upp er b ound for the forlo ops

decompress

 The mo died decompress interface

static int decompress ip data compdata ga gb

int ip

with an added ip parameter to use as index into the NL array

 Use NLip as upp er b ound for the forlo op

guic

create widgets

 Create no buttons for singlelevel elds for isosurfaces and vertical slices

button row add

 When a new button row is created for clone and analysis variables disable the

isosurface and vertical slice buttons if the variable has only one level

init new var

 Initialize the horizontal slice level to NLnewvar This will b e zero for

singlelevel elds which is correct

 Do the same for horizontal color slices

mainc

initialize

 Initialize the horizontal contour and color slice levels of all physical parameters to

levels as in guic

 Initialize the horizontal wind slice levels to WindNL

 Initialize the D cursor p osition to the middle of the b ox MaxNL

renderc

init box

 Initialize the scale of the b ox using MaxNL instead of Nl

box draw

 When plotting grid dimensions at the corners of the b ox MaxNL should b e used

draw hslices

 If a horizontal contour slice is drawn for a singlelevel eld initialize the Z

co ordinate of the slice to Zmax instead of doing the division which will b e a division

by zero

 Disable the drawing of slice ticks for singlelevel elds contour slices

APPENDIX D VISD MODIFICATIONS

 Use a new more dicult calculation to nd the le address in a McIDAS GRID

le This is more dicult b ecause the grids can vary in size First the total size

of one time step is calculated Then the oset in the current time step is found

and is added to timestepnumbertimestepsize Returned by the function is the

sum of the value calculated and the size of the header which is calculated in

read variableNL grid

from disk read

 Add the new le format When a variableNL typ e COMP le is used it is p ossible

to read the original data from the McIDAS GRID le on disc

 Use the numb er of levels of the current parameter to read the ga gb values and

to allo cate the correct grid size

 Read the correct numb er of bytes from the le the oset is calculated by

grid address

grid get

 Allo cate a buer of the right size using NLip ip was already available as a

parameter thankfully

 Get the address of the ga gb values for the grid to compress using the new macros

 Decompress the data using a mo died version of the function decompress The

parameter numb er ip is passed as an extra parameter

release grid

 Deallo cate is called with the mo died grid size as an extra parameter

grid value get

 If the lev value to nd a value at exceeds the total numb er of levels available for

the requested parameter return a missing value

 Mo dify the upp er b ound check of k the level grid index of the p oint to obtain

and if the parameter has only one level available set b oth level grid indices to zero

Interp olation in a cub e is not p ossible in this case

allocate clone variable

 Initialize the NL array entry for the new clone variable to the value of the original

variable the one b eing cloned

 Use the new numb er of levels as upp er b ound in the forlo op

analysis variable allocate

 Set the NL array entry for the new variable to b ecause no levels are yet

calculated by the external analysis function

new grid install

 Use the macro COMPSIZE to calculate the grid size

D D FIELDS MODIFICATIONS

old grid read

 When the program is compiled with the prepro cessor symb ol VARIABLE NL dened

it must still b e p ossible to read the old COMP formats see app endix A for a

description of the various le formats VISD can handle Therefore the old

functions must b e patched in the following way

Read the single value tempNL from the le and copy it into every used entry

of NLMAXPARMS Also initialize MaxNL to tempNL Initialization of WindNL is

delayed until the parameters are scanned for existance of the U V and W

parameters later in gridc

Allo cate the buers for ga and gb changed in size use MaxNL instead of Nl

When reading the ga and gb values from the le use NLip as upp er b ound

of the forlo op instead of Nl b ecause Nl no longer exists

Allo cate a buer for the grid data size has changed now uses the COMPSIZE

macro

Read the grid from the le size has changed now uses the COMPSIZE macro

read new grid

 Read the single value tempNL from the le and copy it into every used entry of

NLMAXPARMS Also initialize MaxNL to tempNL Initialization of WindNL is delayed

until the parameters are scanned for existance of the U V and W parameters later

in gridc

 The new grid format contains a Height array of values given the height values of

the grid levels The size of this array is MaxNL

new grid are analog to the changes to The rest of the changes to the function read

old grid from the ga gb buer allo cation onwards read

read variableNL grid

 A new function is written to read the new format COMP les describ ed in ap

p endix A This function is just a straightforward implementation that reads the

new le format The functions read oldnewvariableNL grid are much alike

data set load

 This is the main function that calls one of the functions read old grid

new grid or read variableNL grid Prior to loading the data set the read

whole NLMAXPARMS array is set to This can make p ossible bugs go real wrong

and is intended to sp ot p ossible bugs more easy

variableNL grid func  Another if id is inserted to call the new read

tion The FileFormat variable is given the value the rst unused value

 After reading the data set the variable WindNL is set to the minimum of the numb er

of levels of the parameters U V and W if they are available If none of them is

available WindNL will have the value again to make bugs more apparent

 Set the TopBound of the domain using MaxNL instead of Nl

grid address

APPENDIX D VISD MODIFICATIONS

where numlevels is the new parameter and is used seven times in an upp er b ound

on the numb er of iterations of forlo ops

get mcgrid

mcgrid interface  The changed get

getmcgrid file grid data numlevels

int numlevels

where numlevels is the numb er of levels to read from the McIDAS GRID le This

value is used to verify the read op eration to check if the correct numb er of levels

is read

globalsc globalsh

 Declaration of the following global variables

int NLMAXPARMS MaxNL WindNL

These are describ ed earlier in this section

gridc The following COMP or grid formats are mentioned

old grid format equal numb er of levels for each grid grid by grid compression

grid format equal numb er of levels for each grid layer level by layer compres new

sion

VariableNL grid format variable numb er of levels for each grid layer level by layer

compression

 In the grid mo dule buers are created to store the ga and gb values of each level

for all parameters and all time steps Entries from this buer are set and obtained

by two macros which are mo died to the following

define GAITIPLEV GaIT MAXPARMS IP MaxNL LEV

define GBITIPLEV GbIT MAXPARMS IP MaxNL LEV

where IT is the time step IP the parameter and LEV the level to obtain or set a ga or

gb value for The array contains gaps b ecause for every parameter MaxNL values are

stored to simplify the indexing Because every grid has its own size it is imp ossible

to use the variable CompSize which was initialized to NrNcNl the

numb er of oats in a grid Therefore a new macro is dened

define COMPSIZEip NrNcNLip

This macro must b e used instead of the old variable CompSize If the parameter

numb er ip is not available it must b e provided by mo difying function interfaces

D D FIELDS MODIFICATIONS

INTEGER FUNCTION VARNLUSERFUNC OUTGRID MAXNL OUTNL

INGRID SUMNL

NR NC NL NLIDX NP

NAMES DATE TIME

SOUTH WEST BOTTOM

DELTALAT DELTALON DELTAHGT

C ARGUMENTS

INTEGER MAXNL OUTNL SUMNL NR NC NP

INTEGER NLNP NLIDXNP

REAL OUTGRIDNRNCMAXNL

REAL INGRIDNRNCSUMNL

CHARACTER NAMESNP

INTEGER DATE TIME

REAL SOUTH WEST BOTTOM

REAL DELTALAT DELTALON DELTAHGT

References to the output grid are not changed outgridir ic il references

grid lo cation row ir column ic level il as normal References to the input grid

are changed in the following way The old intuitive manner of referencing ingrid

to read grid lo cation ir ic il of parameter ip

ingridir ic il ip

now b ecomes

ingridir ic NLIDXip il

which is only slightly less intuitive

 The compress routine compress grid must know the numb er of levels to com

press so this value is passed as an extra integer parameter The new interface is

describ ed b elow in this mo dule

 The proto col of the output grid sent back to visd has changed First the numb er

of levels in the output grid is sent then the grid data The numb er of ga and gb

values sent back also changed b ecause there is one such value for each level in the

output grid

compress grid

 The changed compress grid interface

compressgrid data comp min max levga levgb numlevels

int numlevels

APPENDIX D VISD MODIFICATIONS

 The receive proto col is changed The external functions sends the numb er of levels

in the grid that it has computed Dynamic allo cation of two buers one for the

uncompressed grid received the other for a compressed grid calculated is done

using this value After receiving the grid the compression values ga and gb are

received one of each for every level in the output grid

cursorc

cursor event

 Scale the cursor Zco ordinate using MaxNL the size of the b ox expressed in numb er

of levels

extmainc This mo dule is separated from visd in that it is not linked with visd but is

linked instead with every external analysis functions The external analysis function is

called from extmainc

 Declare the following new global variables

int NLMAXPARMS Number of levels for each parameters

MaxNL Largest number of levels in NL

SumNL Sum of all levels in NL

NLindexMAXPARMS Cumulative sum of levels in NL

call user function

 Declare a new integer variable to pass to the external analysis function After

execution of the external analysis function it contains the numb er of levels in the

output grid

 Receive an array of Nls one for each parameter instead of one These values are

stored in NLMAXPARMS and MaxNL SumNL and NLindex are calculated during the

reception of the NL array

 Allo cate storage for all the input grids of one time step and the output grid A total

time step has NrNcSumNL oats The output grid must b e allo cated worst case

ie the largest numb er of levels MaxNL b ecause it is not known in advance how

many levels the external analysis function will compute Also worst case buers

are allo cated for the ga and gb values and the compressed grid

 Storing of the input grids received from visd is done using NLindex If the

input buer of size NrNcSumNL is seen as an array of levels then NLindex gives

the start index for each parameter in this array

mcgrid which now  Read a grid from a McIDAS GRID le using the function get

takes the numb er of levels to read as an extra parameter change describ ed b elow

in this mo dule

 The interface of the external analysis functions has b een changed It now lo oks like

D D FIELDS MODIFICATIONS

D D elds mo dications

The C prepro cessor statements have the following form

ifdef VARIABLENL

newcode

else

oldcode

endif

The following extra or new global variables are declared

 int NLMAXPARMS to hold the numb er of levels for each parameter Note that the low

ercase l in the old single integer Nl has b een changed delib erately to make the compiler

generate a lot of errors which has help ed in nding the places where mo dications had

to b e made

 int MaxNL contains the maximum of all the numb ers of levels of all physical variables

MaxNL represents the size of the viewb ox in levels and must b e used in every op eration

that needs the height of the b ox

 int WindNL contains the minimum numb er of levels of the three parameters U V and

W which are used for wind tra jectories and wind slices This variable is intro duced for

safety only In practice the user could present VISD with a le containing dierent

sized U V and W grids Using the WindNL variable VISD will only use the levels

available for all three parameters

The following list of mo dication descriptions is alphab etically ordered by mo dule and the

mo dications made to each mo dule are listed from top to b ottom Line numb ers have b een

omitted b ecause these are sub ject to change Instead mo died functions are listed b etween

parentheses

analysisc

compute analysis variable

 Send a Nl value numb er of levels for each parameter instead of just one at the

b eginning to the external analysis functions The co de that handles reception of

the data can b e found in the mo dule extmainc

 Send a variable sized grid to the external analysis function The size in oats is

given by the formula NrNcNLip where Nr is the numb er of rows of the grid Nc

the numb er of columns and NLip the numb er of levels of the current parameter

ip

 Declare a new integer variable to receive an extra integer from the external function

the numb er of levels in the grid it will send thereafter

APPENDIX D VISD MODIFICATIONS

 The appropriate MAKECOLOR macro must b e dened For HP systems this the same

macro as for SGI and IBM systems

extmainc

 On HP systems the signed keyword is invalid in the typ edef for int

globalsh

TASK  Dene the symb ol SINGLE

 Dene a new typ e int as char

graphicsc

graphicsc contains all D graphics library related co de Most changes are related to

VOGL see app endix D Currently the following parts are HP sp ecic

 Initialization of integers holding the current screen size

 Setting of le format ags VISD can save XWindows dump for HP

mainc

main

CORE is not dened for HP Therefore the core dump disabling  The symb ol RLIMIT

has b een turned o for HP

 The font command line option is available on HP so notify the user when the

command line options are printed

 Scan the command line arguments for the font option

 Call the main pro cessing function main loop for HP b ecause HP is a single

threaded system

matrixh

 Include xh to dene the Matrix typ e

xh

 Include the graphics library and XWindows header les

App endix D

VISD mo dications

This app endix contains high level descriptions of the mo dications made to VISD The

accent lies on the reasons for the mo dications For details ab out the implementation of the

changes the reader is referred to the source co de of visd All changes have b een marked by

prepro cessor statements for easy nding of the changes and backward compatibility an old

version of VISD without this mo dications can easily b e restored this way should problems

arise due to the mo dications The changes are ordered alphab etically by mo dule name

The name of the mo died function is listed b etween parentheses

D HP p ort mo dications

D LUI changes

luic

MoveResizeWindow LUI

 Set XSizeHints of the window by calling XSetNormalHints and

XSetStandardProperties The p osition and size must b e set but also the max

imum size of the window Otherwise all VISD windows can b e resized to full

screen size

LUI ResizeWindow

 Same as the change for LUI MoveResizeWindow but only the size and maximum

size have to b e set not the p osition

D visd changes

cwc

APPENDIX C LIBRARIES

C RUL LIBRARIES

C gribvis

cmdline arguments Parse the command line arguments and store the results in pro cess

global variables If a variable is not set a default value will b e taken if appropriate

otherwise an error is rep orted

grid header Allo cation and initialization where p ossible of the GRID le header init

write grid header Write the GRID le header to a le

grid Write a grid to the current output le write

print grid info Print selected contents of a sp ecied grid information structure

timesteps Determine the numb er of time steps in a sp ecied time range count

APPENDIX C LIBRARIES

C cutil

The headers of the cutil functions can b e found in the header le cutilh

yymmddcenturyday Convert the date in yymmdd format to century day

centurydayyymmdd Convert the century day to the date in yymmdd format

hhmmminutes Convert time in hhmm format to minutes since midnight

minuteshhmm Convert the minutes since midnight to the time in hhmm format

iallo c Allo cate oat buer and terminate if error o ccured

ifree Free oat buer and warn if error o ccured

icheck Check if p ointer equals NULL and warn when this is the case

reorder matrix Reorder the input matrix from rowma jor to columnma jor

mirror matrix Mirror the matrix around the horizontal axis

sort Sort an array of integers in ascending or descending order

rep ortminmax Calculate the minimum and maximum of data and rep ort them

getstring Read a string enclosed in double quotes from buer

C futil

These are functions that are not in the KNMI libraries or are a small section of functions

from the KNMI libraries

calcq Calculate the relative humidity

iyyddd Conversion from century day days since januari to the date in yyddd

format

setfortrancommon Set the variables to indicate the presence or absence of physical pa

rameters This function should rst b e called b efore using the interp olation routine

intpre Physical variables not present will b e calculated by intpre if p ossible

conphys Dene the physical constants used by the interp olation routines

ab ort A routine to simulate the ab ort function which is not known to the HP FORTRAN

compiler

getarg A routine to simulate the command line argument pro cessing function getarg not

known to the HP FORTRAN compiler

C RUL LIBRARIES

C grib

The headers of the grib functions can b e found in the header le gribh

grib parnumvalid Private test whether a passed physical variable is within the range of

the current parameter table size Returns TRUE when the parameter numb er is valid

FALSE otherwise

shortname Return p ointer to the short parameter name if the parameter numb er is grib

valid Otherwise a p ointer to NA Not Available is returned

unit Return p ointer to the unit of the passed parameter if the parameter is within grib

range Otherwise a p ointer to NA is returned

grib parname Return p ointer to the full parameter name if the parameter numb er is valid

Otherwise a p ointer to NA is returned

listparameters Print a list of physical variables as dened in section of the grib grib

denition

grib parnumfromname The parameter name that is passed invoking the function is re

turned as the parameter numb er if it exists

C interp ol

The headers of the interp ol functions can b e found in the header le interpolh For more

information ab out co ordinate systems see section C

calcmo delparameters Calculate the half and full mo del level parameters and interp olate

the pressure half and full mo del level parameters

interp olate calcindexarray Calculate index eld that maps output gridp oints to input

gridp oints with the help of the KNMI routine defind

init Initialize all global variables used for the interp olation The information interp olate

ab out the gridsize is passed in the Asimof Information structure The parameters ini

tialized are the data grids of the surface pressure the surface temp erature and the full

level parameters temp erature U V and the sp ecic humidity Also the mo del level

parameters are calculated These parameters are used by the interp olation

interp olate destroy Free all allo cated blo cks and unset all variables set by the routine

init interp olate

interp olate pressure Interp olate a D data grid to pressure levels according to the passed

Asimof Variable structure input grid and output grid with the help of the KNMI routine

intpre

APPENDIX C LIBRARIES

C asimof

The information needed for calling the functions loadfd and getfd is stored in the Asimof

Variable AsimofVars structure The grid information from an ASIMOF le is stored in the

Asimof Information AsimofInfo structure The exact headers of the asimof routines in this

section can b e found in the le asimofh The following routines are implemented in the

mo dule asimofc

allo cvars Allo cate and initialize an Asimof Variable structure with the parameter asimof

values If an input parameters is the default value from asimofh is used The

output is a p ointer to an allo cated and lled AsimofVars structure

asimof freevars Free all blo cks used by the Asimof Variable structure and memory used

by the structure itself

asimof op en Op en the ASIMOF grib database with the help of the function loadfd from

the KNMI p ort library and ll the Asimof Variable structure with all relevant data from

the ASIMOF le Returns the errorco de as returned by loadfd

asimof close Close the ASIMOF grib database connected to the device describ ed by the

Asimof Variable structure with the help of the function asimhc Returns the errorco de

as returned by asimhc

geteld Get a eld from the ASIMOF database le with the help of the function asimof

getfd Returns the errorco de as returned by getfd

asimof imdi Returns the key entry not used indicator

asimof setkey Fill the given key with imdi key entry not used values and insert values

given as routine parameters The function has a variable numb er of arguments

destagger Destagger data to a grid dened by the Asimof Variable structure Destaggering

of the data is necesssary when the grid co ordinates are not the same as the grid data

co ordinates used by visd

asimof getdata Extract data elds from the ASIMOF le The actual reading of the

getfield The parameter and level typ e of data in done with the function asimof

the physical variable to extract can b e sp ecied with the function parameters When

no level numb er is sp ecied this function extracts all data matching the parameter

and level typ e When more than one level numb er is found the levels are sorted from

b ottom level to top level Also the visd grid information structure is lled with values

known at that p oint When necessary the data array is destaggered with the function

destagger see section C Optionally the data array is reordered to row ma jor and

is mirrored across the horizontal axis see section C

asimof getco ordinates Calculate the GRIB co ordinates of an input eld using the integer

section with the help of the function gbgfc Returns the numb er of grid p oints found

C RUL LIBRARIES

pint Vertical interp olation of geop otential from a hybrid mo del level to pressure levels

intpre Organization of the interp olation to pressure levels during p ostpro cessing

omint Vertical interp olation of OMEGA vertical velo city

p ostpp Main routine for p ostpro cessing to pressure levels and to mo del levels This routine

also handles the extraction of surface parameters It calls at ab out all vertical inter

p olation routines describ ed in this library Because the many parameters involved in

calling this function we prefered to call the separate interp olation functions

tpint Vertical interp olation of the temp erature to pressure levels

vineta Vertical interp olation from one level into another level

xpint Vertical interp olation from mo del levels to a pressure level

xtreta Organization of the extraction of mo del level data during p ostpro cessing

C grw

asddr Op en an ASIMOF le and contruct the DDR from it

grclos Interface for the function asimhw

gread Read blo ck and blo ck from an ASIMOF le and print the DDR

grop en Interface to the routine asddr and ASIMOF

gwclos Interface for the routine asimhc

gwop en Load blo ck and blo ck from an ASIMOF le and contruct the DDR

gwrite Prints the DDR for a GRIB co ded HIRLAM eld le and writes the blo cks to an

ASIMOF le

priddr Prints the DDR for a GRIB co ded HIRLAM eld le

C RUL libraries

Information and denition of the GRID le header and the D grid information blo ck can

b e found in the header le griddh

APPENDIX C LIBRARIES

grib ex Co ding and deco ding of GRIB le format messages

minmax Calculate minimum and maximum values from an array of oating p oint numb ers

C util

cddat Converts century day numb er of the day in this century to daymonthyear format

ddmmyyyy

convdt Converts daymonthyear format ddmmyyyy to century day dddd

diasim Diagnose an ASIMOF le diasim can b e run with two options The option h will

print an extensive header and s will print the statistics of the eld data No option

will just print the GRIB section values of all variables

gregor Converts Julian day numb er into Gregorian normal date year month day

icymd Converts century day to day month and year

idatc Converts a given day month and year into century day

C vari

gbgcc Transform co ordinates describ ed in input section GRIB format to co ordinate

system describ ed in output section

gbllc Transform from one latitudelongitude grid to another This function is mainly used

to transform from or to the geographical system

gblp c Transform from geographical grid to p olar stereographical grid

gbplc Transform from p olar stereographical grid to latitudelongitude grid

gbslc Shift p ole of regular latitudelongitude grid

gbtlc Stretch regular latitudelongitude co ordinates toward the north p ole

C prp o

dend Denition of a p ointer eld to b e used for the extraction of gridp oint values in a

subarea from a gridp oint eld dened in a larger area

destag Destaggering of wind comp onents to t the analysis program conventions This

program is used when the gridp oints of the wind comp onents are not the same as the

gridp oints of the system

etaeta Vertical interp olation from one level into another level

App endix C

Libraries

In this app endix the most imp ortant routines from the KNMI and RUL libraries are listed

For more detail the reader is referred to the inline do cumentation of the libraries

C KNMI libraries

C p ort

asimhc Close an ASIMOF le

asimhr Read an array from the ASIMOF le If the key passed along do es not exists in the

database an error is returned

asimhw Write an array into the ASIMOF le If the key passed along is not unique an error

is returned

getfd Get a co ded eld from the ASIMOF database and deco de a eld from GRIB This

function calls the functions asimhr and degrib see app endix C

loadfd Op en a directaccess le as GRIB database If the le exists the contents will b e

extracted else the le will b e op ened with an empty table of contents

putfd Convert a eld into GRIB format and place it in an ASIMOF database This function

calls the functions asimhw and engrib see app endix C

C gco d

degrib Deco ding of data or identication sections section and from GRIB format

enco de Enco ding of data in GRIB format

APPENDIX B VISD SOURCE CODE STRUCTURE

B LITTLE USER INTERFACE LUI LIBRARY

getd Read a GRID le to obtain the grid info structures

iggtd Read a data grid from a GRID le returning the numb er of data p oints read This

function is used from within visd

For a description of the VISD utilities see section

B Little User Interface LUI library

The LUI library contains the following mo dules

browser File browser mo dule

button Provides functions to create and maintain all sorts of buttons like toggle buttons

oneshot buttons etc Buttons can b e group ed in button pads

dial Provides functions to create and maintain dials

dialog Provides functions to create dialog b oxes which can contain a message and OK and

Cancel buttons

event Event dispatcher Each window created by the LUI library can sp ecify events and a

call back function This call back function is called only for the sp ecied events

lab el Provides text lab els and typ eins

lui Main LUI mo dule that contains the LUI initialization and most functions dealing with

windows It also contains various color transformation functions

pixmaps Contains pixmap denitions for radio widgets

p opup Handles p opup menus

slider Slider supp ort The user can use sliders to adjust a value used by the program

APPENDIX B VISD SOURCE CODE STRUCTURE

INTEGER DATE Datestamp of variables in HHMMSS format

ie hours minutes seconds

INTEGER TIME Timestamp of variables in YYDDD format

ie year century day

REAL SOUTH WEST BOTTOM Geographic location of grids SOUTH

latitude in degrees WEST longitude

in degrees BOTTOM coordinate in

kilometres

REAL DELTALAT DELTALON

DELTAHGT Grid increments DELTALAT and DELTALON

in degrees DELTAHGT in kilometres

A user function should return if completed successfully and a nonzero value if an error

o ccured

The extmain mo dule contains co de to receive the input data from visd through a so cket

and send the output grid back to visd The user functions is called from extmain

B Utilities

The most imp ortant utility mo dules include the following

compd Conversion of McIDAS GRID les to COMP les the compressed visd le for

mat There are several compd programs one for each typ e of COMP le see ap

p endix A The structure of the compd programs is as follows

 Read the rst time step grid info structures checking that every physical variable

has the same numb er of levels etc

 Read the following time steps grid info structures checking if the same physical

variables are encountered as in the rst time step

 Allo cate memory to hold input grids

 Read input grids from input GRID les

 Compress grid data

 Write grids to output COMP le

 Write header of output COMP le

Note that the time steps must b e ordered chronologically and the order of the physical

variables must b e the same for each time step

compinfo Read and display contents of COMP les

The rest of the programs can only handle the McIDAS GRID le format The most imp ortant

subroutines are

B EXTERNAL USER FUNCTIONS

slice Slice handling functions This mo dule pro cesses all events that o ccur when visd is

in slice mo de The most imp ortant function is to nd the correct slice and moving it

when the user drags from a sp ecic p osition in the D window

so cketio Provides functions to send and receive data through a so cket These functions are

used to send to and receive from the external analysis functions

sync Provides semaphore functions for systems that allow multithreaded execution

top o Functions for reading and drawing the top ography

tra j Tra jectory mo dule Tra jectories are traced using this mo dule

vtmcp Mo dule dedicated solely to the calculation of isosurfaces

work This mo dule contains the actual routines to extract contour color and wind slices an

interface to the isosurface and tra jectory mo dule

zcont Contouring mo dule Given an input slice of data and a contour interval it calculates

the p osition of contours on the slice and outputs vector arrays containing the contour

p ositions

The mo dules guic and cwc contain all the user interface functions making use of the LUI

library For the direct reading of McIDAS GRID les visd uses the McIDAS GRID le

library

B External User functions

The Fortran mo dules must all contain a function called USERFUNC with the following in

terface

INTEGER FUNCTION USERFUNC OUTGRID INGRID NR NC NL NP

NAMES DATE TIME

SOUTH WEST BOTTOM

DELTALAT DELTALON DELTAHGT

REAL OUTGRIDNRNCNL Output grid calculated by the function

REAL INGRIDNRNCNLNP Input grids all physical variables

one time step

INTEGER NR Number of latitude points rows in

input grids

INTEGER NC Number of longitude points columns in

input grids

INTEGER NL Number of levels in input grids

INTEGER NP Number of physical variables

CHARACTER NAMESNP Names of variables Padded with spaces

APPENDIX B VISD SOURCE CODE STRUCTURE

function of visd needs a data grid it must b e requested from the grid mo dule Grids

are stored in a compressed form in memory and are decompressed when requested The

decompression routine uses two values which are also stored in a compressed grid le

ga and gb These values are used to scale and map oating p oint values fromto bit

integers This conversion cannot b e done without losing precision visd is able to read

the original GRID les with the oats as well see also app endix A

gui The GUI Graphical User Interface mo dule takes care of the creation and maintenance

of all windows except for the D window which is created in the graphics mo dule

GUI pro cesses all user input from the mouse and the keyb oard and up dates appropriate

global variables contained within the globals mo dule which determine how the data set

is displayed GUI makes extensive use if the User Interface Library LUI discussed in

section B

main Entryp oint of visd After initialization pro cessing command line parameter reading

of the data set etc an eternal lo op is executed pro cessing user input

map Contains functions to read a map le draw the map in the D window and up dat

ing the display if necessary A map le usually contains a numb er of line segments

dening landsea b orders and country outlines The elevation is calculated from the

top ography

matrix visd uses its own library routines of matrix op erations to create and mo dify the

transformation and pro jection matrices used to map ob ject co ordinates into the D

window see section Matrix multiplication concatenation copying inversion

vector normalization and vectormatrix multiplication is provided

memory Memory management mo dule visd functions needing large amounts of memory

should call one of the functions from this mo dule visd tries to retain all requested

graphics in memory When allo cation of a requested blo ck fails however the memory

management mo dule will try to create enough free memory by deallo cating the least

recently viewed graphics A numb er of functions is provided Memory allo cated using

pallo cate p ermanent allo cate will never b e deallo cated contrary to memory allo cated

by allo cate

queue Implementation of a task queue When only one pro cessor is available the requested

graphic will b e calculated immediately On systems with multiple pro cessors multi

threaded execution is p ossible Each requested graphic is put into the task queue

Pro cessors will calculate the graphics in the queue multithreaded Access to graphics

is made exclusive through the use of semaphores

render The render mo dule contains the drawing functions which are all based on the graph

ics mo dule The b ox slices tra jectories slice ticks clo ck etc are drawn from within

the render mo dule

save VISD allows the user to save the current state of the D window to a le Data

saved includes top ography colors lab els and graphics with their colors and p ositions

Such a le can later b e restored

App endix B

VISD source co de structure

B VISD main source co de

visd version is split into several mo dules The most imp ortant mo dules include in

alphab etical order

analysis Activation of activate external user analysis functions which can calculate new

grids from the available data Analysis programs must reside in a sp ecial directory

which is scanned by visd When an analysis function is activated all available data

one time step at the time is sent through the so cket to the analysis program The

analysis program can calculate a new grid of data derived from the existing data This

new grid is then sent back through the so cket to the analysis mo dule of visd When

successful the new grid is installed and can b e visualized as usual

extmain Wrapp er for visd external analysis co de It is linked separately with every ex

ternal analysis function It receives the grid description and data through the so cket

connection with visd and calls the user analysis function The grid description and

data are passed as parameters to the analysis function The interface is describ ed in

section B

globals Contain declarations of globally accessible variables and constants The most im

p ortant variables include the grid dimensions and the grid data p ointers

graphics All D graphics library related co de is contained in the graphics mo dule It

contains functions to make the D window initialize the graphics mo dulelibrary draw

p olylines text triangle meshes quadrilateral meshes etc All functions in the graphics

mo dule are based up on functions from the D graphics library XFDI for the Stellar

GL for the SGI and IBM Functions from other mo dules call functions from the graphics

mo dule if they want something drawn in the D window

grid All grid management functions are contained in the grid mo dule grid will determine

the le format of an input le and read the data sets contained within the le If a

APPENDIX A F ILE FORMATS

int offset Offset in byte ints from start of file

int length Length of segment data in byte ints

 Co ordinate information for each segment The p osition and length of the data is ob

tained from the directory structure The data consists of an array of l eng th l at l on

5

pairs in degrees

A VISD top ography le format

A VISD top ography le contains the surface elevation and landsea mask of a sp ecic part

of the earth surface Each le starts with the following header

char id ID string TOPO

int westlon West longitude in s of degrees

int eastlon East longitude in s of degrees

int northlat North latitude in s of degrees

int southlat South latitude in s of degrees

int rows nlat Number of rows latitude

int columns nlon Number of columns longitude

Positive latitude degrees are north p ositive longitude degrees are west

After the header the top ography data follows

short datarowscolumns

Row corresp onds to the north edge of the top ography Row ROWS corresp onds to the

south edge Column corresp onds to the west edge and Column COLUMNS corresp onds

to the east edge The shorts of the top ography data consists of the surface elevation in

metres multiplied by and with added if the lo cation is water

A VISD MAP FILE FORMAT

int GRIDTIMES Maximum numb er of time steps

int NumTimes Numb er of time steps

int NumParms Numb er of parameters

int Nr Nc Horizontal grid dimensions global ie

for all grids

int NLNumParms A numb er of levels for every parameter in the le

oat LatInc LonInc Horizontal grid increments in latitude and

longitude direction

int LevelTyp e Typ e of vertical co ordinate

oat HeightNl Levelvalues unit dep ends on leveltyp e

char ParmNameGRIDPARMS Names of parameters

oat MinValNumParms Minimum values of parameters

oat MaxValNumParms Maximum values of parameters

int TimeStampGRIDTIMES Timestamp of time steps

int DayStampGRIDTIMES Daystamp of time steps

oat NorthLatGRIDTIMES North latitude of domain

oat WestLonGRIDTIMES West longitude of domain

The data grids vary in size The size can b e calculated using the NL values from the array

and are again rounded up to a multiple of four

for each time step

for each parameter

int McFile McIDAS GRID file number with original data

int McGrid Grid number in GRID file

float gaNLip

float gbNLip Decompression values for each level ip is

the parameter index

float griddata Data for this grid consisting of NrNcNLip

floats rounded up the nearest multiple of

A VISD map le format

A VISD map le holds information of landsea b orders etc as a numb er of continuous

p olylines map segments A map le has the following structure

 Numb er of map line segments

int nsegs

 Directory structure containing for every segment

int d d d d Not used

APPENDIX A F ILE FORMATS

int GRIDTIMES Maximum numb er of time steps

int NumTimes Numb er of time steps

int NumParms Numb er of physical variables

int Nr Numb er of rows latitude p oints

Nc Numb er of columns longitude p oints

Nl Numb er of levels

oat LatInc LonInc Horizontal grid increments in latitude and

longitude direction in degrees

oat HeightNl Heights of levels in km

char ParmNameGRIDPARMS Names of physical variables

oat MinValNumParms Minimum value of physical variables

oat MaxValNumParms Maximum value of physical variables

int TimeStampGRIDTIMES Timestamp of time steps HHMMSS format

int DayStampGRIDTIMES Daystamp of time steps YYDDD format

oat NorthLatGRIDTIMES North latitude of domain in degrees

oat WestLonGRIDTIMES West longitude of domain in degrees

There is now slightly more data for each grid than in the case of the old style format due to

the extra decompression values

for each time step

for each parameter

if IDx

int McFile McIDAS GRID file number with original data

int McGrid Grid number in GRID file

fi

float gaNl gbNl Decompression values for each level

float griddata Data for this grid consisting of NrNcNl

rounded up to the nearest multiple of floats

A Variable NL format

This is the new style format made to enable the of singlelevel elds The header

lo oks like

A COMP FILE FORMAT

 Variable NL format new style format with layer by layer compression GRID le read

and a variable numb er of levels for each parameter

A Old style format

Grid compression is done grid by grid entire grid at the time The maximum numb er of time

steps GRIDTIMES is for IDx and for IDx The maximum

numb er of parameters GRIDPARMS is for IDx and for IDx

The following typ elengths are used char is byte int is bytes float is bytes

The header lo oks like

int NumTimes Numb er of time steps

int NumParms Numb er of physical variables

int Nr Numb er of rows latitude p oints

Nc Numb er of columns longitude p oints

Nl Numb er of levels

oat LatN LonW Geographic lo cation in degrees

oat HeightTop Height of highest grid level in km

oat LatInc LonInc Horizontal grid increments in latitude and

longitude direction in degrees

oat HeightInc Vertical grid increment in km

int DayStampGRIDTIMES Daystamp of time steps in YYDDD format

Note that the le always contains GRIDTIMES

DayStamps despite the numb er of time steps

int TimeStampGRIDTIMES Timestamp of time steps in HHMMSS format

char ParmNameGRIDPARMS Names of parameters

Then the data follows in the same order as the time stamps and variable names

for each time step

for each parameter

float ga gb Grid decompression values

float griddata Data for this grid consisting of NrNcNl

rounded up to the nearest multiple of floats

A New style format

Compression of the grids is done layer by layer and extra information is contained within the

le to retrace the origin of the grids the McIDAS GRID le and grid numb er in the le to

enable visd to read the original uncompressed grid data only for IDx The

header lo oks like

APPENDIX A F ILE FORMATS

co ordinate unit to visd Therefore the eld pad is replaced by

int leveltyp e Indicator of unit of vertical co ordinate system on

which grid is dened

int pad Reserved now one integer less

The following values for the leveltyp e are currently valid

LEVELS This is the default leveltyp e and set for old HEIGHT

style COMP les The unit of the vertical

co ordinate is km

LEVELS Indicates equidistant pressure levels Vertical PRESSURE

interp olation b etween levels will b e done using the

logarithm of the pressure The unit of the vertical

co ordinate is Pa

The contents of the top and topinc entries must b e changed These will contain the pressure

level of the highest level and the pressure level increment b oth multiplied by if the

leveltyp e is PRESSURE LEVELS Otherwise the contents will b e the same as b efore height

level and height increment

The data grids are stored as byte oating p oints numb ers A data value greater than e

indicates missing data usually the value e is used

A COMP le format

The COMP compressed le format is the only format that can b e read directly into visd

VISD is supplied with skeleton example programs for converting data into COMP le format

and utilities for converting the GRID le format see app endix A into COMP les During

this conversion all data p oints in the grids are compressed from byte oating p oints values

to bit integers hence the name of the format Because this compression results in loss of

accuracy it is p ossible to read grids from the uncompressed GRID les when they are needed

for calculations by visd The compression uses two oating p oint values g and g These

a b

(g +g )

max 250

min

the range and g g  the oset values are equal to g

b a a

(g g ) 2

max

min

of the input grid data New compressed data values are then calculated using the formula

g g  g g

new a old b

There are several COMP le formats which are identied by an ID eld in the rst bytes

in the le The following ID elds are valid

 Old style format with grid by grid compression IDs x and x

 New style format with layer by layer compression and GRID le read and the new format

A GRID FILE FORMAT

char ident File descriptionidentic ation

int npro j Pro ject numb er

int creation date Date created in YYDDD format

int maxsize Numb er of data p oints in largest D grid

int numgrid Numb er of D grids in this le

int rstgrid Lo cation of rst grids data as oset

in byte words from start of le

int pad Pad to bytes

The gridinfo structures contain the following elds each

int size Numb er of data p oints words of data

nrncnl

int nr Numb er of rows latitude p oints

int nc Numb er of columns longitude p oints

int nl Numb er of levels

int iword Lo cation of data as oset in byte

words from start of le

int date Grid date stamp in YYDDD format

int time Grid time stamp in HHMMSS format

int pad Reserved

char name character name of physical variable

char units character unit description

int pad Reserved

int ityp e Always

int latn North latitude

int lonw West longitude

int latinc Latitude increment

int loninc Longitude increment

int pad Reserved

int ihtyp e Always

int top Top height

int topinc Height increment

Because the grid info structure contains the lo cation of the grid data in the le it is p ossible

to create les with a gap b etween the grid info structures and the data This way space can

b e reserved for future headers

For an original McIDAS GRID le the gridinfo structures are padded to bytes in length

by adding

int pad Reserved

In order to make visd p erform the correct typ e of vertical interp olation dep ending on the

co ordinate system automatically it must know the leveltype ie the unit of the vertical

co ordinate on which the grids are dened Because the conversion from GRIB to COMP

takes the indirect route via GRID to retain the functionality of the utilities supplied with

VISD it is necessary to mo dify the GRID format to pass information ab out the vertical

APPENDIX A F ILE FORMATS

predetermined bit map provided by the centre that made the GRIB message The rest of the

section contains the bit map This section is optional

Section The binary data section starts with three o ctets describing the length of the

section The next o ctet contains a ag setting the representation of the binary data Octet

contain the scale factor for the binary data Octet are set to the minimum of the

binary data The following o ctet has the numb er of bits containing each packed value Then

from o ctet on the actual data is describ ed dep ending on the ag values in o ctet

Section The end section ending the GRIB message is always o ctets long and contains

the character co ded message

A ASIMOF le format

The ASIMOF le format was designed as a database le system at KNMI as a standard

interface b etween their numerical mo dels and presentation systems It was adopted as the

standard for the reference HIRLAM system It is used at KNMI many other HIRLAM

institutes use it or are considering its use For more detailed information ab out the format

see the inline do cumentation of the ASIMOF routines of the HIRLAM system The ASIMOF

le format is computer dep endent

A GRID le format

The GRID le format is used by the McIDAS system VISD is a stand alone subsystem

of McIDAS see Smit GRID les cannot b e read directly by visd but they can b e

converted to the COMP le format app endix A which is currently the only format visd

can read There exists a compile time option ReadOnDemand that enables visd to read

GRID les but even then the header of the COMP le that is made from the GRID les

must b e available

The global structure of a GRID le is

header size is bytes

numtimesnumparms gridinfo headers size of each is bytes numtimes is the numb er

of time steps numparms is the numb er of physical variables

space for future headers

numtimesnumparms data grids each data p oint is a byte oat

The following typ elengths are used char is byte int is bytes float is bytes

The McIDAS GRID le header consists of the following entries

A GRIB FILE FORMAT

Octet No Contents Description

Numb er of o ctets in section

No vertical parameters

No list present

Rotated latitudelongitude grid

Points on parallel

Points on meridian

Latitude rst grid p oint

Longitude rst grid p oint

Direction increments given

Earth assumed spherical

Positive U and V in easterly and northerly directions

Latitude last grid p oint

Longitude last grid p oint

Latitude direction increment

Longitude direction increment

First grid p oint left down b ottom

Latitude southern p ole

Longitude southern p ole

Angle of rotation

Table A GRIB format Section example values for HIRLAM

APPENDIX A F ILE FORMATS

Octet No Contents

Length of section

NV Numb er of vertical co ordinate parameters

PV Lo cation of list of vertical co ordinate

parameters if present or

PL Lo cation of list of numb ers of p oints in each

row if o ctet if present or

if neither are present

Data representation typ e grid typ e

Numb er of p oints along a parallel

Numb er of p oints along a meridian

Latitude of rst grid p oint in millidegrees

Longitude of rst grid p oint in millidegrees

Resolution and comp onent ags

Latitude of last grid p oint in millidegrees

Longitude of last grid p oint in millidegrees

Latitude direction increment in millidegrees

Longitude direction increment in millidegrees

Scanning mo de direction of increments

Reserved set to zero

Latitude of southern p ole in millidegrees

Longitude of southern p ole in millidegrees

Angle of rotation

Reserved for stretched latitudelongitude grid

PV List of vertical co ordinate parameters

PL List of numb ers of p oints in each row

Table A GRIB format Section grid description section for rotated latitudelongitude

grid typ e as used by HIRLAM

A GRIB FILE FORMAT

Octet No Contents

Length of section

Version numb er currently

Identication of centre

Generating pro ces identication numb er

Grid denition numb er according to

Volume B of publication WMO No

Flag signaling if section is included bit

and if section is included bit

Indicator of parameter

Indicator of leveltyp e

Height pressure etc of levels

Year of century

Month

Day

Hour

Minute

Indicator of unit of time range

Numb er of time units

Same as o ctet or time interval undergoing

averaging or accumulation

Time range indicator

Numb er included in average if o ctet or

otherwise set to zero

Numb er missing from averaging or accumulation

Century of reference time of data

Reserved set to zero

Units decimal scale factors

Reserved for future use may not b e present

nn Reserved for originating centre use

Table A GRIB format Section pro duct denition section

APPENDIX A F ILE FORMATS

Section The indicator section contains o ctets where the rst o ctets are character

co ded as GRIB the next o ctets contain the length of the entire GRIB message and the last

o ctet represents the GRIB edition numb er

Section The pro duct denition section starts with three o ctets describing the length of

this section The rest of this section contains the information of when where by whom etc

the GRIB message has b een made More sp ecic information ab out this section can b e found

in table A

While working with HIRLAM data we encountered the following level typ es o ctet

 Isobaric surface Grid values are given at a xed pressure level Octet

contain the pressure in hPa

 Mean sea level Grid values are given at mean sea level Octet are set to

zero

 Sp ecied altitude Grid values are given at a sp ecic altitude Octet contain

the altitude in metres

 Sp ecied height level ab ove ground Grid values are given at on a sp ecic height

ab ove the ground Octet contain the height in metres

 Hybrid level Grid values are given at mo del levels see section Octet

contain the level numb er

Section The grid description section starts with three o ctets indicating the length of this

section The rest of this section describ es the grid as set in o ctet numb er of section

Because HIRLAM uses a rotated latitudelongitude grid o ctet o ctet contain

sp ecic information for that typ e of grid More information ab out section can b e found in

table A For HIRLAM an example section is given in table A

The rotated latitudelongitude co ordinate system that is used by HIRLAM formed by a

general rotation of the earth can b e describ ed by three parameters

 The geographic latitude in degrees of the southern p ole

p

 The geographic longitude in degrees of the southern p ole

p

 The rotation of the new p olar axis p ositive in easterly direction This new p olar axis

can b e obtained by rst rotating the sphere through degrees ab out the geographical

p

p olar axis and then rotating through degrees so that the southern p ole moved

p

along the previously rotated Greenwich meridian

Section The bit map section starts with three o ctets used for the length of this section

Octet is used for giving the numb er of unused bits at the end of section The next

two o ctets are the table reference if they are zero a bit map follows else it refers to a

App endix A

File formats

In this app endix all relevant le formats are explained HIRLAM pro duces les in the GRIB

le format which is the world standard format for storage of meteorological data The

ASIMOF le format is used at KNMI to store several GRIB elds in one le The remaining

le formats are related to VISD GRID COMP map and top ography le formats

A GRIB le format

GRIB gridded binary as describ ed in FM IX ExtGRIB WMO is a le format for

pro cessed data in the form of gridp oint values expressed in binary form In this paragraph

the GRIB edition format will b e explained

In GRIB the data are represented in a sequence of an even numb er of o ctets o ctet bits

This representation is indep endent of any particular machine representation The o ctets of a

GRIB message are group ed in sections

 Section Indicator section

 Section Pro duct denition section

 Section Grid description section

 Section Bit map section

 Section Binary data section

 Section End section

Every section contains an even numb er of o ctets If not the section is app ended with bits set

to zero

BIBLIOGRAPHY

Bibli og raphy

Baas Baas SA Meteorological Visualization using apE a to olkit for visualization

Internal rep ort Leiden University

GLman Fisher S M Heinrich Graphics Library programming guide do cument ver

sion Silicon Graphics Incorp orated

Gour Gouraud H Continuous shading of curved surfaces IEEE

and Applications C pp

Hibb Hibbard WL R Kraus JT Young D Weather Displays Using McIDAS

Preprints ICI IPSMOH Los Angeles American Meteorological So ciety

Hibb Hibbard W D Santek Visualizing large data sets in the earth sciences IEEE

Computer Graphics and Applications pp

Hill Hill Jr FS Computer Graphics Maxwell MacMillan International Editions

LoCl Lorensen WE HE Cline Marching Cub es a high resolution D surface

construction algorithm Pro ceedings Siggraph Computer Graphics

pp

Smit Smith EA The McIDAS System IEEE Transactions on Geoscience Electron

ics GE

WMO Secretariat of the World Meteorlogical Organization Manual on Co des Volume

I Annex II to WMO Technical Regulations International Co des Part B

Binary Co des edition Supplement No Geneva Switzerland

CHAPTER FUTURE WORK

 It would b e more realistic to insert missing values b elow the orography instead of

extrap olating the data values This is not appropriate for all variables In general all

full mo del level elds should b e substituted with missing values b elow the orography

but not the pressure at at mean sea level

 The vertical co ordinate of the top ography should b e converted from metres to Pascal

Because the pressure is not constant at the earth surface this implies a change to visd

to calculate a dierent top ography every time step

 Logarithmic interp olation of vertical slices is not yet implemented

 Enhance VISD in such a way that the user can determine the place of each colormap

legends in the same way as the lab els can b e p ositioned

 For HP hardware platforms at Leiden University the Starbase Graphics Library can b e

tested for use with VISD Starbase is a HP sp ecic library and is probably faster than

VOGL but not p ortable

Chapter

Future work

The recommendations listed in this chapter can b e used as a guide to future work They

include required features see section for a list that are not yet implemented

 Extend the D p oint prob e in VISD to a D curve prob e A D curve prob e should

enable the user to manipulate a spline curve in the domain b eing visualized The

value of the physical variables are then plotted as a function of the displacement along

the curve

 In meteorology wind vectors are often visualized using shafts and various attachments

The shafts linesegment are all equal in length and p oint in the opp osite direction of

the wind vector The sp eed of the wind is visualized by attaching several line segment

and triangles to the shaft degrees rotated This can easily b e added to VISD

 When multiple vertical co ordinate units are supp orted it is recommended to print the

unit in the D window near the height axis to avoid misinterpretation of the data A

unit for every physical variable would b e useful to o

 A visualization technique not currently supp orted by VISD is Fu

ture versions of VISD will include this technique but will use transparency blending

features from the graphics library These are currently not supp orted by VOGL and

should b e implemented if the sp eed of VOGL allows it

 The visualization of D elds is currently restricted in the way that every D slice is

placed in the b ottom of the b ox Slices can b e visualized for arbitrary height it is the

placement that is always at the b ottom The D elds of the KNMI not p ositioned at

the earth surface include the metre temp erature and metre wind vectors With

the current vertical resolution of the vertical slices it is not useful to mo dify VISD to

draw the elds at the correct place moreso b ecause only one equidistant set of vertical

co ordinates can b e used all physical variables must b e dened on the same grid p oints

 The lighting mo del implemented in VOGL must b e enhanced For instance sp otlights

are not supp orted at the moment

CHAPTER CONCLUSIONS

on any hardware platform as long as a C compiler is available Note however that in

order to use VOGL with VISD other system requirements see section must also b e satised

Chapter

Conclusions

In order to visualize the output of a numerical weather forecasting mo del HIRLAM the

visualization package VISD was chosen VISD is suitable although a numb er of mo di

cations were necessary Based on our exp eriences with VISD the following conclusions can

b e drawn

Advantages of VISD are

 VISD has a very intuitive user interface and enables the user to combine all supp orted

visualization techniques and all available physical variables easily into one image

 VISD is free under the GNU licence

 the source co de is supplied with VISD

1

 go o d supp ort For the growing list of users a mailinglist end email to Bill Hib

bard whibbardvmsmaccwiscedu or Brian Paul bpaulvmsmaccwiscedu if you

would like to b e added to the VISD mailing list is available and the authors are very

resp onsive when presented with questions and suggestions

 VISD is still in development which means that future versions will have more func

tionality and keep up to date with resp ect to new visualization techniques

A disadvantage of VISD is

 VISD relies heavily on the existence of a D graphics library If such a library is not

available VISD cannot b e used This problem has b een solved for HP Series by

extending the library VOGL software implementation of the SGI GL libraries with

the functionality needed by VISD However a software implementation of a hardware

library can never match its sp eed so VISD is a bit slow the reader is referred to

chapter for concrete timing values when using VOGL VOGL by itself can b e used

1

S

CHAPTER RESULTS

lines of co de and ca lines were added

Images showing some of the capabilities of VOGL are included in app endix F

Because VOGL is quite slow a numb er of sp eed tests were executed on a HP RX The

drawing of color slices is tested b ecause these take the longest time to render The following

times resulted

Rendered graphics Time seconds

Empty b ox ca

One horizontal color slice ca

Two horizontal color slices ca

To determine how much time each op eration p erformed by VOGL costs the op erations are

split into the following categories

 drawing the drawing of pixels on the screen and setting of colors

 scan conversion calculation of which pixels to draw

 p olygon clipping

 miscellaneous the remaining op erations

The same sp eed tests were run without execution of one of the listed categories which resulted

in the following

VOGL categories Time relative to normal

Normal op eration

No drawing

No scan conversion no drawing

No clipping

No clipping No scan conversion

From this results the conclusion can b e drawn that drawing and clipping are the categories

that should b e considered rst to sp eed up VOGL

Colormap legends are implemented The only restriction is currently the space of the D

window Dep ending on the width of the values printed next to the legends up to ca

legends can b e displayed An image displaying a colormap legend is given in app endix F

Chapter

Results

This chapter presents the results obtained by using VISD for the visualization of the

HIRLAM output

The required visualization techniques see section are all p ossible with VISD To obtain

a discretized color mapping the user must form the colored bands by changing the color map

in the RGB widget window of VISD Wind vector slices can only b e visualized if the U and V

wind comp onents are present if the vertical wind comp onent W is present it is used otherwise

it is substituted with zeros To visualize wind tra jectories all three wind comp onents U V

and W must b e present and more than one time step must b e available Currently HIRLAM

do es not calculate the vertical wind comp onent W although the equations to do so are

present which means that wind tra jectories cannot b e used for the HIRLAM data

Of the additional required features see section only the D data prob e is not yet

available but will b e included in future versions of VISD

The HIRLAM data can b e visualized using pressure for the vertical co ordinate This is

realized by interp olating the HIRLAM data from HIRLAM mo del levels to pressure levels

and writing the resulting data to a le that can b e further pro cessed by VISD Due to

the exp onential decrease of pressure with height logarithmic interp olation must b e used For

large pressure values Pa the linear and logarithmic fractions are nearly equal

however

The VISD mo dications describ ed in chapter are all implemented succesfully except for

the logarithmic interp olation of vertical slices The source co de of visd consists of ca

lines of co de The mo dications add ca lines of co de all mo dications including the

graphics mo dule mo dications This numb er of lines is exaggerated b ecause the old co de is

retained and every mo dication is emb edded within C prepro cessor statements for backward

compatability

VISD is p orted to the HP hardware platform for use at Leiden University VOGL a software

implementation of the SGI Graphics Library is used for all graphics related functions VOGL

is enhanced with functionality necessary for VISD The original VOGL consisted of ca

CHAPTER VISD MODIFICATIONS

the gravitational acceleration at the earth surface The resulting geop otential height cor

resp onds with the geometrical height height ab ove mean sea level The landsea mask

variable leveltyp e height can b e extracted directly from the HIRLAM climate le

The values must b e rounded to the nearest integer is land is sea

VISD is adapted to display the b ox height co ordinates in Pascal but the vertical co ordinate

of the top ography is still in metres If the vertical co ordinate should b e changed to pressure

co ordinates visd should also b e enhanced to calculate a new top ography every time step

b ecause it dep ends on the nonconstant surface pressure

Map conversion

visd has a builtin function to display the map of the world This map consists only of coast

lines not the b orders b etween countries The data are extracted from the default map le

OUTLSUPW which is supplied with VISD

This map le has the same grid problems as the VISD top ography le as describ ed in

section the data grid p oints are in a latitudelongitude format while the HIRLAM grid

p oints are in a rotated latitudelongitude format Because the climate le do es not contain

a map of the HIRLAM area the default map le had to b e converted to the correct grid

In the standard VISD package the map mo dule handles reading and drawing of the map

This mo dule is the starting p oint to construct a function that makes a map of the HIRLAM

area in the correct grid format

The conversion of grids is p ossible with the ASIMOF library routine

gbgccpxold pyold pxnew pynew k kbi pbi kbo pbo

where pxold and pyold denote the grid values in the longitude and latitude direction resp ec

tively pxnew and pynew the converted longitude and latitude grid values k is the numb er of

longitude and latitude values kbi and pbi are the values of the integer and realblo ck of

the GRIB section of the input grid and kbo and pbi are the section integer and real

blo cks of the output grid

The HIRLAM map can b e made by typing at the commandline

hirlammap

or

hirlammap input map file output map file

Running hirlammap without commandline arguments assumes OUTLSUPW as the input map

le and HIRLAMMAP as the output map le

SCALING VERTICAL WIND COMPONENT

is visualized on pressure levels logarithmic interp olation must b e used instead The change

necessary to visd uses the same logarithmic fraction as derived for the horizontal slice

extraction see section

Scaling vertical wind comp onent

When a vertical co ordinate system dierent from metres is used the scaling of the vertical

wind comp onent W must b e adjusted Currently VISD scales W from the unit ms to

gridb oxess The unit of the vertical wind comp onent if calculated by HIRLAM is Pas

instead of ms which VISD assumes The required scaling can easily b e p erformed by

dividing the values of the vertical wind comp onent by the height of a grid b ox in Pascal

These mo dications must b e p erformed in the trajectory and work mo dules for the tra jec

tory calculation and horizontal and vertical wind slice calculation resp ectively

Top ography conversion

VISD has a builtin function to display the top ography of the world The VISD top ogra

phy consists of two items for every grid p oint

Surface elevation height ab ove sealevel

Landsea mask

The word top ography assumes that there is more information than just the height and the

landsea mask available for instance the ow of rivers roads and the use of land The correct

word should b e orography but since VISD refers to top ography when meaning the orography

this will b e used in the remainder of this section

The top ography le format is describ ed in app endix A The grid of the default top ography

le EARTHTOPO is in a standard latitudelongitude format whereas the HIRLAM grid is

a rotated latitudelongitude grid With VISD a sample le maketopoc is supplied that

enables the user to make his own top ography data le This sample le has b een adjusted

to make a correct HIRLAM top ography The top ography le can b e made with the program

hirlamtopo by simply typing

hirlamtopo inputclimatefile outputfile

The information necessary to create the top ography in the correct grid format can b e ex

tracted from the HIRLAM climate le The height ab ove the ground is calculated by extract

2

ing the geop otential variable leveltyp e height and dividing by G ms 0

CHAPTER VISD MODIFICATIONS

To intro duce logarithmic interp olation into the iso surface calculation the following equation

must b e mo died

isov al ue nodev al

1

f

nodev al nodev al

2 1

where isov al ue is the value for which the iso surface is calculated nodev al and nodev al are

1 2

the data values at the edge no des b etween which is linearly interp olated and f is the fraction

ie the p osition of isov al ue within the interval nodev al nodev al

1 2

In order to use logarithmic interp olation a threestep calculation must b e p erformed First

the linear fraction f is calculated using formula Then the pressure value corresp onding

with isov al ue in the given interval can b e found by using the following formula for f

l nP l nP

1 iso

f

l nP l nP

1 2

where P and P are the pressure levels for the edge no des P must b e calculated b ecause

1 2 iso

this value determines the lo cation of isov al ue in the interval nodev al nodev al when inter

1 2

p olating using the logarithm of the pressure levels Solving equation using equation

yields

(ln(P )f (ln(P )ln(P )))

1 1 2

P e

iso

Third and last the values of P P and P are used to calculate the following fraction

iso 1 2

P P

1 iso

f

iso

P P

1 2

Fraction f corresp onds to the logarithmic intersection p oint b etween the two no des

iso

The mo dications necessary to visd use the ab ove equations in a new macro LOGcalcNode

This macro is used only to calculate intersections of vertical cub e edges

Wind tra jectories

To calculate a smo oth wind tra jectory VISD linearly interp olated in a D b ox three spatial

and one time dimension The interp olation in the vertical co ordinate should b e p erformed

logarithmically if pressure levels are used The change necessary to visd uses the same

logarithmic fraction as used for the horizontal slice extraction see section

A second mo dication is necessary to the tra jectory to scale the vertical wind comp onent

correctly see section

Data prob e

The data prob e is used to obtain single values from the data grids If the data prob e is

p ositioned b etween two levels visd linearly interp olated b etween the levels When data

LOGARITHMIC INTERPOLATION

where

P the pressure of the upp er level of the adjoining pair

abov e

P the pressure of the lower level of the adjoining pair

below

P the pressure of the level that must b e computed

w anted

The new data values are now calculated in the normal way using the logarithmic fraction

The pressure value P is calculated from the slice p osition and P and P by linear

w anted abov e below

interp olation

Vertical slices

A vertical slice is calculated by horizontal interp olation of the data values nearest to the slice

for every level of data available No interp olation b etween the levels is done so a vertical

slice has the same numb er of data p oints in the vertical direction as there are levels There

are several ways to intro duce the logarithmic interp olation b etween the levels

 Extract the slice as normal For a contour slice the contouring algorithm must b e mo d

ied so that intersections of edges spanning dierent levels are calculated by logarithmic

interp olation For a color slice the graphics library must interp olate the colors b etween

the vertices logarithmically For the wind vector slices no change is necessary b ecause

only the data values extracted from the grid p oints are used

 Extract extra levels in b etween the levels Calculate these extra data values in b etween

by the same typ e interp olation as describ ed in section This way the contouring

algorithm do esnt have to b e mo died provided the vertical resolution is high enough

The color slices can b e rendered as normal using linear interp olation b etween the ver

tices

The rst metho d cannot b e used b ecause the GL library do es not supp ort logarithmic color in

terp olation the GL man pages refer to p ossible future implementation of this feature though

see GLman Only the second option can b e used but has the disadvantage that more data

p oints are extracted which increases the time needed to calculate and render the slices

Implementation of this metho d is not yet nished

Iso surfaces

The iso surfaces are calculated using the Marching Cub es algorithm LoCl The data grid

is divided into cub es with eight data values at the corners of each cub e For every edge of a

cub e iso surface intersections are determined The isosurface intersects an edge of the cub e

if the values at the cub e no des lie on opp osite sides of the iso value the data value for which

the isosurface is calculated The intersections of all twelve edges together determine the

part of the iso surface that lies within the cub e A D p olygon is generated

The intersections of vertical cub e edges must b e interp olated logarithmically whilst the in

tersections of horizontal cub e edges must b e interp olated linearly as normal

CHAPTER VISD MODIFICATIONS

 Floating levels D elds at a certain altitude are not allowed All single level elds

are assumed to b e surface elds

 The levels must still b e equidistant

 Each physical variable must have the same numb er of levels in each time step

For a detailed description of the changes see app endix D

Logarithmic interp olation

The co ordinate system chosen for visualization uses the pressure as the vertical co ordinate

unit see section for a description of p ossible co ordinate systems Because in nature

the pressure decreases exp onentially as a function of the altitude vertical interp olation of

the physical variables b etween the data levels must b e p erformed using the logarithm of

the pressure level values Currently visd can only interp olate linearly Because the correct

interp olation metho d to use dep ends on the co ordinate system an extra entry in the visd

COMP and GRID le format is necessary an integer leveltype The GRID and COMP

le formats and the mo dications are describ ed in app endix A The leveltype variable

indicates what kind of vertical co ordinate system is used Currently these can b e height

and pressure values In the following sections the changes to visd are describ ed Only the

calculation of graphics and the data prob e ie the extraction of data from the grids has to

b e mo died In the following sections the mo dications are explained

Horizontal slices

When the user selects a horizontal slice for a level that is not in the data grid but b etween

existing levels visd calculates the values on the requested slice by interp olation of the data

values of the two adjoining levels The current interp olation function of visd calculates

linear fractions f and f which are used to calculate the data values on the requested

slice

data f  data f  data

v alue below abov e

where

data data value on lower adjacent slice

below

data data value on upp er adjacent slice

abov e

This formula is evaluated for every grid p oint on the horizontal slice

The most easy way to p erform the logarithmic interp olation is to add an alternative way to

compute the fractions The logarithmic interp olation can b e expressed using the following

formula for the logarithmic fraction

l nP l nP

below w anted

f

log

l nP l nP

below abov e

VISUALIZATION OF D FIELDS

 No redundant data

Disadvantages

 Only a color mapping can b e visualized no contour or wind vector slices

 Mo dication of VISD is necessary

 The D elds must b e stored in separate les

 Recoloring the top ography with a physical variable can b e confusing to the user

who loses his p erception of the actual height of the top ography

Mo dify VISD to eliminate the restriction of the trivial height dimension

Advantages

 No redundant data

 All visualization techniques as far as useful are available for each physical vari

able Visualization techniques that are not applicable to D elds can b e turned

o in the control window

 Userfriendly Everything concerning grid dimensions can b e hidden from the user

but the user can never forget the numb er of levels due to the restricted slice

movement etc visd can simply prohibit op erations that are illegal for D

elds

 All combinations of physical variables can b e visualized simultaneously

 Each eld has an unique button row in the control window and can thus b e easily

identied

Disadvantages

 Requires the most work of all available solutions

 The complexity of VISD increases

After examination of the source co de of VISD it was decided to cho ose solution b ecause

 It is the most elegant and userfriendly metho d

 No redundant data needs to b e stored This is quite imp ortant b ecause visd already

needs a lot of memory it is wise to use it sparingly

 Various changes to VISD were already necessary for other reasons see section

The amount of work was limited in the following ways

 Only the trivial dimension height the numb er of levels is eliminated In other words

all data grids must still have the same numb er of rows and columns The numb er of

rows and columns must each b e at least

CHAPTER VISD MODIFICATIONS

 Mo dication of VISD is not necessary

Disadvantages

 The user has to keep track of where the D elds are p ositioned in the D grid

A horizontal slice must b e p ositioned exactly on the real D eld otherwise the

D eld is interp olated with a neighb ouring D eld which is incorrect This

cannot b e solved by inserting dummy levels with missing data indicators b etween

each pair of levels b ecause the slice interp olation will then return missing data

values for a slice adjacent to the missing value slice

 Vertical slices and isosurfaces are incorrect but can still b e visualized

 For each time step dummy values must b e used to ll the D grid in which the D

elds are stacked if there are not enough D elds to ll the D eld completely

A separate physical variable is used for every D eld and all levels in a D grid are

set to the same values as in the D eld

Advantages

 All physical variables can b e viewed simultaneously

 Mo dication of VISD is not necessary

 The slice p osition is not relevant all p ositions will result in the correct values b eing

obtained

Disadvantages

 A lot of redundant data

 Vertical slices and isosurfaces are still meaningless and incorrect

Split the physical variables to visualize into two separate COMP les one with the D

elds and another one with the D elds The D elds are duplicated so that they

are two levels high eliminating the trivial height dimension of one Visualizing of the

D elds constructed this way can b e done as normal

Advantages

 Not many redundant data all D elds are only duplicated

 Vertical slices and isosurfaces are incorrect but less confusing b ecause of the

reduced volume of data

 Mo dication of VISD is not necessary

Disadvantages

 Combinations of D and D elds cannot b e visualized

Color the top ography using one of the required D elds The D elds are stored in

a separate le

Advantages

Chapter

VISD mo dications

In this chapter the mo dications to VISD are discussed which were necessary to make

VISD able to visualize the HIRLAM output The following mo dications are discussed

 D eld visualizations VISD could only cop e with D elds

 logarithmic interp olation of the vertical co ordinate when pressure levels are used

 creation of top ography and map les of the current domain of HIRLAM

 creation of colormap legends

The D prob e mo dications have not yet b een studied

Visualization of D elds

In order for VISD to b e useful for visualizing the HIRLAM data a solution must b e found

to visualize D elds VISD has b een written sp ecically for the visualization of D data

elds Fields with only one row column or level cannot b e visualized Another restriction is

that every physical variable must have the same numb er of p oints in all four dimensions

Possible solutions to visualize D elds with VISD are

Stack all D elds which must b e visualized in D data elds and ll the remaining

levels with arbitrary dummy values

Advantages

 All physical variables can b e viewed simultaneously rememb er that multiple vi

sualizations of one physical variable are p ossible by cloning the variable using the

NEWVAR option

CHAPTER INTERFACING HIRLAM WITH VISD

GRID TO COMP CONVERSION

GRID to COMP conversion

In order to visualize the GRID les created by xgv they must b e converted to COMP les

which can b e read by visd This can b e done with the utility compd which is supplied with

VISD Due to the changes to VISD which will b e describ ed in chapter the standard

compd program can not b e used anymore b ecause it terminates with an error if the data

grids in the input GRID les do not have equal dimensions To imp ort the new GRID les

a new program varNLcompd has b een derived from the existing compd program with the

following mo dications

 When reading the rst time step the numb er of levels and height of each grid in the

time step is stored in an array and kept for later use

 When reading the remaining time steps the numb er of levels and height of each grid is

compared with the appropriate value from the arrays

 The compression is mo died to handle variable sized grids

CHAPTER INTERFACING HIRLAM WITH VISD

Figure window with list of data elds

CONVERSION FROM GRIB TO GRID

Starting xgv will op en the main data le window see gure In the top of this window

the following buttons are available

Options Op ens or closes the options window see gure In this window the default

conversion options can b e mo died

Create Create the output le as selected by the user

Exit Exit xgv

Under this row of buttons the window displays a list of les found in the sp ecied search

directories and matching the sp ecied lename pattern

The lenames are sorted in chronological order which results in the time steps b eing written

to the output le in the correct order Each data le has a separate button which are all

turned o by default The left mouse button can b e used to select and deselect data les A

highlighted button will mean that the corresp onding data le is included in the output le

The middle mouse button is used to op enclose a new window displaying the contents of the

corresp onding data le as a list of data elds see gure The names of the data elds

consist of the following information

 GRIB variable numb er according to WMO sp ecications

 A short name of the variable

 Leveltyp e numb er according to WMO sp ecications

 Levelrange

Fields of equal variable numb er and leveltyp e are group ed under one button Using the left

mouse button data elds can b e selected and deselected The data elds are read from the

le the rst time the user clicks on a data le button in the main window

xgv will make sure that the selection of les and elds remains consistent by

 Prohibiting the selection of new data les that do not contain all the selected data elds

 Prohibiting the selection of new data elds that are not present in every selected data

le

If such a selection is attempted by the user xgv will rep ort this in the standard output

window

CHAPTER INTERFACING HIRLAM WITH VISD

Figure main window of xgv

Figure options window of xgv

CONVERSION FROM GRIB TO GRID

More information ab out the RUL libraries can b e found in app endix C

The RUL library functions were implemented in C except for the functions in futilf for

the following reasons

 C provides dynamic memory allo cation

 C provides b etter string handling than FORTRAN

The routines in futilf are provided b ecause a FORTRAN common block cannot b e refer

enced from C

In order to call FORTRAN functions from a C program the following should b e noted

 FORTRAN passes the address of every function parameter Therefore when calling a

FORTRAN function from C of every parameter that is not a p ointer the address must

b e passed

 FORTRAN has no string termination character When a character string is passed to

a FORTRAN function exp ecting a CHARACTER the string length must b e passed as

an extra parameter after the list of remaining formal parameters

 Arrays in C are row ma jor opp osed to arrays in FORTRAN b eing column ma jor

 The index of the rst element in a C array is in FORTRAN this is

Conversion program

The program xgv is resp onsible for the conversion of GRIB elds stored in ASIMOF les to

McIDAS GRID les xgv must b e started with the command

xgv options

The following options are available

Option Description Default

le Sp ecify wildcarded input lename pattern fc

path Sp ecify commaseparated list of directories

out Override the default output lename GRD

climatele Override the default climate le cl

pro jectname Override the default pro ject name gribvis testle

pro jectnumb er Override the default pro ject numb er

outputleveltyp e Override the default output level typ e

outputlevelrange Override the default output level start and

end separated by a minus sign

numoutputlevels Override the default numb er of output levels

v Increases the amount of information printed

to the screen during conversion

CHAPTER INTERFACING HIRLAM WITH VISD

util Provides routines for date conversion and ASIMOF information programs

vari Provides conversions from one co ordinate system into another as well as routines to

convert U and V to several co ordinate systems

prp o Provides routines used for p ostpro cessing vertical interp olation and destaggering of

the wind comp onents of the data

grw Provides functions that are used as an interface to ASIMOF les The DDR data

description record is the same as the keys of a GRIB message blo ck and blo ck The

parameters are kept in a common FORTRAN blo ck

More information ab out the KNMI libraries can b e found in app endix C

Using the KNMI libraries not only reduces the work necessary but also ensures future com

patibility if the KNMI libraries are changed or extended

RUL libraries

The RUL libraries were created to provide an interface b etween the KNMI libraries and

the main GRIB to VISD conversion program xgv XWindows GRIB to VISD for the

following reasons

 The KNMI libraries use very cryptic function and variable names

 The function interfaces of the KNMI libraries are sometimes very complex function

parameters is no exception The RUL libraries hide unnecessary detail but still retain

enough exibility to provide the same functionality as the KNMI libraries The param

eters that need not b e altered are placed in a C struct which is passed to the functions

in the RUL libraries

The following RUL mo dules are implemented

asimof Handles the op ening and closing of ASIMOF les and the extraction of data from

these les

grib Provides functions to convert b etween GRIB physical variable names and numb ers

Also a unit and short name is dened for every physical parameter b ecause the GRID

le format reserves only characters for the names of the physical variables

interp ol Provides functions to interp olate GRIB data from levels to pressure levels

cutil Provides general purp ose utility Cfunctions

futil Provides general purp ose utility FORTRANfunctions

xgv Main program mo dule providing a XWindows based user interface for the conversion

CONVERSION FROM GRIB TO GRID

level upwards This means that when a physical variable is extracted with more than one

level from an ASIMOF le the levels must b e sorted b efore writing them to an output GRID

le Because each GRIB message contains one level is it most easy to extract the levels

in the correct order This has the additional advantage that it is easy to extract elds in

reverse order which is necessary for vertical co ordinates such as pressure where the p ositive

co ordinate direction is downwards The HIRLAM mo del levels are also dened downwards

level is the top level

For each eld read from an ASIMOF le two additional reordering op erations must take place

First the array has to b e converted from column ma jor to row ma jor b ecause the eld is read

by a FORTRAN function and is further pro cessed by a C function The second op eration is a

mirror op eration around the horizontal axis b ecause the origin of the HIRLAM domain is the

southwestb ottom grid p oint while VISD exp ects the origin to b e the northwestb ottom

grid p oint

Not all physical variables within HIRLAM are calculated on the same grid p oints Some

variables are translated a half grid p oint distance with resp ect to the grid for which the

surface geop otential is dened this grid is used as a reference grid for the remaining elds

b ecause the top o is derived from it and used as reference by the user Because VISD can

only cop e with variables dened on equal grid p oints the physical variables will b e lineair

interp olated to the reference gridp oints read from the surface geop otential eld This

pro cess is called destaggering

After the data elds are extracted and converted they are written to a GRID data le The

grid info structure which contents is completely known after the conversions is written also

Since single level elds cannot b e vertically interp olated they will b e written to the GRID

le without b eing interp olated but reordering mirroring and destaggering are p erformed on

al l elds

Variables that are already interp olated to pressure levels will also b e directly written to the

GRIB le

Conversion from GRIB to GRID

KNMI libraries

The KNMI has several libraries available that provide functions to manipulate the ASIMOF

les to p erform various co ordinate transformations to transform time and date formats etc

The following libraries are available

p ort Provides routines used for the ASIMOF le handling

gco d Provides GRIB related routines such as enco ding and deco ding retrieving sections

from GRIB messages printing these sections and checking the parameters of the sections etc

CHAPTER INTERFACING HIRLAM WITH VISD

 The pressure decreases exp onentially with the height and therefore cannot b e in

terp olated linearly in height

 The vertical velo city must b e converted from Pas to ms in order to keep the

tra jectory mo dule functioning correctly

 Extrap olating variables b elow the orography takes sp ecial care

Considering the advantages and disadvantages of these three co ordinate systems the chosen

vertical co ordinate representation in VISD is the pressure level co ordinate system b ecause

it is the representation that corresp onds b est with the meteorological practice As a result

this means that leveltyp es other than pressure levels will have to b e interp olated to pressure

levels

ASIMOF to GRID conversion sp ecication

In order to b e able to interp olate variables to pressure levels the following physical variables

must b e present in every ASIMOF le

 Pressure at ground level

 Temp erature at ground level

 Temp erature at mo del full levels

 U comp onent of the wind at mo del full levels

 V comp onent of the wind at mo del full levels

 Sp ecic humidity at mo del full levels

In addition the geop otential at ground level variable numb er level typ e height

must b e read from a climate le which is an ASIMOF le and contains the average of several

variables over a long p erio d usually a year of time

If one of these variables is not available it is imp ossible to interp olate to pressure levels and

the conversion program will stop with an error message

Furthermore the full mo del vertical level parameters A and B are needed to interp olate cor

rectly A and B represent the contribution of the orography and pressure to the co ordinate

resp ectively Between the full mo del levels of HIRLAM half mo del levels are dened There

is one half level more than there are full levels The lowest and highest half levels corresp ond

with the b ottom and top of the domain of HIRLAM resp ectively The half mo del level pa

rameters can b e calculated from the full mo del level parameters From the mo del half and

full level parameters the pressure at half and full mo del levels can b e derived

The ASIMOF le format imp oses no ordering on the GRIB elds contained within the le

However VISD exp ects the grids in the GRID and COMP les to b e given from the b ottom

VERTICAL COORDINATE

 The largest change in pressure p er height are in the lowest levels of the mo del

This results in the highest resolution in the area of most interest

 Pressure levels corresp ond b est with meteorological practice

Disadvantages

 The orography ie the surface pressure is not constant in time

 The vertical interp olation of variables must b e done in the logarithm of the pressure

b ecause of the exp onential decrease of the pressure with height

 The p ositive co ordinate direction is downwards

 Sp ecial care must b e taken to extrap olate variables b elow the orography

Model level numbers The HIRLAM mo del levels are used directly as an equidistant

co ordinate system

Advantages

 The most simple of all co ordinate systems

 The levels are equidistant so no initial interp olation is needed

 No orography is needed at orography b ecause the b ottom mo del level follows

this orography

 Best representation for a mo del b ehaviour study

Disadvantages

 The vertical velo city is dened as the change in pressure Pas This has to b e

transformed to a velo city expressed in mo del levels p er second to b e able to use

the tra jectory mo dule

 The p ositive co ordinate direction is downwards

 Vertical interp olation of the physical variables cannot b e done linear but must b e

done in the logarithm of the pressure

 The eects of the orography are b eing masked b ecause the used orography is at

Geopotential height levels with the same geop otential ie the same p otential energy of

an air particle

Advantages

 Easy to calculate using the HIRLAM p ost pro cessing package postpp

 The orography is constant and dened as the geop otential height of the surface

 All variables except the pressure can b e interp olated in height

 The p ositive co ordinate direction is upwards

Disadvantages

 The levels are not equidistant The highest resolution is given and needed at

the surface of the earth Interp olation to equidistant levels will result in loss of

essential information in the most interesting part of the atmosphere

CHAPTER INTERFACING HIRLAM WITH VISD

 Only a single conversion step resulting in quicker conversion and less disc space

usage

Twostep conversion First convert GRIB data elds to a GRID le then convert the

GRID le to a COMP le with the already existing VISD utilities This has the

following advantages

 The VISD package includes several utilities that allows the user to p erform var

ious op erations on GRID les such as interp olation b etween dierent time steps

resampling of the grid data etc see section for an overview of available

utilities

 The visd program includes prepro cessor statements RD ON DEMAND which en

ables the readondemand le access feature visd will read the COMP le header

information as usual but when a data grid is requested the data is read from the

GRID le with the original uncompressed data if p ossible The advantage of this

feature is that the data can b e visualized without the loss of accuracy that hap

p ens when converting GRID to COMP data values are compressed from float to

onebyte integer see also app endix A

Considering the two p ossibiliti es the choice was made to convert the HIRLAM output to the

GRID le format b ecause in that way the functionality of the VISD utilities and direct

GRID le access remains available

Vertical co ordinate

The vertical co ordinate used in the HIRLAM system is the so called coordinate The

co ordinate system also referred to as hybrid co ordinate system combines the orography

surface elevation with pressure levels Close to the ground the levels follow the orography

Going upward the relative contribution of the orography decreases while the relative contri

bution of the pressure increases The relative amounts of each contribution are given for each

level by the HIRLAM mo del vertical parameters Furthermore the levels of the co ordinate

systems are not equidistant The largest resolution is close the ground which is the part

of the atmosphere of most interest In order to visualize the HIRLAM data with VISD a

co ordinate system must b e used with equidistant levels b ecause VISD can not cop e with

nonequidistant levels

In general p ossible vertical co ordinate systems for visualization are

Pressure levels levels given at sp ecic pressure values

Advantages

 Pressure levels can easily b e calculated from the surface pressure and the vertical

mo del parameters which are b oth directly available from the GRIB messages

 The vertical velo city is correctly dened in Pas

Chapter

Interfacing HIRLAM with VISD

HIRLAM output

The HIRLAM output data les are available in the ASIMOF le format see app endix A

ASIMOF les consist of one or more GRIB messages see app endix A with a directory

structure giving information ab out the lo cation and characteristics of the GRIB messages

The GRIB messages in the le contain the data Each GRIB message can contain information

and data of one level eld of a physical variable Information such as time and date stamp of

the eld level typ e and value are included

The ASIMOF data or history les have a name like fcpp where

fc le typ e fc forecast an analysis in initialised analysis

start of forecast year month day hour

length of forecast

pp status identier pp p ostpro cessed not p ostpro cessed

In the following sections the conversion from the ASIMOF le format to the COMP le format

will b e discussed

Conversion to GRID versus COMP

To view the HIRLAM data using VISD a conversion from the ASIMOF le format the

GRIB database le format to the VISD COMP le format is necessary Two choices can

b e made for converting GRIB data to the COMP le format

Onestep conversion Convert GRIB data immediately to the COMP le format This

has the following advantages

CHAPTER PORTING VISD

MISCELLANEOUS PROBLEMS

Fortran function call a version with and one without an underscore attached to the

function name is available

 Due to dierences in the X versions on the SGIIBMStellar and the HP it is neces

sary to set the new p osition and size of a window when it is op ened moved or resized

using XWindows SizeHints

The rest of the p ort is just a matter of following the instructions in the p orting guide supplied

with VISD See app endix D for a description of HP p ort mo dications

CHAPTER PORTING VISD

Scan conversion

Because every draw op eration must b e p erformed on a p erpixel basis for correct functioning

of the Zbuer lines and p olygons must b e scan converted by VOGL and for every pixel the

Zbuer must b e checked Two typ es of scan conversion are necessary Line scan conversion

and p olygon scan conversion Line scan conversion is implemented using the Bresenham line

drawing algorithm see Hill Two versions are supplied The rst is just a pure line

drawing algorithm The second takes extra color parameters for the start and endp oint of

the line The line color is interp olated linearly b etween these values Polygon scan conversion

is more dicult The algorithm used is a variant of the p olygon scan conversion algorithm

as describ ed in Hill For each scanline the intersections with the p olygon edges are found

and sorted in increasing x values Then for each pair of sorted x values a run of pixels is

lled The color of a run is determined by the color of the start and endpixels of the run

Colors along the run are linearly interp olated b etween these values Start and endcolors of

each run are found by linearly interp olated the vertex colors over the p olygon edges

Due to the manner of geometry sp ecication of the GL p oints and colors are sp ecied by a

sequence of function calls a change to VOGL is necessary so that vertices are shaded as so on

as they are sp ecied b ecause the current color and normal used for shading are changed by

the next color or normal sp ecifying function call

VOGL device drivers

The device dep endent parts of VOGL are separated from the rest of the co de into device

drivers A device driver gives VOGL access to certain device sp ecic features such as draw

ing keyb oard and mouse read op erations device initialization and clean up The use of

device drivers makes VOGL very p ortable b ecause only the device driver needs to b e altered

when p orting VOGL to a new system The structure of a VOGL device driver is given in

app endix E

Miscellaneous problems

The following miscellaneous problems were solved when p orting VISD to HP

 The C prepro cessor used at Leiden University release do es not understand elif

which has b een changed to else if statements

 The HP FORTRAN compiler do es not understand the typ elength combination

INTEGER the typ e BYTE must b e used instead

 For compilers on some systems it is necessary to attach an underscore to function

names of Fortran functions that are called from C This is not the case for HP

Series systems A new prepro cessor symb ol has b een used underscored and of each

D GRAPHICS LIBRARY

Sp ecular

f

I I r u  u

sp s s r v

where I intensity of sp ecular reected light

sp

I intensity of light source

s

r material sp ecular reectance co ecient

d

u normal vector p ointing in the direction of

r

reected light R

u normal vector p ointing in the direction of the

v

vertex to viewp oint vector

f shininess co ecient

Because the cosine of the angle b etween two vectors is prop ortional to the dot pro duct b e

tween their normalized versions the latter is used to avoid cosine calculations This has the

consequence that all vectors used in the calculations must b e normalized Normalization of

normal vectors is necessary if the supplied normal vectors do not have unit length or if the

current Mo delView matrix which is used to transform the normal vectors to eye co ordinates

b efore doing lighting calculations is not orthonormal The GL can b e notied by the user

when to normalize normal vectors

Two shading mo dels have b een added to VOGL FLAT and GOURAUD shading Gour

When FLAT shading is used the shade of the last vertex of a geometry determines the shade

of the whole geometry When GOURAUD shading is used each vertex of a geometry is

shaded and colors are interp olated linearly b etween the vertices

All lighting functions have b een implemented in a new mo dule called light The functions of

the light mo dule are listed in app endix E

Depthcueing

Depthcueing has b een added to VOGL b ecause while working with visd without depth

cued lines in combination with orthogonal pro jections it b ecame apparent that it is very

hard to determine the orientation of the b ox After implementation of the Zbuer the only

mo dications necessary were to implement functions to set the depthcueing color and Z range

and to turn depthcueing on or o These are describ ed in app endix E

To simplify the implementation of the depthcueing there are currently two restrictions to

the depthcueing First only lines can b e depthcued Second lighting and depthcueing are

mutually exclusive that is when depthcueing is on lighting commands are ignored In fact

they are not ignored but the colors calculated by the lightmo del are overwritten by the

depthcueing color

CHAPTER PORTING VISD

eye

n n light source v light source θ s r s

diffuse reflection specular reflection (highlights)

Figure Vectors in the lighting calculations

 Light source color scaled by the material diuse reection and a function of the angle

b etween the vertex surface normal and the vertextolight source vector

 Light source color scaled by material sp ecular reectance and a function of the angle

b etween the vertextoviewp oint vector and the reected light vector

For each light source two typ es of reection due to the light source incident light are usually

computed

 Diuse reection scattering This o ccurs when some of the incident light slightly

p enetrated the surface and is reemitted uniformly in all directions

 Sp ecular reection These kind of reections are more mirrorlike and highly directional

These are the reections that make the surface lo ok shiny

The various vectors used for lighting calculations are depicted in gure n is the surface

normal vector s is the vertextolight source vector v is the vertextoviewp oint vector and

r is the direction of reected sp ecular light

Diuse and sp ecular reection can b e expressed using the following formulas

Diuse

I I r u  u

d s d s n

where I intensity of diuse reected light

d

I intensity of light source

s

r material diuse reectance co ecient

d

u normal vector p ointing in the direction of s

s

u normal vector p ointing in the direction of n n

D GRAPHICS LIBRARY

A typical GL lighting session go es as follows

 Dene prop erties for each material light and lighting mo del wanted

 Activate by binding to one of the eleven resources the denitions

 Draw the scene providing the surface normals and vertices for all primitives to b e

lighted

The reader is referred to GLman for more details In the following sections the enhancements

made to VOGL are discussed

Zbuering

The use of a Zbuer has a great impact on the current structure of VOGL The calculation

has to b e done on a p erpixel basis b ecause every pixel of a geometry can b e b ehind or

b efore the existing geometry VOGL uses highlevel drawing primitives to draw lines and

lled p olygons which are implemented in the device drivers Drawing of these primitives

must now b e done on a p erpixel basis so the device driver routines cannot b e used anymore

Instead a new device driver routine must b e added to draw a single pixel this routine did

not exist a single pixel was drawn by drawing a line with equal start and endp oints

The Zco ordinate used for Zbuering is the screen Zco ordinate of the pixel This value is

obtained by a new function which maps a vertex in clip co ordinates to screen Zco ordinates

using the current Zbuer depthrange A new typ e typedef zbuftype is added to VOGL

This typ e is used for each entry in the Zbuer Currently an bit Zbuer is used but

this can b e changed easily by changing the zbuftype typedef and the dene for MAXZ the

maximum p ossible value to store in the Zbuer

The reader is referred to app endix E for a description of implemented functions

Lighting

GL lighting calculates the color at each lighted vertex by summing the total ambient light

scaled by the material ambient reectance the material emitted light and the contributions

of each light source

The total ambient light is the sum of the ambient light asso ciated with each light source and

the ambient light asso ciated with the scene as given by the lighting mo del

The contribution of each light source is the sum of

 Light source ambient color scaled by the material ambient reectance

CHAPTER PORTING VISD

GL lighting p erforms the shading calculation on vertices in eye co ordinates This has the

consequence that GL lighting calculations are only p ossible in multi matrix mode and not in

single matrix mode

GL lighting is controlled by dening various instances of three typ es of resources

 materials surface prop erties

 light sources

 lightmo del environment prop erties

These denitions can then b e b ound to one of eleven light control ling resources a material

a backmaterial up to eight light sources and a lighting mo del GL lighting is inactive if no

material or no lighting mo del has b een b ound

A material denition consists of the following prop erties

 transparency

 ambient reectance

 diuse reectance

 material emitted light

 sp ecular reectance

 sp ecular exp onent shininess

A light source denition consists of the following prop erties

 ambient light asso ciated with the light source

 light source color

 light source p osition

 sp otlight direction if the light source is a sp otlight

 exp onent and spread of sp otlight cone

A lighting mo del denition consists of the following prop erties

 ambient light asso ciated with the entire scene

 various attenuation factors to reduce direct light on ob jects and make the light intensity

vary prop ortional to the ob jectlight source distance

D GRAPHICS LIBRARY

Zbuering

A Zbuer is a set of integers asso ciated with pixels in the framebuer The integers represent

the distance of the pixel to the viewp oint When Zbuering is activated for each pixel x y

to draw the Zbuer is checked to see if the new pixel is closer to the eye than the pixel already

present at p osition x y If the new pixel is closer the pixel is drawn and the Zbuer is

up dated VOGL do es not supp ort Zbuering rendering

Depthcueing

When lo oking at ob jects in real life the eyes ability to p erceive depth gives awareness of

the D nature of ob jects and judgement of the relative distance of ob jects The illusion of

depth p erception can b e created on D screens by depthcued images Depthcueing mo dies

an ob jects color based on the distance to the viewer The screen Zco ordinate is used to

determine the depth of an ob ject This value is translated to a corresp onding Zbuer value

By sp ecifying a color range and depth range the user can determine what color the Zvalues

maps to For a prop er depthcueing eect ob jects farther from the viewp oint should b e colored

darker Depthcueing is not supp orted by VOGL

RGB and colormap mo de

The GL supp orts two colormo des RGB and colormap mo de In colormap mo de a Color

Lo okUp Table LUT is used Colors are sp ecied by entries in the LUT single integer

values The LUT contains the red green and blue color values In RGB mo de true color red

green and blue values are sp ecied directly Not all op erations of the library are p ossible in

colormap mo de the most p owerful of the two is RGB mo de Other op erations need sp ecial

actions For example when drawing depthcued lines in colormap mo de the LUT must rst

b e loaded with a color ramp b efore the line can b e displayed correctly VOGL only supp orts

colormap mo de but VISD needs RGB mo de b ecause all colors in VISD are represented

as bit color

GL lighting

In GL lighting as in the real world the characteristics of the light source determine the color

and intensity of incident light on a surface The characteristics of the ob ject geometry and

its surface material determine the direction intensity and color of reected light How light

is reected dep ends on the interaction b etween the incident light and the surface material

The interaction b etween light and matter is far more complicated than can b e simulated in

realtime Lighting in the GL achieves a balance b etween realistic app earance and realtime

drawing sp eed The GL achieves this balance by p erforming lighting calculations only at

geometry vertices rather than calculating lighting for each pixel rendered

CHAPTER PORTING VISD

The eye coordinate system is the result of transforming through matrix multiplication the

geometry co ordinates by the contents of the mo deling and viewing ModelView matrix The

eye co ordinate system is the system in which lighting calculations are p erformed internally

Points in eye co ordinates are transformed to clip coordinates by matrix multiplication with

the Projection matrix The next system is the Normalized coordinate system which is the

result of limiting xy and z to the range w  x y z  w clipping and dividing x y and

z by w The result are normalized co ordinates in the range  x y z  The space

of normalized co ordinates is called the D unit cub e The x and y co ordinates of this D

unit cub e are scaled directly into the Window coordinate system The pixel at the lowerleft

corner has window co ordinates

Window co ordinates mo died by a window oset that represents the windows lo cation on

the screen represents the Screen coordinate system which corresp onds to pixel values Screen

co ordinates are typically thought of as D but in fact all three dimensions of the normalized

co ordinates are scaled The screen Zco ordinate can b e used for hiddensurface removal and

depthcueing

The co ordinate systems are all present in VOGL except for the eye co ordinate system this

is skipp ed b ecause the Mo delView and Pro jection matrices are concatenated The eye co

ordinate system is necessary for lighting calculations Furthermore the incorrect term World

coordinates is used instead of Object coordinates In fact if the Mo delView matrix would

b e separated in a Mo del matrix and a View matrix the co ordinate system b etween these

matrices would b e correctly referred to as the World coordinate system

Transformation matrices

The graphics system of the GL maintains three transformation matrices the Mo delView Pro

jection and Texture matrices The Mo delview and Pro jection matrices are already discussed

The Texture matrix transforms texture co ordinates directly from ob ject to clip co ordinates

Its transformation is unrelated to that sp ecied by the Mo delView and Pro jection matrices

Op erations on the matrices are p erformed dep ending on the current matrix mode Four matrix

mo des are available In single matrix mode only one transformation matrix is maintained

which transforms p oints directly from ob ject to clip co ordinates This is the only matrix

mo de available in VOGL but cannot b e used when lighting calculations are necessary b ecause

these must b e done in eye co ordinates The other three matrix mo des are viewing projection

and texture matrix mo de which sp ecify the matrix that is mo died by op erations such as

loadmatrix Other functions will always aect the Pro jection matrix disregarding the

current matrix mo de Examples are perspective and ortho which are used to dene the

view volume that is mapp ed to the D unit cub e Multimatrix mo de not available in VOGL

is necessary to obtain ob jects in eye co ordinates which are used for lighting calculations A

more detailed description is b eyond the scop e of this rep ort the reader is referred to GLman for details

D GRAPHICS LIBRARY

Object coordinates

ModelView matrix

Eye coordinates

Projection matrix

Clip coordinates

Divide by w

Normalized coordinates

Viewport transform

Window coordinates

Window offset

Screen coordinates

Pixel values

Figure Co ordinate systems used by the SGI GL

An intro duction to the SGI GL

In this section parts of the existing SGI Graphics Library GL are discussed that are imp or

tant in relation to the mo dications and enhancements that are necessary to VOGL

Geometry sp ecication

Sp ecication of the geometry to draw is done by issueing function calls that each send a

vertex p osition vertex normal or vertex color to the GL For instance when a line is drawn

the GL must rst b e set to line drawing mo de After that separate function calls are issued

to set the color supply normals and to supply vertices which are used to draw and color or

shade the line After the line is completely sp ecied the line drawing mo de must b e unset

Geometries drawn this way include lines triangle meshes and quadrilateral meshes

Co ordinate systems

The co ordinate systems used by the GL are imp ortant b ecause each function acting up on

geometry do es so in one of the available co ordinate systems The co ordinate systems used

by the GL are displayed in gure It starts with a D system dened in righthanded

cartesian oating p oint co ordinates called the object coordinate system Geometry vertices

sp ecied by the user as x y z triplets are in this co ordinate system There are no limits to

the size of co ordinates in this system other than the largest legal oating p oint value

CHAPTER PORTING VISD

b e written providing functions to draw lines text set color etc For a description of a

VOGL device driver the reader is referred to app endix E

 VOGL resembles the SGI GL the subset implemented so mo dications to VISD are

hardly necessary

 VOGL February has enough functionality to give an adequate display

of contour slices and windtra jectories

 VOGL is free and can b e mo died and used for every purp ose as long as the original

COPYRIGHT notice remains intact

Disadvantages of VOGL are

 Slow compared with the hardware SGI GL The sp eed of the hardware GL can of

course never b e matched by VOGL This is made worse by the tradeo b etween p orta

bility and sp eed Every geometry is drawn by device driver calls To keep VOGL

p ortable device dep endent optimalizations should only b e used in the device drivers

and not in the main co de section

 Not all GL functionality used by VISD are provided by VOGL GL functionality used

by VISD but not available in VOGL include

Zbuering

shading

depthcueing

transparency

textures

Zbuering and shading are vital The others are not but can enhance the rendered

images and increase the ease with which the images are interpreted by the viewer

It was decided to use VOGL for p orting VISD for the following reasons

 Portability which is a great advantage b ecause VISD must b e p orted to HP and DEC

Using VOGL will probably also reduce the work necessary for future p orts of VISD

 The resemblance to the SGI GL makes changes to VISD hardly necessary which

reduces complexity of VISD Also in co op eration with the KNMI we had access to

the manuals and do cumentation of the SGI GL

 The subset of the GL already implemented reduces the amount of work to do

The mo dications necessary to visd for using VOGL are describ ed in app endix D In the

following sections the enhancements made to VOGL are discussed after a short intro duc

tion to the SGI GL which is necessary to understand why the mo dications to VOGL were

necessary

Chapter

Porting VISD

VISD do es not work on HP Series and DEC hardware platforms see section for

a list of system requirements VISD had to b e p orted to HP systems to b e able to use

VISD at Leiden University The KNMI is interested in a p ort of VISD to a DEC Alpha

station The D graphics library requirement is the most serious requirement for a p ort

to HP and DEC VISD uses the XFDI library for Stellar and the SGI Graphics Library

GL for SGI and IBM hardware platforms see GLman The XFDI library uses very

highlevel drawing primitives like XFDIVnormPolyTri which draws a p olytriangle strip

a p olygonal mesh built of triangles using normals for lighting calculations The GL uses

lowlevel primitives and draws a p olytriangle strip by separately sending the normal vectors

and vertex p ositions to the GL The function calls that supply the normals and vertices must

b e enclosed by function calls that notify the GL that a p olytriangle strip must b e drawn

These two examples are fairly representative for the remaining part of the libraries The D

library is further discussed in the next section

D graphics library

In order to p ort VISD to HP and DEC systems a D graphics library is necessary for b oth

systems An ideal solution would b e a portable graphics library which can b e used for b oth

1

target systems A lowcost solution is available in the form of VOGL which stands for Very

Ordinary GL like Graphics Library VOGL is a software implementation of a subset of the

hardware SGI Graphics Library GL

Advantages of VOGL are

 VOGL is p ortable The device dep endent source co de is separated from the main source

co de into device drivers To use VOGL with a new device only a device driver has to

1

VOGL was written by Eric H Echidna at the University of Melb ourne echidnamunnariOZAU It may

b e freely used and mo died as long as the original COPYRIGHT notice remains intact

CHAPTER OVERVIEW OF VISD

Figure Control window

VISD SOURCE CODE ORGANIZATION

Figure Example contents of the VISD D window

CHAPTER OVERVIEW OF VISD

 External user functions directory userfuncs One way of deriving new physical vari

ables from existing ones is to have an external user function calculate the new variable

In the userfuncs directory the user can install Fortran mo dules which are all compiled

and linked into separate programs visd scans the userfuncs directory and the user

can execute them from within visd More information ab out external user functions

is provided in app endix B

 Utilities for managing and analyzing vedimensional data grids and converting data

into VISD le format directory util In the VISD package several utilities see

section are included for various op erations on GRID and COMP les see ap

p endix A and A Skeleton example programs reside also in the utilities directory

These programs show how to imp ort data into visd The util directory also contains

a library of utility functions McIDAS library for reading McIDAS GRID les The

main co de of visd makes use of the McIDAS library for the direct reading of GRID

les

 LUI Little User Interface library directory lui The LUI library is based up on X

Windows and provides convenient functions for all sorts of manipulation and interaction

needed in a window environment VISD uses this library for all graphical user interface

functions

The main program visd relies on the LUI library for all XWindows based functions and

the McIDAS library functions for reading GRID les For a more detailed overview of the

available source co de the reader is referred to app endix B

VISD SOURCE CODE ORGANIZATION

isosurfaces horizontal contour slices vertical contour slices horizontal colored slices and

vertical colored slices of the data The buttons are arranged in a matrix Each row corresp onds

to a physical variable in the data set Each column corresp onds to one typ e of graphic listed

b elow

To display the graphic click the left mouse button on the widget button A small control

window will app ear that is dierent for each typ e of graphic The following graphic typ es are

supp orted

D contour surface isosurface The isosurface control window that app ears is used to

set the isolevel value for the contour surface The desired value can b e selected by

dragging the slider to the correct place When the correct value is selected click on the

NEW SURF button The right mouse button can b esides to change the colors of the

surface b e used to change the transparency The transparency value can slide b etween

invisible and opaque

Contour slice After selecting a contour slice with the left mouse button a contour slice

control window containing a typ ein widget will app ear This typ ein is used to sp ecify

the interval b etween contour lines These intervals can b e typ ed in while p ointing the

mouse to the widget A RETURN at the end will change the values When a negative

value is entered all contour lines with a negative value will b e dashed and all p ositive

values will b e drawn in solid lines Optionally after the interval value a range of values

a b can b e sp ecied which will cause only contour lines b etween a and b to b e

drawn

Color slice The color slice control window that turns up contains a function graph for

red green and blue that maps data values to colors To change the red green and

blue function press the left middle and right mouse button resp ectively and drag the

mouse to draw a new function Also the keyb oard cursor arrow keys can b e used

to change the function curves Press rightleft to move the function rightleft Press

updown to change the shap e of the curve

VISD source co de organization

In order to succesfully make mo dications to VISD a clear understanding of the source

co de is necessary The source co de which is written in b oth C and FORTRAN total ca

lines can b e split into four parts

 visd main source co de directory src The source co de of visd is written in a mo du

lar fashion The rst systems visd was programmed for included the Silicon Graphics

and Stellar Stardent using multithreaded execution The parts of the program that

mo dify exclusive resources are enclosed within semaphore statements Singlethreaded

execution is also p ossible Due to the sp eed of these systems the source co de is easy

to understand b ecause it is programmed in a very straightforward way This makes

mo dications and enhancements to visd more easy

CHAPTER OVERVIEW OF VISD

bigger or smaller resp ectively When pressed and moved left or right the clipping plane

ie plane of invisibili ty moves towards or away from the user resp ectively When the

right mouse button is pressed the b ox in the window can b e translated

 Tra jectory This mo de is used for creating and displaying wind tra jectories This is

only p ossible if the data set contains U V and W wind comp onents and more than one

time step First a p osition for the cursor must b e selected This can b e done with the

right mouse button Then a time step must b e selected with the STEP button The

tra jectory will b e traced forward from the chosen time step to the last time step and

backward through time to the rst time step Finally the middle mouse button must

b e pressed to activate the tra jectory Wind tra jectories can b e displayed in two ways

as line segments D and as ribb ons D The tra jectory window also contains two

buttons lab eled STEP and LENGTH The STEP button is used to control the step size

used in the tra jectory tracing algorithm The LENGTH value is used to control the

length of the tra jectories

 Slice This mo de is used to rep osition horizontal and vertical slices contour slices

colored slices and wind vector slices To move a slice p oint the mouse at any slice

corner and drag the slice to its desired p osition while holding the right mouse button

Horizontal slices can b e p ositioned in any way as long as they are parallel to the b ottom

of the b ounding b ox Vertical slices can have any orientation as long as they remain

vertical They can b e moved parallel by p ointing to the middle of the top or b ottom

edge and then dragging to the new p osition while holding the right mouse button

 Lab el This mo de is used to create and edit text lab els in the D window First

p osition the mouse p ointer in the D window and press the left mouse button A

vertical bar cursor will app ear where the text can b e typ ed in The middle mouse

button can b e used to move the text to another p osition To delete a text p oint the

cursor at the text and press the right mouse button

 Prob e Used to insp ect individual grid values by moving a D cursor through the

D grid For each physical variable the value is printed along the left edge of the D

window

Wind slice buttons

If the data set contains U and V wind comp onent variables there will b e a row of four wind

slice buttons if the W wind comp onent is present it is used otherwise the W comp onent is

assumed to b e zero for all grid p oints

The lo cation of the slice plane can b e changed with the mouse while in Slice mo de The

color of the slice can b e changed by selecting the widget button with the right mouse button

The wind slice control window contains two typ ein widgets to control the scale and density

of the wind vectors The scale parameter is used to multiply the length of the vectors drawn

The density parameter controls how many wind vectors are b eing displayed

Display buttons

The last set of widget buttons in the control window is used to control the display of D

USER INTERFACE

ANIMATE Toggle on or o Left and middle mouse button

will result in forward animation right mouse button in backward

animation

STEP Step ahead one time step left mouse button go to rst time

step middle mouse button or step backward one step

right mouse button

NEW VAR Duplicate physical variables or invoke external analysis functions

Two kinds of new variables can b e added Clone variables copies

of existing variables and external function variables calculated

as a function of the existing variables see also

app endix B

EXIT Exit the program The decision must b e veried

NEW SURF Compute a new D contour surface

TOP Set D window to a top view left and middle mouse button or

to a b ottom view right mouse button

SOUTH Set D window to a south view left and middle mouse button

or to a north view right mouse button

WEST Set D window to a west view left and middle mouse button or

to a east view right mouse button

TOPO Toggle display of top ography Right mouse button will edit the

top ography color The commandline option topo topographyfile

can b e used to load a top ography le Default le is EARTHTOPO

MAP Toggle display of map The commandline option map mapfile

can b e used to load a map le The default map is OUTLSUPW

BOX Toggle the display of the D b ox

CLOCK Toggle clo ck on or o

SAVE Save current graphics and colors left mouse button or only

save colors right mouse button

RESTORE Restore the data set last saved with the SAVE button

GRID s Toggle b ounds along the edges of the b ox in latitude longitude

and height co ordinates or grid co ordinates

CONT s Toggle contour lab eling on or o

PRETTY Toggle the pretty rendering option on or o

REVERSE Toggle white b ox on black background to black b ox on white

background

SAVE PIC Save picture in the D window to a le

PERSPEC Toggle b etween p ersp ective and orthogonal viewing pro jections

Mouse b ehaviour buttons

This group of radio buttons only one may b e selected at the time is used to determine the

eect of pressing a mouse button while the mouse p ointer is p ositioned in the D window

To the immediate right of these buttons the mouse button legend is displayed The following

mouse b ehaviour buttons are available

 Normal This mo de is used to view the graphics in the D window By pressing the

left mouse button and dragging the mouse the D image can b e rotated The center

mouse button has two functions When pressed and moved up or down the b ox gets

CHAPTER OVERVIEW OF VISD

Graphical user interface

When starting visd it op ens two windows a D window on the right of the screen and a

control panel on the left

The D window is used to view and interact with the data In its upp er left corner a

analogdigital clo ck is displayed which indicates the current time step In the center of the

window a b ox is drawn when selected by the user which depicts the domain of the D data

All graphics will b e displayed in this b ox To the left side on the b ottom the values of all

physical parameters are displayed when the Prob e button is selected In the right b ottom

corner the name of the program is shown An example is shown in gure

The control window contains several groups of buttons that are used to control various func

tions The graphical user interface is an XWindows based interface that is device indep en

dent Another p ossibility is to op en the D window with maximum size full screen and to

op en the control window and all other windows on a second terminal

The control window see gure is used to control any graphic by clicking on its widget

button with the left mouse button A small control window will app ear To bring up the

graphics control window without toggling the display use the middle mouse button To

change the color of the graphic click with the right mouse button on the widget button

Some functions may not b e present on the control window This can happ en b ecause the

function is not available on the hardware platform the button do es not apply to the data set

or the button conicts with a command line option that is set

The buttons of the control window can b e divided into four groups see gure

 control buttons

 mouse b ehaviour buttons

 wind slice buttons

 display buttons

Control buttons

These buttons are used to toggle activate or control various functions

USER INTERFACE

visd command line options

After pro ducing a compressed le the data can b e visualized with the command

visd compfile options

The following command line options are available

map mapfile Use a maple other than the default maple

le OUTLSUPW This default le is a world map in

a normal latitudelongitude grid The reader is

referred to app endix A

for a description of the map le format

topo topographyfile Use a top ography le other than the default

top ography le EARTHTOPO This default le

is a world top ography in a normal

latitudelongitude grid with heights and a

landwater mask The reader is referred to

app endix A for a description

of the top ography le format

box x y z Sp ecify the asp ect ratio of the D b ox in the

D window The default ratios of this b ox are

font fontname height Set the font used in the D window On the

SGI system the height of the font can also b e

sp ecied

mbs n Override the assumed system memory size of Mb

rate ms Change the default animation rate to ms

microseconds b etween frames The default

animation rate is ms

full Op en the D window as a b orderless

fullscreen sized window

wdpy xdisplay Make the control window app ear on a dierent

X display

alpha Use alpha blending instead of screen do or

transparency This feature is only available on

SGI systems

wide w Set width of line segments in pixels The

default width is pixels

An overview of the command line options is given on the screen by running visd without

arguments

CHAPTER OVERVIEW OF VISD

lat XLATS XLATN

which sets the latitude range b ounds south north and

lon XLONE XLONW

which sets the longitude range b ounds east west and

hgt XHGTB XHGTT

which set the height range b ounds b ottom top for the destination grid

Before viewing the data set the GRID les must b e converted to a compressed le structure

COMP le This can b e done using the command

compd N M F

where N is the rst D grid le numb er M is the numb er of grid les in the data set and F is

the name of the compressed grid le

If the data set contains wind vector comp onents U V and W the horizontal wind SPD can

b e included in the COMP le using the command

compd N M F wind SPD U

This will result in including SPD and U in the COMP le not V and W

To create D grid le numb er N which allows D grids of up to M p oints each use the

command

igud make N M

To get information ab out the COMP le made use the command

compinfo COMPfile

that prints the grid dimensions numb er of time steps numb er of variables etc of the COMP

le

The command

help NAME

can b e used to get a quick overview of the parameter format of the VISD utilities

USER INTERFACE

where grid numb er K is pro duced by interp olating b etween grid numb ers I and J all in D

grid le numb er N Grid numb er K will b e assigned day D in YYDDD format and time T in

HHMMSS format The relative weighting of grids I and J is calculated from this time and

date assuming linear time interp olation If grid K is not b etween grids I and J in date and

time iggd prints an error message

The second way to interp olate in time is to use the command

iggd int I D T setdel S M lag U V grdf N

This will put a grid in the next empty slot of D grid le numb er N assigned to day D in

YYDDD format and time T in HHMMSS format This grid will b e interp olated from a

sequence of grids all in le numb er N at grid numb ers I IS IS IMS This

sequence of grids should b e ascending in date and time iggd will search the sequence and

linearly interp olate b etween the two consectutive grids from the sequence which bracket day

D and time T Furthermore the interp olation will b e done in a co ordinate system moving at

constant velo city U V where U and V are in ms with V p ositive for motion from south

to north and U p ositive for motion from west to east The two bracketing grids from the

sequence will b e shifted in latitude and longitude to their p ositions at day D and time T and

the result interp olated b etween these two spatially shifted grids Furthermore if the grids in

the sequence are identied in their directory entries with variable name U or V then the

corresp onding comp onent of the velo city UV will b e subtracted from the grid values

There is a builtin p ossibility to resample the GRID le This is done with the commands

ggd samp N M I J

and

ggd ave N M I J

where a NM grid is resampled to a IJ grid The samp option will linear interp olate b etween

source grid p oints and is appropriate for increasing resolution The ave option averages

multiple source grid p oints and is used to decrease the resolution of a grid

Starting ggd without keywords will do a straight copy op eration ggd can b e invoked with

the keyword

size NLATS NLONS NHGTS

which will cause the destination grid dimensions to dier from the source grid dimensions

NLATS NLONS NHGTS are the destination grid latitude longitude and height dimension

resp ectively Other keywords that can b e used are

CHAPTER OVERVIEW OF VISD

le format see app endix A D GRID le names consists of GRDxxxx where xxxx is the

D GRID le number the numb er is assumed to b e digits A D GRID le consists of

one or more D data grids which are numb ered in the order in which they app ear in the

GRID le starting with Grids in a particular GRID le are referenced by the utilities

using this grid number

VISD utility commands

The directory information of the grids in the GRID les can b e viewed with the command

iggd list I J grdf N

where N is the D grid le numb er and I and J give the range of grid numb ers to list

A short overview of the data in the GRID les such as the minimum and maximum values

the mean and the standard deviation and the numb er of grid p oints with missing data can

b e viewed with the command

iggd info I J grdf N

with IJ and N the same as ab ove

The iggd command also provides options for copying and deleting D grids and interp olat

ing D grids in time Sequences of D grids are copied using the command

iggd get N I J M K

where N is the source D grid le numb er I and J are the range of source grid numb ers M

is the destination grid le numb er and K is the starting grid le numb er

A single grid can b e copied using the command

iggd copy I J grdf N

where N is the D grid le numb er I is the numb er of the source grid and J is the numb er

of the destination grid The same way a numb er of grids can b e deleted with the command

iggd del I J grdf N

There are two ways to interp olate in time The rst way is use the command

iggd ave K I J D T grdf N

CAPABILITIES

The reader is referred to chapter for information ab out p orting VISD to other hardware

platforms

Capabilities

visd can handle physical variables in single time steps and multiple time steps It is also

p ossible to pro duce a new variable as a function of the existing variables All these data can

b e easily visualized manipulated and lo oked at from every p ossible viewp oint

visd is capable of visualizing data in the following ways

 D contour surface isosurface a surface that shows the D volume b ounded by a

particular isovalue This is the D equivalent of a D contour line

 contour slice a slice with lines on which values in the data set are equal

 colored slice a slice with data values mapp ed to colors

 wind vector slice a slice that depicts the motions of the wind by drawing arrows

which p oint in the direction of the wind The length of each line segment indicates its

magnitude The tail of the line segments are all anchored within a horizontal or vertical

plane through the D b ox

 wind tra jectories tracing of the motion of air through the D volume much like the

trailing of line smoke in a wind tunnel

 prob e insp ection of individual grid values

All these visualization techniques can b e shown simultaneously during one or more time steps

All graphics can b e manipulated interactively even during animation

With equal ease text lab els can b e put in the D window and a window dump can b e made

from this window and saved to a le or printed

User interface

In VISD there are two ways of controlling the data The rst way of doing this is using

command line options when starting visd or making and analyzing the data with the utility

commands The second way is with the use of the graphical user interface within the program

Command line interface

With visd additional programs are supplied that enable the user to make and analyse the

data The grids are assumed to b e in D GRID le format see app endix A or in COMP

CHAPTER OVERVIEW OF VISD

VISD is oered under the terms of the GNU General Public License There is no warranty

for the VISD package

VISD is b eing distributed as a stand alone system free of charge However it is also a

subsystem of a much larger ca two million lines of FORTRAN co de system named McIDAS

Mancomputer Interactive Data Access System see Smit and Hibb

System requirements

VISD version works on the following hardware platforms

Stardent GS or GS with

truecolor display ie planes

MB RAM

optional SpaceBall is supp orted

Stellix version or later is suggested

Silicon Graphics with

bit color and Zbuer or bit Indigo

MB RAM

IRIX version or higher

multiple pro cessors are used when present

IBM RS

mo del H or higher

requires bit color and Zbuer GTO desirable

MB RAM

AIX version or later is suggested

To b e able to use VISD on a sp ecic target machine the following resources should b e

available

 C Compiler

 FORTRAN Compiler

 XWindows

 D graphics library with Zbuer

And preferable

 MB of memory

 bit color display with high p erformance D graphics hardware

Chapter

Overview of VISD

1

This chapter gives an overview of VISD as originally distributed by ftp The latest avail

able version of VISD August is used as the basis of this chapter The mo dica

tions made in order to visualize the HIRLAM data with VISD are describ ed in chapter

Background

VISD is a software system for visualizing data made by numerical weather mo dels and

similar sources VISD works on data in the form of a vedimensional rectangle That

is the data are real numb ers at each p oint of a grid or lattice which spans three space

dimensions one time dimension and a dimension for enumerating multiple physical variables

VISD works p erfectly well on data sets with only one variable or one time step ie no time

dynamics However the data should have some depth in all three spatial dimensions This

makes visualization of D elds imp ossible

The VISD package includes the visd visualization program several programs for manag

ing and analyzing vedimensional data grids and instructions and sample source co de for

converting your data into its le format The VISD source co de is also included so it can

b e mo died or extended There are also sample data sets from the LAMPS Limited Area

MesoScale Prediction System mo del and from Rob ert Schlesingers numerical thunderstorm

mo del available

VISD version was written by Bill Hibbard and Dave Santek of the University of Wis

consin Space Science and Engineering Center supp orted by the NASA Marshall Space Flight

Center and by MarieFrancoise VoidrotMartinez of the French Meteorology Oce Later

version enhancements were written by Bill Hibbard Brian Paul and Andre Battaiola Dave

Kamins and Je Vro om of Stellar Computer Inc provided substantial help and advice in

using the Stellar software libraries

1

VISD can b e obtained via anonymous ftp from visdssecwiscedu in the directory pubvisd

CHAPTER INTRODUCTION

 VISD is restricted to height as the vertical co ordinate

 VISD do esnt supp ort the creation of color map legends

 VISD supp orts only a D p oint prob e instead of a D curve prob e

Solving these problems requires a relatively small eort compared to the eort required to

implement a complete visualization package

VISUALIZATION TOOLS

Furthermore the following features should b e supp orted

 supp ort for various vertical co ordinate systems

 colormap legends for color mappings a legend should b e optionally displayed giving

information ab out the corresp ondence b etween colors and data values

 data prob e to insp ect the value of one or more physical variables along a path through

the data domain

Visualization to ols

To visualize the output of HIRLAM a visualization to ol is needed Visualization programs

can b e divided into two categories First there are programs written with a sp ecic purp ose

in mind These kind of programs contain sp ecic routines to calculate and display an often

restricted range of images Secondly there are visualization to olkits These consist of a

collection of mo dules all containing only a small part of the total visualization pro cess By

combining mo dules the user can construct larger applications suited to his visualization needs

Advantages of a to olkit are exibili ty and the ease with which the to olkit can b e enhanced

with new mo dules For this reasons the required visualizations were rst attempted using

apE I I I a to olkit for visualization Due to the large numb er of shortcomings and bugs

see Baas apE was abandoned in favour of another package called VISD Chapter

will give an overview of VISD

VISD was chosen for the following reasons

 VISD is written sp ecically for the visualization of meteorological data

 free under the GNU licence

 the source co de is available

 supp ort an active VISD mailinglist is available

 VISD is written with p ortability in mind

 the KNMI evaluated VISD and are very enthousiastic ab out it

To make VISD able to visualize the HIRLAM output as describ ed in section the fol

lowing problems had to b e solved

 VISD only runs on SGI Stellar Stardent and IBM RS systems

 VISD cant read the HIRLAM output data format

 VISD cant visualize D data sets

CHAPTER INTRODUCTION

Pro ject description

Currently the physical variables pro duced by HIRLAM include

 wind direction and sp eed

 temp erature

 surface pressure

 air density

 humidity

For the purp ose of visualization the output variables can b e divided into three categories

 D scalar elds surface pressure

 D scalar elds temp erature air density humidity

 D vector elds wind

The wind is actually a D eld of D vectors b ecause the vertical comp onent of the wind

vectors physical variable W is currently not present it is not calculated by HIRLAM but

this can easily b e changed

The following visualization techniques stationary or as time lo ops are required

 For D scalar variables and D slices taken from D scalar variables

contour images lines connecting the gridp oints where the variable has the same

value the contours lab eled with corresp onding values

color mappings data values are mapp ed to colors according to a sp ecied col

ormap

discretized color mappings the data is rst mapp ed into intervals using a step

function so that colored bands are formed

 For D scalar variables

isosurfaces D equivalent of a contour line

 For D vector variables

D slices with arrows representing wind vectors

wind tra jectories streaklines depicting the path of particles through a stationair

p oint moved by the wind

Chapter

Intro duction

Pro ject background

In collab oration with the KNMI the Royal Dutch Meteorological Institute the High Per

formance Computing Division of the Department of Computer Science Leiden University

RUL researches ecient implementations of a numerical weather forecasting mo del on var

ious parallel computer systems This mo del called HIRLAM HIgh Resolution Limited Area

Mo del is the result of a co op erative pro ject b etween Denmark Finland Iceland Ireland

The Netherlands Norway and Sweden The purp ose of the HIRLAM pro ject is to design a

stateoftheart weather forecasting system HIRLAM is already used by some of the partici

pating countries to make predictions of the weather The horizontal domain of HIRLAM as

used at KNMI is displayed in gure

Figure Horizontal domain of HIRLAM

The output of the atmospheric circulation mo del of HIRLAM consists of large volumes of

fourdimensional data currently several time steps each consisting of ca by by

calculated data p oints representing several physical variables Visualization is a natural way

to obtain insight in these data

CONTENTS v

C futil

C gribvis

D VISD mo dications

D HP p ort mo dications

D LUI changes

D visd changes

D D elds mo dications

D Logarithmic interp olation mo dications

D VOGL related mo dications

E VOGL implementation details

E VOGL enhancements

E Zbuer functions

E RGB color functions

E Lighting functions

E Depthcueing functions

E VOGL device driver structure

F Example Images

iv CONTENTS

VISD mo dications

Visualization of D elds

Logarithmic interp olation

Horizontal slices

Vertical slices

Iso surfaces

Wind tra jectories

Data prob e

Scaling vertical wind comp onent

Top ography conversion

Map conversion

Results

Conclusions

Future work

A File formats

A GRIB le format

A ASIMOF le format

A GRID le format

A COMP le format

A Old style format

A New style format

A Variable NL format

A VISD map le format

A VISD top ography le format

B VISD source co de structure

B VISD main source co de

B External User functions

B Utilities

B Little User Interface LUI library

C Libraries

C KNMI libraries

C p ort

C gco d

C util

C vari

C prp o

C grw

C RUL libraries

C asimof

C grib

C interp ol

C cutil

Contents

Preface i

Intro duction

Pro ject background

Pro ject description

Visualization to ols

Overview of VISD

Background

System requirements

Capabilities

User interface

Command line interface

Graphical user interface

VISD source co de organization

Porting VISD

D graphics library

An intro duction to the SGI GL

Zbuering

Lighting

Depthcueing

Scan conversion

VOGL device drivers

Miscellaneous problems

Interfacing HIRLAM with VISD

HIRLAM output

Conversion to GRID versus COMP

Vertical co ordinate

ASIMOF to GRID conversion sp ecication

Conversion from GRIB to GRID

KNMI libraries

RUL libraries

Conversion program

GRID to COMP conversion iii ii

Preface

This is a master thesis ab out the visualization of meteorological data on b ehalf

of Leiden University and the KNMI Royal Dutch Meteorological Institute We

would like to thank a numb er of p eople who help ed us with the many problems

that arose during the research

In the rst place we would like to thank our sup ervisor Lex Wolters Leiden

University for his supp ort during the research and the time he has sp ent in

correcting this thesis

Sp ecial thanks go es to Gerard Cats KNMI To on Mo ene KNMI and Ben Wich

ers Schreur KNMI for their help in explaining the sometimes complex working

of meteorology Furthermore we would like to thank Nies Huijsmans Leiden Uni

versity for his advice on the sub ject of computer graphics i

Meteorolog i cal

Visualization

using VISD

Simon Baas Hans de Jong

Leiden University August