DecMachineBroker.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.3 $
00022 // $Date: 2003/08/29 07:19:26 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/machineBroker/DecMachineBroker.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/actor/broker/DecMachineBroker.h
00027 //
00028 // Written: fmk
00029 // Created: Fri Sept 20 12:27:47: 1996
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the class definition for DecMachineBroker.
00033 // DecMachineBroker is a machine broker for use with the cluster of
00034 // dec machines in 509 Davis Hall.
00035 //
00036 // What: "@(#) DecMachineBroker.h, revA"
00037 
00038 #include <DecMachineBroker.h>
00039 #include <stdlib.h>
00040 
00041 #include <string.h>
00042 #include <remote.h>
00043 #include <Channel.h>
00044 
00045 
00046 DecMachineBroker::DecMachineBroker(FEM_ObjectBroker *theBroker)
00047 :MachineBroker(theBroker), currentMachine(0), maxNumMachines(9)
00048 {
00049     char *dec1 = "dec-1";
00050     char *dec2 = "dec-2";
00051     char *dec3 = "dec-3";
00052     char *dec4 = "dec-4";
00053     char *dec5 = "dec-5";
00054     char *dec6 = "dec-6";    
00055     char *dec7 = "dec-7";    
00056     char *dec8 = "dec-8";        
00057     char *dec9 = "dec-9";            
00058     
00059     char **theMachines = (char **)malloc(9*sizeof(char *));
00060     theMachines[0] = dec9;
00061     theMachines[1] = dec8;
00062     theMachines[2] = dec7;
00063     theMachines[3] = dec6;
00064     theMachines[4] = dec5;
00065     theMachines[5] = dec4;
00066     theMachines[6] = dec3;    
00067     theMachines[7] = dec2;    
00068     theMachines[8] = dec1;        
00069     
00070     machines = theMachines;
00071 }
00072 DecMachineBroker::~DecMachineBroker()
00073 {
00074 }
00075 
00076 
00077 int 
00078 DecMachineBroker::startActor(char *actorProgram, 
00079                                Channel &theChannel,
00080                                int compDemand)
00081 { 
00082     char  remotecmd[400];
00083 
00084     // get the next machine, a round-robin approach
00085     char *machine;
00086     if (currentMachine < maxNumMachines)
00087         machine = machines[currentMachine];
00088     else {
00089         currentMachine = 0;
00090         machine = machines[currentMachine];
00091     }
00092 
00093     currentMachine++;
00094     
00095     strcpy(remotecmd,REMOTE);
00096     strcat(remotecmd," ");          
00097     strcat(remotecmd,machine);
00098     strcat(remotecmd," ");
00099     strcat(remotecmd,actorProgram);
00100     strcat(remotecmd," ");
00101     strcat(remotecmd,theChannel.addToProgram());    
00102     strcat(remotecmd,"\n");
00103 
00104     system(remotecmd);
00105 
00106     return 0;
00107 }
00108 

Generated on Mon Oct 23 15:04:56 2006 for OpenSees by doxygen 1.5.0