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
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
00116 extern PartitionedDomain theDomain;
00117
00118 extern int OPS_PARALLEL_PROCESSING;
00119 extern int OPS_NUM_SUBDOMAINS;
00120 extern bool OPS_PARTITIONED;
00121 extern FEM_ObjectBroker *OPS_OBJECT_BROKER;
00122 extern MachineBroker *OPS_MACHINE;
00123 extern bool OPS_USING_MAIN_DOMAIN;
00124 extern int OPS_MAIN_DOMAIN_PARTITION_ID;
00125
00126 MPI_MachineBroker *theMachineBroker = 0;
00127
00128 int
00129 main(int argc, char **argv)
00130 {
00131 FEM_ObjectBroker theBroker;
00132 MPI_MachineBroker theMachine(&theBroker, argc, argv);
00133 theMachineBroker = &theMachine;
00134
00135 int rank = theMachine.getPID();
00136 int np = theMachine.getNP();
00137
00138
00139
00140
00141 if (rank != 0) {
00142
00143
00144
00145
00146 fprintf(stderr, "Slave Process Running\n");
00147 theMachine.runActors();
00148 fprintf(stderr, "Slave Process DONE %d\n", rank);
00149
00150 } else {
00151
00152
00153
00154
00155 fprintf(stderr, "Master Process Running OpenSees Interpreter\n");
00156
00157
00158
00159
00160 OPS_OBJECT_BROKER = &theBroker;
00161 OPS_MACHINE = &theMachine;
00162 OPS_PARALLEL_PROCESSING = np;
00163
00164 if (np%2 == 0) {
00165 OPS_NUM_SUBDOMAINS = np;
00166 OPS_USING_MAIN_DOMAIN = true;
00167 OPS_MAIN_DOMAIN_PARTITION_ID = 1;
00168 } else
00169 OPS_NUM_SUBDOMAINS = np - 1;
00170
00171 OPS_PARTITIONED = false;
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 #ifndef TCL_LOCAL_APPINIT
00185 #define TCL_LOCAL_APPINIT Tcl_AppInit
00186 #endif
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 #ifdef TCL_LOCAL_MAIN_HOOK
00199 extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
00200 #endif
00201
00202 #ifdef TCL_XT_TEST
00203 XtToolkitInitialize();
00204 #endif
00205
00206 #ifdef TCL_LOCAL_MAIN_HOOK
00207 TCL_LOCAL_MAIN_HOOK(&argc, &argv);
00208 #endif
00209
00210 g3TclMain(argc, argv, TCL_LOCAL_APPINIT, 1, 0);
00211
00212
00213 theDomain.clearAll();
00214
00215
00216 theMachine.shutdown();
00217 }
00218
00219
00220
00221
00222
00223
00224 fprintf(stderr, "Process Terminating %d\n", rank);
00225
00226 return 0;
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 int Tcl_AppInit(Tcl_Interp *interp)
00250 {
00251 if (Tcl_Init(interp) == TCL_ERROR) {
00252 return TCL_ERROR;
00253 }
00254
00255 #ifdef TCL_TEST
00256 #ifdef TCL_XT_TEST
00257 if (Tclxttest_Init(interp) == TCL_ERROR) {
00258 return TCL_ERROR;
00259 }
00260 #endif
00261 if (Tcltest_Init(interp) == TCL_ERROR) {
00262 return TCL_ERROR;
00263 }
00264 Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
00265 (Tcl_PackageInitProc *) NULL);
00266 if (TclObjTest_Init(interp) == TCL_ERROR) {
00267 return TCL_ERROR;
00268 }
00269 #ifdef TCL_THREADS
00270 if (TclThread_Init(interp) == TCL_ERROR) {
00271 return TCL_ERROR;
00272 }
00273 #endif
00274 if (Procbodytest_Init(interp) == TCL_ERROR) {
00275 return TCL_ERROR;
00276 }
00277 Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
00278 Procbodytest_SafeInit);
00279 #endif
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 if (g3AppInit(interp) < 0)
00298 return TCL_ERROR;
00299
00300
00301
00302
00303
00304
00305
00306
00307 Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
00308 return TCL_OK;
00309 }
00310
00311
00312 int OpenSeesExit(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv)
00313 {
00314 theDomain.clearAll();
00315
00316
00317
00318
00319
00320 if (theMachineBroker != 0) {
00321 theMachineBroker->shutdown();
00322 fprintf(stderr, "Process Terminating\n");
00323 }
00324
00325 Tcl_Exit(0);
00326
00327 return 0;
00328 }
00329