AlphaMachineBroker.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/AlphaMachineBroker.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/actor/broker/AlphaMachineBroker.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 AlphaMachineBroker.
00033 // AlphaMachineBroker is a machine broker for use with the cluster of
00034 // alpha machines in 509 Davis Hall.
00035 //
00036 // What: "@(#) AlphaMachineBroker.h, revA"
00037 
00038 #include <AlphaMachineBroker.h>
00039 #include <stdlib.h>
00040 
00041 #include <string.h>
00042 #include <remote.h>
00043 #include <Channel.h>
00044 
00045 AlphaMachineBroker::AlphaMachineBroker(FEM_ObjectBroker *theBroker)
00046   :MachineBroker(theBroker), currentMachine(0),maxNumMachines(8)
00047 {
00048     char *alpha1 = "alpha-1";
00049     char *alpha2 = "alpha-2";
00050     char *alpha3 = "alpha-3";
00051     char *alpha4 = "alpha-4";
00052     char *alpha5 = "alpha-5";
00053     char *alpha6 = "alpha-6";    
00054     char *alpha7 = "alpha-7";    
00055     char *alpha8 = "alpha-8";        
00056     
00057     char **theMachines = (char **)malloc(8*sizeof(char *));
00058     theMachines[0] = alpha5;
00059     theMachines[1] = alpha2;
00060     theMachines[2] = alpha8;
00061     theMachines[3] = alpha1;
00062     theMachines[4] = alpha4;
00063     theMachines[5] = alpha6;
00064     theMachines[6] = alpha3;    
00065     theMachines[7] = alpha7;    
00066     
00067     machines = theMachines;
00068 }
00069 AlphaMachineBroker::~AlphaMachineBroker()
00070 {
00071 }
00072 
00073 
00074 int 
00075 AlphaMachineBroker::startActor(char *actorProgram, 
00076                                Channel &theChannel,
00077                                int compDemand)
00078 { 
00079     char  remotecmd[400];
00080 
00081     // get the next machine, a round-robin approach
00082     char *machine;
00083     if (currentMachine < maxNumMachines)
00084         machine = machines[currentMachine];
00085     else {
00086         currentMachine = 0;
00087         machine = machines[currentMachine];
00088     }
00089     currentMachine++;
00090     //opserr << "CurrentMachine : " << machine <<  endln;
00091     strcpy(remotecmd,REMOTE);
00092     strcat(remotecmd," ");          
00093     strcat(remotecmd,machine);
00094     strcat(remotecmd," ");
00095     strcat(remotecmd,actorProgram);
00096     strcat(remotecmd," ");
00097     strcat(remotecmd,theChannel.addToProgram());    
00098     strcat(remotecmd,"\n");
00099 
00100     system(remotecmd);
00101 
00102     return 0;
00103 }
00104 

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