SMARTS Component Software Interface Specifications

DEOS Technical Note #13

Dr. Geoffrey E. Quelch

Research Fellow,
University of Delaware,
Center for Climatic Research


   University of Delaware
   NewarkDE 19716
   
  

Version 2

All material herein is copyright by The Delaware Environmental Observing System

Published: August 6th 2004

Revision History
Revision 1.12004/08/06GEQ
Initial version
Revision 1.22004/08/30GEQ
Revised for rrpm real index arrays.
Revision 1.32004/09/08GEQ
Added statement of missing data.
Revision 1.42004/09/21GEQ
Added error condition to interface, specified possible error values and clarified output coordinate specifications.
Revision 1.52004/10/12GEQ
Modified error conditions for block use. Added data convention statement for rrpm.
Revision 1.62005/03/23GEQ
Modified error conditions to the more general status conditions after adding extract program use.
Revision 1.72005/03/25GEQ
Added -22 and -23 to error conditions.
Revision 1.82005/03/29GEQ
Added -10 to error conditions. Made the status condition message section it's own main section.
Revision 1.92005/04/11GEQ
Added -11 and -12 to error conditions.
Revision 1.102006/03/27GEQ
Added interface for calibrated product.
Revision 1.112006/03/30GEQ
Added revised interface for Z bias and exponent values. Now providing file value and station value.
Revision 1.122006/03/31GEQ
Added -102 and -103 to error conditions.
Revision 2.12006/09/26GEQ
Incremented version number of this document to 2.
Revision 2.12006/12/11GEQ
Added -24 to error conditions.
Revision 2.22006/12/13GEQ
Added -3 to error conditions.
Revision 2.32007/01/03GEQ
Added dfe to -102 error condition. Added -104 condition.
Revision 2.1.62008/02/13GEQ
Revised compiler versions to their current values.
Revision 2.1.72008/03/21GEQ
Added ifgen interface.

Table of Contents

Introduction
General Issues
Fortran
C++
Data Interchange
Status Condition Messages
Specific Programs
General Considerations
RRPM
IFGEN

Introduction

This document summarizes the interfaces between the C++ and Fortran components of the SMARTS programs.

General Issues

The following are general issues surrounding the discussions in the following sections. and Fortran components of SMARTS .

Fortran

SMARTS is built using version 4.1.2 of the GNU Fortran compiler.

The numerically intensive parts of the program are constructed using Fortran.

C++

SMARTS is built using version 4.1.2 of the Gnu Compiler System.

The non-numerically intensive parts of the SMARTS programs are constructed using C++.

Data Interchange

In order for the numerical processing to be undertaken using the Fortran derived components, data must be exchanged between the C++ driving component and the Fortran numerical processing component. This is accomplished using combinations of the following structures to hide most of the details of the data being transferred.

In each case, details are given of the C++ class and the corresponding Fortran derived type.

Member Names

The names of internal data members can differ between the two languages. The types must correspond as written as well as the sizes of the items, but the names do not have to match.

Missing Data

For the array data, values that are ≥ zero shall be considered to be valid data, any value < zero will be considered missing data and thus be ignored.

Integer Array Data

This class is designed to store a single index of an array to be passed as a separate command line argument. However, it may be used to store any run-time integer data as required.

class IntegerArray {
public:
    int   order;
    int   x_start;
    int   y_start;
    int   x_size;
    int   y_size;
    int * data;
    int   padding[20];
};
1

This is the class definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement indicates that the member values described below are directly accessible.

3

The rank of the data array contained in the class is given by order.

4

The X value of the starting cell of the data array.

5

The Y value of the starting cell of the data array.

6

The size of the array in the X direction.

7

The size of the array in the Y direction.

8

An integer array of rank order containing the data values.

9

An array containing the Fortran array information metadata.

The equivalent derived type in Fortran would be:

      type f_integer_array
          sequence
          integer :: order
          integer :: x_start
          integer :: y_start
          integer :: x_size
          integer :: y_size
          integer,dimension(:), pointer :: data
          integer :: padding(20)
      end type
1

This is the derived type definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement guarantees that the elements are stored in the order specified.

3

The rank of the data array contained in the class is given by order.

4

The X value of the starting cell of the data array.

5

The Y value of the starting cell of the data array.

6

The size of the array in the X direction.

7

The size of the array in the Y direction.

8

An integer array of rank order containing the data values.

9

An array containing the Fortran array information metadata.

The order value must always have a meaningful value. The other options, including the data array, may be provided, if they are not, then a negative value shall be placed in that variable. An unallocated data array must be accompanied by a value of order of zero.

Real Array Data

This class is designed to store a single floating-point data array. However, it may be used to store any run-time integer data as required. The class also contains data to allow an entire array to be specified, if desired.

