Commit 2d63351f authored by Marco Govoni's avatar Marco Govoni
Browse files

Added read_long_string

parent c0697463
......@@ -164,7 +164,6 @@ MODULE function3d
CHARACTER(LEN=:),ALLOCATABLE :: buff2
CHARACTER(LEN=:),ALLOCATABLE :: charbase64
LOGICAL :: lread
LOGICAL :: lstop
INTEGER, ALLOCATABLE :: nl(:,:)
CHARACTER(LEN=:),ALLOCATABLE :: ctype
!
......@@ -210,8 +209,6 @@ MODULE function3d
ctype = bufftag(is:ie)
lread = .true.
ENDIF
!
lstop = .FALSE.
!
IF( lread ) THEN
ndim = nx*ny*nz
......@@ -223,24 +220,14 @@ MODULE function3d
CASE DEFAULT
END SELECT
nlen = lenbase64(nbytes)
charbase64=""
ALLOCATE( CHARACTER(LEN=nlen) :: charbase64 )
!
CALL read_long_string(iu,charbase64)
!
DO
READ(iu,'(a)',IOSTAT=ios) buffline
IF( ios /=0 ) EXIT
IF(INDEX(buffline,"</grid_function>") /= 0) THEN
lstop = .TRUE.
EXIT
ENDIF
charbase64 = charbase64 // TRIM( buffline )
ENDDO
ELSE
CALL errore("","Could not start tag",1)
ENDIF
!
IF( .NOT. lstop ) THEN
CALL errore("","Could not close tag",1)
ENDIF
!
CLOSE(iu)
!
......@@ -298,7 +285,7 @@ MODULE function3d
! I/O
!
INTEGER,INTENT(IN) :: iu
CHARACTER(LEN=*) :: longstring
CHARACTER(LEN=*),INTENT(IN) :: longstring
!
! Workspace
!
......@@ -314,4 +301,38 @@ MODULE function3d
!
END SUBROUTINE
!
!
SUBROUTINE read_long_string(iu,longstring)
!
! Read a long string on multiple lines (each line has a max of 72 charachter)
! The unit "iu" is NOT opened and closed here
!
IMPLICIT NONE
!
! I/O
!
INTEGER,INTENT(IN) :: iu
CHARACTER(LEN=*),INTENT(INOUT) :: longstring
!
! Workspace
!
INTEGER :: j, nlines, thislen
INTEGER, PARAMETER :: maxlen = 72
CHARACTER(LEN=maxlen) :: buffline
!
thislen = LEN(longstring)
nlines = thislen / maxlen
!
DO j = 1, nlines
READ(iu,'(a)') buffline
longstring((j-1)*maxlen+1:j*maxlen) = buffline(1:maxlen)
ENDDO
!
IF( MOD( thislen, maxlen ) > 0 ) THEN
READ(iu,'(a)') buffline
longstring(nlines*maxlen+1:thislen) = buffline(1:MOD( thislen, maxlen ))
ENDIF
!
END SUBROUTINE
!
END MODULE
!
! Copyright (C) 2015-2017 M. Govoni
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! Contributors to this file:
! Marco Govoni
!
!-----------------------------------------------------------------------
MODULE west_version
!-----------------------------------------------------------------------
!
IMPLICIT NONE
!
SAVE
!
CHARACTER (LEN=6) :: west_version_number = '3.1.0'
CHARACTER (LEN=12) :: west_svn_revision = 'unknown'
!
END MODULE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment