Merge remote-tracking branch 'origin/development' into internal-restructure

This commit is contained in:
Sharan Roongta 2021-05-21 12:32:59 +02:00
commit fa3b077b72
4 changed files with 23 additions and 16 deletions

View File

@ -1 +1 @@
v3.0.0-alpha3-89-g4ba4ca133 v3.0.0-alpha3-101-g0f4e7e96d

View File

@ -629,7 +629,7 @@ class Rotation:
else: else:
if np.any(qu[...,0] < 0.0): if np.any(qu[...,0] < 0.0):
raise ValueError('Quaternion with negative first (real) component.') raise ValueError('Quaternion with negative first (real) component.')
if not np.all(np.isclose(np.linalg.norm(qu,axis=-1), 1.0)): if not np.all(np.isclose(np.linalg.norm(qu,axis=-1), 1.0,rtol=0.0)):
raise ValueError('Quaternion is not of unit length.') raise ValueError('Quaternion is not of unit length.')
return Rotation(qu) return Rotation(qu)

View File

@ -113,8 +113,7 @@ end function IO_readlines
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Read whole file. !> @brief Read whole file.
!> @details ensures that the string ends with a new line (expected UNIX behavior) and rejects !> @details ensures that the string ends with a new line (expected UNIX behavior)
! windows (CRLF) line endings
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
function IO_read(fileName) result(fileContent) function IO_read(fileName) result(fileContent)
@ -124,8 +123,7 @@ function IO_read(fileName) result(fileContent)
integer :: & integer :: &
fileLength, & fileLength, &
fileUnit, & fileUnit, &
myStat, & myStat
firstEOL
character, parameter :: CR = achar(13) character, parameter :: CR = achar(13)
@ -143,12 +141,17 @@ function IO_read(fileName) result(fileContent)
if(myStat /= 0) call IO_error(102,ext_msg=trim(fileName)) if(myStat /= 0) call IO_error(102,ext_msg=trim(fileName))
close(fileUnit) close(fileUnit)
foundCRLF: if (scan(fileContent(:index(fileContent,IO_EOL)),CR) /= 0) then
CRLF2LF: block
integer :: c
do c=1, len(fileContent)
if (fileContent(c:c) == CR) fileContent(c:c) = ' '
enddo
end block CRLF2LF
endif foundCRLF
if(fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF if(fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF
firstEOL = index(fileContent,IO_EOL)
if(scan(fileContent(firstEOL:firstEOL),CR) /= 0) call IO_error(115)
end function IO_read end function IO_read
@ -400,9 +403,6 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg)
msg = 'invalid character for logical:' msg = 'invalid character for logical:'
case (114) case (114)
msg = 'cannot decode base64 string:' msg = 'cannot decode base64 string:'
case (115)
msg = 'found CR. Windows file endings (CRLF) are not supported.'
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! lattice error messages ! lattice error messages
@ -644,11 +644,16 @@ subroutine selfTest
if(dNeq(1.0_pReal, IO_stringAsFloat('1.0'))) error stop 'IO_stringAsFloat' if(dNeq(1.0_pReal, IO_stringAsFloat('1.0'))) error stop 'IO_stringAsFloat'
if(dNeq(1.0_pReal, IO_stringAsFloat('1e0'))) error stop 'IO_stringAsFloat' if(dNeq(1.0_pReal, IO_stringAsFloat('1e0'))) error stop 'IO_stringAsFloat'
if(dNeq(0.1_pReal, IO_stringAsFloat('1e-1'))) error stop 'IO_stringAsFloat' if(dNeq(0.1_pReal, IO_stringAsFloat('1e-1'))) error stop 'IO_stringAsFloat'
if(dNeq(0.1_pReal, IO_stringAsFloat('1.0e-1'))) error stop 'IO_stringAsFloat'
if(dNeq(0.1_pReal, IO_stringAsFloat('1.00e-1'))) error stop 'IO_stringAsFloat'
if(dNeq(10._pReal, IO_stringAsFloat(' 1.0e+1 '))) error stop 'IO_stringAsFloat'
if(3112019 /= IO_stringAsInt( '3112019')) error stop 'IO_stringAsInt' if(3112019 /= IO_stringAsInt( '3112019')) error stop 'IO_stringAsInt'
if(3112019 /= IO_stringAsInt(' 3112019')) error stop 'IO_stringAsInt' if(3112019 /= IO_stringAsInt(' 3112019')) error stop 'IO_stringAsInt'
if(-3112019 /= IO_stringAsInt('-3112019')) error stop 'IO_stringAsInt' if(-3112019 /= IO_stringAsInt('-3112019')) error stop 'IO_stringAsInt'
if(3112019 /= IO_stringAsInt('+3112019 ')) error stop 'IO_stringAsInt' if(3112019 /= IO_stringAsInt('+3112019 ')) error stop 'IO_stringAsInt'
if(3112019 /= IO_stringAsInt('03112019 ')) error stop 'IO_stringAsInt'
if(3112019 /= IO_stringAsInt('+03112019')) error stop 'IO_stringAsInt'
if(.not. IO_stringAsBool(' true')) error stop 'IO_stringAsBool' if(.not. IO_stringAsBool(' true')) error stop 'IO_stringAsBool'
if(.not. IO_stringAsBool(' True ')) error stop 'IO_stringAsBool' if(.not. IO_stringAsBool(' True ')) error stop 'IO_stringAsBool'

View File

@ -178,8 +178,7 @@ subroutine fromQuaternion(self,qu)
class(rotation), intent(out) :: self class(rotation), intent(out) :: self
real(pReal), dimension(4), intent(in) :: qu real(pReal), dimension(4), intent(in) :: qu
if (dNeq(norm2(qu),1.0_pReal)) & if (dNeq(norm2(qu),1.0_pReal,1.0e-8_pReal)) call IO_error(402,ext_msg='fromQuaternion')
call IO_error(402,ext_msg='fromQuaternion')
self%q = qu self%q = qu
@ -1394,7 +1393,7 @@ end function conjugate_quaternion
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Check correctness of some rotations functions. !> @brief Check correctness of some rotations functions.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine selfTest subroutine selfTest()
type(rotation) :: R type(rotation) :: R
real(pReal), dimension(4) :: qu, ax, ro real(pReal), dimension(4) :: qu, ax, ro
@ -1405,7 +1404,7 @@ subroutine selfTest
integer :: i integer :: i
do i = 1, 10 do i = 1, 20
#if defined(__GFORTRAN__) && __GNUC__<9 #if defined(__GFORTRAN__) && __GNUC__<9
if(i<7) cycle if(i<7) cycle
@ -1433,6 +1432,7 @@ subroutine selfTest
sin(2.0_pReal*PI*x(1))*A] sin(2.0_pReal*PI*x(1))*A]
if(qu(1)<0.0_pReal) qu = qu * (-1.0_pReal) if(qu(1)<0.0_pReal) qu = qu * (-1.0_pReal)
endif endif
if(.not. quaternion_equal(om2qu(qu2om(qu)),qu)) error stop 'om2qu/qu2om' if(.not. quaternion_equal(om2qu(qu2om(qu)),qu)) error stop 'om2qu/qu2om'
if(.not. quaternion_equal(eu2qu(qu2eu(qu)),qu)) error stop 'eu2qu/qu2eu' if(.not. quaternion_equal(eu2qu(qu2eu(qu)),qu)) error stop 'eu2qu/qu2eu'
if(.not. quaternion_equal(ax2qu(qu2ax(qu)),qu)) error stop 'ax2qu/qu2ax' if(.not. quaternion_equal(ax2qu(qu2ax(qu)),qu)) error stop 'ax2qu/qu2ax'
@ -1479,6 +1479,8 @@ subroutine selfTest
if(all(dNeq(R%rotTensor4(R%rotTensor4(t3333),active=.true.),t3333,1.0e-12_pReal))) & if(all(dNeq(R%rotTensor4(R%rotTensor4(t3333),active=.true.),t3333,1.0e-12_pReal))) &
error stop 'rotTensor4' error stop 'rotTensor4'
call R%fromQuaternion(qu * (1.0_pReal + merge(+5.e-9_pReal,-5.e-9_pReal, mod(i,2) == 0))) ! allow reasonable tolerance for ASCII/YAML
enddo enddo
contains contains