From 8d00f99d41f972fee327ebafa0bb5fd0bd534fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=BCtt?= Date: Thu, 21 May 2015 06:56:28 +0000 Subject: [PATCH] Add file discovery mechanism to xml_parser svn-origin-rev: 15327 --- src/common/xml_parser.F | 35 +++++++++++++----------------- tools/conventions/conventions.supp | 2 -- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/common/xml_parser.F b/src/common/xml_parser.F index 88ecaccfce..dd3eb86230 100644 --- a/src/common/xml_parser.F +++ b/src/common/xml_parser.F @@ -45,6 +45,9 @@ ! - simple checking via a table: parent, tag, id, min, max ! MODULE xml_parser + USE cp_files, ONLY: close_file,& + file_exists,& + open_file IMPLICIT NONE @@ -266,8 +269,7 @@ SUBROUTINE xml_open( info, fname, mustread ) CHARACTER(len=*), INTENT(in) :: fname LOGICAL, INTENT(in) :: mustread - INTEGER :: i, ierr, k, kend - LOGICAL :: exists, opend + INTEGER :: ierr, k, kend info%lun = 10 info%ignore_whitespace = .FALSE. @@ -279,23 +281,16 @@ SUBROUTINE xml_open( info, fname, mustread ) info%level = -1 info%lineno = 0 - DO i = 10,99 - INQUIRE( unit = i, opened = opend ) - IF ( .NOT. opend ) THEN - info%lun = i - INQUIRE( file = fname, exist = exists ) - IF ( .NOT. exists .AND. mustread ) THEN - CALL xml_report_errors( 'XML_OPEN: file does not exist:', TRIM(fname)) - info%lun = -1 - info%error = .TRUE. - ELSE - OPEN( unit = info%lun, file = fname ) - CALL xml_report_details( 'XML_OPEN: opened file ', TRIM(fname) ) - CALL xml_report_details( 'at LU-number: ', info%lun ) - ENDIF - EXIT - ENDIF - ENDDO + IF ( .NOT. file_exists(fname) .AND. mustread ) THEN + CALL xml_report_errors( 'XML_OPEN: file does not exist:', TRIM(fname)) + info%lun = -1 + info%error = .TRUE. + ELSE + CALL open_file(file_name=fname, unit_number=info%lun) + CALL xml_report_details( 'XML_OPEN: opened file ', TRIM(fname) ) + CALL xml_report_details( 'at LU-number: ', info%lun ) + ENDIF + IF ( .NOT. info%error .AND. mustread ) THEN k = 1 DO WHILE ( k .GE. 1 ) @@ -341,7 +336,7 @@ END SUBROUTINE xml_open SUBROUTINE xml_close( info ) TYPE(XML_PARSE), INTENT(inout) :: info - CLOSE( info%lun ) + CALL close_file(info%lun) ! ! Only clean up the LU-number, so that the calling program diff --git a/tools/conventions/conventions.supp b/tools/conventions/conventions.supp index 45487898b9..969a3ba06a 100644 --- a/tools/conventions/conventions.supp +++ b/tools/conventions/conventions.supp @@ -743,8 +743,6 @@ xc_xpbe_hole_t_c_lr.F: Unused dummy argument 'epsilon_norm_drho' at (1) xc_xpbe_hole_t_c_lr.F: Unused dummy argument 'ndrho' at (1) xc_xwpbe.F: Unused dummy argument 'epsilon_norm_drho' at (1) xml_parser.F: Copyright banner malformed -xml_parser.F: Found CLOSE statement in procedure "xml_close" -xml_parser.F: Found OPEN statement in procedure "xml_open" xyz_to_vab_optimised.F: Routine XYZ_TO_VAB called with an implicit interface. xyz_to_vab_optimised.F: Routine XYZ_TO_VAB_0_0 called with an implicit interface. xyz_to_vab_optimised.F: Routine XYZ_TO_VAB_0_1 called with an implicit interface.