Python Interface to MAPL: Difference between revisions
Line 58: | Line 58: | ||
== A python component with Children in Fortran == | == A python component with Children in Fortran == | ||
In this example, the '''GEOSgcs''' component is implemented in Python, with its | In this example, the '''GEOSgcs''' component is implemented in Python, with its children, components '''ANA''' and '''GCM''', implemented in Fortran. | ||
import MAPL | import MAPL | ||
class GridComp(MAPL.GridComp): | class GridComp(MAPL.GridComp): | ||
"""Implements the GEOSgcs component by subclassing MAPL.GridComp""" | """Implements the GEOSgcs component by subclassing MAPL.GridComp""" | ||
def SetServices(self): | def SetServices(self): | ||
"""SerServices for a composite component""" | """SerServices for a composite component""" | ||
# Instantiate Children component | # Instantiate Children component | ||
# ------------------------------ | # ------------------------------ | ||
ana = MAPL.GridComp(lib='/some/path/libGEOSana.so') | ana = MAPL.GridComp(lib='/some/path/libGEOSana.so') | ||
gcm = MAPL.GridComp(lib='/some/path/libGEOSgcm.so') | gcm = MAPL.GridComp(lib='/some/path/libGEOSgcm.so') | ||
# Adopt children | # Adopt children | ||
# -------------- | # -------------- | ||
self.AddChild(ana) | self.AddChild(ana) | ||
self.AddChild(gcm) | self.AddChild(gcm) | ||
# Set connectivity among children | # Set connectivity among children | ||
# ------------------------------- | # ------------------------------- | ||
Line 83: | Line 83: | ||
self.AddConnectivity(src=[ana,vars], dst=[gcm,vars]) | self.AddConnectivity(src=[ana,vars], dst=[gcm,vars]) | ||
self.AddConnectivity(src=[gcm,'LWI'], dst=[ana,'ORO']) | self.AddConnectivity(src=[gcm,'LWI'], dst=[ana,'ORO']) | ||
# Run the base class SetServices | # Run the base class SetServices | ||
# ------------------------------ | # ------------------------------ | ||
MAPL.GridComp.__SetServices__(self) | MAPL.GridComp.__SetServices__(self) |