Skip to content

Commit

Permalink
simplified cutest_classification
Browse files Browse the repository at this point in the history
  • Loading branch information
dalekopera committed Oct 1, 2024
1 parent b716b04 commit 21a6559
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/test/c_OUTSDIF.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
5 14 11 15 15 4 0 0 4 2
3ALLINITC 0
3ALLINITC 0 OOR2-AY-4-1
1 1 1 2 4 6 7 7 7 8
10 12 13 14 16
1 1 1 1 1 1 1 1 1 1
Expand Down
2 changes: 1 addition & 1 deletion src/test/q_OUTSDIF.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
10 7 19 19 28 11 0 0 2 0
3ALLINQP 0
3ALLINQP 0 QLR2-AN-V-V
1 1 1 1 1 1 1 20
1 1 1 1 1 1 1 1
1 2 4 6 8 10 12 12
Expand Down
2 changes: 1 addition & 1 deletion src/test/u_OUTSDIF.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
5 13 11 13 15 4 0 0 4 2
3ALLINITU 0
3ALLINITU 0 OUR2-AY-4-0
1 1 1 2 4 6 7 7 7 8
10 12 13 14
1 1 1 1 1 1 1 1 1 1
Expand Down
79 changes: 7 additions & 72 deletions src/tools/classification.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,80 +68,15 @@ SUBROUTINE CUTEST_classification_r( status, input, classification )
! local variables

CHARACTER ( LEN = 10 ) :: pname
INTEGER :: i, j, jstart, jstop, read_error, sif_unit
LOGICAL :: sif_exists, cstart
INTEGER, PARAMETER :: max_record_length = 80
CHARACTER ( LEN = max_record_length ) :: nuline
INTEGER ( KIND = ip_ ), DIMENSION( 10 ) :: I_temp

classification = REPEAT( ' ', 30 )

! find the name of the SIF file from which OUTSDIF.d was generated

CALL CUTEST_pname_r( status, input, pname )

! check that the SIF file still exists

INQUIRE( FILE = TRIM( pname ) // '.SIF', EXIST = sif_exists )
IF ( .NOT. sif_exists ) THEN
status = - 1

! open the SIF file

ELSE
OPEN( NEWUNIT = sif_unit, FILE = TRIM( pname ) // '.SIF' )

! read each line, one by one, until the string 'classification' is found

rec: DO
nuline = REPEAT( ' ', max_record_length )
READ( sif_unit, "( A80 )", IOSTAT = read_error ) nuline

! check that the end of file has not been reached

IF ( read_error == 0 ) THEN

! skip lines that are not comments

IF ( nuline( 1 : 1 ) /= '*' ) CYCLE
DO i = 1, 67
IF ( nuline( i : i + 13 ) == 'classification' .OR. &
nuline( i : i + 13 ) == 'CLASSIFICATION' ) THEN

! the string has been found, now search for the classification string itself

cstart = .FALSE. ; jstop = 80
DO j = i + 14, 80
IF ( .NOT. cstart ) THEN
IF ( nuline( j : j ) /= ' ' ) THEN
jstart = j
cstart = .TRUE.
END IF
ELSE
IF ( nuline( j : j ) == ' ' ) THEN
jstop = j - 1
EXIT
END IF
END IF
END DO

! copy the string and exit

classification( 1 : jstop - jstart + 1 ) &
= nuline( jstart : jstop )
status = 0
EXIT rec
END IF
END DO

! the end of file has been reached without identifying the string

ELSE
status = - 2
EXIT rec
END IF
END DO rec
CLOSE( sif_unit )
END IF
REWIND( input )
READ( input, "( 10I10 )" ) I_temp
READ( input, "( I2, A10, I2, 1X, A30 )" ) &
I_temp( 1 ), pname, I_temp( 2 ), classification
REWIND( input )
status = 0
RETURN

! End of subroutine CUTEST_classification_r
Expand Down

0 comments on commit 21a6559

Please sign in to comment.