Skip to content

Commit

Permalink
updates BOZ-initializations for hash keys (fix for gfortran versions …
Browse files Browse the repository at this point in the history
…<= 9)
  • Loading branch information
danielpeter committed Jan 24, 2024
1 parent af1f2e3 commit 63773d0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/shared/write_VTK_data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ subroutine write_VTK_data_elem_cr_meshfem(nspec,nglob,NGLL,xstore_db,ystore_db,z

! special routine for meshfem3D with simpler mesh arrays

use constants, only: CUSTOM_REAL,MAX_STRING_LEN,NGNOD_EIGHT_CORNERS,IOUT_VTK
use constants, only: CUSTOM_REAL,MAX_STRING_LEN,IOUT_VTK

implicit none

Expand Down
25 changes: 20 additions & 5 deletions src/specfem3D/read_stations.f90
Original file line number Diff line number Diff line change
Expand Up @@ -581,18 +581,33 @@ subroutine create_stations_checksum(hashsum)
do i = 1,64
K(i) = floor(2**32 * dabs(dsin((i-1) + 1.d0)))

Check warning on line 582 in src/specfem3D/read_stations.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/read_stations.f90#L581-L582

Added lines #L581 - L582 were not covered by tests
enddo
! (the original MD5 algorithm seems to use big endian initializations)

! magic numbers: the original MD5 algorithm seems to use big endian initializations
!if (is_big_endian) then
! a0 = int(z'67452301',kind=4)
! b0 = int(z'EFCDAB89',kind=4)
! c0 = int(z'98BADCFE',kind=4)
! d0 = int(z'10325476',kind=4)
!else
a0 = int(z'01234567')
b0 = int(z'89ABCDEF')
c0 = int(z'FEDCBA98')
d0 = int(z'76543210')
! a0 = int(z'01234567')
! b0 = int(z'89ABCDEF')
! c0 = int(z'FEDCBA98')
! d0 = int(z'76543210')
!endif
! note: using gfortran versions <= 9 will return a compilation error for these boz-initializations:
! "Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) .."
! thus, instead of
! b0 = int(z'89ABCDEF') or b0 = int(z'89ABCDEF',kind=4)
! one could split it and use
! b0 = ior(ishft(int(z'89AB'), 16), int(z'CDEF'))
! or
! b0 = transfer(int(z'89ABCDEF',kind=8),b0)
! these hexadecimals all fit into a 32-bit representation, and therefore the transfer() function
! should return valid results.
a0 = transfer(int(z'01234567',kind=8),a0)
b0 = transfer(int(z'89ABCDEF',kind=8),b0)
c0 = transfer(int(z'FEDCBA98',kind=8),c0)
d0 = transfer(int(z'76543210',kind=8),d0)

Check warning on line 610 in src/specfem3D/read_stations.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/read_stations.f90#L607-L610

Added lines #L607 - L610 were not covered by tests

do irec = 1,nrec
single_station_line(:) = ''

Check warning on line 613 in src/specfem3D/read_stations.f90

View check run for this annotation

Codecov / codecov/patch

src/specfem3D/read_stations.f90#L612-L613

Added lines #L612 - L613 were not covered by tests
Expand Down

0 comments on commit 63773d0

Please sign in to comment.