From 84b9104302bb34755de8c959f1e627c024c49ecb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 13 Sep 2020 20:14:34 +0200 Subject: [PATCH] clearly indicate origin of functions also supresses (flawed) error message of gfortran related to non-standard type 'bytes' --- src/grid/discretization_grid.f90 | 28 +++++++++---------- src/prec.f90 | 48 ++++++++++++++++---------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/grid/discretization_grid.f90 b/src/grid/discretization_grid.f90 index c6f117a97..fa732863a 100644 --- a/src/grid/discretization_grid.f90 +++ b/src/grid/discretization_grid.f90 @@ -458,13 +458,13 @@ subroutine readVTR(grid,geomSize,origin,microstructure) select case(dataType) case('Int32') - as_Int = int(bytes_to_C_INT32_T(asBytes(base64_str,headerType,compressed))) + as_Int = int(prec_bytesToC_INT32_T(asBytes(base64_str,headerType,compressed))) case('Int64') - as_Int = int(bytes_to_C_INT64_T(asBytes(base64_str,headerType,compressed))) + as_Int = int(prec_bytesToC_INT64_T(asBytes(base64_str,headerType,compressed))) case('Float32') - as_Int = int(bytes_to_C_FLOAT (asBytes(base64_str,headerType,compressed))) + as_Int = int(prec_bytesToC_FLOAT (asBytes(base64_str,headerType,compressed))) case('Float64') - as_Int = int(bytes_to_C_DOUBLE (asBytes(base64_str,headerType,compressed))) + as_Int = int(prec_bytesToC_DOUBLE (asBytes(base64_str,headerType,compressed))) case default call IO_error(844_pInt,ext_msg='unknown data type: '//trim(dataType)) end select @@ -486,13 +486,13 @@ subroutine readVTR(grid,geomSize,origin,microstructure) select case(dataType) case('Int32') - as_pReal = real(bytes_to_C_INT32_T(asBytes(base64_str,headerType,compressed)),pReal) + as_pReal = real(prec_bytesToC_INT32_T(asBytes(base64_str,headerType,compressed)),pReal) case('Int64') - as_pReal = real(bytes_to_C_INT64_T(asBytes(base64_str,headerType,compressed)),pReal) + as_pReal = real(prec_bytesToC_INT64_T(asBytes(base64_str,headerType,compressed)),pReal) case('Float32') - as_pReal = real(bytes_to_C_FLOAT (asBytes(base64_str,headerType,compressed)),pReal) + as_pReal = real(prec_bytesToC_FLOAT (asBytes(base64_str,headerType,compressed)),pReal) case('Float64') - as_pReal = real(bytes_to_C_DOUBLE (asBytes(base64_str,headerType,compressed)),pReal) + as_pReal = real(prec_bytesToC_DOUBLE (asBytes(base64_str,headerType,compressed)),pReal) case default call IO_error(844_pInt,ext_msg='unknown data type: '//trim(dataType)) end select @@ -539,15 +539,15 @@ subroutine readVTR(grid,geomSize,origin,microstructure) integer(pI64) :: headerLen, nBlock, b,s,e if (headerType == 'UInt32') then - temp = int(bytes_to_C_INT32_T(base64_to_bytes(base64_str(:base64_nChar(4_pI64)))),pI64) + temp = int(prec_bytesToC_INT32_T(base64_to_bytes(base64_str(:base64_nChar(4_pI64)))),pI64) nBlock = int(temp(1),pI64) headerLen = 4_pI64 * (3_pI64 + nBlock) - temp = int(bytes_to_C_INT32_T(base64_to_bytes(base64_str(:base64_nChar(headerLen)))),pI64) + temp = int(prec_bytesToC_INT32_T(base64_to_bytes(base64_str(:base64_nChar(headerLen)))),pI64) elseif(headerType == 'UInt64') then - temp = int(bytes_to_C_INT64_T(base64_to_bytes(base64_str(:base64_nChar(8_pI64)))),pI64) + temp = int(prec_bytesToC_INT64_T(base64_to_bytes(base64_str(:base64_nChar(8_pI64)))),pI64) nBlock = int(temp(1),pI64) headerLen = 8_pI64 * (3_pI64 + nBlock) - temp = int(bytes_to_C_INT64_T(base64_to_bytes(base64_str(:base64_nChar(headerLen)))),pI64) + temp = int(prec_bytesToC_INT64_T(base64_to_bytes(base64_str(:base64_nChar(headerLen)))),pI64) endif allocate(size_inflated(nBlock),source=temp(2)) @@ -585,13 +585,13 @@ subroutine readVTR(grid,geomSize,origin,microstructure) s=0_pI64 if (headerType == 'UInt32') then do while(s+base64_nChar(4_pI64)<(len(base64_str,pI64))) - nByte = int(bytes_to_C_INT32_T(base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(4_pI64)))),pI64) + nByte = int(prec_bytesToC_INT32_T(base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(4_pI64)))),pI64) bytes = [bytes,base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(4_pI64+nByte(1))),5_pI64)] s = s + base64_nChar(4_pI64+nByte(1)) enddo elseif(headerType == 'UInt64') then do while(s+base64_nChar(8_pI64)<(len(base64_str,pI64))) - nByte = int(bytes_to_C_INT64_T(base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(8_pI64)))),pI64) + nByte = int(prec_bytesToC_INT64_T(base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(8_pI64)))),pI64) bytes = [bytes,base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(8_pI64+nByte(1))),9_pI64)] s = s + base64_nChar(8_pI64+nByte(1)) enddo diff --git a/src/prec.f90 b/src/prec.f90 index 6ee3a7e79..87c2f6848 100644 --- a/src/prec.f90 +++ b/src/prec.f90 @@ -235,57 +235,57 @@ end function cNeq !-------------------------------------------------------------------------------------------------- !> @brief Decode byte array (C_SIGNED_CHAR) as C_FLOAT array (4 byte float). !-------------------------------------------------------------------------------------------------- -pure function bytes_to_C_FLOAT(bytes) +pure function prec_bytesToC_FLOAT(bytes) integer(C_SIGNED_CHAR), dimension(:), intent(in) :: bytes !< byte-wise representation of a C_FLOAT array real(C_FLOAT), dimension(size(bytes,kind=pI64)/(storage_size(0._C_FLOAT,pI64)/8_pI64)) :: & - bytes_to_C_FLOAT + prec_bytesToC_FLOAT - bytes_to_C_FLOAT = transfer(bytes,bytes_to_C_FLOAT,size(bytes_to_C_FLOAT)) + prec_bytesToC_FLOAT = transfer(bytes,prec_bytesToC_FLOAT,size(prec_bytesToC_FLOAT)) -end function bytes_to_C_FLOAT +end function prec_bytesToC_FLOAT !-------------------------------------------------------------------------------------------------- !> @brief Decode byte array (C_SIGNED_CHAR) as C_DOUBLE array (8 byte float). !-------------------------------------------------------------------------------------------------- -pure function bytes_to_C_DOUBLE(bytes) +pure function prec_bytesToC_DOUBLE(bytes) integer(C_SIGNED_CHAR), dimension(:), intent(in) :: bytes !< byte-wise representation of a C_DOUBLE array real(C_DOUBLE), dimension(size(bytes,kind=pI64)/(storage_size(0._C_DOUBLE,pI64)/8_pI64)) :: & - bytes_to_C_DOUBLE + prec_bytesToC_DOUBLE - bytes_to_C_DOUBLE = transfer(bytes,bytes_to_C_DOUBLE,size(bytes_to_C_DOUBLE)) + prec_bytesToC_DOUBLE = transfer(bytes,prec_bytesToC_DOUBLE,size(prec_bytesToC_DOUBLE)) -end function bytes_to_C_DOUBLE +end function prec_bytesToC_DOUBLE !-------------------------------------------------------------------------------------------------- !> @brief Decode byte array (C_SIGNED_CHAR) as C_INT32_T array (4 byte signed integer). !-------------------------------------------------------------------------------------------------- -pure function bytes_to_C_INT32_T(bytes) +pure function prec_bytesToC_INT32_T(bytes) integer(C_SIGNED_CHAR), dimension(:), intent(in) :: bytes !< byte-wise representation of a C_INT32_T array integer(C_INT32_T), dimension(size(bytes,kind=pI64)/(storage_size(0_C_INT32_T,pI64)/8_pI64)) :: & - bytes_to_C_INT32_T + prec_bytesToC_INT32_T - bytes_to_C_INT32_T = transfer(bytes,bytes_to_C_INT32_T,size(bytes_to_C_INT32_T)) + prec_bytesToC_INT32_T = transfer(bytes,prec_bytesToC_INT32_T,size(prec_bytesToC_INT32_T)) -end function bytes_to_C_INT32_T +end function prec_bytesToC_INT32_T !-------------------------------------------------------------------------------------------------- !> @brief Decode byte array (C_SIGNED_CHAR) as C_INT64_T array (8 byte signed integer). !-------------------------------------------------------------------------------------------------- -pure function bytes_to_C_INT64_T(bytes) +pure function prec_bytesToC_INT64_T(bytes) integer(C_SIGNED_CHAR), dimension(:), intent(in) :: bytes !< byte-wise representation of a C_INT64_T array integer(C_INT64_T), dimension(size(bytes,kind=pI64)/(storage_size(0_C_INT64_T,pI64)/8_pI64)) :: & - bytes_to_C_INT64_T + prec_bytesToC_INT64_T - bytes_to_C_INT64_T = transfer(bytes,bytes_to_C_INT64_T,size(bytes_to_C_INT64_T)) + prec_bytesToC_INT64_T = transfer(bytes,prec_bytesToC_INT64_T,size(prec_bytesToC_INT64_T)) -end function bytes_to_C_INT64_T +end function prec_bytesToC_INT64_T !-------------------------------------------------------------------------------------------------- @@ -309,17 +309,17 @@ subroutine selfTest ! https://www.binaryconvert.com ! https://www.rapidtables.com/convert/number/binary-to-decimal.html - f = real(bytes_to_C_FLOAT(int([-65,+11,-102,+75],C_SIGNED_CHAR)),pReal) - if(dNeq(f(1),20191102.0_pReal,0.0_pReal)) error stop 'bytes_to_C_FLOAT' + f = real(prec_bytesToC_FLOAT(int([-65,+11,-102,+75],C_SIGNED_CHAR)),pReal) + if(dNeq(f(1),20191102.0_pReal,0.0_pReal)) error stop 'prec_bytesToC_FLOAT' - f = real(bytes_to_C_DOUBLE(int([0,0,0,-32,+119,+65,+115,65],C_SIGNED_CHAR)),pReal) - if(dNeq(f(1),20191102.0_pReal,0.0_pReal)) error stop 'bytes_to_C_DOUBLE' + f = real(prec_bytesToC_DOUBLE(int([0,0,0,-32,+119,+65,+115,65],C_SIGNED_CHAR)),pReal) + if(dNeq(f(1),20191102.0_pReal,0.0_pReal)) error stop 'prec_bytesToC_DOUBLE' - i = int(bytes_to_C_INT32_T(int([+126,+23,+52,+1],C_SIGNED_CHAR)),pInt) - if(i(1) /= 20191102_pInt) error stop 'bytes_to_C_INT32_T' + i = int(prec_bytesToC_INT32_T(int([+126,+23,+52,+1],C_SIGNED_CHAR)),pInt) + if(i(1) /= 20191102_pInt) error stop 'prec_bytesToC_INT32_T' - i = int(bytes_to_C_INT64_T(int([+126,+23,+52,+1,0,0,0,0],C_SIGNED_CHAR)),pInt) - if(i(1) /= 20191102_pInt) error stop 'bytes_to_C_INT64_T' + i = int(prec_bytesToC_INT64_T(int([+126,+23,+52,+1,0,0,0,0],C_SIGNED_CHAR)),pInt) + if(i(1) /= 20191102_pInt) error stop 'prec_bytesToC_INT64_T' end subroutine selfTest