Skip to content

Commit

Permalink
Fixed issue #1. It was caused by the sgn() function, which returned 0…
Browse files Browse the repository at this point in the history
… if the input was 0. It now returns 1 if the input is 0. Also changed the FORTRAN implementation to the original one and included the necessary dependencies. The d1mach and i1mach functions are not taken from SLATEC, however; they come from Algorithm 528 by P. Fox et al. It fixes the over/underflow issues caused by the original implementations.
  • Loading branch information
joeydumont committed Jul 18, 2014
1 parent 4e3e17f commit f4ec6d3
Show file tree
Hide file tree
Showing 15 changed files with 1,555 additions and 205 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ aux_source_directory(./src SRC_LIST)
add_library(${PROJECT_NAME} SHARED
${SRC_LIST}
"./src/wignerSymbols-fortran.f"
"./src/machine.for"
"./src/fdump.f"
"./src/j4save.f"
"./src/xercnt.f"
"./src/xerhlt.f"
"./src/xermsg.f"
"./src/xerprn.f"
"./src/xersve.f"
"./src/xgetua.f"
"./src/wignerSymbols-fortran-c-binding.f90" )

SET_TARGET_PROPERTIES(${PROJECT_NAME}
Expand Down
31 changes: 5 additions & 26 deletions include/wignerSymbols/commonFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,10 @@ namespace WignerSymbols {
template <typename T>
double sgn(T val)
{
return (T(0) < val) - (val < T(0));
}

template <typename T>
int maxThree(T a, T b, T c)
{
int maxIndex;
T max;
if (a > b)
{
max = a;
maxIndex = 1;
}
else
{
max = b;
maxIndex = 2;
}

if (max < c)
{
max = c;
maxIndex = 3;
}

return maxIndex;
int sgn = (T(0) < val) - (val < T(0));
if (sgn == 0)
return 1.0;
else
return (double)sgn;
}
}
31 changes: 31 additions & 0 deletions src/fdump.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
*DECK FDUMP
SUBROUTINE FDUMP
C***BEGIN PROLOGUE FDUMP
C***PURPOSE Symbolic dump (should be locally written).
C***LIBRARY SLATEC (XERROR)
C***CATEGORY R3
C***TYPE ALL (FDUMP-A)
C***KEYWORDS ERROR, XERMSG
C***AUTHOR Jones, R. E., (SNLA)
C***DESCRIPTION
C
C ***Note*** Machine Dependent Routine
C FDUMP is intended to be replaced by a locally written
C version which produces a symbolic dump. Failing this,
C it should be replaced by a version which prints the
C subprogram nesting list. Note that this dump must be
C printed on each of up to five files, as indicated by the
C XGETUA routine. See XSETUA and XGETUA for details.
C
C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
C
C***REFERENCES (NONE)
C***ROUTINES CALLED (NONE)
C***REVISION HISTORY (YYMMDD)
C 790801 DATE WRITTEN
C 861211 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C***END PROLOGUE FDUMP
C***FIRST EXECUTABLE STATEMENT FDUMP
RETURN
END
65 changes: 65 additions & 0 deletions src/j4save.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
*DECK J4SAVE
FUNCTION J4SAVE (IWHICH, IVALUE, ISET)
C***BEGIN PROLOGUE J4SAVE
C***SUBSIDIARY
C***PURPOSE Save or recall global variables needed by error
C handling routines.
C***LIBRARY SLATEC (XERROR)
C***TYPE INTEGER (J4SAVE-I)
C***KEYWORDS ERROR MESSAGES, ERROR NUMBER, RECALL, SAVE, XERROR
C***AUTHOR Jones, R. E., (SNLA)
C***DESCRIPTION
C
C Abstract
C J4SAVE saves and recalls several global variables needed
C by the library error handling routines.
C
C Description of Parameters
C --Input--
C IWHICH - Index of item desired.
C = 1 Refers to current error number.
C = 2 Refers to current error control flag.
C = 3 Refers to current unit number to which error
C messages are to be sent. (0 means use standard.)
C = 4 Refers to the maximum number of times any
C message is to be printed (as set by XERMAX).
C = 5 Refers to the total number of units to which
C each error message is to be written.
C = 6 Refers to the 2nd unit for error messages
C = 7 Refers to the 3rd unit for error messages
C = 8 Refers to the 4th unit for error messages
C = 9 Refers to the 5th unit for error messages
C IVALUE - The value to be set for the IWHICH-th parameter,
C if ISET is .TRUE. .
C ISET - If ISET=.TRUE., the IWHICH-th parameter will BE
C given the value, IVALUE. If ISET=.FALSE., the
C IWHICH-th parameter will be unchanged, and IVALUE
C is a dummy parameter.
C --Output--
C The (old) value of the IWHICH-th parameter will be returned
C in the function value, J4SAVE.
C
C***SEE ALSO XERMSG
C***REFERENCES R. E. Jones and D. K. Kahaner, XERROR, the SLATEC
C Error-handling Package, SAND82-0800, Sandia
C Laboratories, 1982.
C***ROUTINES CALLED (NONE)
C***REVISION HISTORY (YYMMDD)
C 790801 DATE WRITTEN
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900205 Minor modifications to prologue. (WRB)
C 900402 Added TYPE section. (WRB)
C 910411 Added KEYWORDS section. (WRB)
C 920501 Reformatted the REFERENCES section. (WRB)
C***END PROLOGUE J4SAVE
LOGICAL ISET
INTEGER IPARAM(9)
SAVE IPARAM
DATA IPARAM(1),IPARAM(2),IPARAM(3),IPARAM(4)/0,2,0,10/
DATA IPARAM(5)/1/
DATA IPARAM(6),IPARAM(7),IPARAM(8),IPARAM(9)/0,0,0,0/
C***FIRST EXECUTABLE STATEMENT J4SAVE
J4SAVE = IPARAM(IWHICH)
IF (ISET) IPARAM(IWHICH) = IVALUE
RETURN
END
Loading

0 comments on commit f4ec6d3

Please sign in to comment.