Statistics
| Revision:

root / src / Die.f90 @ 5

History | View | Annotate | Download (1.4 kB)

1
! This routine prints an error message and stops.
2
! Taken from Siesta 3.1 
3
    SUBROUTINE die(routine, msg, file, line, unit)
4

    
5
      Use VarTypes
6
      Use io_module
7

    
8
      implicit none
9
!--------------------------------------------------------------- Input Variables
10
      character(len=*), intent(in)           :: routine, msg
11
      character(len=*), intent(in), optional :: file
12
      integer(KINT), intent(in), optional      :: line, unit
13

    
14
!--------------------------------------------------------------- Local Variables
15
      integer(KINT)                            :: die_unit
16

    
17

    
18
!------------------------------------------------------------------------- BEGIN
19
      if (PRESENT(unit)) then
20
        die_unit = unit
21
      else
22
        die_unit = IOERR
23
      endif
24

    
25
      write(die_unit,'(a)') '*************************************************************'
26
      write(die_unit,'(a)') 'ERROR'
27
      write(die_unit,'(a)') ' '
28
      write(die_unit,'(3a)') TRIM(routine), ': ', TRIM(msg)
29
      write(die_unit,'(a)') ' '
30
      if (PRESENT(file)) write(die_unit,'(5x,2a)') 'File: ', file
31
      if (PRESENT(line)) write(die_unit,'(5x,a,i5)') 'Line: ', line
32
      write(die_unit,'(a)') '*************************************************************'
33

    
34
      if (die_unit .ne. IOERR) then
35
        write(die_unit,'(a)') 'Stopping Program'
36
      endif
37

    
38
      STOP 'Stopping Program'
39

    
40
!--------------------------------------------------------------------------- END
41
    END SUBROUTINE die
42