!
! $Id: abort_gcm.F 1279 2009-12-10 09:02:56Z fairhead $
!
c
c
      SUBROUTINE abort_gcm(modname, message, ierr)
     
#ifdef CPP_IOIPSL
      USE IOIPSL
#else
! if not using IOIPSL, we still need to use (a local version of) getin_dump
      USE ioipsl_getincom
#endif
#include "iniprint.h"
 
C
C Stops the simulation cleanly, closing files and printing various
C comments
C
C  Input: modname = name of calling program
C         message = stuff to print
C         ierr    = severity of situation ( = 0 normal )

      character(len=*) modname
      integer ierr
      character(len=*) message

!      write(lunout,*) 'in abort_gcm'
      write(6,*) 'in abort_gcm'
#ifdef CPP_IOIPSL
      call histclo
      call restclo
#endif
      call getin_dump
c     call histclo(2)
c     call histclo(3)
c     call histclo(4)
c     call histclo(5)
c     write(lunout,*) 'Stopping in ', modname
c     write(lunout,*) 'Reason = ',message
c     if (ierr .eq. 0) then
c       write(lunout,*) 'Everything is cool'
c     else
c       write(lunout,*) 'Houston, we have a problem ', ierr
c     endif
      write(6,*) 'Stopping in ', modname
      write(6,*) 'Reason = ',message
      if (ierr .eq. 0) then
        write(6,*) 'Everything is cool'
      else
        write(6,*) 'Houston, we have a problem ', ierr
      endif
      STOP
      END