class FloatArray {
public:
    int     order;
    int     x_start;
    int     y_start;
    int     x_size;
    int     y_size;
    float * data;
    int     padding[20];
};
1

This is the class definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement indicates that the member values described below are directly accessible.

3

The rank of the data array contained in the class is given by order.

4

The X value of the starting cell of the data array.

5

The Y value of the starting cell of the data array.

6

The size of the array in the X direction.

7

The size of the array in the Y direction.

8

An floating-point array of rank order containing the data values. If values are provided for x_size and y_size then x_size*y_size must equal order. The array, if used to store 2D data (i.e. both x_size and y_size > 1) , will be stored row-wise.

9

An array containing the Fortran array information metadata.

The equivalent derived type in Fortran would be:

      type f_real_array
          sequence
          integer :: order
          integer :: x_start
          integer :: y_start
          integer :: x_size
          integer :: y_size
          real,dimension(:), pointer :: data
          integer :: padding(20)
      end type
1

This is the derived type definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement guarantees that the elements are stored in the order specified.

3

The rank of the three arrays contained in the class is given by order.

4

The X value of the starting cell of the data array.

5

The Y value of the starting cell of the data array.

6

The size of the array in the X direction.

7

The size of the array in the Y direction.

8

An floating-point array of rank order containing the data values. If values are provided for x_size and y_size then x_size*y_size must equal order. The array, if used to store 2D data (i.e. both x_size and y_size > 1) , will be stored row-wise.

9

An array containing the Fortran array information metadata.

The order value must always have a meaningful value. The other options, including the data array, may be provided, if they are not, then a negative value shall be placed in that variable. An unallocated data array must be accompanied by a value of order of zero.

Integer Processing Options

This section describes the method whereby integer user or system settings for the product are transferred from C++ to the Fortran processing portion.

class IntegerOptions {
public:
    int order;
    int option[N_I];
};
1

This is the class definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement indicates that the member values described below are directly accessible.

3

The rank of the option array set to N_I.

4

An array of rank order containing the integer settings for the process. The value N_I will be known at compile time. The meaning of all N_I options will be outline below.

The equivalent derived type in Fortran would be:

      type f_integer_options
          sequence
          integer :: order
          integer,dimension(N_I) :: option
      end type
1

This is the derived type definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement guarantees that the elements are stored in the order specified.

3

The rank of the integer options array set to N_I.

4

An array of rank order containing the integer settings for the process. The value N_I will be known at compile time. The meaning of all N_I integer options for all SMARTS programs are outlined below.

Even if there is only one option, the derived type will use an embedded array of length one.

Floating-Point Processing Options

This section describes the method whereby floating point user or system settings for the product are transferred from C++ to the Fortran processing portion.

class FloatOptions {
public:
    int   order;
    float option[N_F];
};
1

This is the class definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement indicates that the member values described below are directly accessible.

3

The rank of the option array set to N_F.

4

An array of rank order containing the integer settings for the process. The value N_F will be known at compile time. The meaning of all N_F floating-point options will be outline below.

The equivalent derived type in Fortran would be:

      type f_real_options
          sequence
          integer :: order
          real,dimension(N_F) :: option
      end type
1

This is the derived type definition statement. The class name in C++ and the derived type name in Fortran do not have to be the same.

2

This statement guarantees that the elements are stored in the order specified.

3

The rank of the integer options array set to N_F.

4

An array of rank order containing the integer settings for the process. The value N_F will be known at compile time. The meaning of all N_F options will be outline below.

Even if there is only one option, the derived type will use an embedded array of length one.

Status Condition Messages

This section describes the possible values of the status flag and associated message passed as an integer as the last argument on a call to a SMARTS processing subroutine call.

The status codes are also used in other areas of SMARTS but adhere to this table.

In general, a value of zero indicates successful completion, a value less than zero indicates a fatal error condition, and a value greater than zero indicates a non-fatal but warning condition.[1]

Table 1. Interpretation of Status Codes

ValueGeneratorDescription
-104dfe ProgramThe option specifying the team name is invalid.
-103rrpm ProgramThe option specifying the calibration method is invalid.
-102ifgen, rrpm or dfe ProgramsThe option specifying the field type is invalid.
-101rrpm ProgramThe option specifying the procedure for combining values for a given cell occurring in multiple radars is invalid.
-24Input Data CheckOne or more alphabetic data type names provided were invalid.
-23General Data ErrorNo records were returned from the database where one or more were expected.
-22Input Data CheckThe stream name provided as input data is invalid.
-21Input Data CheckThe station name provided as input data is invalid.
-20Input Data CheckThe network name provided as input data is invalid.
-12File OpenWhen opening the file requested, one of more "bad" bits was set.
-11File CheckThe file requested was empty.
-10File CheckThe file requested could not be found.
-3AnyApplication and database version mismatch.
-2AnyA call to a deallocate function failed.
-1AnyA call to an allocate function failed.
0AnySuccessful completion.

