6 extern "C" unsigned long fegettrapenable();
7 extern "C" void fesettrapenable(
unsigned long);
10 #if defined(__ia64) && defined(__INTEL_COMPILER)
11 extern "C" unsigned long fpgetmask();
12 extern "C" void fpsetmask(
unsigned long);
15 #if defined(__sun) || defined(__sgi)
17 #if defined(HAVE_SUNMATH) || defined(FLUSH_DENORM_TO_ZERO)
22 #if defined(__alpha) && defined(__linux) && defined(__GNUC__)
47 sigemptyset( &p_action.sa_mask );
48 p_action.sa_flags = SA_NODEFER;
50 p_default.sa_handler = SIG_DFL;
51 sigemptyset( &p_default.sa_mask );
52 p_default.sa_flags = SA_NODEFER;
54 for(
int sig=1; sig <= 31; sig++ )
57 if( sigaction( sig, NULL, NULL ) == 0 )
59 if( sig != SIGSTOP && sig != SIGCONT )
60 sigaction( sig, action(), NULL );
108 if(
sizeof(
double) == 8 )
126 if(
sizeof(
double) == 8 )
171 # if defined(_SC_NPROCESSORS_ONLN)
173 # elif defined(_SC_NPROC_ONLN)
175 # elif defined(_SC_CRAY_NCPU)
177 # elif defined(_WIN32)
178 str = getenv(
"NUMBER_OF_PROCESSORS" );
195 str = getenv(
"COMPUTERNAME" );
197 str = getenv(
"HOSTNAME" );
207 const char *path = getenv(
"CLOUDY_DATA_PATH" );
210 string chSearchPathRaw = ( path != NULL ) ?
string( path ) : string(
CLOUDY_DATA_PATH );
213 string separator(
";" );
214 char chExpectedEnd =
'\\';
216 string separator(
":" );
217 char chExpectedEnd =
'/';
232 if( chEnd != chExpectedEnd )
249 # if defined(_MSC_VER)
250 volatile unsigned int NewMask;
255 NewMask = _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_INVALID;
258 _controlfp( NewMask , _MCW_EM );
263 # elif defined(__GNUC__) && ( defined(__i386) || defined(__amd64) )
264 volatile unsigned int Old_Mask, New_Mask;
265 # if defined(__SSE__) || defined(__SSE2__)
266 volatile unsigned int SSE_Mask;
269 # define _FPU_MASK_IM 0x01
270 # define _FPU_MASK_DM 0x02
271 # define _FPU_MASK_ZM 0x04
272 # define _FPU_MASK_OM 0x08
273 # define _FPU_MASK_UM 0x10
274 # define _FPU_MASK_PM 0x20
284 volatile unsigned int UnMask = ~((
unsigned int)( _FPU_MASK_ZM | _FPU_MASK_IM | _FPU_MASK_OM ));
286 __asm__
volatile(
"fnstcw %0" :
"=m" (*&Old_Mask));
288 New_Mask = Old_Mask & UnMask;
290 __asm__
volatile(
"fldcw %0" : :
"m" (*&New_Mask));
292 # if defined(__SSE__) || defined(__SSE2__)
294 # if defined(FLUSH_DENORM_TO_ZERO)
305 __asm__
volatile(
"ldmxcsr %0" : :
"m" (*&SSE_Mask) );
310 # elif defined(__ia64)
312 # define FPSR_TRAP_VD (1 << 0)
313 # define FPSR_TRAP_DD (1 << 1)
314 # define FPSR_TRAP_ZD (1 << 2)
315 # define FPSR_TRAP_OD (1 << 3)
316 # define FPSR_TRAP_UD (1 << 4)
317 # define FPSR_TRAP_ID (1 << 5)
319 # define FPSR_SF0_FTZ (1 << 6)
321 # if defined(__GNUC_EXCL__)
323 # define _IA64_REG_AR_FPSR 40
325 # define ia64_getreg( regnum ) __asm__ volatile( "mov %0=ar%1" : "=r" (fpsr) : "i"(regnum) )
326 # define ia64_setreg( regnum, val ) __asm__ volatile( "mov ar%0=%1" :: "i" (regnum), "r"(val): "memory" )
327 # define ia64_serialize __asm__ volatile( "srlz.i" );
329 volatile unsigned long fpsr, flags = FPSR_TRAP_VD | FPSR_TRAP_ZD | FPSR_TRAP_OD;
331 ia64_getreg( _IA64_REG_AR_FPSR );
333 # if defined(FLUSH_DENORM_TO_ZERO)
334 fpsr |= FPSR_SF0_FTZ;
336 ia64_setreg( _IA64_REG_AR_FPSR, fpsr );
340 # elif defined(__INTEL_COMPILER)
342 unsigned long fpsr = fpgetmask();
343 fpsr |= FPSR_TRAP_VD | FPSR_TRAP_ZD | FPSR_TRAP_OD;
345 # elif defined(__HP_aCC)
347 unsigned long fpsr = fegettrapenable();
348 fpsr |= FPSR_TRAP_VD | FPSR_TRAP_ZD | FPSR_TRAP_OD;
349 fesettrapenable( fpsr );
353 # elif defined(__sun) || defined(__sgi)
358 # if defined(HAVE_SUNMATH) || defined(FLUSH_DENORM_TO_ZERO)
395 nonstandard_arithmetic();
400 mask = mask | FP_X_INV | FP_X_OFL | FP_X_DZ;
403 # elif defined(__alpha) && defined(__linux) && defined(__GNUC__)
408 # ifdef FE_NONIEEE_ENV
412 fesetenv(FE_NONIEEE_ENV);
433 fprintf(
ioQQQ,
"The path is:\n");
443 string FileName( fname );
444 vector<string>::size_type begin, end;
476 for( vector<string>::size_type i=begin; i < end && handle == NULL; ++i )
479 handle = fopen( FullName.c_str(), mode );
483 fprintf(
ioQQQ,
" opening %s mode %s handle %p\n", FullName.c_str(), mode, handle );
485 if( handle == NULL && lgAbort )
489 fprintf(
ioQQQ,
"\nI could not open the data file %s\n\n", fname );
491 fprintf(
ioQQQ,
"\nPROBLEM DISASTER I could not open the data file %s\n\n", fname );
496 fprintf(
ioQQQ,
"Although there may be other reasons you have received this error,\n");
497 fprintf(
ioQQQ,
"the most likely are that the path has not been properly set\n");
498 fprintf(
ioQQQ,
"or that the path points to an old version of the data.\n\n");
499 fprintf(
ioQQQ,
"Please have a look at the file path.h in the source directory\n");
500 fprintf(
ioQQQ,
"to check how the variable CLOUDY_DATA_PATH is set - \n");
501 fprintf(
ioQQQ,
"it should give the location of the data files I need.\n");
502 fprintf(
ioQQQ,
"These are the files in the data download from the web site.\n\n");
503 fprintf(
ioQQQ,
"Recompile the code with the correct data path set in path.h\n");
504 fprintf(
ioQQQ,
"or use the shell command \"export CLOUDY_DATA_PATH=path\" to set the\n");
505 fprintf(
ioQQQ,
"path from a bash command prompt.\n\n");
513 fprintf(
ioQQQ,
"These are all the paths I tried:\n" );
514 for( vector<string>::size_type i=begin; i < end; ++i )
519 fprintf(
ioQQQ,
" ==<local directory>==\n" );
524 fprintf(
ioQQQ,
"\nAlthough there may be other reasons you have received this error,\n");
525 fprintf(
ioQQQ,
"the most likely are that you mistyped the file name, or that you\n");
526 fprintf(
ioQQQ,
"are running Cloudy in the wrong directory. If you are running a\n");
527 fprintf(
ioQQQ,
"COMPILE command, this needs to be done in the data directory.\n\n");
528 fprintf(
ioQQQ,
"Otherwise, please have a look at the file path.h in the source\n");
529 fprintf(
ioQQQ,
"directory to check how the variable CLOUDY_DATA_PATH is set - \n");
530 fprintf(
ioQQQ,
"it should give the location of the data files I need.\n");
531 fprintf(
ioQQQ,
"These are the files in the data download from the web site.\n\n");
532 fprintf(
ioQQQ,
"Recompile the code with the correct data path set in path.h\n");
533 fprintf(
ioQQQ,
"or use the shell command \"export CLOUDY_DATA_PATH=path\" to set the\n");
534 fprintf(
ioQQQ,
"path from a bash command prompt.\n\n");
537 fprintf(
ioQQQ,
"Sorry.\n\n\n");
566 int32 *y =
reinterpret_cast<int32*
>(x);
567 for( i=0; i < n; i++ )
572 for( i=0; i < n; i++ )
579 if(
sizeof(
double) == 8 )
584 int32 *y = reinterpret_cast<int32*>(&x);
599 if(
sizeof(
double) == 8 )
602 int64 *y =
reinterpret_cast<int64*
>(x);
603 for( i=0; i < n; i++ )
606 int32 *y = reinterpret_cast<int32*>(x);
607 for( i=0; i < n; i++ )
616 for( i=0; i < n; i++ )
624 if(
sizeof(
sys_float) == 4 && FLT_MAX_EXP-FLT_MIN_EXP+3 == 256 )
626 int32 *p =
reinterpret_cast<int32*
>(&x);
627 int32 r = *p & 0x7f800000; r ^= 0x7f800000;
628 int32 s = *p & 0x007fffff;
629 return ( r == 0 && s != 0 );
639 if(
sizeof(
double) == 8 && DBL_MAX_EXP-DBL_MIN_EXP+3 == 2048 )
642 int64 *p =
reinterpret_cast<int64*
>(&x);
643 int64 r = *p & 0x7ff0000000000000; r ^= 0x7ff0000000000000;
644 int64 s = *p & 0x000fffffffffffff;
645 return ( r == 0 && s != 0 );
647 int32 *p =
reinterpret_cast<int32*
>(&x);
650 int32 r = p[1] & 0x7ff00000; r ^= 0x7ff00000;
651 int32 s = p[1] & 0x000fffff; s |= p[0];
652 return ( r == 0 && s != 0 );
656 int32 r = p[0] & 0x7ff00000; r ^= 0x7ff00000;
657 int32 s = p[0] & 0x000fffff; s |= p[1];
658 return ( r == 0 && s != 0 );