From 9a37b6ddbe027be0c9ac07fc16192e81a08c6747 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 19 May 2021 09:03:10 +0200 Subject: [PATCH 1/3] support windows line endings if first line ends with CRLF, convert all CR to ' ' (trailing spaces will cause no harm) --- PRIVATE | 2 +- src/IO.f90 | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/PRIVATE b/PRIVATE index d10a94a36..dab246aea 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit d10a94a36056d99ea0892d1c6c69aa0e1dbe9d46 +Subproject commit dab246aea2cc3f29d57e0043edfebd3aedded124 diff --git a/src/IO.f90 b/src/IO.f90 index 9ea35503b..81745441a 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -113,8 +113,7 @@ end function IO_readlines !-------------------------------------------------------------------------------------------------- !> @brief Read whole file. -!> @details ensures that the string ends with a new line (expected UNIX behavior) and rejects -! windows (CRLF) line endings +!> @details ensures that the string ends with a new line (expected UNIX behavior) !-------------------------------------------------------------------------------------------------- function IO_read(fileName) result(fileContent) @@ -124,8 +123,7 @@ function IO_read(fileName) result(fileContent) integer :: & fileLength, & fileUnit, & - myStat, & - firstEOL + myStat 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)) 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 - firstEOL = index(fileContent,IO_EOL) - if(scan(fileContent(firstEOL:firstEOL),CR) /= 0) call IO_error(115) - end function IO_read @@ -400,9 +403,6 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg) msg = 'invalid character for logical:' case (114) msg = 'cannot decode base64 string:' - case (115) - msg = 'found CR. Windows file endings (CRLF) are not supported.' - !-------------------------------------------------------------------------------------------------- ! 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('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('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('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' From 26484645257fbe16eef7518e43b67b7882acc863 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 19 May 2021 09:46:02 +0200 Subject: [PATCH 2/3] relax tolerances for quaternion initialization we read in ASCII/YAML files, 1e-8 must be enough --- python/damask/_rotation.py | 2 +- src/rotations.f90 | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index c329464ed..c76f95c8e 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -629,7 +629,7 @@ class Rotation: else: if np.any(qu[...,0] < 0.0): 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.') return Rotation(qu) diff --git a/src/rotations.f90 b/src/rotations.f90 index 171db2466..531b08d14 100644 --- a/src/rotations.f90 +++ b/src/rotations.f90 @@ -178,8 +178,7 @@ subroutine fromQuaternion(self,qu) class(rotation), intent(out) :: self real(pReal), dimension(4), intent(in) :: qu - if (dNeq(norm2(qu),1.0_pReal)) & - call IO_error(402,ext_msg='fromQuaternion') + if (dNeq(norm2(qu),1.0_pReal,1.0e-8_pReal)) call IO_error(402,ext_msg='fromQuaternion') self%q = qu @@ -1394,7 +1393,7 @@ end function conjugate_quaternion !-------------------------------------------------------------------------------------------------- !> @brief Check correctness of some rotations functions. !-------------------------------------------------------------------------------------------------- -subroutine selfTest +subroutine selfTest() type(rotation) :: R real(pReal), dimension(4) :: qu, ax, ro @@ -1405,7 +1404,7 @@ subroutine selfTest integer :: i - do i = 1, 10 + do i = 1, 20 #if defined(__GFORTRAN__) && __GNUC__<9 if(i<7) cycle @@ -1433,6 +1432,7 @@ subroutine selfTest sin(2.0_pReal*PI*x(1))*A] if(qu(1)<0.0_pReal) qu = qu * (-1.0_pReal) endif + 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(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))) & 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 contains From 838e9dbc2475bf6de4f30d5084a93bb3c5097e07 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 20 May 2021 10:43:10 +0200 Subject: [PATCH 3/3] [skip ci] updated version information after successful test of v3.0.0-alpha3-101-g0f4e7e96d --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4e093adc2..498ff3ca4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha3-89-g4ba4ca133 +v3.0.0-alpha3-101-g0f4e7e96d