Specific Programs

The following sections detail the specific interfaces between components for each program of the SMARTS system. The following programs have C++ and Fortran components.

General Considerations

Unless specified below, structures designated as input will have their member arrays allocated from C++ and so should not be altered in the Fortran code. Similarly, arrays designated as output, should be allocated in the Fortran code. In both cases, the C++ code will be responsible for deallocating the arrays once they are no longer needed.

All Latitude/Longitude coordinate arrays will be assumed to be in decimal degrees below and that the values indicate the center of the grid cell unless specified below.

In all cases, the components inside the options structure shall be allocated and deallocated from the C++ code.

RRPM

The Re-sampled Radar Precipitation Mosaic (RRPM) program generates one of two different products. Firstly, it can create a product that combines the available DPA data into a mosaic, by either averaging or taking the maximum of data values for the same cell that occur in two or more radar fields; secondly it can generate a product based on the mosaic but include calibration of the individual radar files by using a fixed Z/R relationship to better describe the individual radar characteristics and utilizing the bias and exponent values used to generate the DPA files themselves to further improve precipitation estimates. In both cases the data is re-sampled to the DEOS grid.

Control over which product is generated by a specific run of the program is described below.

Data Storage to Disk

The program stores completed fields to disk in compressed (gzip) format. The gzstream interface (a C++ wrapper to the Zlib library) is used to achieve this.

Call Interface

This section describes the method whereby user or system settings for the product are transferred from C++ to the Fortran processing portion.

The call interface for this program on the C++ side will be:

IntegerArray x_coord_input;
IntegerArray y_coord_input;
FloatArray   input_data;
FloatArray   z_r_data;
FloatArray   longitude_points;
FloatArray   latitude_points;
FloatArray   output_data;

IntegerOptions rrpm_int_options;
FloatOptions   rrpm_float_options;

int   error_code;

...
extern "C" {
 void rrpm (IntegerArray *, IntegerArray *, FloatArray *, FloatArray *,
            FloatArray*, FloatArray *, FloatArray *,
            IntegerOptions *, FloatOptions *, int *);
}
...
rrpm (&x_coord_input, &y_coord_input, &input_data, &z_r_values,
      &latitude_points, &longitude_points, &output_data,
      &rrpm_int_options, &rrpm_float_options, &error_code);

The call interface for this program on the Fortran side will be:

      subroutine rrpm(in_x_coord, in_y_coord, in_grid, in_z_r_data
     + out_lat_coord, out_long_coord, out_grid,
     + i_options, r_options, error_code)
!
      implicit none

      type(f_integer_array) :: in_x_coord ! HRAP X coordinate for data
      type(f_integer_array) :: in_y_coord ! HRAP Y coordinate for data

      type(f_real_array) :: in_grid     ! Input DPA data in HRAP coordinates
      type(f_real_array) :: in_z_r_data ! Z/R data for the individual radars

      type(f_real_array)  :: out_lat_coord  ! Latitude value of data on DEOS real grid
      type(f_real_array)  :: out_long_coord ! Longitude value of data on DEOS real grid
      type(f_real_array)  :: out_grid       ! Output re-sampled and mosaicked DEOS data on Real grid

      type(f_integer_options) :: i_options ! rrpm integer options
      type(f_real_options) ::    r_options ! rrpm real options

      integer  error_code

For this interface, the out_lat_coord and out_long_coord derived types will have values for order, and the option array, but the other values will be set to missing (negative).

Data Conventions

This section describes the data ordering conventions applied to the arrays passed to Fortran from C++.

If the integer option array has only one element, i.e. order is one, the a mosaic product is to be generated, if order is greater than one, then a calibrated product is to be generated.

The input data array will consist of N blocks of DPA data, each one of size 131x131. The individual DPA data is sent row-wise from West to East and then North to South columnwise.

The input Z/R data array will consist of two pairs of data for each radar site (a total of 4 times the number of station files), in the same order as the data in the input data array. The first pair of data values will be Z bias and then Z exponent of the data file itself, the second pair will be the the Z bias and then Z exponent to be used in generating the revised precipitation estimate.

The order of the elements in the two input coordinate arrays will be the values as dictated by the data array.

No ordering convention has been established for the output data array.

The order of the elements in the two output coordinate arrays will be the values as dictated by the data array.

Option Specifications

This section describes the options that are passed to Fortran from C++, their meanings and possible values.

Integer Options

The following table describes the integer processing options for the rrpm program.

Table 2. Interpretation of Integer Control Options

