Commit d02bed64 authored by giannozz's avatar giannozz

Trying to figure out how to clean up the considerable mess with units ...

Input is easier: stdin is fixed to 5 and is used only to read from stdin;
if a file is opened, either xml or text, a different unit "qestdin" fixed
to 9 is used. The above applies ONLY to codes reading either the xml input 
file or the namelists+cards; all other read from unit 5 anyway, open unit 5
if reading from file. Shouldn't have any nonlocal consequences hopefully


git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/[email protected] c92efa57-630b-4861-b058-cf58834340f0
parent facd90d7
!
! Copyright (C) 2002-2004 FPMD & PWSCF group
! Copyright (C) 2002-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,
......@@ -14,11 +14,11 @@ MODULE io_global
PRIVATE
SAVE
!
PUBLIC :: stdin, xmlstdin, stdout
PUBLIC :: stdin, stdout, qestdin
PUBLIC :: ionode, ionode_id, meta_ionode, meta_ionode_id
!
INTEGER :: stdin = 5 ! unit connected to standard input
INTEGER :: xmlstdin=5 ! unit connected to input xml file
INTEGER, PARAMETER :: stdin = 5 ! unit connected to standard input
INTEGER :: qestdin= 9 ! unit connected to input file (xml or text)
INTEGER :: stdout = 6 ! unit connected to standard output
!
! For parallel execution: I/O within an image
......
......@@ -7,7 +7,7 @@
!
MODULE open_close_input_file
!
USE io_global, ONLY : stdin, stdout, xmlstdin
USE io_global, ONLY : stdin, stdout, qestdin
USE iotk_module, ONLY : iotk_open_read, iotk_close_read,iotk_attlenx
!
LOGICAL, SAVE :: lxmlinput_loc = .false.
......@@ -20,10 +20,9 @@ CONTAINS
INTEGER FUNCTION open_input_file ( input_file_, lxmlinput, attr )
!-----------------------------------------------------------------------------
!
! ... Open file "input_file_" for input read, connecting it to unit stdin
! ... (text input) or xmlstdin (xml file). If "input_file_" is empty,
! ... the standard input is dumped to temporary file "input_tmp.in"
! ... and this is opened for read
! ... Open file "input_file_" for input read, connecting it to unit qestdin.
! ... If "input_file_" is empty, the standard input is dumped to temporary
! ... file "input_tmp.in" and this is opened for read
! ... If optional variable lxmlinput is present, test if the file is a
! ... valid xml file. In this case, optional variable attr must be
! ... present and is used to open the file.
......@@ -112,7 +111,7 @@ CONTAINS
ELSE
WRITE(stdout, '(5x,a)') "Reading xml input from standard input"
END IF
CALL iotk_open_read( xmlstdin, TRIM(input_file), attr = attr, &
CALL iotk_open_read( qestdin, TRIM(input_file), attr = attr, &
qe_syntax = .true., ierr = ierr)
ELSE
IF ( input_file .NE. "input_tmp.in") THEN
......@@ -120,7 +119,7 @@ CONTAINS
ELSE
WRITE(stdout, '(5x,a)') "Reading input from standard input"
END IF
OPEN ( UNIT = stdin, FILE = TRIM(input_file), FORM = 'FORMATTED', &
OPEN ( UNIT = qestdin, FILE = TRIM(input_file), FORM = 'FORMATTED', &
STATUS = 'OLD', IOSTAT = ierr )
ENDIF
IF ( ierr > 0 ) GO TO 30
......@@ -141,20 +140,19 @@ INTEGER FUNCTION close_input_file ( )
!
IMPLICIT NONE
!
LOGICAL :: opened
LOGICAL :: opnd
INTEGER :: ierr
!
INQUIRE ( stdin, opened = opened )
IF (.NOT.opened .AND. stdin /= xmlstdin) INQUIRE ( xmlstdin, opened = opened )
IF (opened) THEN
INQUIRE ( qestdin, opened = opnd )
IF (opnd) THEN
!
IF (lxmlinput_loc) THEN
CALL iotk_close_read(unit=xmlstdin, ierr = ierr)
CALL iotk_close_read(unit=qestdin, ierr = ierr)
ELSE
IF ( TRIM(input_file) == "input_tmp.in") THEN
CLOSE (UNIT=stdin, STATUS='delete', IOSTAT=ierr )
CLOSE (UNIT=qestdin, STATUS='delete', IOSTAT=ierr )
ELSE
CLOSE (UNIT=stdin, STATUS='keep', IOSTAT=ierr )
CLOSE (UNIT=qestdin, STATUS='keep', IOSTAT=ierr )
ENDIF
ENDIF
!
......
......@@ -28,7 +28,7 @@ MODULE read_input
USE input_parameters, ONLY : reset_input_checks
USE read_namelists_module, ONLY : read_namelists
USE read_cards_module, ONLY : read_cards
USE io_global, ONLY : ionode, ionode_id
USE io_global, ONLY : ionode, ionode_id, qestdin
USE xml_input, ONLY : xml_input_dump
USE read_xml_module, ONLY : read_xml
USE mp, ONLY : mp_bcast
......@@ -65,11 +65,11 @@ MODULE read_input
!
! ... Read NAMELISTS
!
CALL read_namelists( prog )
CALL read_namelists( prog, qestdin )
!
! ... Read CARDS
!
CALL read_cards ( prog )
CALL read_cards ( prog, qestdin )
!
END IF
IF ( ionode) ierr = close_input_file( )
......
......@@ -10,7 +10,7 @@ MODULE read_xml_module
!
USE input_parameters
!
USE io_global, ONLY : ionode, ionode_id, xmlinputunit=>xmlstdin
USE io_global, ONLY : ionode, ionode_id, xmlinputunit => qestdin
USE mp, ONLY : mp_bcast
USE iotk_module, ONLY : iotk_attlenx
!
......
......@@ -20,7 +20,7 @@
MODULE read_xml_cards_module
!
!
USE io_global, ONLY : xmlinputunit=>xmlstdin
USE io_global, ONLY : xmlinputunit => qestdin
USE iotk_module, ONLY : iotk_scan_begin, iotk_scan_end, iotk_scan_dat,&
iotk_scan_dat_inside, iotk_scan_attr, iotk_attlenx
USE read_xml_fields_module, ONLY : clean_str
......
......@@ -7,7 +7,7 @@
MODULE read_xml_fields_module
!
!
USE io_global, ONLY : xmlinputunit => xmlstdin
USE io_global, ONLY : xmlinputunit => qestdin
USE kinds, ONLY : DP
USE input_parameters
!
......
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