-namespace simgrid{
-namespace smpi{
-
- File::File(MPI_Comm comm, const char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
- if (info_ != MPI_INFO_NULL)
- info_->ref();
- std::string fullname=filename;
- xbt_assert(not simgrid::s4u::Host::current()->get_disks().empty(),
- "SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
-
- size_t found=fullname.find('/');
- //in case no fullpath is provided ... just pick the first mountpoint.
- if(found==std::string::npos || fullname.rfind("./", 1) != std::string::npos){
- auto disk = simgrid::s4u::Host::current()->get_disks().front();
- std::string mount;
- if (disk->get_host() != simgrid::s4u::Host::current())
- mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point(disk->get_host());
- else
- mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point();
- XBT_DEBUG("No absolute path given for file opening, use '%s'", mount.c_str());
- if(fullname.rfind("./",1) != std::string::npos)
- fullname.replace(fullname.begin(), fullname.begin() + 1, mount);
- else{
- mount.append("/");
- fullname.insert(0, mount);
- }
- }
-
- file_= new simgrid::s4u::File(fullname, nullptr);
- list_=nullptr;
- if (comm_->rank() == 0) {
- int size= comm_->size() + FP_SIZE;
- list_ = new char[size];
- errhandler_= SMPI_default_File_Errhandler;
- errhandler_->ref();
- memset(list_, 0, size);
- shared_file_pointer_ = new MPI_Offset();
- shared_mutex_ = s4u::Mutex::create();
- *shared_file_pointer_ = 0;
- win_=new Win(list_, size, 1, MPI_INFO_NULL, comm_);
- }else{
- errhandler_ = MPI_ERRHANDLER_NULL;
- win_=new Win(list_, 0, 1, MPI_INFO_NULL, comm_);
+namespace simgrid::smpi {
+
+File::File(MPI_Comm comm, const char* filename, int amode, MPI_Info info) : comm_(comm), flags_(amode), info_(info)
+{
+ if (info_ != MPI_INFO_NULL)
+ info_->ref();
+ std::string fullname = filename;
+ xbt_assert(not simgrid::s4u::Host::current()->get_disks().empty(),
+ "SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
+
+ // in case no fullpath is provided ... just pick the first mountpoint.
+ if (size_t found = fullname.find('/'); found == std::string::npos || fullname.rfind("./", 1) != std::string::npos) {
+ const auto* disk = simgrid::s4u::Host::current()->get_disks().front();
+ std::string mount;
+ if (disk->get_host() != simgrid::s4u::Host::current())
+ mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point(disk->get_host());
+ else
+ mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point();
+ XBT_DEBUG("No absolute path given for file opening, use '%s'", mount.c_str());
+ if (fullname.rfind("./", 1) != std::string::npos)
+ fullname.replace(fullname.begin(), fullname.begin() + 1, mount);
+ else {
+ mount.append("/");
+ fullname.insert(0, mount);