9 extern "C" unsigned long fegettrapenable();
10 extern "C" void fesettrapenable(
unsigned long);
13 #if defined(__ia64) && defined(__INTEL_COMPILER)
14 extern "C" unsigned long fpgetmask();
15 extern "C" void fpsetmask(
unsigned long);
18 #if defined(__sun) || defined(__sgi)
20 #if defined(HAVE_SUNMATH) || defined(FLUSH_DENORM_TO_ZERO)
25 #if defined(__alpha) && defined(__linux) && defined(__GNUC__)
30 #if defined(__unix) || defined(__APPLE__)
34 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
35 #include <sys/types.h>
36 #include <sys/sysctl.h>
127 if(
sizeof(
double) == 8 )
145 if(
sizeof(
double) == 8 )
198 # if defined(_SC_NPROCESSORS_ONLN)
200 # elif defined(_SC_NPROC_ONLN)
202 # elif defined(_SC_CRAY_NCPU)
204 # elif defined(_WIN32)
205 str = getenv(
"NUMBER_OF_PROCESSORS" );
216 # elif defined(HW_AVAILCPU)
220 mib[1] = HW_AVAILCPU;
244 str = getenv(
"COMPUTERNAME" );
246 str = getenv(
"HOSTNAME" );
256 const char *path = getenv(
"CLOUDY_DATA_PATH" );
259 string chSearchPathRaw = ( path != NULL ) ?
string( path ) : string( CLOUDY_DATA_PATH );
262 string separator(
";" );
265 string separator(
":" );
298 # if defined(_MSC_VER)
299 volatile unsigned int NewMask;
304 NewMask = _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_INVALID;
307 _controlfp( NewMask , _MCW_EM );
312 # elif defined(__GNUC__) && ( defined(__i386) || defined(__amd64) )
313 volatile unsigned int Old_Mask, New_Mask;
314 # if defined(__SSE__) || defined(__SSE2__)
315 volatile unsigned int SSE_Mask;
318 # define _FPU_MASK_IM 0x01
319 # define _FPU_MASK_DM 0x02
320 # define _FPU_MASK_ZM 0x04
321 # define _FPU_MASK_OM 0x08
322 # define _FPU_MASK_UM 0x10
323 # define _FPU_MASK_PM 0x20
333 volatile unsigned int UnMask = ~((
unsigned int)( _FPU_MASK_ZM | _FPU_MASK_IM | _FPU_MASK_OM ));
335 __asm__
volatile(
"fnstcw %0" :
"=m" (*&Old_Mask));
337 New_Mask = Old_Mask & UnMask;
339 __asm__
volatile(
"fldcw %0" : :
"m" (*&New_Mask));
341 # if defined(__SSE__) || defined(__SSE2__)
343 # if defined(FLUSH_DENORM_TO_ZERO)
354 __asm__
volatile(
"ldmxcsr %0" : :
"m" (*&SSE_Mask) );
359 # elif defined(__ia64)
361 # define FPSR_TRAP_VD (1 << 0)
362 # define FPSR_TRAP_DD (1 << 1)
363 # define FPSR_TRAP_ZD (1 << 2)
364 # define FPSR_TRAP_OD (1 << 3)
365 # define FPSR_TRAP_UD (1 << 4)
366 # define FPSR_TRAP_ID (1 << 5)
368 # define FPSR_SF0_FTZ (1 << 6)
370 # if defined(__GNUC_EXCL__)
372 # define _IA64_REG_AR_FPSR 40
374 # define ia64_getreg( regnum ) __asm__ volatile( "mov %0=ar%1" : "=r" (fpsr) : "i"(regnum) )
375 # define ia64_setreg( regnum, val ) __asm__ volatile( "mov ar%0=%1" :: "i" (regnum), "r"(val): "memory" )
376 # define ia64_serialize __asm__ volatile( "srlz.i" );
378 volatile unsigned long fpsr, flags = FPSR_TRAP_VD | FPSR_TRAP_ZD | FPSR_TRAP_OD;
380 ia64_getreg( _IA64_REG_AR_FPSR );
382 # if defined(FLUSH_DENORM_TO_ZERO)
383 fpsr |= FPSR_SF0_FTZ;
385 ia64_setreg( _IA64_REG_AR_FPSR, fpsr );
389 # elif defined(__INTEL_COMPILER)
391 unsigned long fpsr = fpgetmask();
392 fpsr |= FPSR_TRAP_VD | FPSR_TRAP_ZD | FPSR_TRAP_OD;
394 # elif defined(__HP_aCC)
396 unsigned long fpsr = fegettrapenable();
397 fpsr |= FPSR_TRAP_VD | FPSR_TRAP_ZD | FPSR_TRAP_OD;
398 fesettrapenable( fpsr );
402 # elif defined(__sun) || defined(__sgi)
407 # if defined(HAVE_SUNMATH) || defined(FLUSH_DENORM_TO_ZERO)
444 nonstandard_arithmetic();
449 mask = mask | FP_X_INV | FP_X_OFL | FP_X_DZ;
452 # elif defined(__alpha) && defined(__linux) && defined(__GNUC__)
457 # ifdef FE_NONIEEE_ENV
461 fesetenv(FE_NONIEEE_ENV);
475 sigemptyset( &p_action.sa_mask );
476 p_action.sa_flags = SA_NODEFER;
478 p_default.sa_handler = SIG_DFL;
479 sigemptyset( &p_default.sa_mask );
480 p_default.sa_flags = SA_NODEFER;
482 for(
int sig=1; sig <= 31; sig++ )
485 if( sigaction( sig, NULL, NULL ) == 0 )
487 if( sig != SIGSTOP && sig != SIGCONT )
488 sigaction( sig, action(), NULL );
517 fprintf(
ioQQQ,
"The path is:\n");
527 vector<string>::size_type begin, end;
558 string FileName( fname );
559 for( vector<string>::size_type
i=begin;
i < end; ++
i )
569 fprintf(
ioQQQ,
"\nI could not open the data file %s\n\n", fname );
571 fprintf(
ioQQQ,
"\nPROBLEM DISASTER I could not open the data file %s\n\n", fname );
576 fprintf(
ioQQQ,
"Although there may be other reasons you have received this error,\n");
577 fprintf(
ioQQQ,
"the most likely are that the path has not been properly set\n");
578 fprintf(
ioQQQ,
"or that the path points to an old version of the data.\n\n");
579 fprintf(
ioQQQ,
"Please have a look at the file path.h in the source directory\n");
580 fprintf(
ioQQQ,
"to check how the variable CLOUDY_DATA_PATH is set - \n");
581 fprintf(
ioQQQ,
"it should give the location of the data files I need.\n");
582 fprintf(
ioQQQ,
"These are the files in the data download from the web site.\n\n");
583 fprintf(
ioQQQ,
"Recompile the code with the correct data path set in path.h\n");
584 fprintf(
ioQQQ,
"or use the shell command \nexport CLOUDY_DATA_PATH=\"/path/to/data\"\n to set the\n");
585 fprintf(
ioQQQ,
"path from a bash command prompt.\n\n");
593 fprintf(
ioQQQ,
"These are all the paths I tried:\n" );
594 for( vector<string>::const_iterator ptr=PathList.begin(); ptr != PathList.end(); ++ptr )
595 fprintf(
ioQQQ,
" ==%s==\n", ptr->c_str() );
599 fprintf(
ioQQQ,
"\nAlthough there may be other reasons you have received this error,\n");
600 fprintf(
ioQQQ,
"the most likely are that you mistyped the file name, or that you\n");
601 fprintf(
ioQQQ,
"are running Cloudy in the wrong directory. If you are running a\n");
602 fprintf(
ioQQQ,
"COMPILE command, this needs to be done in the data directory.\n\n");
603 fprintf(
ioQQQ,
"Otherwise, please have a look at the file path.h in the source\n");
604 fprintf(
ioQQQ,
"directory to check how the variable CLOUDY_DATA_PATH is set - \n");
605 fprintf(
ioQQQ,
"it should give the location of the data files I need.\n");
606 fprintf(
ioQQQ,
"These are the files in the data download from the web site.\n\n");
607 fprintf(
ioQQQ,
"Recompile the code with the correct data path set in path.h\n");
608 fprintf(
ioQQQ,
"or use the shell command \nexport CLOUDY_DATA_PATH=\"/path/to/data\"\n to set the\n");
609 fprintf(
ioQQQ,
"path from a bash command prompt.\n\n");
612 fprintf(
ioQQQ,
"Sorry.\n\n\n");
623 vector<string> PathList;
627 vector<string>::const_iterator ptr;
628 for( ptr=PathList.begin(); ptr != PathList.end() && handle == NULL; ++ptr )
630 handle = fopen( ptr->c_str(), mode );
632 fprintf(
ioQQQ,
" open_data trying %s mode %s handle %p\n", ptr->c_str(), mode, handle );
635 if( handle == NULL && lgAbort )
650 vector<string> PathList;
653 ASSERT( !stream.is_open() );
654 vector<string>::const_iterator ptr;
655 for( ptr=PathList.begin(); ptr != PathList.end() && !stream.is_open(); ++ptr )
657 stream.open( ptr->c_str(), mode );
659 fprintf(
ioQQQ,
" open_data trying %s succes? %c\n", ptr->c_str(),
TorF(stream.is_open()) );
662 if( !stream.is_open() &&
lgAbort )
688 int32 *y =
reinterpret_cast<int32*
>(x);
689 for( i=0; i < n; i++ )
694 for( i=0; i < n; i++ )
701 if(
sizeof(
double) == 8 )
706 int32 *y =
reinterpret_cast<int32*
>(&x);
721 if(
sizeof(
double) == 8 )
724 int64 *y =
reinterpret_cast<int64*
>(x);
725 for( i=0; i < n; i++ )
728 int32 *y =
reinterpret_cast<int32*
>(x);
729 for( i=0; i < n; i++ )
738 for( i=0; i < n; i++ )
746 if(
sizeof(
sys_float) == 4 && FLT_MAX_EXP-FLT_MIN_EXP+3 == 256 )
748 const int32 *p =
reinterpret_cast<const int32*
>(&x);
749 int32 r = *p & 0x7f800000; r ^= 0x7f800000;
750 int32 s = *p & 0x007fffff;
751 return ( r == 0 && s != 0 );
761 if(
sizeof(
double) == 8 && DBL_MAX_EXP-DBL_MIN_EXP+3 == 2048 )
764 const int64 *p =
reinterpret_cast<const int64*
>(&x);
765 int64 r = *p & 0x7ff0000000000000; r ^= 0x7ff0000000000000;
766 int64 s = *p & 0x000fffffffffffff;
767 return ( r == 0 && s != 0 );
769 const int32 *p =
reinterpret_cast<const int32*
>(&x);
772 int32 r = p[1] & 0x7ff00000; r ^= 0x7ff00000;
773 int32 s = p[1] & 0x000fffff; s |= p[0];
774 return ( r == 0 && s != 0 );
778 int32 r = p[0] & 0x7ff00000; r ^= 0x7ff00000;
779 int32 s = p[0] & 0x000fffff; s |= p[1];
780 return ( r == 0 && s != 0 );
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
static void signal_handler(int sig)
void getPathList(const char *fname, vector< string > &PathList, access_scheme scheme) const
bool p_lgMPISingleRankMode
NORETURN void TotalInsanity(void)
void set_NaN(sys_float &x)
int32 Double_SNaN_Value[2]
bool MyIsnan(const sys_float &x)
STATIC NORETURN void AbortErrorMessage(const char *fname, vector< string > &PathList, access_scheme scheme)
bool little_endian() const
void Split(const string &str, const string &sep, vector< string > &lst, split_mode mode)
void printDataPath() const
vector< string > p_exit_status
#define DEBUG_ENTRY(funcname)
void set_signal_handlers()
void enable_traps() const
vector< string > chSearchPath