Coupler (download)


The coupler is designed to run as a seperate executable between two physical models of the hydrologic system. The coupler uses a simple bilinear interpolation scheme to transform a field of data from one grid size to another. Other interpolation schemes could be added as needed.

In the client/server model implemented by the field transfer library the coupler is both a client and a server. Its a client which recieves data from the upstream model and then serves interpolated data to the downstream model. Using the field library calls, the coupler "learns" what data is will receive and send. Further information about the data is currently provided by command line arguments but could be added to the info provided by the field library. Because info about data fields is passed from a server to a client, the coupler temporarily acts as a client for the downstream model.

To do the interpolation, the coupler needs the to know the x and y dimensions of each grid. This is provided by the field library. It then needs to know the physical distance between points in each grid and the distance that the smaller grids origin is located from the larger grids origin (the x and y offset). The coupler uses the latter info to only interpolate the correct piece of data from the larger grids domain. The units of the grid distance and offset can be anything (meters, kilometers, etc.) but they must be the same for all quantities.

To keep the coupler flexible, all memory needed to hold the fields is dynamically allocated (the coupler is written in C) and pointers are used to reference data for the interpolation.

The pseudocode version of the coupler looks like this:

---------Initialize------
Process command line arguments
Make client connection to upstream model
Make client connection to downstream model
Close client connection to downstream model and free resources
Open server for downstream model
Allocate memory to hold incoming and outgoing fields.
---------Loop-----
Receive data from upstream model
Interpolate
Send interpolated data to downstream model
--------Finish----
Close server and client connections
Free resources

The coupler can be downloaded but must be hooked up to two models to see it working. See instructions for running base components manually. The coupler was written by Robert Jacob.

Back to the technical information page