MPI: redirect output for ranks>0 to file
changes to main.cpp: read global command line arguments first to allow for immediate output redirection Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>pull/1/head
parent
75fb5a0cc9
commit
9c061e9d84
|
@ -60,6 +60,19 @@ openEMS_FDTD_MPI::openEMS_FDTD_MPI() : openEMS()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Original_Grid = NULL;
|
m_Original_Grid = NULL;
|
||||||
|
|
||||||
|
//redirect output to file for all ranks > 0
|
||||||
|
if ((m_MyID>0) && (g_settings.GetVerboseLevel()==0))
|
||||||
|
{
|
||||||
|
stringstream out_name;
|
||||||
|
out_name << "ID" << m_MyID << "_" << "output.txt";
|
||||||
|
m_Output = new ofstream();
|
||||||
|
m_Output->open(out_name.str().c_str());
|
||||||
|
cout.rdbuf(m_Output->rdbuf());
|
||||||
|
cerr.rdbuf(m_Output->rdbuf());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_Output = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
openEMS_FDTD_MPI::~openEMS_FDTD_MPI()
|
openEMS_FDTD_MPI::~openEMS_FDTD_MPI()
|
||||||
|
@ -70,6 +83,8 @@ openEMS_FDTD_MPI::~openEMS_FDTD_MPI()
|
||||||
m_Energy_Buffer = NULL;
|
m_Energy_Buffer = NULL;
|
||||||
delete m_Original_Grid;
|
delete m_Original_Grid;
|
||||||
m_Original_Grid = NULL;
|
m_Original_Grid = NULL;
|
||||||
|
delete m_Output;
|
||||||
|
m_Output=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool openEMS_FDTD_MPI::parseCommandLineArgument( const char *argv )
|
bool openEMS_FDTD_MPI::parseCommandLineArgument( const char *argv )
|
||||||
|
|
|
@ -58,6 +58,9 @@ protected:
|
||||||
double CalcEnergy();
|
double CalcEnergy();
|
||||||
|
|
||||||
virtual bool SetupProcessing();
|
virtual bool SetupProcessing();
|
||||||
|
|
||||||
|
//output redirection to file for ranks > 0
|
||||||
|
ofstream* m_Output;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPENEMS_FDTD_MPI_H
|
#endif // OPENEMS_FDTD_MPI_H
|
||||||
|
|
10
main.cpp
10
main.cpp
|
@ -38,6 +38,13 @@ using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
//read global command line arguments first
|
||||||
|
for (int n=2; n<argc; ++n)
|
||||||
|
{
|
||||||
|
if (g_settings.parseCommandLineArgument(argv[n]))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MPI_SUPPORT
|
#ifdef MPI_SUPPORT
|
||||||
//init MPI
|
//init MPI
|
||||||
MPI::Init(argc,argv);
|
MPI::Init(argc,argv);
|
||||||
|
@ -87,9 +94,6 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
for (int n=2; n<argc; ++n)
|
for (int n=2; n<argc; ++n)
|
||||||
{
|
{
|
||||||
if (g_settings.parseCommandLineArgument(argv[n]))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!FDTD.parseCommandLineArgument(argv[n]))
|
if (!FDTD.parseCommandLineArgument(argv[n]))
|
||||||
cout << "openEMS - unknown argument: " << argv[n] << endl;
|
cout << "openEMS - unknown argument: " << argv[n] << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ ssh_options = [scp_options ' -x'];
|
||||||
if isfield(Settings.MPI,'HostFile')
|
if isfield(Settings.MPI,'HostFile')
|
||||||
[status, result] = unix(['mpirun -machinefile ' Settings.MPI.HostFile ' -n ' int2str(NrProc) ' hostname']);
|
[status, result] = unix(['mpirun -machinefile ' Settings.MPI.HostFile ' -n ' int2str(NrProc) ' hostname']);
|
||||||
else
|
else
|
||||||
[status, result] = unix(['mpirun -n ' int2str(NrProc) ' hostname'])
|
[status, result] = unix(['mpirun -n ' int2str(NrProc) ' hostname']);
|
||||||
end
|
end
|
||||||
|
|
||||||
if (status~=0)
|
if (status~=0)
|
||||||
|
@ -108,10 +108,14 @@ end
|
||||||
|
|
||||||
disp(['Running remote openEMS_MPI in working dir: ' work_path]);
|
disp(['Running remote openEMS_MPI in working dir: ' work_path]);
|
||||||
|
|
||||||
|
if ~isfield(Settings.MPI,'GlobalArgs')
|
||||||
|
Settings.MPI.GlobalArgs = '';
|
||||||
|
end
|
||||||
|
|
||||||
if isfield(Settings.MPI,'HostFile')
|
if isfield(Settings.MPI,'HostFile')
|
||||||
[status] = system(['LD_LIBRARY_PATH= mpirun -machinefile ' Settings.MPI.HostFile ' -l -n ' int2str(NrProc) ' -wdir ' work_path ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
|
[status] = system(['LD_LIBRARY_PATH= mpirun -machinefile ' Settings.MPI.HostFile ' -l -n ' int2str(NrProc) ' -wdir ' work_path ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
|
||||||
else
|
else
|
||||||
[status] = system(['LD_LIBRARY_PATH= mpirun -l -n ' int2str(NrProc) ' -wdir ' work_path ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
|
[status] = system(['LD_LIBRARY_PATH= mpirun ' Settings.MPI.GlobalArgs ' -n ' int2str(NrProc) ' -wdir ' work_path ' ' Settings.MPI.Binary ' ' Sim_File ' ' opts ' ' append_unix]);
|
||||||
end
|
end
|
||||||
if (status~=0)
|
if (status~=0)
|
||||||
error('openEMS:RunOpenEMS','mpirun openEMS failed!');
|
error('openEMS:RunOpenEMS','mpirun openEMS failed!');
|
||||||
|
|
Loading…
Reference in New Issue