c     Copyright 2012 Leon van Dommelen.  This software is made available
c     under the GNU Public License version 3.

      subroutine fatal(msg)

c     Terminate execution on error, printing error message msg.

      implicit none

c input:

c     message to show
      character*(*) msg

c executable

c     generic format
 10   format(a,a,a,a)

c     print the message
      print10,char(7),'*** ',msg,'!'
      write(3,10)'*** ',msg,'!'

      call fatal0
      end



      subroutine fatal2(msg1,msg2)

c     Terminate execution on error, printing error message msg1msg2.

      implicit none

c input:

c     message to show
      character*(*) msg1
      character*(*) msg2

c local

c     lengths of the two components
      integer l1,l2

c executable

c     generic format
 10   format(a,a,a,a,a)

c     find the lengths
      l1=len(msg1)
      l2=len(msg2)

c     print the message
      if(l1+l2+5.le.79)then
         print10,char(7),'*** ',msg1,msg2,'!'
         write(3,10)'*** ',msg1,msg2,'!'
      else
         print10,char(7),'*** ',msg1
         print10,        '    ',msg2,'!'
         write(3,10)'*** ',msg1
         write(3,10)'    ',msg2,'!'
      endif

      call fatal0
      end



      subroutine fatal0()

c     really exit

      implicit none

c executable

      call exit(1)
      end
