
This chapter provides an overview of the basic concepts you must know to develop applications programs in McIDAS-X. First, it looks at McIDAS-X from a user's perspective. Then it provides an overview of McIDAS-X at the system level. Finally, it describes how to build user applications that will interact appropriately with the McIDAS-X environment. You will learn:
This chapter is organized into these sections:
McIDAS-X is a tool for collecting, displaying and analyzing earth science data. As a McIDAS-X programmer, you should have a basic, user-level understanding of McIDAS-X. This section provides a general overview of McIDAS-X from a user's perspective, including:
|
For a more complete description of user-level applications in McIDAS-X, see the McIDAS User's Guide. |

Ingestors and decoders receive raw data signals from a variety of sources and convert them into these McIDAS-X data types:
Once the data is converted, users can store, analyze, display and manipulate it using McIDAS-X applications. Figure 2-1 shows how data is received, stored and distributed in McIDAS-X.
Figure 2-1 . Ingestors and decoders partition, format, and file data on machines running ADDE (Abstract Data Distribution Environment) server software. Then client applications analyze, process, and convert the data.

A fifth data type, called static data, is also provided with the McIDAS-X software. Each type of McIDAS-X data is described briefly below. More information is presented in following chapters.
McIDAS-X images refer to satellite and radar data. The primary characteristics of image data include:
Gray shading is the most common method of displaying image data.
Satellite images are received from geostationary and polar orbiting satellites. Geostationary satellites remain above a fixed location on the Earth's surface, about 36,000 km above the equator. They are limited in view, approximately 60° either side of the equator. Because geostationary satellites rotate with the Earth, they always view the same portion of the globe. There are usually five geostationary satellites approximately equally spaced, resulting in nearly complete global coverage.
Polar orbiting satellites orbit at much lower elevations, normally 800 to 900 km. Their field of view is about 2,400 km, centered on the orbit path. Unlike geostationary satellites, one polar orbiting satellite generally provides complete coverage of the Earth's surface twice per day.
Radars use active sensors that emit short-wave radiation and sample the signals reflected back to the radar antenna. The information represented in radar data is related to the strength of the reflected radar signal and is usually correlated with rainfall intensities. Modern radars also sense the radial component of droplet velocity.
Point observations refer to data reports at specific, irregularly spaced locations. These reports usually contain data for multiple parameters. Most data gathered by direct measurements, such as weather balloons and synoptic reports, is stored as point data.
Point data is listed on the McIDAS-X Text and Command Window in tabular form. If displayed on the Image Window, it is superimposed as a graphic on a frame at the reporting locations.
Grids refer to data placed at regularly spaced intervals at some level in the atmosphere. Grids are displayed graphically using isopleths.
Like images, grids represent data in a two-dimensional, evenly spaced matrix. Unlike images, grids represent data having low volume and high resolution at each data point.
Since grids may represent forecast fields from numerical models, they must have two separate time attributes to identify the data temporally. One time attribute represents the time the model was initialized. The second represents the time the data is valid. For example, a 36-hour forecast from a model run at 00 UTC on 17 January is valid at 12 UTC on 18 January.
Weather text refers to any information transmitted in alphanumeric form. It can be man- or computer-generated output containing forecasts, observations, weather advisories or other public information.
In McIDAS-X, static data refers to database information that changes little over time. Two examples of static data are:
These static data make dissemination of the other McIDAS-X data easier.
The McIDAS-X MAP command uses map files to superimpose outlines of political or geographic boundaries on the McIDAS-X Image Window. These outlines may be associated with data already on the frame or defined in the MAP command itself.
Station tables provide a cross reference list of reporting stations, independent of the reports themselves. For example, if a synoptic observation tells you that the station reporting is number 72641, the report doesn't tell you that 72641 is Madison, Wisconsin. The station tables provide this information.

