00001
00015 #include <stdlib.h>
00016 #include <string.h>
00017
00018 #include "environment.h"
00019 #include "exec.h"
00020 #include "save.h"
00021 #include "matlab.h"
00022 #include "server.h"
00023
00026 STATUS environment_start(int argc,
00027 char *argv[])
00028 {
00029 if (strcmp(global_environment,"batch")==0)
00030 {
00031
00032 if (exec_start()==FAILED)
00033 {
00034 output_fatal("shutdown after simulation stopped prematurely");
00035
00036
00037
00038
00039
00040
00041
00042
00043 if (global_dumpfile[0]!='\0')
00044 {
00045 if (!saveall(global_dumpfile))
00046 output_error("dump to '%s' failed", global_dumpfile);
00047
00048
00049
00050
00051
00052 else
00053 output_message("dump to '%s' complete", global_dumpfile);
00054 }
00055 return FAILED;
00056 }
00057 return SUCCESS;
00058 }
00059 else if (strcmp(global_environment,"matlab")==0)
00060 {
00061 output_verbose("starting Matlab");
00062 return matlab_startup(argc,argv);
00063 }
00064 else if (strcmp(global_environment,"server")==0)
00065 {
00066 #ifndef WIN32
00067 output_verbose("starting server");
00068 if (server_startup(argc,argv))
00069 return exec_start();
00070 else
00071 return FAILED;
00072 #else
00073 output_fatal("server environment not supported on this platform");
00074 return FAILED;
00075 #endif
00076 }
00077 else
00078 {
00079 output_fatal("%s environment not recognized or supported",global_environment);
00080
00081
00082
00083
00084
00085 return FAILED;
00086 }
00087 }
00088