diff --git a/mcstas-comps/misc/MCPL_output.comp b/mcstas-comps/misc/MCPL_output.comp index 233e2d1eaa..fb3645f7f2 100644 --- a/mcstas-comps/misc/MCPL_output.comp +++ b/mcstas-comps/misc/MCPL_output.comp @@ -65,32 +65,6 @@ int mcpl_file_exist (char *filename) struct stat buffer; return (stat (filename, &buffer) == 0); } - -int run_mcpltool(char *filename) -{ - - FILE *fp; - char path[CHAR_BUF_LENGTH]; - char cmd[2*CHAR_BUF_LENGTH]; - - sprintf(cmd,"mcpltool %s",filename); - /* Open the command for reading. */ - fp = popen(cmd, "r"); - if (fp == NULL) { - printf("Failed to run command %s\n",cmd); - exit(1); - } - - /* Read the output a line at a time - output it. */ - while (fgets(path, sizeof(path), fp) != NULL) { - printf("%s", path); - } - - /* close */ - pclose(fp); - - return 0; -} %} DECLARE @@ -201,7 +175,7 @@ INITIALIZE #endif if (verbose==1) { - printf("MCPL_output verbose mode: after generating the mcpl-file a summary from mcpltool will be printed.\n"); + printf("MCPL_output verbose mode: after generating the mcpl-file a summary will be printed.\n"); } #if defined (USE_MPI) @@ -457,8 +431,8 @@ FINALLY } /* Recheck for file existance */ if (mcpl_file_exist(finalfile)) { - printf("\n\nMCPL output summary from 'mcpltool %s'\n",finalfile); - run_mcpltool(finalfile); + printf("\n\nMCPL output summary from %s\n",finalfile); + mcpl_dump(finalfile, 0, 0, 10); } else { printf("\n\nWarning, did not localize expected output file for stat summary!\n"); } diff --git a/mcxtrace-comps/misc/MCPL_output.comp b/mcxtrace-comps/misc/MCPL_output.comp index 2678595b91..14a504abfa 100644 --- a/mcxtrace-comps/misc/MCPL_output.comp +++ b/mcxtrace-comps/misc/MCPL_output.comp @@ -88,6 +88,7 @@ DECLARE DArray1d P; DArray1d U; int captured; + char finalfile[CHAR_BUF_LENGTH]; %} INITIALIZE @@ -106,7 +107,18 @@ INITIALIZE sprintf(extension,"mcpl"); #endif /*add output dir (if applicable) to the output filename and add extension if */ - myfilename=mcfull_file(filename,extension); + // Append the extension to the filename + // -- do not use mcfull_file for this since it can not handle absolute filenames with a '.' in them + char * actual_filename = (char *) calloc(strlen(filename)+strlen(extension)+2, sizeof(char)); + strcpy(actual_filename, filename); + strcat(actual_filename, "."); + strcat(actual_filename, extension); + + // still use mcfull_file in case the filename does not include path information + myfilename = mcfull_file(actual_filename, NULL); + + // release the memory now that we have the full filename + if (actual_filename) free(actual_filename); char line[256]; outputfile = mcpl_create_outfile(myfilename); @@ -130,7 +142,7 @@ INITIALIZE fseek(fp, 0L, SEEK_SET); // seek back to beginning of file if ( size && (buffer=malloc(size))!=NULL){ if (size!=(fread(buffer,1,size,fp))){ - fprintf(stderr,"Warning (%s): Source instrument file not read cleanly\n", NAME_CURRENT_COMP); + fprintf(stderr,"\nWarning (%s): Source instrument file not read cleanly\n", NAME_CURRENT_COMP); } mcpl_hdr_add_data(outputfile, "mccode_instr_file", size, buffer); free(buffer); @@ -165,7 +177,7 @@ INITIALIZE #endif if (verbose==1) { - printf("MCPL_output verbose mode: after generating the mcpl-file it will be reread and a summary printed.\n"); + printf("MCPL_output verbose mode: after generating the mcpl-file a summary will be printed.\n"); } #if defined (USE_MPI) @@ -187,6 +199,9 @@ INITIALIZE } } if (myfilename){ + MPI_MASTER( + sprintf(finalfile,myfilename); + ); free(myfilename); } #ifndef OPENACC @@ -368,13 +383,22 @@ FINALLY int j; mcpl_outfile_t merge_outfile; - merge_outfilename=mcfull_file(filename,extension); + char * real_filename = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); + strcpy(real_filename, filename); + strcat(real_filename, "."); + strcat(real_filename, extension); + + merge_outfilename = mcfull_file(real_filename, NULL); mpi_node_files=(char **) calloc(mpi_node_count,sizeof(char *)); + sprintf(extension,"node_%i.mcpl", mpi_node_count); + char * temp_name = (char *) calloc(strlen(filename) + strlen(extension) + 2, sizeof(char)); for (j=0;j