File: io_pattern.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 (58 lines) | stat: -rw-r--r-- 1,864 bytes parent folder | download | duplicates (5)
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
55
56
57
58
!
! Copyright (C) 2001-2008 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 .
!
!---------------------------------------------------------------------
SUBROUTINE io_pattern (nat,fildrho,nirr,npert,u,xq,directory,iflag)
!---------------------------------------------------------------------
  !
  USE kinds,            ONLY : DP
  USE io_global,        ONLY : stdout
  USE dfile_autoname,   ONLY : dfile_name
  USE io_files,         ONLY : prefix, tmp_dir, seqopn
  USE cell_base,        ONLY : at

  IMPLICIT NONE
!
!   the i/o variables first
!
  INTEGER :: nirr, iflag, nat, npert(3*nat)
  COMPLEX(DP) :: u(3*nat,3*nat)
  REAL(DP) :: xq(3)
  CHARACTER (len=256),INTENT(in)::  directory ! where to read/write the file
  CHARACTER (len=*)  ::  fildrho   ! name of the file
  CHARACTER (len=256)::  filname   ! complete name of the file
!
!   here the local variables
!
  INTEGER :: i,iunit
  INTEGER, EXTERNAL :: find_free_unit
  LOGICAL :: exst

  IF (ABS(iflag).NE.1) CALL errore('io_pattern','wrong iflag',1+ABS(iflag))

  iunit = find_free_unit() 
  filname = TRIM(dfile_name(xq, at, fildrho, TRIM(directory)//prefix, (iflag>0),-1)) //".pat"
  CALL seqopn(iunit,filname,'formatted',exst, directory)

  IF (iflag.GT.0) THEN
     !WRITE( stdout,'(5x,"WRITING PATTERNS TO FILE ",2a)') TRIM(directory), TRIM(filname)
     WRITE(iunit,*) nirr
     WRITE(iunit,*) (npert(i),i=1,nirr)
     WRITE(iunit,*) u
     WRITE(iunit,*) xq
  ELSE
     !WRITE( *,'(5x,"READING PATTERNS FROM FILE ",2a)') TRIM(directory), TRIM(filname)
     READ(iunit,*) nirr
     READ(iunit,*) (npert(i),i=1,nirr)
     READ(iunit,*) u
     READ(iunit,*) xq
  END IF
  !
  CLOSE (iunit)

  RETURN
END SUBROUTINE io_pattern