From 3e439503fe0378c63a671bef5f2d34f442649a36 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 9 Feb 2023 23:34:45 +0100 Subject: [PATCH] enable strings > 2Gb --- src/IO.f90 | 16 ++++++++-------- src/YAML_parse.f90 | 2 +- src/system_routines.f90 | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index b7bd5e982..2ca2afd70 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -136,7 +136,7 @@ function IO_read(fileName) result(fileContent) if (myStat /= 0) call IO_error(102,trim(fileName)) close(fileUnit) - if (index(fileContent,CR//LF) /= 0) fileContent = CRLF2LF(fileContent) + if (index(fileContent,CR//LF,kind=pI64) /= 0) fileContent = CRLF2LF(fileContent) if (fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF end function IO_read @@ -607,17 +607,17 @@ pure function CRLF2LF(string) character(len=*), intent(in) :: string character(len=:), allocatable :: CRLF2LF - integer :: c,n + integer(pI64) :: c,n - allocate(character(len=len_trim(string))::CRLF2LF) - if (len(CRLF2LF) == 0) return + allocate(character(len=len_trim(string,pI64))::CRLF2LF) + if (len(CRLF2LF,pI64) == 0) return - n = 0 - do c=1, len_trim(string) + n = 0_pI64 + do c=1_pI64, len_trim(string,pI64) CRLF2LF(c-n:c-n) = string(c:c) - if (c == len_trim(string)) exit - if (string(c:c+1) == CR//LF) n = n + 1 + if (c == len_trim(string,pI64)) exit + if (string(c:c+1_pI64) == CR//LF) n = n + 1_pI64 end do CRLF2LF = CRLF2LF(:c-n) diff --git a/src/YAML_parse.f90 b/src/YAML_parse.f90 index 89cbcd147..d0f047a4a 100644 --- a/src/YAML_parse.f90 +++ b/src/YAML_parse.f90 @@ -221,7 +221,7 @@ function to_flow(mixed) result(flow) call to_flow_C(str_ptr,strlen,f_c_string(mixed)) - if (strlen < 1) call IO_error(703,ext_msg='libyfaml') + if (strlen < 1_C_LONG) call IO_error(703,ext_msg='libyfaml') allocate(character(len=strlen,kind=c_char) :: flow) block diff --git a/src/system_routines.f90 b/src/system_routines.f90 index 74aa4685b..6b9f7d908 100644 --- a/src/system_routines.f90 +++ b/src/system_routines.f90 @@ -181,15 +181,15 @@ pure function c_f_string(c_string) result(f_string) character(kind=C_CHAR), dimension(:), intent(in) :: c_string character(len=:), allocatable :: f_string - integer :: i + integer(pI64) :: i - allocate(character(len=size(c_string))::f_string) - arrayToString: do i=1,len(f_string) + allocate(character(len=size(c_string,kind=pI64))::f_string) + arrayToString: do i=1_pI64,len(f_string,pI64) if (c_string(i) /= C_NULL_CHAR) then f_string(i:i)=c_string(i) else - f_string = f_string(:i-1) + f_string = f_string(:i-1_pI64) exit end if end do arrayToString @@ -203,11 +203,11 @@ end function c_f_string !-------------------------------------------------------------------------------------------------- pure function f_c_string(f_string) result(c_string) - character(len=*), intent(in) :: f_string - character(kind=C_CHAR), dimension(len_trim(f_string)+1) :: c_string + character(len=*), intent(in) :: f_string + character(kind=C_CHAR), dimension(len_trim(f_string,pI64)+1_pI64) :: c_string - c_string = transfer(trim(f_string)//C_NULL_CHAR,c_string,size=size(c_string)) + c_string = transfer(trim(f_string)//C_NULL_CHAR,c_string,size=size(c_string,kind=pI64)) end function f_c_string