@@ -781,9 +781,15 @@ static pmix_iof_write_event_t* pmix_iof_setup(pmix_namespace_t *nptr,
781
781
}
782
782
/* define a sink to that file descriptor */
783
783
snk = PMIX_NEW (pmix_iof_sink_t );
784
- PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
785
- PMIX_FWD_STDOUT_CHANNEL , pmix_iof_write_handler );
784
+ if (nptr -> iof_flags .merge ) {
785
+ PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
786
+ PMIX_FWD_ALL_CHANNELS , pmix_iof_write_handler );
787
+ } else {
788
+ PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
789
+ PMIX_FWD_STDOUT_CHANNEL , pmix_iof_write_handler );
790
+ }
786
791
pmix_list_append (& nptr -> sinks , & snk -> super );
792
+ return & snk -> wev ;
787
793
} else {
788
794
/* setup the stderr sink */
789
795
pmix_asprintf (& outfile , "%s/stderr" , outdir );
@@ -799,8 +805,8 @@ static pmix_iof_write_event_t* pmix_iof_setup(pmix_namespace_t *nptr,
799
805
PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
800
806
PMIX_FWD_STDERR_CHANNEL , pmix_iof_write_handler );
801
807
pmix_list_append (& nptr -> sinks , & snk -> super );
808
+ return & snk -> wev ;
802
809
}
803
- return & snk -> wev ;
804
810
}
805
811
806
812
/* see if we are to output to a file */
@@ -814,22 +820,71 @@ static pmix_iof_write_event_t* pmix_iof_setup(pmix_namespace_t *nptr,
814
820
free (outdir );
815
821
return NULL ;
816
822
}
817
- /* setup the file */
818
- pmix_asprintf (& outfile , "%s.%s.%0*u" , nptr -> iof_flags .file ,
819
- nptr -> nspace , numdigs , rank );
820
- fdout = open (outfile , O_CREAT | O_RDWR | O_TRUNC , 0644 );
821
- free (outfile );
822
- if (fdout < 0 ) {
823
- /* couldn't be opened */
824
- PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
825
- return NULL ;
823
+ if (PMIX_FWD_STDOUT_CHANNEL & stream ||
824
+ nptr -> iof_flags .merge ) {
825
+ /* setup the stdout sink */
826
+ if (nptr -> iof_flags .pattern ) {
827
+ /* if there are no '%' signs in the pattern, then it is just a literal string */
828
+ if (NULL == strchr (nptr -> iof_flags .file , '%' )) {
829
+ /* setup the file */
830
+ pmix_asprintf (& outfile , "%s.out" , nptr -> iof_flags .file );
831
+ } else {
832
+ /* must process the pattern - for now, just take it literally */
833
+ pmix_asprintf (& outfile , "%s.out" , nptr -> iof_flags .file );
834
+ }
835
+ } else {
836
+ /* setup the file */
837
+ pmix_asprintf (& outfile , "%s.%s.%0*u.out" , nptr -> iof_flags .file ,
838
+ nptr -> nspace , numdigs , rank );
839
+ }
840
+ fdout = open (outfile , O_CREAT | O_RDWR | O_TRUNC , 0644 );
841
+ free (outfile );
842
+ if (fdout < 0 ) {
843
+ /* couldn't be opened */
844
+ PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
845
+ return NULL ;
846
+ }
847
+ /* define a sink to that file descriptor */
848
+ snk = PMIX_NEW (pmix_iof_sink_t );
849
+ if (nptr -> iof_flags .merge ) {
850
+ PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
851
+ PMIX_FWD_ALL_CHANNELS , pmix_iof_write_handler );
852
+ } else {
853
+ PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
854
+ PMIX_FWD_STDOUT_CHANNEL , pmix_iof_write_handler );
855
+ }
856
+ pmix_list_append (& nptr -> sinks , & snk -> super );
857
+ return & snk -> wev ;
858
+ } else {
859
+ /* setup the stderr sink */
860
+ if (nptr -> iof_flags .pattern ) {
861
+ /* if there are no '%' signs in the pattern, then it is just a literal string */
862
+ if (NULL == strchr (nptr -> iof_flags .file , '%' )) {
863
+ /* setup the file */
864
+ pmix_asprintf (& outfile , "%s.err" , nptr -> iof_flags .file );
865
+ } else {
866
+ /* must process the pattern - for now, just take it literally */
867
+ pmix_asprintf (& outfile , "%s.err" , nptr -> iof_flags .file );
868
+ }
869
+ } else {
870
+ /* setup the file */
871
+ pmix_asprintf (& outfile , "%s.%s.%0*u.err" , nptr -> iof_flags .file ,
872
+ nptr -> nspace , numdigs , rank );
873
+ }
874
+ fdout = open (outfile , O_CREAT | O_RDWR | O_TRUNC , 0644 );
875
+ free (outfile );
876
+ if (fdout < 0 ) {
877
+ /* couldn't be opened */
878
+ PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
879
+ return NULL ;
880
+ }
881
+ /* define a sink to that file descriptor */
882
+ snk = PMIX_NEW (pmix_iof_sink_t );
883
+ PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
884
+ PMIX_FWD_STDERR_CHANNEL , pmix_iof_write_handler );
885
+ pmix_list_append (& nptr -> sinks , & snk -> super );
886
+ return & snk -> wev ;
826
887
}
827
- /* define a sink to that file descriptor */
828
- snk = PMIX_NEW (pmix_iof_sink_t );
829
- PMIX_IOF_SINK_DEFINE (snk , & pmix_globals .myid , fdout ,
830
- PMIX_FWD_ALL_CHANNELS , pmix_iof_write_handler );
831
- pmix_list_append (& nptr -> sinks , & snk -> super );
832
- return & snk -> wev ;
833
888
}
834
889
835
890
return NULL ;
@@ -870,6 +925,9 @@ void pmix_iof_check_flags(pmix_info_t *info, pmix_iof_flags_t *flags)
870
925
} else if (PMIX_CHECK_KEY (info , PMIX_IOF_LOCAL_OUTPUT )) {
871
926
flags -> local_output = PMIX_INFO_TRUE (info );
872
927
flags -> set = true;
928
+ } else if (PMIX_CHECK_KEY (info , PMIX_IOF_FILE_PATTERN )) {
929
+ flags -> pattern = PMIX_INFO_TRUE (info );
930
+ /* don't mark as set here as this is just a qualifier */
873
931
}
874
932
}
875
933
0 commit comments