Page 1 of 1

Redirecting stdout and stderr for each $pid

Posted: Tue Apr 19, 2011 5:43 am
by arbarbosa
Hi,

How can I redirect stdout and stderr for the process running in a $pid to a different file (see example below)?

I tried the following command that outputs all stdout and stderr from all $pid to the same logFile: mpiexec -np 3 OpenSeesMP runAll.tcl > logFile.out 2>&1

Thank you
Andre
*****************************************************************
set pid [getPID]
set numP [getNP]
set count 0

foreach {EqName } {
Tabas
LGPC
Sylmar_OV } {

if {[expr $count % $numP] == $pid} {
puts "$EqName do something"
}

incr count 1
}

Re: Redirecting stdout and stderr for each $pid

Posted: Fri Apr 22, 2011 10:24 am
by fmk
that won't work as mpi sends all the stdout and stderr stuff back to the main process .. some implementations will tell you what process the message came from .. you can use the logFile command to
get OpenSees messages .. puts will not go here however,

Re: Redirecting stdout and stderr for each $pid

Posted: Fri Apr 22, 2011 11:47 am
by arbarbosa
Thanks Frank.

Would something like is described in the following link work? Would OpenSeesMP have to be compiled with mpich2?

h***://wiki.mcs.anl.gov/mpich2/index.php/Hydra_Output_Redirection

For now, I tried the following "mpiexec -l -np 3 OpenSeesMP runAll.tcl > logFile.out 2>&1" where the "-l" option prints a prefix output with the process at the beginning of each line. Example of the output is below.

For the stdout it looks fine, but for some lines coming from the stderr, it does not write the prefix, which would be nice to have if I wanted to parse through the logFile for all stderr coming from one process, which in my case corresponds to some stderr from one analysis with one specific eqke record.

Thanks

[0] -----------------------------------------
[1] -----------------------------------------
[0]Gravity load analysis: starting
[1]Gravity load analysis: starting
[2] -----------------------------------------
[2]Gravity load analysis: starting
[2]Entering Model.Build.tcl
[0]Entering Model.Build.tcl
[1]Entering Model.Build.tcl
[1]Gravity Analysis: starting
[2]Gravity Analysis: starting
[0]Gravity Analysis: starting
[2]CTestEnergyIncr::test() - iteration: 1 current EnergyIncr: 2973.19 (max: 1e-012)
[1]CTestEnergyIncr::test() - iteration:
1 current EnergyIncr: 2973.19 (max: 1e-012)
[0] OpenSees -- Open System For Earthquake Engineering Simulation
[0] Pacific Earthquake Engineering Research Center -- 2.2.2
[0] (c) Copyright 1999,2000 The Regents of the University of California
[0] All Rights Reserved
[0] (Copyright and Disclaimer @ http://www.berkeley.edu/OpenSees/copyright.html)
[0]CTestEnergyIncr::test() - iteration: 1 current EnergyIncr: 2973.19 (max: 1e-012)
[2]CTestEnergyIncr::test() - iteration: 2 current EnergyIncr: 4.50689 (max: 1e-012)
[1]CTestEnergyIncr::test() - iteration: 2 current EnergyIncr: 4.50689 (max: 1e-012)
[0]CTestEnergyIncr::test() - iteration: 2 current EnergyIncr: 4.50689 (max: 1e-012)
[2]CTestEnergyIncr::test() - iteration: 3 current EnergyIncr: 0.0677937 (max: 1e-012)
[1]CTestEnergyIncr::test() - iteration: 3 current EnergyIncr: 0.0677937 (max: 1e-012)
[0]CTestEnergyIncr::test() - iteration:
3 current EnergyIncr: 0.0677937 (max: 1e-012)
[2]CTestEnergyIncr::test() - iteration: 4 current EnergyIncr: 3.85188e-006 (max: 1e-012)
[1]CTestEnergyIncr::test() - iteration:
4 current EnergyIncr: 3.85188e-006 (max: 1e-012)
[0]CTestEnergyIncr::test() - iteration: 4 current EnergyIncr: 3.85188e-006 (max: 1e-012)
[2]CTestEnergyIncr::test() - iteration: 5 current EnergyIncr: 2.5565e-013 (max: 1e-012)
[1]CTestEnergyIncr::test() - iteration: 5 current EnergyIncr: 2.5565e-013 (max: 1e-012)
[2]Gravity analysis: done - Model.Build.tcl
[2] -----------------------------------------
[2]Sylmar_OV - Gravity load analysis: 10 seconds
[2] -----------------------------------------
[2]Sylmar_OV - AnalysisType analysis: starting...
[2]Sylmar_OV - Dynamic.EQ.bidirect analysis: complete...
[2]$Sylmar_OV - AnalysisType analysis: 0 seconds
[2] --------------- End Analysis -----------------
[1]Gravity analysis: done - Model.Build.tcl
[1] -----------------------------------------
[1]LGPC - Gravity load analysis: 10 seconds
[1] -----------------------------------------
[1]LGPC - AnalysisType analysis: starting...
[1]LGPC - Dynamic.EQ.bidirect analysis: complete...
[1]$LGPC - AnalysisType analysis: 0 seconds
[1] --------------- End Analysis -----------------
[0]CTestEnergyIncr::test() - iteration:
5 current EnergyIncr: 2.5565e-013 (max: 1e-012)
[0]Gravity analysis: done - Model.Build.tcl
[0] -----------------------------------------
[0]Tabas - Gravity load analysis: 11 seconds
[0] -----------------------------------------
[0]Tabas - AnalysisType analysis: starting...
[0]Tabas - Dynamic.EQ.bidirect analysis: complete...
[0]$Tabas - AnalysisType analysis: 0 seconds
[0] --------------- End Analysis -----------------
[1]Process Terminating 1
[0]Process Terminating 0
[2]Process Terminating 2