Python Interface to MAPL: Difference between revisions

From GEOS-5
Jump to navigation Jump to search
New page: Here is a very high level example of a MAPL ocean/atmosphere couple model in Python: import MAPL atm = MAPL.GridComp(rc='atm.rc') ocn = MAPL.GridComp(rc='ocn.rc') atm.initialize() ...
 
No edit summary
Line 1: Line 1:
Here is a very high level example of a MAPL ocean/atmosphere couple model in Python:
This document presents a very high level description of a python interface to MAPL.


import MAPL
= GEOS-5 Use Cases =


atm = MAPL.GridComp(rc='atm.rc')
The examples below are based on the actual GEOS-5 GCM Application, and a few components at the very top of the hierarchy. Here we assumed that MAPL Grid Components can be implemented entirely in C/Fortran or in Python.  
ocn = MAPL.GridComp(rc='ocn.rc')


atm.initialize()
== GEOS-5 Application with Fortran Root Component ===
ocn.initialize()


for t in clock.tick():
In this example, the very top root component is implemented entirely in a shared library.
    atm.run()
    ocn.run()


   atm.finalize()
""""
   ocn.finalize()
The GEOSgcm application written in python, starting from a
Root Component implemented in Fortran.
"""
 
import MAPL
 
if __name == "__main__":
 
#  Instantiate the root component
#   ------------------------------
    gcs = MAPL.GridComp(lib='/some/path/libGEOSana.so')
 
#  Instantiate MAPL, using a "Fortran" as a root component
#   -------------------------------------------------------
    mapl = MAPL(root=gcs)
 
#  Run the cap
#  -----------
    mapl.go()

Revision as of 11:46, 18 August 2008

This document presents a very high level description of a python interface to MAPL.

GEOS-5 Use Cases

The examples below are based on the actual GEOS-5 GCM Application, and a few components at the very top of the hierarchy. Here we assumed that MAPL Grid Components can be implemented entirely in C/Fortran or in Python.

GEOS-5 Application with Fortran Root Component =

In this example, the very top root component is implemented entirely in a shared library.

"""" The GEOSgcm application written in python, starting from a Root Component implemented in Fortran. """

import MAPL

if __name == "__main__":

  1. Instantiate the root component
  2. ------------------------------
   gcs = MAPL.GridComp(lib='/some/path/libGEOSana.so')
  1. Instantiate MAPL, using a "Fortran" as a root component
  2. -------------------------------------------------------
   mapl = MAPL(root=gcs)
  1. Run the cap
  2. -----------
   mapl.go()