NumberDescriptionAcceptable ValuesInterpretation
1Procedure for combining values for a given cell occurring in multiple radars3Take the maximum value
5Take the average value
2Procedure for generating calibrated product0Fixed Z/R values per radar
1TBD
Floating-Point Options

The following table describes the floating-point processing options for the rrpm program.

Table 3. Interpretation of Floating-Point Options

NumberDescriptionExample ValuesInterpretation
1Cell Center Latitude-179.99 (DEOS value)A value of any cell center latitude in degrees
2Cell Center Longitude-89.99 (DEOS value)A value of any cell center longitude in degrees
3Cell Spacing (width)0.02 (DEOS value)The grid cell width in degrees
4Cell Spacing (height)0.02 (DEOS value)The grid cell height in degrees

IFGEN

The Interploated Field Generator (IFGEN) program generates gridded products for all defined fields, other than the precipitation fileds which are produced by the RRPM program. Products are generated on the DEOS grid.

Control over which product is generated by a specific run of the program is described below.

Data Storage to Disk

The program stores completed fields to disk in compressed (gzip) format. The gzstream interface (a C++ wrapper to the Zlib library) is used to achieve this.

Call Interface

This section describes the method whereby user or system settings for the product are transferred from C++ to the Fortran processing portion.

The call interface for this program on the C++ side will be:


int   product_type;
int   n_stations;

FloatArray   elevations;

FloatArray   station_lat;
FloatArray   station_long;
FloatArray   station_data_values;
FloatArray   station_data_values_supp;

FloatArray   latitude_points;
FloatArray   longitude_points;
FloatArray   output_data;
FloatArray   output_data_supp;

IntegerOptions ifgen_int_options;
FloatOptions   ifgen_float_options;

int   error_code;

...
extern "C" {
 void ifgen (int *, int *, FloatArray *,
            FloatArray *, FloatArray *, FloatArray *, FloatArray *,
            FloatArray *, FloatArray *, FloatArray *, FloatArray *,
            IntegerOptions *, FloatOptions *, int *);
}
...
ifgen (&product_type, &n_stations, &elevations,
       &station_lat, &station_long, &station_data_values, &station_data_values_supp,
       &latitude_points, &longitude_points, &output_data, &output_data_supp,
       &ifgen_int_options, &ifgen_float_options, &error_code);

The call interface for this program on the Fortran side will be:

      subroutine ifgen(product_type, n_stations, elevations,
     + station_lat, station_long, station_data_values, station_data_supp,
     + out_lat_coord, out_long_coord, out_grid, out_grid_supp,
     + i_options, r_options, error_code)

!
      implicit none

      integer  product_type
      integer  n_stations

      type(f_real_array) :: elevations ! ifgen real options

      type(f_real_array) :: station_lat         ! Latitude value of data on DEOS real grid
      type(f_real_array) :: station_long        ! Longitude value of data on DEOS real grid
      type(f_real_array) :: station_data_values ! Input station data
      type(f_real_array) :: station_data_supp   ! Input station data (supplemental for vector data

      type(f_real_array) :: out_lat_coord  ! Latitude value of data on DEOS real grid
      type(f_real_array) :: out_long_coord ! Longitude value of data on DEOS real grid
      type(f_real_array) :: out_grid       ! Output data on DEOS real grid
      type(f_real_array) :: out_grid_supp  ! Vector data supplement provided in this array if applicable

      type(f_integer_options) :: i_options ! ifgen integer options
      type(f_real_options) ::    r_options ! ifgen real options

      integer  error_code

Data Conventions

This section describes the data ordering conventions applied to the arrays passed to Fortran from C++.

The numerical product type is given in this table.

Option Specifications

This section describes the options that are passed to Fortran from C++, their meanings and possible values.

Integer Options

The following table describes the integer processing options for the ifgen program.

Table 4. Interpretation of Integer Control Options

NumberDescriptionAcceptable ValuesInterpretation
1Elevation effect inclusion0Do not include elevation effect
1Include elevation effect
2Interpolation parameters calibration0Do not calibrate interpolation parameters
1Calibrate interpolation parameters effect
Floating-Point Options

The following table describes the floating-point processing options for the ifgen program.

Table 5. Interpretation of Floating-Point Options

NumberDescriptionExample ValuesInterpretation
1Cell Center Latitude-179.99 (DEOS value)A value of any cell center latitude in degrees
2Cell Center Longitude-89.99 (DEOS value)A value of any cell center longitude in degrees
3Cell Spacing (width)0.02 (DEOS value)The grid cell width in degrees
4Cell Spacing (height)0.02 (DEOS value)The grid cell height in degrees
5Influence Radius100The value, in kilometers, for the interpolation influence radius


[1] An entry in the program column indicates which specific program, if any, that the status message can occur or the general area of cause.