Users request, receive and display McIDAS-X data using the following:
ADDE makes McIDAS-X image, point, grid and weather text data available to users. During a McIDAS-X session, however, users may need to access other files, such as font files, political and geographic boundary files or station tables, which reside on their workstations but are not available with ADDE. These files can be accessed using file redirection. Additionally, users may want to access files specific to their application that aren't needed by other users. The Unix environment variable MCPATH allows them to do this.
ADDE, file redirection and MCPATH are briefly described on the following pages.
|
For more information about accessing McIDAS-X data, see the McIDAS User's Guide. |
ADDE is a networked system of clients and servers that makes McIDAS-X data available to users. A client is a workstation in a distributed system that initiates a data request, then receives and displays the requested data. A server is the machine in a distributed system that stores data and supplies it to the client upon request. ADDE allows many users to access ingested and decoded data from the same machine, regardless of their location. See Figure 2-2 below.
Figure 2-2. ADDE is a networked system of clients and servers that communicate using the TCP/IP communications protocol.

Each McIDAS-X workstation session acts as both a client and a local server. When a client requests data from the local server, this server searches for the data in the directories that the user's session has access to. A client may also request data from a remote server , which can be one of the following:
Any ADDE command entered by a user to access data must include the ADDE dataset name. The ADDE dataset name consists of two parts:
The group name, which the user configures with the McIDAS-X DATALOC command, is stored in a client routing table . On the client, the group name identifies the server machine to get the data from. On the server, it helps identify the data that the client is requesting.
The server uses the descriptor name to identify the type of data the user wants to access and the range or names of files to search. The table containing this information is called the server mapping table. Users assign dataset names on the server with the DSSERVE command.
When a user enters an ADDE request, the McIDAS-X software performs the steps below to determine the source of the data.
File redirection lets a user identify the location of individual files on the system. The default configuration of a McIDAS-X session is to search for local files in the following directories.
Local files may exist anywhere on the workstation, as long as an application knows where to look for them.
Entries in the file redirection table are made with the McIDAS-X REDIRECT command. For example, a user who has a McIDAS-X application that requires the file MYFILE in the directory /home/fred/data, would enter this REDIRECT command:
REDIRECT ADD MYFILE "/home/fred/data
All subsequent commands that access MYFILE would assume it is in /home/fred/data.
McIDAS-X also contains the environment variable, MCPATH , which defines directories for McIDAS-X commands to search when looking for data and help files. Commands requiring these types of files search each directory in the order listed in MCPATH .
If a user lets McIDAS-X set MCPATH , it will contain the directories shown below. Other directories can be added to MCPATH using the colon (:) character to separate the directory names.
$HOME/mcidas/data:$HOME/mcidas/help:~mcidas/data:~mcidas/help |
If a file exists in more that one directory in MCPATH , McIDAS-X will use the first one that it finds. If you write data to a new file, MCPATH will place that file in the first writable directory in the MCPATH list.

When a user starts a McIDAS-X session, these two windows appear on the screen:
Figure 2-3 below shows a typical start-up screen. The title bar in each window lists the version of McIDAS-X. In McIDAS-X, it also shows the user's logon and the host name. Optionally, a Graphical User Interface (GUI) can be started, which will become part of the Image Window.
In this section, you will learn how the windows are used and the type of output displayed on them.
Figure 2-3. At start-up, the McIDAS-X display contains the McIDAS-X Text and Command Window (in the foreground) and the McIDAS-X Image Window (in the background).

The McIDAS-X Text and Command Window is used for:
When a session is started, McIDAS-X can display output on 10 different text frames in this window. You can switch between these text frames using the numeric keypad on the keyboard. Figure 2-4 shows a sample McIDAS-X Text and Command Window.
Figure 2-4 . The McIDAS-X Text and Command Window displays text messages.

