TABLE OF CONTENTS


m_errors/leave_new [ Functions ]

[ Top ] [ m_errors ] [ Functions ]

NAME

  leave_new

FUNCTION

  Routine for clean exit of f90 code, taking into account possible parallelization.

  Note the this routine is private and should never be called explicitly.
  Please, use the macros:
    MSG_ERROR, MSG_BUG
  defined in abi_common.h to abort the execution.
  XG : this is not true, in very rare cases, ABINIT has to exit without giving an error (e.g. for non-zero prtkpt )

INPUTS

  exit_status=(optional, default=1 or -1, see below) the return code of the routine
  mode_paral=
   'COLL' if all procs are calling the routine with the same message to be
     written once only or
   'PERS' if the procs are calling the routine with different mesgs
     each to be written, or if one proc is calling the routine
  print_config=(optional, default=true)
       if true print out several informations before leaving

OUTPUT

  (only writing, then stop)

NOTES

  By default, it uses "call exit(1)", that is not completely portable.

PARENTS

      m_errors,testkgrid,vtorho

CHILDREN

      dump_config,print_kinds,wrtout,xmpi_abort,xmpi_show_info

SOURCE

38 #if defined HAVE_CONFIG_H
39 #include "config.h"
40 #endif
41 
42 #include "abi_common.h"
43 
44 
45 subroutine leave_new(mode_paral,exit_status,print_config)
46 
47  use defs_basis
48  use m_xmpi
49 
50  use m_build_info,      only : dump_config
51 
52 !This section has been created automatically by the script Abilint (TD).
53 !Do not modify the following lines by hand.
54 #undef ABI_FUNC
55 #define ABI_FUNC 'leave_new'
56  use interfaces_14_hidewrite
57 !End of the abilint section
58 
59  implicit none
60 
61 !Arguments ------------------------------------
62  character(len=4),intent(in) :: mode_paral
63  integer,intent(in),optional :: exit_status
64  logical,intent(in),optional :: print_config
65 
66 !Local variables-------------------------------
67  logical :: print_config_
68  !character(len=500) :: msg
69 
70 ! **********************************************************************
71 
72  call wrtout(std_out,ch10//' leave_new: decision taken to exit ...','PERS')
73 
74 ! Caveat: Do not use MPI collective calls!
75  if (mode_paral == "COLL") then
76    call wrtout(std_out,"Why are you using COLL? Are you sure that ALL the processors are calling leave_new?")
77  end if
78 
79 !Dump configuration before exiting
80  print_config_=.False.; if (present(print_config)) print_config_=print_config
81  if (print_config_) then
82    call print_kinds()
83    call xmpi_show_info()
84    call dump_config(std_out)
85  end if
86 
87  if (present(exit_status)) then
88    call xmpi_abort(exit_status=exit_status)
89  else
90    call xmpi_abort()
91  end if
92 
93 end subroutine leave_new