⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmpiexec.cs

📁 fortran并行计算包
💻 CS
📖 第 1 页 / 共 5 页
字号:
				// Or run "mpiexec -validate" and check the output for SUCCESS				// This code will last longer because it doesn't rely on known information about the smpd implementation				// The disadvantage of this code is that the user credentials have to be valid on the local host.				/*				Process p1 = new Process();				p1.StartInfo.RedirectStandardOutput = true;				p1.StartInfo.RedirectStandardError = true;				p1.StartInfo.UseShellExecute = false;				p1.StartInfo.CreateNoWindow = true;				p1.StartInfo.FileName = mpiexec;				p1.StartInfo.Arguments = "-validate";				p1.Start();				string output = p1.StandardOutput.ReadToEnd() + p1.StandardError.ReadToEnd();				p1.WaitForExit();				p1.Close();				if (output.IndexOf("SUCCESS") != -1)				{					popup = false;				}				*/				if (popup)				{					string wmpiregister;					wmpiregister = mpiexec.Replace("mpiexec.exe", "wmpiregister.exe");					Process p = new Process();					p.StartInfo.FileName = wmpiregister;					p.Start();					p.WaitForExit();				}			}			catch (Exception)			{			}		}		private void break_button_Click(object sender, System.EventArgs e)		{			if (process != null)			{				process.Kill();			}		}		#region Get known files: mpiexec, jumpshot, and clog2 files		private string get_jumpshot()		{			string jumpshot = "";			object obj;			try			{				RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\MPICH2");				if (key != null)				{					obj = key.GetValue("Path");					key.Close();					if (obj != null)					{						jumpshot = obj.ToString();						if (jumpshot.EndsWith(@"\"))						{							jumpshot = jumpshot + @"bin\jumpshot.jar";						}						else						{							jumpshot = jumpshot + @"\bin\jumpshot.jar";						}						if (!File.Exists(jumpshot))						{							jumpshot = "";						}					}				}				if (jumpshot == "")				{					key = Registry.LocalMachine.OpenSubKey(@"Software\MPICH\SMPD");					if (key != null)					{						obj = key.GetValue("binary");						key.Close();						if (obj != null)						{							jumpshot = obj.ToString().Replace("smpd.exe", "jumpshot.jar");							if (!File.Exists(jumpshot))							{								jumpshot = "";							}						}					}				}				if (jumpshot == "")				{					jumpshot = "jumpshot.jar";				}				jumpshot = jumpshot.Trim();				if (jumpshot.IndexOf(' ') != -1)				{					jumpshot = "\"" + jumpshot + "\"";				}			}			catch (Exception)			{				jumpshot = "jumpshot.jar";			}			return jumpshot;		}		private string get_clog2()		{			int index, last;			string app = application_comboBox.Text;			try			{				if (app[0] == '\"')				{					// remove the quotes to be restored at the end					app = app.Replace("\"", "");				}				index = app.LastIndexOf('\\');				if (index == -1)				{					index = 0;				}				last = index;				// find the index of .exe starting from the last \				index = app.IndexOf(".exe", last);				if (index == -1)				{					// no .exe so find the first space after the last \					// This assumes the executable does not have spaces in its name					index = app.IndexOf(' ', last);					if (index == -1)					{						// no .exe and no spaces found so take the entire string						index = app.Length;					}				}				app = app.Substring(0, index) + ".exe.clog2";				app = app.Trim();				if (!File.Exists(app) && wdir_textBox.Text.Length > 0)				{					// file not found from the application combo box so try finding it in the working directory					string app2 = application_comboBox.Text;					if (app2[0] == '\"')					{						// remove the quotes to be restored at the end						app2 = app2.Replace("\"", "");					}					index = app2.LastIndexOf('\\');					if (index != -1)					{						// remove the path						app2 = app2.Remove(0, index);					}					// find the index of .exe					index = app2.IndexOf(".exe");					if (index != -1)					{						// remove any arguments after the executable name						app2 = app2.Substring(0, index + 4);					}					else					{						// no .exe so find the first space						// This assumes the executable does not have spaces in its name						index = app.IndexOf(' ');						if (index != -1)						{							app2 = app2.Substring(0, index) + ".exe";						}						else						{							// no .exe and no arguments so append .exe							app2 += ".exe";						}					}					// app2 should now contain only the executable name					// Add the wdir path and clog2 extension					if (wdir_textBox.Text.EndsWith("\\"))						app2 = wdir_textBox.Text + app2 + ".clog2";					else						app2 = wdir_textBox.Text + "\\" + app2 + ".clog2";					if (File.Exists(app2))					{						app = app2;						FileStream f = File.OpenRead(app2);						app = f.Name;						f.Close();					}				}				if (app.IndexOf(' ') != -1)				{					app = "\"" + app + "\"";				}			}			catch (Exception)			{				app = "";			}			return app;		}		private string get_mpiexec()		{			string mpiexec = "";			object obj;			try			{				RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\MPICH2");				if (key != null)				{					obj = key.GetValue("Path");					key.Close();					if (obj != null)					{						mpiexec = obj.ToString();						if (mpiexec.EndsWith(@"\"))						{							mpiexec = mpiexec + @"bin\mpiexec.exe";						}						else						{							mpiexec = mpiexec + @"\bin\mpiexec.exe";						}						if (!File.Exists(mpiexec))						{							mpiexec = "";						}					}				}				if (mpiexec == "")				{					key = Registry.LocalMachine.OpenSubKey(@"Software\MPICH\SMPD");					if (key != null)					{						obj = key.GetValue("binary");						key.Close();						if (obj != null)						{							mpiexec = obj.ToString().Replace("smpd.exe", "mpiexec.exe");							if (!File.Exists(mpiexec))							{								mpiexec = "";							}						}					}				}				if (mpiexec == "")				{					mpiexec = "mpiexec.exe";				}				mpiexec = mpiexec.Trim();				mpiexec_command = mpiexec; // save the path to mpiexec.exe without quotes				if (mpiexec.IndexOf(' ') != -1)				{					mpiexec = "\"" + mpiexec + "\"";				}			}			catch (Exception)			{				mpiexec = "mpiexec.exe";			}			return mpiexec;		}		#endregion		private string get_command_line()		{			string cmd, mpiexec;			cmd = mpiexec = get_mpiexec();			if (application_radioButton.Checked)			{				wdir_textBox.Text = wdir_textBox.Text.Trim();				if (wdir_textBox.Text.Length > 0)				{					if (wdir_textBox.Text.IndexOf(' ') != -1)					{						cmd = cmd + " -wdir \"" + wdir_textBox.Text + "\"";					}					else					{						cmd = cmd + " -wdir " + wdir_textBox.Text;					}				}				drive_map_textBox.Text = drive_map_textBox.Text.Trim();				if (drive_map_textBox.Text.Length > 0)				{					if (drive_map_textBox.Text.IndexOf(' ') != -1)					{						cmd = cmd + " -map \"" + drive_map_textBox.Text + "\"";					}					else					{						cmd = cmd + " -map " + drive_map_textBox.Text;					}				}				if (log_checkBox.Checked)				{					cmd = cmd + " -log";				}				channel_comboBox.Text = channel_comboBox.Text.Trim();				if (channel_comboBox.Text != "default" && channel_comboBox.Text != "auto" && channel_comboBox.Text != "")				{					cmd = cmd + " -env MPICH2_CHANNEL " + channel_comboBox.Text;				}				env_textBox.Text = env_textBox.Text.Trim();				if (env_textBox.Text.Length > 0)				{					foreach (string keyval in env_textBox.Text.Split(' '))					{						string [] kv;						kv = keyval.Split('=');						if (kv.Length > 1)						{							cmd = cmd + " -env " + kv[0] + " " + kv[1];						}					}				}				hosts_textBox.Text = hosts_textBox.Text.Trim();				if (hosts_textBox.Text.Length > 0)				{					string [] hosts;					int n;					hosts = hosts_textBox.Text.Split(' ');					n = (int)nproc_numericUpDown.Value;					if (n > hosts.Length)					{						int max = n % hosts.Length;						cmd = cmd + " -hosts " + hosts.Length + " ";						for (int i=0; i<hosts.Length; i++)						{							if (i<max)							{								cmd = cmd + hosts[i] + " " + ((n / hosts.Length) + 1) + " ";							}							else							{								cmd = cmd + hosts[i] + " " + (n / hosts.Length) + " ";							}						}					}					else					{						cmd = cmd + " -hosts " + n + " ";						for (int i=0; i<n; i++)						{							cmd = cmd + hosts[i] + " ";						}					}				}				else				{					cmd = cmd + " -n " + nproc_numericUpDown.Value + " ";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -