Changeset 2024 for trunk/source/cpu.cpp

Show
Ignore:
Timestamp:
05/05/08 08:48:31 (8 months ago)
Author:
peter
Message:

source/cpu.cpp:

Improve diagnostic of failure to open data file.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/cpu.cpp

    r1970 r2024  
    480480        if( handle == NULL && lgAbort ) 
    481481        { 
    482                 // failed on very first open -> probably path is not correct 
    483482                fprintf( ioQQQ, "\nPROBLEM DISASTER I could not open the data file %s\n\n", fname ); 
    484                 fprintf( ioQQQ, "Although there may be other reasons you have received this error,\n"); 
    485                 fprintf( ioQQQ, "the most likely are that the path has not been properly set\n"); 
    486                 fprintf( ioQQQ, "or that the path points to an old version of the data.\n\n"); 
    487                 fprintf( ioQQQ, "Please have a look at the file path.h in the source directory\n"); 
    488                 fprintf( ioQQQ, "to check how the variable CLOUDY_DATA_PATH is set - \n"); 
    489                 fprintf( ioQQQ, "it should give the location of the data files I need.\n"); 
    490                 fprintf( ioQQQ, "These are the files in the data download from the web site.\n\n"); 
    491                 fprintf( ioQQQ, "Recompile the code with the correct data path set in path.h\n"); 
    492                 fprintf( ioQQQ, "or use the shell command \"set CLOUDY_DATA_PATH=path\" to set the\n"); 
    493                 fprintf( ioQQQ, "path from a command prompt.\n\n"); 
    494                 cpu.printDataPath(); 
    495  
    496                 fprintf( ioQQQ, " These are all the paths I tried:\n", fname ); 
    497                 for( vector<string>::size_type i=begin; i < end; ++i ) 
    498                 { 
    499                         if( cpu.chSearchPath[i].length() > 0 ) 
    500                                 fprintf( ioQQQ, "   ==%s==\n", cpu.chSearchPath[i].c_str() ); 
    501                         else 
    502                                 fprintf( ioQQQ, "   ==<local directory>==\n" ); 
     483                if( cpu.nFileDone == 0 || scheme == AS_DATA_ONLY ) 
     484                { 
     485                        // failed on very first open -> most likely path is not correct 
     486                        // failed on AS_DATA_ONLY -> CLOUDY_DATA_PATH may point to obsolete data dir 
     487                        fprintf( ioQQQ, "Although there may be other reasons you have received this error,\n"); 
     488                        fprintf( ioQQQ, "the most likely are that the path has not been properly set\n"); 
     489                        fprintf( ioQQQ, "or that the path points to an old version of the data.\n\n"); 
     490                        fprintf( ioQQQ, "Please have a look at the file path.h in the source directory\n"); 
     491                        fprintf( ioQQQ, "to check how the variable CLOUDY_DATA_PATH is set - \n"); 
     492                        fprintf( ioQQQ, "it should give the location of the data files I need.\n"); 
     493                        fprintf( ioQQQ, "These are the files in the data download from the web site.\n\n"); 
     494                        fprintf( ioQQQ, "Recompile the code with the correct data path set in path.h\n"); 
     495                        fprintf( ioQQQ, "or use the shell command \"export CLOUDY_DATA_PATH=path\" to set the\n"); 
     496                        fprintf( ioQQQ, "path from a bash command prompt.\n\n"); 
     497                        cpu.printDataPath(); 
     498                } 
     499                else 
     500                { 
     501                        // failed on search including local directory -> most likely the file name 
     502                        // was mistyped on a compile command, or Cloudy is run in the wrong directory 
     503                        fprintf( ioQQQ, "These are all the paths I tried:\n" ); 
     504                        for( vector<string>::size_type i=begin; i < end; ++i ) 
     505                        { 
     506                                if( cpu.chSearchPath[i].length() > 0 ) 
     507                                        fprintf( ioQQQ, "   ==%s==\n", cpu.chSearchPath[i].c_str() ); 
     508                                else 
     509                                        fprintf( ioQQQ, "   ==<local directory>==\n" ); 
     510                        } 
     511                        fprintf( ioQQQ, "\nAlthough there may be other reasons you have received this error,\n"); 
     512                        fprintf( ioQQQ, "the most likely are that you mistyped the file name, or that you\n"); 
     513                        fprintf( ioQQQ, "are running Cloudy in the wrong directory. If you are running a\n"); 
     514                        fprintf( ioQQQ, "COMPILE command, this needs to be done in the data directory.\n\n"); 
     515                        fprintf( ioQQQ, "Otherwise, please have a look at the file path.h in the source\n"); 
     516                        fprintf( ioQQQ, "directory to check how the variable CLOUDY_DATA_PATH is set - \n"); 
     517                        fprintf( ioQQQ, "it should give the location of the data files I need.\n"); 
     518                        fprintf( ioQQQ, "These are the files in the data download from the web site.\n\n"); 
     519                        fprintf( ioQQQ, "Recompile the code with the correct data path set in path.h\n"); 
     520                        fprintf( ioQQQ, "or use the shell command \"export CLOUDY_DATA_PATH=path\" to set the\n"); 
     521                        fprintf( ioQQQ, "path from a bash command prompt.\n\n"); 
    503522                } 
    504523                fprintf(ioQQQ, "Sorry.\n\n\n");