1

Running C++ code using Repast HPC 2.1 on an Ubuntu 14.04 VirtualBox VM. This code has been proven to work when run in XCode on a Mac laptop. I'm currently trying to make the existing code run in Ubuntu. Make runs successfully on the code in Ubuntu, but when trying to call mpirun -n 4, I receive the following error, indicating that the file will not open properly:

file open fail /home/repasthpc/Desktop/hpcmodel/angiogenesis-osteogenesis-simulator/concFiles/c100forC.txt
file open fail /home/repasthpc/Desktop/hpcmodel/angiogenesis-osteogenesis-simulator/concFiles/c100forC.txt
file open fail /home/repasthpc/Desktop/hpcmodel/angiogenesis-osteogenesis-simulator/concFiles/c100forC.txt
file open fail /home/repasthpc/Desktop/hpcmodel/angiogenesis-osteogenesis-simulator/concFiles/c100forC.txt

This is using multiple threads (4), which I've heard can be an issue when opening files in Ubuntu, but I'm not sure how to fix it if this is the problem.

The error is generated by the file.fail() call in this method:

#include <fstream>
#include <string>
#include <vector>
#include <math.h>
#include "repast_hpc/Random.h"
#include "SolubleMap.h"
#include "BoneModel.h"

using namespace std;

void SolubleMap::releaseVEGF(std::string filename){
    ifstream file;
    file.open(filename.c_str());

    int row=time; //time
    int column=ydim; // location

    if(file.fail()){
        cerr << "file open fail" << endl;
    }

    else{
        this->VEGFConcentration = new double*[row]; // memory allocated for elements of rows
        for(int j = 0; j < row; j++){ 
            this->VEGFConcentration[j] = new double[column]; // memory allocated for elements of columns
            for(int i = 0; i < column; i++){
                if (!(file >> this->VEGFConcentration[j][i])){
                    std::cerr << "error while reading file";
                    break;
                }
            }
            if (!file) break;
        }
    }
    file.close();
}

When the full filepath is passed as a string to file.open() in line 2 of the method, still produces the same error.

Is there some reference or library I am missing that is provided by XCode?

Thanks!

Rachael
  • 23
  • 8
  • 2
    obvious question: is that path correct? note that osx filesystem is by default not case sensitive, while ubuntu is. – Marc B Jul 28 '15 at 20:04
  • I would recommend adding the file name to the error message. It is always good practice, but in particular, it may shed light directly on your current problem. – donjuedo Jul 28 '15 at 20:09
  • You may also want to check file permissions. (run `ls -la`, if this is new for you -- I don't know) – donjuedo Jul 28 '15 at 20:11
  • Checked the file path with "vim filepath", opens the correct file. Added the file name to error message, results in the program crashing before it can output the filename. Perhaps it has an issue with processing the filename/filepath itself? – Rachael Jul 28 '15 at 20:16
  • Was able to change "/home/reapsthpc" to "~", and the filename now outputs in the error message. Still getting the error though... – Rachael Jul 30 '15 at 20:17
  • File permissions are -rw-r--r-- – – Rachael Jul 30 '15 at 20:25
  • What happens if instead of `if(file.fail())` you use `if(!file.is_open())`? – jandres742 Jul 30 '15 at 20:38
  • Same error is thrown. The error is thrown no matter what text file I use as well... – Rachael Jul 30 '15 at 21:19

0 Answers0