At the moment, I have an if statement and check if the user provides a topology file from STDIN or a file. If the file is provided from STDIN, because it is not possible to determine the exact size of STDIN I read the file in chunks of READCHAR_BUFFER with fgets and store it in the graph_buffer until I read the EOF character. When a file is provided, I check the size of the file with stat and I read the whole file in graph_buffer at once with fread. Then I broadcast the graph_buffer to all of the participating MPI nodes and preparing the graph with the agmemread command.
Unless the single fread() is significantly faster than reading the file in chunks (even if I know the size of it), the if statement could be dropped and I could be reading both STDIN and files in the same way (by chunks of READCHAR_BUFFER with fgets as if both STDIN and files have an unknown size).
At the moment, I have an if statement and check if the user provides a topology file from
STDINor a file. If the file is provided fromSTDIN, because it is not possible to determine the exact size ofSTDINI read the file in chunks ofREADCHAR_BUFFERwithfgetsand store it in thegraph_bufferuntil I read theEOFcharacter. When a file is provided, I check the size of the file withstatand I read the whole file ingraph_bufferat once withfread. Then I broadcast thegraph_bufferto all of the participating MPI nodes and preparing the graph with theagmemreadcommand.Unless the single
fread()is significantly faster than reading the file in chunks (even if I know the size of it), the if statement could be dropped and I could be reading bothSTDINand files in the same way (by chunks ofREADCHAR_BUFFERwithfgetsas if bothSTDINand files have an unknown size).