The Elk Code
modvars.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2011 J. K. Dewhurst, S. Sharma and E. K. U. Gross
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 module modvars
7 
8 ! if wrtvars is .true. then variables are written to VARIABLES.OUT
9 logical wrtvars
10 ! if batch is .true. then Elk will run in batch mode
11 logical batch
12 
13 contains
14 
15 subroutine writevars(vname,n1,n2,n3,n4,n5,n6,nv,iv,iva,rv,rva,zv,zva,sv,sva)
16 implicit none
17 ! arguments
18 character(*), intent(in) :: vname
19 integer, optional, intent(in) :: n1,n2,n3,n4,n5,n6
20 integer, optional, intent(in) :: nv,iv,iva(*)
21 real(8), optional, intent(in) :: rv,rva(*)
22 complex(8), optional, intent(in) :: zv,zva(*)
23 character(*), optional, intent(in) :: sv,sva(*)
24 ! local variables
25 integer i
26 if (present(iva).or.present(rva).or.present(zva).or.present(sva)) then
27  if (.not.present(nv)) then
28  write(*,*)
29  write(*,'("Error(writevars): missing argument nv")')
30  write(*,*)
31  stop
32  else
33  if (nv < 0) then
34  write(*,*)
35  write(*,'("Error(writevars): nv < 0 : ",I8)') nv
36  write(*,*)
37  stop
38  end if
39  end if
40 end if
41 open(95,file='VARIABLES.OUT',form='FORMATTED',action='WRITE',position='APPEND')
42 write(95,*)
43 write(95,'(A)',advance='NO') trim(vname)
44 if (present(n1)) write(95,'(I8)',advance='NO') n1
45 if (present(n2)) write(95,'(I8)',advance='NO') n2
46 if (present(n3)) write(95,'(I8)',advance='NO') n3
47 if (present(n4)) write(95,'(I8)',advance='NO') n4
48 if (present(n5)) write(95,'(I8)',advance='NO') n5
49 if (present(n6)) write(95,'(I8)',advance='NO') n6
50 write(95,*)
51 if (present(iv)) then
52  write(95,'(2I8)') 1,1
53  write(95,'(I8)') iv
54 else if (present(rv)) then
55  write(95,'(2I8)') 2,1
56  write(95,'(G24.14)') rv
57 else if (present(zv)) then
58  write(95,'(2I8)') 3,1
59  write(95,'(2G24.14)') dble(zv),aimag(zv)
60 else if (present(sv)) then
61  write(95,'(2I8)') 4,1
62  write(95,'(A)') trim(sv)
63 else if (present(iva)) then
64  write(95,'(2I8)') 1,nv
65  do i=1,nv
66  write(95,'(I8)') iva(i)
67  end do
68 else if (present(rva)) then
69  write(95,'(2I8)') 2,nv
70  do i=1,nv
71  write(95,'(G24.14)') rva(i)
72  end do
73 else if (present(zva)) then
74  write(95,'(2I8)') 3,nv
75  do i=1,nv
76  write(95,'(2G24.14)') dble(zva(i)),aimag(zva(i))
77  end do
78 else if (present(sva)) then
79  write(95,'(2I8)') 4,nv
80  do i=1,nv
81  write(95,'(A)') trim(sva(i))
82  end do
83 end if
84 close(95)
85 end subroutine
86 
87 end module
88 
logical batch
Definition: modvars.f90:11
logical wrtvars
Definition: modvars.f90:9
subroutine writevars(vname, n1, n2, n3, n4, n5, n6, nv, iv, iva, rv, rva, zv, zva, sv, sva)
Definition: modvars.f90:16