The most likely reason is that input file is not in the run directory.
However, you have called the mesh read routine within your MPI code, which means that ALL processors will try to open and read the file and, let's just say, they aren't very good at sharing.
If you are running a multi-processor code then let root read the mesh and distribute it to other processors in an orderly fashion. If you don't want to do that yet then invoke the program (the mpirun call) with only one processor.
There is a logic issue. If OFF or END OFF is found, the code then tries to extract from the string stream buffer. If these are found, then the while should be continued. Something like (NOT tried):
If you're on Windows:
1. Turn OFF the "hide extensions of known file types" in file explorer.
2. Verify that the file is really called mesh.txt and not something like mesh.txt.txt if you saved the file using notepad and it automatically assumed an extension for you.
3. Make sure that your file is ASCII encoded and not Unicode.
@salem c it's already turned off. when I go to properties to see the file detail, in name section I see mesh.txt. When I open it with notepad, on the top, I see mesh.txt - notepad. can that be a problem?
operating system, windows 64bit. visual studio 2022. I'm using Microsoft MPI v10.0.
I run above code and the following is the result. Processor 0 reports file is not open
On Windows, add the following line to the beginning of your program (and #include <cstdlib>): system("cd");
This prints out the current (working) directory.
The location of mesh.txt needs to match this directory.
(Note to others reading, *nix equivalent is system("pwd");)
Visual Studio is notorious for having different default run locations, depending on how you run the executable. And how you initially set up your project/solution.
Are you running the executable from a command line or using the IDE?
If running the exe from the command line your input file must reside in the same location as the executable.
If running the exe via the IDE the input file must be in the same location as your source files.