- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
How do I check if a file exists and has been successfully opened. MPI::File::Open function suspends my program.
Thanks,
Stan
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Stan,
If MPI_File_open were returning, you could use the return code to determine if the file exists or not. Since your program isn't getting past MPI_File_open, you'll need to use a non-MPI mechanism to do this. In C++, I would likely try to open the file (closing it immediately afterwards), as this is a portable method. You can check the return values from the open attempt. There are also non-portable methods that can check without opening the file.
Sincerely,
James Tullos
Technical Consulting Engineer
Intel® Cluster Tools
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi James,
Many thanks for the comprehensive answer. Because I use C + + interface I adopted _access_s () function. I think it is safe:
MPI::File fin = MPI::FILE_NULL;
if(_access_s( fname, 0 ) == 0) fin = MPI::File::Open(MPI::COMM_WORLD, fname, MPI::MODE_RDONLY, MPI::INFO_NULL);
if(fin != MPI::FILE_NULL){
something, something ....
}
Width regards,
Stan

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page