init.F90 2.11 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

7
      MODULE m_juDFT_init
8

Gregor Michalicek's avatar
Gregor Michalicek committed
9
      USE m_judft_time
10 11 12
      USE m_judft_sysinfo
      USE m_judft_stop

13 14
      IMPLICIT NONE
      PRIVATE
Daniel Wortmann's avatar
Daniel Wortmann committed
15
      PUBLIC juDFT_init
16
      CONTAINS
Daniel Wortmann's avatar
Daniel Wortmann committed
17
     
18 19
      SUBROUTINE juDFT_init()
      CALL signal_handler()
20
      CALL checkstack()
21 22 23 24 25 26 27 28 29 30 31 32
      END SUBROUTINE juDFT_init

      SUBROUTINE signal_handler()
      !Installs custom handlers for SIGTERM,SIGSEGV
#ifdef __INTEL_COMPILER
      USE ifport
      INTEGER :: result
      EXTERNAL intel_signal_handler
      result=signal(SIGTERM,intel_signal_handler,-1)
      result=signal(SIGSEGV,intel_signal_handler,-1)
#endif
      END SUBROUTINE signal_handler
Gregor Michalicek's avatar
Gregor Michalicek committed
33

34 35
      END MODULE m_juDFT_init

Gregor Michalicek's avatar
Gregor Michalicek committed
36 37 38
      ! NOTE: The intel_signal_handler has to be outside the module
      !       as the OS has to have it under a certain name that
      !       would be changed if it would be defined in the module.
39 40
#ifdef __INTEL_COMPILER
      FUNCTION intel_signal_handler(signal)
Gregor Michalicek's avatar
Gregor Michalicek committed
41
      USE m_judft_time
42
      USE m_judft_sysinfo
43 44 45 46 47 48 49 50 51 52 53 54
      IMPLICIT NONE
      INTEGER :: signal
      INTEGER :: intel_signal_handler
#ifdef CPP_MPI
      include "mpif.h"
      INTEGER:: irank,ierr

      CALL MPI_COMM_RANK (MPI_COMM_WORLD,irank,ierr)
      WRITE(*,*) "Signal ",signal," detected on PE:",irank
#else
      WRITE(*,*) "Signal detected:",signal
#endif
Gregor Michalicek's avatar
Gregor Michalicek committed
55
      WRITE(*,*) "This might be due to either:"
Daniel Wortmann's avatar
Daniel Wortmann committed
56 57 58
      WRITE(*,*) " - A bug in FLEUR"
      WRITE(*,*) " - Your job running out of memory"
      WRITE(*,*) " - Your job got killed externally (e.g. no cpu-time left)"
59
      WRITE(*,*) " - ...." 
Daniel Wortmann's avatar
Daniel Wortmann committed
60 61
      WRITE(*,*) "Please check and report if you believe you found a bug"
      CALL writetimes()
62
      CALL PRINT_memory_info()
63 64 65 66
      STOP "Signal"
      intel_signal_handler=0
      END FUNCTION intel_signal_handler
#endif