Many system defined single-letter commands toggle the McIDAS-X session between different modes. Others run commands to provide information. These system defined commands are run by simultaneously pressing the Alt key and the letter key, or by typing the letter and pressing Enter from the Text and Command Window.
The table below lists the system defined single-letter commands currently provided in McIDAS-X.
|
Command |
Description |
|---|---|
|
lists Metar, Synoptic and RAOB stations within the cursor bounds |
|
|
toggles the velocity cursor on and off when tracking cloud drift winds |
|
User defined single-letter commands are run by simultaneously pressing the Ctrl key and the letter key. This causes the contents of the McIDAS-X string corresponding to this letter to be run.
Multiple-letter commands, which are the most common interface for manipulating a McIDAS-X session, have four components:
A sample McIDAS-X command line is shown below.

Each command line component and value is separated by one or more blank spaces. An individual parameter requiring a space must be surrounded with single quotes (` ') so it is treated as one parameter.
Command positional parameters provide input to a command and must be entered in the exact order specified. Use them in commands that have options which the user must always enter. One advantage of positional parameters is minimizing the number of keystrokes a user types. Be careful not to negate this advantage by using so many positional parameters that the user can't remember them all.
Like command positional parameters, keywords are used for entering command input. Unlike command positional parameters, they are optional for most McIDAS-X commands and can be entered in any order as long as they follow command positional parameters and precede quoted text.
Keyword parameters are often used to clarify commands with many complicated options. Although keywords can occur in any order, their positional parameters must be entered in the order indicated. Since users don't always specify all keyword positional parameters in a command, be sure to assign them reasonable defaults.
In addition to the keywords that an application has built into it, McIDAS-X has six global keywords, which are common to all McIDAS-X commands:
You can retrieve the parameters for these global keywords in your applications, as long as you don't change their functionality.
|
For more information about the McIDAS global keywords, see the McIDAS User's Guide. |
Quoted text input is most often used when a single string entered by a user may require extra spaces. Each application can contain only one quote string and it must be the last part of the command the user enters. Using quote fields in McIDAS commands is relatively easy from the McIDAS Text and Command Window; running McIDAS commands with quote strings from Unix shell prompts is more difficult. For this reason, the preferred method for entering strings with spaces in them from the command line is to use a positional or keyword parameter and surround the string with single quotes.
Text output generated by commands occurs in three different forms.
The default mode for text output is to display standard and error text messages on the Text and Command Window, and to suppress debug messages. Use the DEV global keyword to specify the destination device of the text output generated by a McIDAS command.
Online helps list the syntax of each McIDAS-X command including the parameters, keywords and remarks. To access the online help, type HELP in the McIDAS-X Text and Command Window followed by the command that you want information for. To get the online help for the DSINFO command, for example, you would type: HELP DSINFO .
Alternatively, you can invoke the HELP command while entering a command from the keyboard by typing the command name, then pressing Alt ?. An abbreviated help is displayed on the current text frame.
The McIDAS-X Image Window displays frames containing McIDAS-X generated images and graphics, and can optionally be surrounded by the McIDAS-X GUI, as shown in Figure 2-5 below.
Figure 2-5. The McIDAS-X Image Window displays images and graphics.

The manner in which images and graphics are displayed on the Image Window is determined by several factors:
The McIDAS-X Image Window displays satellite and radar data in shades of gray. Alphanumeric data and scientific diagrams are displayed with colored graphical lines and symbols independent of the grayshaded data. Users define the number of gray shades and graphical colors in the .mcidasrc file. The default configuration is 128 gray shades and 16 graphics levels with a maximum of 254 total levels for the image and graphics levels.
When McIDAS-X displays images and graphics on the Image Window, it stores each pixel value in a frame object. The user can map these pixel values to specific red, green and blue color values. The McIDAS-X EU and EB commands modify the color combinations for image data; the GU command modifies the colors of graphics levels.
Via the .mcidasrc file, users can also define the number and size of frames in the McIDAS-X Image Window. The default is to start the session with four frames that are 480 lines (vertical) by 640 elements (horizontal).
McIDAS-X can display an automatically repeating sequence of frames much like a movie loop. The McIDAS-X commands LS and LB define the sequence of frames. The DR command modifies the speed of the loop. The Alt A and Alt B commands step through the individual frames in the loop. Alt L starts and stops the loop.
McIDAS-X uses four different, yet interconnected coordinate systems to define the location of data points within an image:
These coordinate systems are used to reference image data on disk and depict it on the McIDAS-X Image Window. McIDAS-X graphics also use a world coordinate system, which is described in the section titled Advanced McIDAS-X graphics techniques in Chapter 4, McIDAS-X Utilities .
McIDAS-X receives satellite and radar images. The image coordinates for this data are defined by the sensor source providing the image and form the basis for the other McIDAS-X coordinate systems.
A full image is the entire image transmitted by the sensor. It is a sequence of lines and elements usually arranged from top to bottom, forming a grid for displaying data points on a McIDAS-X frame. Lines run horizontally across the frame; elements run vertically up and down the frame. The top line and leftmost element have the image coordinates (1,1). Each pixel has a unique pair of line and element values that are its image coordinates.
Some sensors have the ability to send only a sector covering a region of interest instead of transmitting a full image. This image sector is a rectangular subset of an image with the same coordinate system. An image sector may also be at a lower resolution , meaning data sampled in lines and/or elements, but the image coordinate system always refers to it relative to a full image. See Figure 2-6 below, which shows a full image and image sector. The upper-left image coordinates of the full image are (1,1); the upper-left coordinates of the image sector are (3501,5001).
In McIDAS-X, images and image sectors are stored in files called areas . File coordinates are based on the physical size of the image sector. They are zero-based and represent the location of a data point in an area file referenced sequentially by lines and elements. In Figure 2-6, the first data point in the image sector has file coordinates (0,0). The bottom-right data point has file coordinates (number of lines minus 1, number of elements minus 1).
Figure 2-6. Image and file coordinates are shown for a full image and image sector..

If the data is navigated, the image coordinates can be converted to earth coordinates (latitude and longitude) and vice versa. Earth coordinates are specified in degrees, minutes, and seconds in the form DDD:MM:SS, or in decimal degrees such as 46.36. In McIDAS-X, all latitudes south of the equator and longitudes east of Greenwich are negative. Latitudes run from -90:00:00 to +90:00:00 and longitudes run from -180:00:00 to +180:00:00.
The pixels on McIDAS-X frames are arranged by lines and elements. A frame contains a representation of an image sector displayed on the McIDAS-X Image Window. The image sector shown in Figure 2-7 is an enlarged view of the image sector shown in Figure 2-6. The mcimage program, which is discussed later, takes the image data in the frame and maps it to the McIDAS-X Image Window. The Window Manager then displays the McIDAS-X Image Window on the workstation monitor.
The pixel in the upper-left corner of the frame has the frame coordinates (1,1) which means (line 1, element 1). The total number of lines and elements on the frame is determined by the frame size. The lower-right corner of the default-sized frame is (480,640).
|
For information about converting coordinate systems from line/element to latitude/longitude and vice versa, see the Image data and McIDAS-X navigation sections in Chapter 5, Accessing Data . |
Frames may be subdivided into rectangular regions called panels. Each panel on an image frame has its own relative coordinate system, which defines the upper-left corner as (1,1). For information about panel generation, and interaction, refer to the McIDAS User's Guide.
Figure 2-7. Earth and frame coordinates are shown for the image sector.

Now that you've seen McIDAS-X from a user's perspective, you need to understand how McIDAS-X operates at the system level. When McIDAS-X is started, it creates the environment in which it will run. In this section, you will learn about the system-level components of the McIDAS-X environment and how they fit together.
The McIDAS-X environment consists of these three components:

When a McIDAS-X session is started, a block of shared memory is created as an inter-process communication mechanism between McIDAS-X applications, resident programs and the display environment. This shared memory block is composed of:
The shared memory key associated with the memory is stored in the environment variable MCENV_POSUC.
User Common (UC) contains information about the McIDAS-X session, such as the current image frame in view, the maximum number of image frames and the cursor position. UC has two parts:
Positive UC contains the current state of the McIDAS-X session. This information is available as long as the session that created positive UC is active. Values in positive UC may change. For example, if frames are looping or you're moving the cursor on the screen, the values in positive UC related to the current frame number or cursor position will change.
Negative UC is not part of the shared memory block created when the McIDAS-X session is started. It is created by mmap when a McIDAS-X command is started, and is initialized with the values in positive UC at the time the command is entered. The file descriptor key associated with negative UC is then placed in the environment variable MCENV_NEGUC.
Negative UC values are not changed by other activities in the McIDAS-X session, such as frame looping or cursor motion. When a command finishes running, its copy of negative UC is deleted if it was not inherited from a parent process.
As a McIDAS-X programmer, you need to understand the concepts of visibility and inheritance when accessing positive and negative UC.
The User Common policy for visibility and inheritance when running a McIDAS-X command is described below.
|
For a complete list of the contents of User Common, see Chapter 6, Format of the Data Files. |
Image frame objects contain information describing the contents and appearance of a frame displayed on the McIDAS-X Image Window. McIDAS-X provides a variety of library functions and commands to manipulate the contents of frame objects. An individual frame object contains not only pixel values to display, but also tables for image color enhancements, graphics color enhancements and stretching tables.
Redirection tables are stored on disk in the file $HOME/mcidas/data/LWPATH.NAM . When McIDAS-X is started, the contents of the current redirection table are loaded into shared memory. This is where the McIDAS-X disk file system retrieves its redirection information.

The second component of the McIDAS-X environment is resident programs. When a user types the mcidas command, the user-specified configuration information, which is in the text file $HOME/.mcidasrc, is determined.
Once the configuration information is extracted, the resident programs below are started.
The mcenv program performs the following procedures to start a McIDAS-X session:
The temporary directory created by mcenv stores session-dependent files such as frame directories, string tables and frame enhancement tables.
The mctext program performs the tasks below, as shown in Figure 2-8:
Figure 2-8. The mctext program controls command line input from the keyboard and displays text output on the Text and Command Window, while mcimage controls the McIDAS-X Image Window for displaying images and graphics.

The command line arguments for mctext can alter the number of text lines in the window buffer and recall the number of previously run commands. mctext can also start several other commands once it initializes its window environment.
When the mcidas script starts a session, one of the command arguments passed to mctext is mcimage .
As shown in Figure 2-8, the mcimage program does the following:

The third component of the McIDAS-X environment is applications programs. A McIDAS-X applications program is any program that runs from the McIDAS-X command line. McIDAS-X provides Application Programming Interface (API) functions that interact with all the McIDAS-X components described in this chapter. These API functions interact with the Image Window, Text and Command Window, and mouse. The programs access data both locally and through ADDE, and manipulate the contents of the session, as shown in Figure 2-9 below.
Figure 2-9. McIDAS-X applications rely on the API functions to read data files for them.

Figure 2-10 combines the three components of the McIDAS-X environment: the shared memory, resident programs and applications. The arrows represent APIs and imply the flow of data or information.
Figure 2-10. The McIDAS-X environment consists of shared memory, the resident programs mctext and mcimage , and user applications.

The previous two sections introduced you to McIDAS-X from a user's perspective and provided an overview of the McIDAS-X environment. This final section describes how to build applications that will interact with the McIDAS-X environment. In this section, you will learn how to:
This chapter contains references to specific source files. The table below describes the suffixes McIDAS-X uses to name source files.
|
Suffix |
Language |
Description |
|---|---|---|

You can write McIDAS-X applications in either C or Fortran. This section describes the concepts you need to know to write basic McIDAS-X applications in either language, along with the formats and policies for writing online command helps and setting status codes.
When you write a Fortran program for McIDAS-X, you can't write it as a Fortran MAIN program. Instead, you must place it in the McIDAS-X environment as a subroutine named MAIN0, which is linked with a command jacket called main .
The command jacket main initializes the run-time environment for the command, including:
The first executable line of any McIDAS-X application written in Fortran must be the statement subroutine main0. The code fragment below is a sample command to print the phrase Hello World to the McIDAS-X Text and Command Window.
subroutine main0 call sdest ('Hello World',0) call mccodeset (0) return end |
When writing a C program for McIDAS-X, the main is provided directly in the C code. The first thing you will do when writing a McIDAS-X application in C is to initialize the McIDAS-X environment with a call to the function Mcinit . This function performs the same command environment initialization performed by the Fortran command jacket main . To write McIDAS-X applications in C, your source code should also contain a reference to the McIDAS-X include file mcidas.h .
The code fragment below demonstrates how the same McIDAS-X command to print Hello World is written as a C application.
McIDAS-X uses include files to hold definitions of constants specific to its software. mcidas.h contains system-wide constants and function prototypes. Equivalanet constants for Fortran applications are found in the *.inc files.
The include file mcidas.h contains all the function prototypes for C-callable API routines in the McIDAS-X library. It also contains two constant values that are commonly used in McIDAS-X applications.
|
Constant value |
Description |
|---|---|
mcidas.h also includes a group of defined types that you should use to ensure platform independence of data types. Use the defined types below when writing interface routines that will be used between C and Fortran.
|
Defined type |
Description |
|---|---|
|
equivalent to a double precision declaration type in Fortran |
|
To ensure portability of Fortran jackets written in C, the preferred types to use are Fdouble, Fint and Freal, as the INTEGER*2, INTEGER*4, REAL*4 and REAL*8 declarations are not part of the Fortran-77 standard.
In both Hello World examples above, calls were made to the functions mccodeset and Mccodeset . These functions set a status code that can be passed from the application to the calling environment. Currently, the acceptable return codes for McIDAS-X commands are as follows:
|
Return code |
Description |
|---|---|
This information may be very useful to the calling environment, especially when using McIDAS-X commands in scripts designed for batch processing. For example, if you have a script that copies satellite images from several different sources and then creates a mosaic of the images, you may not want the script to generate the mosaic until all of the images are available. The processing script will not be able to verify that all of the data is available until all of the commands necessary to acquire the satellite data have returned a status of 0 indicating success.
If a command returns a status of 1, it typically means the user entered the command incorrectly and it will never run properly. A status of 2 is typically returned when data requested by a user is not yet available.
Setting return statuses for McIDAS-X applications became mandatory, beginning with McIDAS-X version 7.0 released in May 1996. Most McIDAS-X applications written before that upgrade do not yet contain the Mccodeset /mccodeset features.
The McIDAS-X command provides users with a quick way to get a listing of a command's structure and available options. The original text for these helps is stored in the source file for each command. You will use one of two template formats when creating online helps. The format for Fortran commands is shown below.
The similar help template for commands written in C is shown below.
The first line of each help contains the command name followed by two dashes (--). These dashes are used as flags to the system for the Alt ? help option described earlier in this chapter.
|
To learn how to build help files, see Chapter 3, Getting Started in McIDAS-X . |

In the Hello World examples above, several function names are in bold type. These are examples of functions included in the McIDAS-X library. The library contains all the object code for the functions and subroutines that make up the McIDAS-X Application Program Interface (API).
The name of the McIDAS-X library is libmcidas.a .
To provide easy recognition of McIDAS-X functions, the names of all new McIDAS-X functions begin with one of the prefixes below.
|
Prefix |
Description |
|---|---|
The McIDAS-X philosophy regarding function prefixes is that once a function is released with an Mc or mc prefix, it is a stable member of the McIDAS-X library and will have neither its functionality nor calling sequence changed. The M0 or m0 prefix is assigned to:
SSEC uses the M0/m0 prefix while testing a routine's functionality and calling sequence. When the function is deemed stable, the prefix is changed to Mc/mc .
SSEC adopted this function prefix naming convention in the spring of 1995. Most of the routines currently found in the McIDAS-X library predate this naming convention. As SSEC modifies existing software, it will make every effort to change the names of older functions where practical.
If new functions are written to replace older, non-prefixed functions, SSEC's policy for removing the old functions from McIDAS-X is as follows:
SSEC has also developed a standard interface documentation block template that you should use for all new McIDAS-X library functions. This format is used to generate the online API function documentation distributed with the McIDAS-X software.
The table below lists and defines each field in the documentation block. More information follows along with examples from the mchmstostr function. If a function doesn't require a description for every field, you should still include all fields in the documentation block and fill the unused fields with the word none.
This field is usually a one-line description of what the function does. The example below is taken from the function mchmstostr .
Name: mchmstostr - Converts a time to a character string |
This field describes the function type value returned, such as float, integer, or subroutine. It also contains any include files associated with the function, and the type and size of each parameter in the calling sequence.
Interface: integer function mchmstostr (integer hms, integer format, character*(*) string) |
This field describes each of the input parameters to a function. It should include any discussion of expected formats and units.
Input: hms - Time in the form hhmmss. format - Output format desired for the string. |
This field describes parameters that pass input to a function and have their values modified within the function. It is important to describe the state of these parameters both on input and output. Since this example doesn't contain parameters in this field, the entry looks like this:
Input and Output: none |
This field describes each of the output parameters to a function. The description should include any discussion of expected formats and units.
Output: string - Destination character string. |
This field describes the possible values that can be returned by this function. The McIDAS-X convention for return values is described below.
A function should have as many unique failure return values as ways the function can fail, as shown in the example below.
Return values: 0 - Success. -1 - Invalid value for hms. -2 - Invalid value for format. -4 - Destination string is not big enough. |
This field describes additional information that is necessary or useful to a programmer. For example, it would be helpful for a programmer to know:
Other useful information may include references to:
An example of this field for mchmstostr is shown below.
Remarks: If the input value for hms is 23444 then: form string 1 02:34:44Z 2 02:34:44 3 02:34:44UTC 4 02:34:44 Z 5 02:34:44 UTC 6 2:34:44 |
This field is used to generate the cross reference list for the online API function documentation. The categories available in McIDAS-X are:
| calibration | converter | day/time | display |
| event | file | graphic | grid |
| image | ingest/decode | met/science | navigation |
| point | text | sys_config | system |
| user_interface | utility |
In mchmstostr , the categories field looks like this:
Categories: converter day/time |
The next two pages contain the complete interface documentation block templates for both C and Fortran functions. Although the categories field contains the complete list of available entries, you will choose only those appropriate to your function. Text files containing the templates are available on the MUG Web Site.

McIDAS-X applications and functions can be written in either Fortran or C. Because McIDAS has its roots in Fortran, not all functions in the McIDAS-X library have both C and Fortran calling interfaces.
While McIDAS-X attempts to accommodate both languages, C language programs will sometimes need to interface with Fortran-coded functions from the McIDAS-X library. When calling Fortran functions from C applications, you must keep in mind these four important differences between the languages.
Below are examples of how these language differences affect a C application calling a Fortran function. Also provided is an example of writing Fortran-callable routines in C and information about writing Dynamic Link Library modules.
The McIDAS-X Fortran function iyxll converts integer values from frame (tv) line and elements to single precision floating point values for latitude and longitude. The sample Fortran code fragment below calls this function.
integer tvlin, tvele integer onscreen real lat, lon tvlin = 100 tvele = 200 onscreen = iyxll(tvlin, tvele, lat, lon) |
To call the same function from a C application, your code would be similar to this:
The special type declarations Fint and Freal are Fortran integer and real declarations defined in the include file mcidas.h . They are designed to provide platform-independent interfaces between Fortran and C applications.
Since parameters are passed into functions in C by value, you must reference the variables in the calling sequence with the ampersand (& ) symbol. Calling iyxll by value, as shown below, would most likely result in a segmentation violation error.
onscreen = iyxll_ (tvlin, tvele, lat, lon); |
The McIDAS-X library function mdsvc , which is coded in Fortran, returns the appropriate real-time MD file given a character string schema type and an integer value representing a Julian day. Below is a sample Fortran code fragment to call this function.
integer mdfile, day character*4 schema schema = 'ISFC' day = 96017 mdfile = mdsvc(schema, day) |
To call the same function from a C application, your code would be similar to this:
Note that the variable schema is passed in with no ampersand character. The function expects the variable to be passed in by address and since schema is already a pointer, no ampersand is required.
Also note that the call to mdsvc_ in C has an additional parameter, schema_length . This argument is passed by value to the Fortran function so the length of the string containing the schema type is known to mdsvc internally.
The conflict of Fortran column-major arrays and C row-major arrays is difficult to resolve. Arrays are contiguous memory segments, no matter how many dimensions they have. The difference between the languages is in how the individual elements of the arrays are arranged and accessed, as described below.
If you declare a Fortran array like this:
integer array(2,3) |
Then to reference the memory segments in increasing order, you will reference them like this:
1,1 2,1 1,2 2,2 1,3 2,3 |
If you declare a C array with the same dimensions:
int array[2][3] |
Then to reference the memory segments in increasing order, you will reference them as shown below. They are shown as one-based values for comparison to the Fortran array even though the C language is actually zero-based.
1,1 1,2 1,3 2,1 2,2 2,3 |
When accessing data stored in multi-dimensional arrays, it is difficult to recognize if an array is stored in Fortran or C. Since most McIDAS-X applications were historically written in Fortran, multi-dimensional data is usually stored in column-major format. To address values for column-major data in C, dimension your arrays as one-dimensional and use the conversion equations below to index to the appropriate location.
The indexing equation for a column-major (Fortran) array is as follows, assuming 1-based indexing:
The indexing equation for a row-major (C) array is as follows, assuming 0-based indexing:
Now that you understand how the C and Fortran languages treat different elements of parameter passing into functions, you need to know how to write Fortran-callable functions in the C language. The example below builds the calling sequence for a unit conversion routine that takes an integer value and unit types and returns a floating point number. The function also returns an integer type for a status code.
In C, the prototype and function would look like this:
int convert (int, char *, char *, float *); /* function prototype */ int convert (int input, char *input_units, char *output_units, float *output) { : : } |
The entire source code for the Fortran-callable version of this function would appear as follows. The important concepts are bolded.
Note that the Fortran-callable function declaration explicitly includes the underscore character (_). The McIDAS-X library function fsalloc converts Fortran strings to C strings. The function strtofs converts C strings to Fortran if you need to pass character string output back to the Fortran program that called this function jacket. Be sure to call the C function with the appropriate data types.
A shell script is a program containing a set of executable commands. Shell scripts are useful for running a series of individual McIDAS-X commands outside of McIDAS-X. Generally, you must invoke the McIDAS-X resident program, mcenv , before running a series of McIDAS-X commands.
|
For information about writing shell scripts in McIDAS-X, see Appendix H, Running Commands Outside a McIDAS-X Session, in the McIDAS User's Guide. |

It's a fact of life that programs do not always behave as expected. Therefore, you should implement some type of debugging strategy to isolate and repair errors. This section describes the tools available to help you debug applications. McIDAS-X provides two facilities to aid your search for the elusive bug. Additionally, Unix systems provide a variety of symbolic debugging tools, the most common of which is dbx or gdb.