File: test_input_file.f90

package info (click to toggle)
espresso 6.7-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 311,068 kB
  • sloc: f90: 447,429; ansic: 52,566; sh: 40,631; xml: 37,561; tcl: 20,077; lisp: 5,923; makefile: 4,503; python: 4,379; perl: 1,219; cpp: 761; fortran: 618; java: 568; awk: 128
file content (54 lines) | stat: -rw-r--r-- 1,418 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
!
! Copyright (C) 2013 Quantum ESPRESSO group
! 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 .
!
LOGICAL FUNCTION test_input_xml (myunit)
   !
   ! check if file opened as unit "myunit" is a xml file or not
   !
   IMPLICIT NONE
   !
   INTEGER, INTENT(in) :: myunit
   !
   CHARACTER(LEN=256) :: dummy
   CHARACTER(LEN=1), EXTERNAL :: capital
   INTEGER :: i, j 
   LOGICAL :: exst
   !
   test_input_xml = .false.
   INQUIRE ( UNIT=myunit, EXIST=exst )
   IF ( .NOT. exst ) GO TO 10
   
   ! read until a non-empty line is found

   dummy = ' '
   DO WHILE ( LEN_TRIM(dummy) < 1 )
      READ ( myunit,'(A)', ERR=10, END=10) dummy
   END DO

   ! remove blanks from line, convert to capital, clean trailing characters

   j=1
   DO i=1, LEN_TRIM(dummy) 
      IF ( dummy(i:i) /= ' ' ) THEN
         dummy(j:j) = capital(dummy(i:i))
         j=j+1
      END IF
   END DO
   DO i=j, LEN_TRIM(dummy) 
      dummy(i:i) = ' '
   END DO

   ! check for string "<?xml" or "<xml" in the beginning, ">" at the end

   j = LEN_TRIM (dummy)
   test_input_xml = ( (dummy(1:5) == "<?XML") .OR. (dummy(1:4) == "<XML") ) &
                      .AND. (dummy(j:j) == ">")
   RETURN

10 WRITE (0,"('from test_input_xml: input file not opened or empty')")

END FUNCTION test_input_xml