View Full Version : File Operation problem in totalview

10-24-2009, 06:01 PM
Our MPI program includes file operations. Without totalview, it can run normally.But when I debug it in totalview, it cannot open the file. Through the totalview, whenever I step to e.g. FILE * fp=fopen(…), the fp always is a null pointer. I have tried absolute/relative file path name, and I also tried to put the put input file into the same folder with the program. But it has the same problem. A more interesting thing is that, occasionally the program is executed successfully in totalview. How to fix this problem?

We installed TotalView Express Student 8.7.0-3 for Linux/x86-64.
In the totalview’s Parallet tag. We use Open MPI. Tasks and nodes are set to be 4, and the additional argument is set to be “--mca btl ^openib?(disable the infiniband)
We also try it in totalview trial with demo license. Still not work.

e.g. this program often cannot get file pointer.
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>

int countData(const char * filename){
FILE * fp=fopen(filename, "r");
fprintf(stderr,"Cannot open the file: %s \n",filename);
int counter=0;
while( feof(fp)==0){//if the file does not reach its end of file
char str[512];
fgets(str, sizeof(str), fp);

return counter;

int main(int argc, char ** argv){
int procRank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &procRank);
//if (procRank ==0){
char filename[]="../data/DataStatistics.txt";
int count =countData(filename);
printf("count=%d\n", count);

11-09-2009, 03:16 PM
Hmm, interesting. There is nothing in TotalView that should restrict an fopen call from succeeding. I've done enough next's over fopen to know that is true. However, I wonder if some of the restrictions on the student express license might be coming into play here? But I see you also mention trying this with a demo license (which is less restrictive) and that still doesn't work. Have you tried putting in code for errno, and seeing what error value is returned? That might shed some light.

I might play around with this if I have time. Which, unfortunately, is not right now...