#!/usr/bin/env python # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # #===================================================================== # # CitcomS.py # --------------------------------- # # Authors: # Eh Tan, Eun-seo Choi, and Pururav Thoutireddy # (c) California Institute of Technology 2002-2005 # # By downloading and/or installing this software you have # agreed to the CitcomS.py-LICENSE bundled with this software. # Free for non-commercial academic research ONLY. # This program is distributed WITHOUT ANY WARRANTY whatsoever. # #===================================================================== # # Copyright June 2005, by the California Institute of Technology. # ALL RIGHTS RESERVED. United States Government Sponsorship Acknowledged. # # Any commercial use must be negotiated with the Office of Technology # Transfer at the California Institute of Technology. This software # may be subject to U.S. export control laws and regulations. By # accepting this software, the user agrees to comply with all # applicable U.S. export laws and regulations, including the # International Traffic and Arms Regulations, 22 C.F.R. 120-130 and # the Export Administration Regulations, 15 C.F.R. 730-744. User has # the responsibility to obtain export licenses, or other export # authority as may be required before exporting such information to # foreign countries or providing access to foreign nationals. In no # event shall the California Institute of Technology be liable to any # party for direct, indirect, special, incidental or consequential # damages, including lost profits, arising out of the use of this # software and its documentation, even if the California Institute of # Technology has been advised of the possibility of such damage. # # The California Institute of Technology specifically disclaims any # warranties, including the implied warranties or merchantability and # fitness for a particular purpose. The software and documentation # provided hereunder is on an "as is" basis, and the California # Institute of Technology has no obligations to provide maintenance, # support, updates, enhancements or modifications. # #===================================================================== # # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # from SimpleApp import SimpleApp import journal class CoupledApp(SimpleApp): def __init__(self, name="citcom"): SimpleApp.__init__(self, name) self.solver = None self.solverCommunicator = None self.myPlus = [] self.remotePlus = [] self.comm = None self.rank = 0 self.nodes = 0 self._info = journal.debug("application") return def initialize(self): layout = self.inventory.layout layout.initialize(self) self.findLayout(layout) self.controller.initialize(self) return def findLayout(self, layout): if layout.coarse: self.controller = self.inventory.coarseController self.solver = self.inventory.coarse self.exchanger = self.inventory.cge self.solverCommunicator = layout.coarse self.myPlus = layout.coarsePlus self.remotePlus = layout.finePlus elif layout.fine: self.controller = self.inventory.fineController self.solver = self.inventory.fine self.exchanger = self.inventory.fge self.solverCommunicator = layout.fine self.myPlus = layout.finePlus self.remotePlus = layout.coarsePlus else: import journal journal.warning(self.name).log("node '%d' is an orphan" % layout.rank) self.comm = layout.comm self.rank = layout.rank self.nodes = layout.nodes return def reportConfiguration(self): rank = self.comm.rank if rank != 0: return self._info.line("configuration:") # self._info.line(" properties:") # self._info.line(" name: %r" % self.inventory.name) # self._info.line(" full name: %r" % self.inventory.fullname) self._info.line(" facilities:") self._info.line(" journal: %r" % self.inventory.journal.name) self._info.line(" launcher: %r" % self.inventory.launcher.name) self._info.line(" coarse: %r" % self.inventory.coarse.name) self._info.line(" fine: %r" % self.inventory.fine.name) self._info.line(" cge: %r" % self.inventory.cge.name) self._info.line(" fge: %r" % self.inventory.fge.name) self._info.line(" coarseController: %r" % self.inventory.coarseController.name) self._info.line(" fineController: %r" % self.inventory.fineController.name) self._info.line(" coupler: %r" % self.inventory.coupler.name) self._info.line(" layout: %r" % self.inventory.layout.name) return class Inventory(SimpleApp.Inventory): import pyre.inventory import Controller import Solver import Coupler import Layout import CitcomS.Components.Exchanger as Exchanger coarseController = pyre.inventory.facility(name="coarseController", factory=Controller.controller, args=("coarseController",)) fineController = pyre.inventory.facility(name="fineController", factory=Controller.controller, args=("fineController",)) coupler = pyre.inventory.facility("coupler", factory=Coupler.coupler) layout = pyre.inventory.facility("layout", factory=Layout.layout) coarse = pyre.inventory.facility("coarse", factory=Solver.fullSolver, args=("coarse", "coarse")) fine = pyre.inventory.facility("fine", factory=Solver.regionalSolver, args=("fine", "fine")) cge = pyre.inventory.facility("cge", factory=Exchanger.coarsegridexchanger) fge = pyre.inventory.facility("fge", factory=Exchanger.finegridexchanger) steps = pyre.inventory.int("steps", default=1) # main if __name__ == "__main__": app = CoupledApp("citcoms") app.run() # version __id__ = "$Id: CoupledApp.py,v 1.14 2005/06/10 02:23:20 leif Exp $" # End of file