c++ - MSMPI Write in file not work correctly -
i want write program in mpi, when program run debug out mpiexec.exe (in cl.exe) works correctly, when run in mpiexec.exe, program blocked mpiexec.exe , never terminated until forced close.
void writeinfile(char * str ,bool needtonewline ) { mpi_status status; mpi_file file; //add newline in str int newcharlenght , charlenght ; charlenght =strlen(str); newcharlenght = charlenght + 1; char * newstr = (char *) malloc(newcharlenght); newstr[0] =needtonewline ? '\n' : ' '; for(int nlc = 1 ; nlc < newcharlenght ; nlc++ ) newstr[nlc] = str[nlc-1]; mpi_file_open(mpi_comm_world , file_path , mpi_mode_rdwr | mpi_mode_create , mpi_info_null ,&file); mpi_file_seek(file , 0 , mpi_seek_end); mpi_file_write(file , newstr , newcharlenght , mpi_character , &status); mpi_file_close(&file); free(newstr); }
how can fix this?
Comments
Post a Comment