00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 extern "C" {
00042 #include <tcl.h>
00043 #include <tk.h>
00044 }
00045
00046
00047
00048 #include "commands.h"
00049
00050
00051
00052
00053
00054
00055 #ifdef _KAI
00056 extern "C" int matherr();
00057 #endif
00058
00059 #ifdef _UNIX
00060 #include <math.h>
00061
00062
00063 #endif
00064
00065
00066 #ifdef TCL_TEST
00067
00068 extern "C" {
00069 #include "tclInt.h"
00070 }
00071
00072
00073
00074 extern int Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00075 extern int Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
00076 extern int TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00077 extern int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00078 #ifdef TCL_THREADS
00079 extern int TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
00080 #endif
00081
00082 #endif
00083
00084 #ifdef TCL_XT_TEST
00085 extern void XtToolkitInitialize _ANSI_ARGS_((void));
00086 extern int Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
00087 #endif
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 extern void g3TclMain(int argc, char **argv, Tcl_AppInitProc *appInitProc, int rank, int np);
00107 #include <stdio.h>
00108 #include <string.h>
00109
00110 #include <PartitionedDomain.h>
00111 #include <MPI_MachineBroker.h>
00112 #include <ShadowSubdomain.h>
00113 #include <ActorSubdomain.h>
00114 #include <FEM_ObjectBroker.h>
00115 #include <Channel.h>
00116 #include <Message.h>
00117
00118 extern PartitionedDomain theDomain;
00119
00120 extern int OPS_PARALLEL_PROCESSING;
00121 extern int OPS_NUM_SUBDOMAINS;
00122 extern bool OPS_PARTITIONED;
00123 extern FEM_ObjectBroker *OPS_OBJECT_BROKER;
00124 extern MachineBroker *OPS_MACHINE;
00125 extern bool OPS_USING_MAIN_DOMAIN;
00126 extern int OPS_MAIN_DOMAIN_PARTITION_ID;
00127
00128 MachineBroker *theMachineBroker = 0;
00129
00130 int
00131 main(int argc, char **argv)
00132 {
00133 FEM_ObjectBroker theBroker;
00134 MPI_MachineBroker theMachine(&theBroker, argc, argv);
00135 theMachineBroker = &theMachine;
00136
00137 int rank = theMachine.getPID();
00138 int np = theMachine.getNP();
00139
00140
00141
00142
00143
00144 int numArg = 0;
00145 int sizeArg = 0;
00146 char **args = 0;
00147 char *dataArgs = 0;
00148
00149 if (rank == 0) {
00150
00151 for (int i=0; i<argc; i++)
00152 if (argv[i] == NULL) {
00153 i = argc+1;
00154 } else {
00155 numArg ++;
00156 sizeArg += strlen(argv[i])+1;
00157 }
00158
00159 static ID data(2);
00160 data(0) = numArg;
00161 data(1) = sizeArg;
00162
00163 dataArgs = new char[sizeArg];
00164 int loc = 0;
00165 for (int i=0; i<numArg; i++) {
00166 int lengthArg = strlen(argv[i]);
00167 strncpy(&dataArgs[loc], argv[i],lengthArg+1);
00168 loc+=lengthArg+1;
00169 }
00170
00171 Message msgChar(dataArgs, sizeArg);
00172
00173 for (int j=0; j<np-1; j++) {
00174 Channel *otherChannel = theMachine.getRemoteProcess();
00175 otherChannel->sendID(0,0,data);
00176 otherChannel->sendMsg(0,0,msgChar);
00177 }
00178
00179 } else {
00180
00181 static ID data(2);
00182
00183 Channel *myChannel = theMachine.getMyChannel();
00184 myChannel->recvID(0,0,data);
00185 numArg = data(0);
00186 sizeArg = data(1);
00187 dataArgs = new char[sizeArg];
00188 Message msgChar(dataArgs, sizeArg);
00189
00190 myChannel->recvMsg(0,0,msgChar);
00191 }
00192
00193 args = new char *[numArg];
00194 args[0] = dataArgs;
00195 int argCount = 1;
00196 for (int j=1; j<sizeArg-1; j++)
00197 if (dataArgs[j] == '\0') {
00198 args[argCount] = &dataArgs[j+1];
00199 argCount++;
00200 }
00201
00202 #ifndef TCL_LOCAL_APPINIT
00203 #define TCL_LOCAL_APPINIT Tcl_AppInit
00204 #endif
00205
00206 #ifdef TCL_LOCAL_MAIN_HOOK
00207 extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
00208 #endif
00209
00210 #ifdef TCL_XT_TEST
00211 XtToolkitInitialize();
00212 #endif
00213
00214 #ifdef TCL_LOCAL_MAIN_HOOK
00215 TCL_LOCAL_MAIN_HOOK(&argc, &argv);
00216 #endif
00217
00218 g3TclMain(numArg, args, TCL_LOCAL_APPINIT, rank, np);
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 fprintf(stderr, "Process Terminating %d\n", rank);
00231
00232 return 0;
00233 }
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 int Tcl_AppInit(Tcl_Interp *interp)
00256 {
00257 if (Tcl_Init(interp) == TCL_ERROR) {
00258 return TCL_ERROR;
00259 }
00260
00261 #ifdef TCL_TEST
00262 #ifdef TCL_XT_TEST
00263 if (Tclxttest_Init(interp) == TCL_ERROR) {
00264 return TCL_ERROR;
00265 }
00266 #endif
00267 if (Tcltest_Init(interp) == TCL_ERROR) {
00268 return TCL_ERROR;
00269 }
00270 Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
00271 (Tcl_PackageInitProc *) NULL);
00272 if (TclObjTest_Init(interp) == TCL_ERROR) {
00273 return TCL_ERROR;
00274 }
00275 #ifdef TCL_THREADS
00276 if (TclThread_Init(interp) == TCL_ERROR) {
00277 return TCL_ERROR;
00278 }
00279 #endif
00280 if (Procbodytest_Init(interp) == TCL_ERROR) {
00281 return TCL_ERROR;
00282 }
00283 Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
00284 Procbodytest_SafeInit);
00285 #endif
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 if (g3AppInit(interp) < 0)
00304 return TCL_ERROR;
00305
00306
00307
00308
00309
00310
00311
00312
00313 Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
00314 return TCL_OK;
00315 }
00316
00317
00318 int OpenSeesExit(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv)
00319 {
00320 theDomain.clearAll();
00321
00322
00323
00324
00325
00326 if (theMachineBroker != 0) {
00327 theMachineBroker->shutdown();
00328 fprintf(stderr, "Process Terminating\n");
00329 }
00330
00331 Tcl_Exit(0);
00332
00333 return 0;
00334 }
00335