File: modtest.f90

package info (click to toggle)
elkcode 5.4.24-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 12,840 kB
  • sloc: f90: 48,415; fortran: 22,457; perl: 965; makefile: 384; sh: 369; python: 105; ansic: 67
file content (101 lines) | stat: -rw-r--r-- 2,489 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

! Copyright (C) 2009 J. K. Dewhurst, S. Sharma and E. K. U. Gross
! This file is distributed under the terms of the GNU General Public License.
! See the file COPYING for license details.

module modtest

use modmpi

! if test is .true. then the test variables are written to file
logical test

contains

subroutine writetest(id,descr,nv,iv,iva,tol,rv,rva,zv,zva)
implicit none
! arguments
integer, intent(in) :: id
character(*), intent(in) :: descr
integer, optional, intent(in) :: nv
integer, optional, intent(in) :: iv
integer, optional, intent(in) :: iva(*)
real(8), optional, intent(in) :: tol
real(8), optional, intent(in) :: rv
real(8), optional, intent(in) :: rva(*)
complex(8), optional, intent(in) :: zv
complex(8), optional, intent(in) :: zva(*)
! local variables
integer j
character(256) fname
if (.not.test) return
if (.not.mp_mpi) return
if ((id.lt.0).or.(id.gt.999)) then
  write(*,*)
  write(*,'("Error(writetest): id out of range : ",I8)') id
  write(*,*)
  stop
end if
if ((present(iva)).or.(present(rva)).or.(present(zva))) then
  if (.not.present(nv)) then
    write(*,*)
    write(*,'("Error(writetest): missing argument nv")')
    write(*,*)
    stop
  else
    if (nv.le.0) then
      write(*,*)
      write(*,'("Error(writetest): nv <= 0 : ",I8)') nv
      write(*,*)
      stop
    end if
  end if
end if
if ((present(rv)).or.(present(rva)).or.(present(zv)).or.(present(zva))) then
  if (.not.present(tol)) then
    write(*,*)
    write(*,'("Error(writetest): missing argument tol")')
    write(*,*)
    stop
  end if
end if
write(fname,'("TEST",I3.3,".OUT")') id
!$OMP CRITICAL(writetest_)
open(90,file=trim(fname),form='FORMATTED')
write(90,'("''",A,"''")') trim(descr)
if (present(iv)) then
  write(90,'(2I8)') 1,1
  write(90,'(2I8)') 1,iv
else if (present(rv)) then
  write(90,'(2I8)') 2,1
  write(90,'(G22.12)') tol
  write(90,'(I8,G22.12)') 1,rv
else if (present(zv)) then
  write(90,'(2I8)') 3,1
  write(90,'(G22.12)') tol
  write(90,'(I8,2G22.12)') 1,dble(zv),aimag(zv)
else if (present(iva)) then
  write(90,'(2I8)') 1,nv
  do j=1,nv
    write(90,'(2I8)') j,iva(j)
  end do
else if (present(rva)) then
  write(90,'(2I8)') 2,nv
  write(90,'(G22.12)') tol
  do j=1,nv
    write(90,'(I8,G22.12)') j,rva(j)
  end do
else if (present(zva)) then
  write(90,'(2I8)') 3,nv
  write(90,'(G22.12)') tol
  do j=1,nv
    write(90,'(I8,2G22.12)') j,dble(zva(j)),aimag(zva(j))
  end do
end if
close(90)
!$OMP END CRITICAL(writetest_)
return
end subroutine

end module