Unverified Commit 9615fa63 authored by COLLINSBS email's avatar COLLINSBS email Committed by GitHub
Browse files

Adds temp variable for optional variables and tests for missing interfaces (#300)

parent 6a8b7896
......@@ -751,7 +751,10 @@ PURE SUBROUTINE getField_string_string(i,string,field,ierrout)
TYPE(StringType),INTENT(IN) :: string
TYPE(StringType),INTENT(OUT) :: field
INTEGER(SIK),INTENT(OUT),OPTIONAL :: ierrout
CALL getField_char_string(i,CHAR(string),field,ierrout)
INTEGER(SIK) :: ierr
CALL getField_char_string(i,CHAR(string),field,ierr)
IF(PRESENT(ierrout)) ierrout=ierr
ENDSUBROUTINE getField_string_string
!
!-------------------------------------------------------------------------------
......@@ -768,7 +771,10 @@ PURE SUBROUTINE getField_string_char(i,string,field,ierrout)
TYPE(StringType),INTENT(IN) :: string
CHARACTER(LEN=:),ALLOCATABLE,INTENT(OUT) :: field
INTEGER(SIK),INTENT(OUT),OPTIONAL :: ierrout
CALL getField_char_char(i,CHAR(string),field,ierrout)
INTEGER(SIK) :: ierr
CALL getField_char_char(i,CHAR(string),field,ierr)
IF(PRESENT(ierrout)) ierrout=ierr
ENDSUBROUTINE getField_string_char
!
!-------------------------------------------------------------------------------
......@@ -785,10 +791,13 @@ PURE SUBROUTINE getField_string_int(i,string,field,ierrout)
TYPE(StringType),INTENT(IN) :: string
INTEGER(SIK),INTENT(OUT) :: field
INTEGER(SIK),INTENT(OUT),OPTIONAL :: ierrout
CHARACTER(LEN=:),ALLOCATABLE :: char_field
INTEGER(SIK) :: ierr
CALL getField_char_char(i,CHAR(string),char_field,ierrout)
IF(ierrout == 0) READ(char_field,*,IOSTAT=ierrout) field
CALL getField_char_char(i,CHAR(string),char_field,ierr)
IF(ierr == 0) READ(char_field,*,IOSTAT=ierr) field
IF(PRESENT(ierrout)) ierrout=ierr
ENDSUBROUTINE getField_string_int
!
!-------------------------------------------------------------------------------
......@@ -805,10 +814,13 @@ PURE SUBROUTINE getField_string_real(i,string,field,ierrout)
TYPE(StringType),INTENT(IN) :: string
REAL(SRK),INTENT(OUT) :: field
INTEGER(SIK),INTENT(OUT),OPTIONAL :: ierrout
CHARACTER(LEN=:),ALLOCATABLE :: char_field
INTEGER(SIK) :: ierr
CALL getField_char_char(i,CHAR(string),char_field,ierrout)
IF(ierrout == 0) READ(char_field,*,IOSTAT=ierrout) field
CALL getField_char_char(i,CHAR(string),char_field,ierr)
IF(ierr == 0) READ(char_field,*,IOSTAT=ierr) field
IF(PRESENT(ierrout)) ierrout=ierr
ENDSUBROUTINE getField_string_real
!
!-------------------------------------------------------------------------------
......
......@@ -51,8 +51,9 @@ ENDSUBROUTINE testParameters
!
!-------------------------------------------------------------------------------
SUBROUTINE testIO_Strings()
INTEGER :: stat
INTEGER,ALLOCATABLE :: tmpint(:)
INTEGER :: stat, tmpint
INTEGER,ALLOCATABLE :: tmpint2(:)
REAL(SRK) :: tmpreal
CHARACTER(LEN=32) :: char
CHARACTER(LEN=52) :: test_phrase
CHARACTER(LEN=256) :: filepath,path,fname,ext
......@@ -94,17 +95,17 @@ SUBROUTINE testIO_Strings()
ASSERT_EQ(strarrayeqind(tmpStrArray,'test8',.TRUE.),10,'testing test8 reverse')
COMPONENT_TEST('strfind')
CALL strfind('stesting','test',tmpint)
ASSERTFAIL(SIZE(tmpint) == 1,'testing SIZE')
ASSERT(ALL(tmpint == (/2/)),'testing')
DEALLOCATE(tmpint)
CALL strfind('TEAM','I',tmpint)
ASSERTFAIL(SIZE(tmpint) == 0,'TEAM')
DEALLOCATE(tmpint)
CALL strfind('t e s t',' ',tmpint)
ASSERTFAIL(SIZE(tmpint) == 3,'t e s t SIZE')
ASSERT(ALL(tmpint == (/2,4,6/)),'t e s t')
DEALLOCATE(tmpint)
CALL strfind('stesting','test',tmpint2)
ASSERTFAIL(SIZE(tmpint2) == 1,'testing SIZE')
ASSERT(ALL(tmpint2 == (/2/)),'testing')
DEALLOCATE(tmpint2)
CALL strfind('TEAM','I',tmpint2)
ASSERTFAIL(SIZE(tmpint2) == 0,'TEAM')
DEALLOCATE(tmpint2)
CALL strfind('t e s t',' ',tmpint2)
ASSERTFAIL(SIZE(tmpint2) == 3,'t e s t SIZE')
ASSERT(ALL(tmpint2 == (/2,4,6/)),'t e s t')
DEALLOCATE(tmpint2)
COMPONENT_TEST('strrep')
string='testing'
......@@ -323,6 +324,36 @@ SUBROUTINE testIO_Strings()
ASSERT_EQ(TRIM(tmpStr2),'2','multi-arg filepath 35 (field)')
ASSERT_EQ(stat,0,'multi-arg filepath 35 (stat)')
COMPONENT_TEST('getField (string,int)')
tmpStr=' cardname 200*3 15*2'
CALL getField(50,tmpStr,tmpint,stat)
ASSERT_EQ(tmpint,3,'50th (field)')
ASSERT_EQ(stat,0,'50th (stat)')
CALL getField(205,tmpStr,tmpint,stat)
ASSERT_EQ(tmpint,2,'205th (field)')
ASSERT_EQ(stat,0,'205th (stat)')
tmpStr='cardname 1 1 2 3 1 6'
CALL getField(50,tmpStr,tmpint,stat)
ASSERT_EQ(stat,IOSTAT_END,' too many (stat)')
CALL getField(5,tmpStr,tmpint,stat)
ASSERT_EQ(tmpint,3,'normal (field)')
ASSERT_EQ(stat,0,'normal (stat)')
COMPONENT_TEST('getField (string,real)')
tmpStr=' cardname 200*3 15*2.3'
CALL getField(50,tmpStr,tmpreal,stat)
ASSERT_APPROXEQ(tmpreal,3.0_SRK,'50th (field)')
ASSERT_EQ(stat,0,'50th (stat)')
CALL getField(205,tmpStr,tmpreal,stat)
ASSERT_APPROXEQ(tmpreal,2.3_SRK,'205th (field)')
ASSERT_EQ(stat,0,'205th (stat)')
tmpStr='cardname 1.2 1.3 2.4 3.5 1.6 6.7'
CALL getField(50,tmpStr,tmpreal,stat)
ASSERT_EQ(stat,IOSTAT_END,' too many (stat)')
CALL getField(5,tmpStr,tmpreal,stat)
ASSERT_APPROXEQ(tmpreal,3.5_SRK,'normal (field)')
ASSERT_EQ(stat,0,'normal (stat)')
COMPONENT_TEST('stripComment')
string='some data !a comment !another comment?'
CALL stripComment(string)
......
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