Hello everybody
I'm using the Slatec library and I found that I had to deal with the subroutines d1mach and i1mach that take into account the processor I'm working with to set the machine precission that my computer can support.
Besides the fact that I couldn't find the kind of processor that I'm using (Intel Q6600), and that in the end I chose the option the most similar to my processor, I received some compiling error regarding the overflow of a variable that was declared as integer but declared as equivalent as a double precision.
I have to admit that I had never used the "Equivalence" command, so I didn't understand exactly what was going on. But my surprise was big when I saw that the compiler error only occurred for the variable whose value was the biggest, not for the smallest one. I have to say that the variables were declared as integer but assigned double precision values, so I thought that this was the problem in the beginning, but I found out that the "Equivalence" command prevents this problem to occur (if dealt correctly).
Please, find below the part of the code that concerns the problem (I've skipped a lot of lines containing only data):
<<
*DECK D1MACH
DOUBLE PRECISION FUNCTION D1MACH (I)
INTEGER SMALL(4)
INTEGER LARGE(4)
INTEGER RIGHT(4)
INTEGER DIVER(4)
INTEGER LOG10(4)
DOUBLE PRECISION DMACH(5)
SAVE DMACH
EQUIVALENCE (DMACH(1),SMALL(1))
EQUIVALENCE (DMACH(2),LARGE(1))
EQUIVALENCE (DMACH(3),RIGHT(1))
EQUIVALENCE (DMACH(4),DIVER(1))
EQUIVALENCE (DMACH(5),LOG10(1))
C..............................................
C MACHINE CONSTANTS FOR THE IBM PC
C ASSUMES THAT ALL ARITHMETIC IS DONE IN DOUBLE
C PRECISION ON 8088, I.E., NOT IN 80 BIT FORM FOR THE C 8087.
C
C DATA SMALL(1) / 2.23D-308 /
C DATA LARGE(1) / 1.79D+308 /
C DATA RIGHT(1) / 1.11D-16 /
C DATA DIVER(1) / 2.22D-16 /
C DATA LOG10(1) / 0.301029995663981195D0 /
>>
The compiler error is the following:
"Error: The value of the integer is either too great or too small, and overflow/underflow occurred. [1.79D+308]
DATA LARGE(1) / 1.79D+308 /"
Could anybody help me to understand why do I receive a compile error for the overflow of the variable LARGE and not an underflow error message for the variable SMALL?
I have to say that when I decreased the value of LARGE in the data statement line to 1e+17 the compiler didn't complain anymore.
Thank you very much for your help.
I'm using the Slatec library and I found that I had to deal with the subroutines d1mach and i1mach that take into account the processor I'm working with to set the machine precission that my computer can support.
Besides the fact that I couldn't find the kind of processor that I'm using (Intel Q6600), and that in the end I chose the option the most similar to my processor, I received some compiling error regarding the overflow of a variable that was declared as integer but declared as equivalent as a double precision.
I have to admit that I had never used the "Equivalence" command, so I didn't understand exactly what was going on. But my surprise was big when I saw that the compiler error only occurred for the variable whose value was the biggest, not for the smallest one. I have to say that the variables were declared as integer but assigned double precision values, so I thought that this was the problem in the beginning, but I found out that the "Equivalence" command prevents this problem to occur (if dealt correctly).
Please, find below the part of the code that concerns the problem (I've skipped a lot of lines containing only data):
<<
*DECK D1MACH
DOUBLE PRECISION FUNCTION D1MACH (I)
INTEGER SMALL(4)
INTEGER LARGE(4)
INTEGER RIGHT(4)
INTEGER DIVER(4)
INTEGER LOG10(4)
DOUBLE PRECISION DMACH(5)
SAVE DMACH
EQUIVALENCE (DMACH(1),SMALL(1))
EQUIVALENCE (DMACH(2),LARGE(1))
EQUIVALENCE (DMACH(3),RIGHT(1))
EQUIVALENCE (DMACH(4),DIVER(1))
EQUIVALENCE (DMACH(5),LOG10(1))
C..............................................
C MACHINE CONSTANTS FOR THE IBM PC
C ASSUMES THAT ALL ARITHMETIC IS DONE IN DOUBLE
C PRECISION ON 8088, I.E., NOT IN 80 BIT FORM FOR THE C 8087.
C
C DATA SMALL(1) / 2.23D-308 /
C DATA LARGE(1) / 1.79D+308 /
C DATA RIGHT(1) / 1.11D-16 /
C DATA DIVER(1) / 2.22D-16 /
C DATA LOG10(1) / 0.301029995663981195D0 /
>>
The compiler error is the following:
"Error: The value of the integer is either too great or too small, and overflow/underflow occurred. [1.79D+308]
DATA LARGE(1) / 1.79D+308 /"
Could anybody help me to understand why do I receive a compile error for the overflow of the variable LARGE and not an underflow error message for the variable SMALL?
I have to say that when I decreased the value of LARGE in the data statement line to 1e+17 the compiler didn't complain anymore.
Thank you very much for your help.