error.F90 Source File


This file depends on

sourcefile~~error.f90~~EfferentGraph sourcefile~error.f90 error.F90 sourcefile~comms.f90 comms.F90 sourcefile~error.f90->sourcefile~comms.f90 sourcefile~error_base.f90 error_base.F90 sourcefile~error.f90->sourcefile~error_base.f90 sourcefile~comms.f90->sourcefile~error_base.f90 sourcefile~constants.f90 constants.F90 sourcefile~comms.f90->sourcefile~constants.f90

Files dependent on this one

sourcefile~~error.f90~~AfferentGraph sourcefile~error.f90 error.F90 sourcefile~berry.f90 berry.F90 sourcefile~berry.f90->sourcefile~error.f90 sourcefile~get_oper.f90 get_oper.F90 sourcefile~berry.f90->sourcefile~get_oper.f90 sourcefile~postw90_common.f90 postw90_common.F90 sourcefile~berry.f90->sourcefile~postw90_common.f90 sourcefile~spin.f90 spin.F90 sourcefile~berry.f90->sourcefile~spin.f90 sourcefile~utility.f90 utility.F90 sourcefile~berry.f90->sourcefile~utility.f90 sourcefile~wan_ham.f90 wan_ham.F90 sourcefile~berry.f90->sourcefile~wan_ham.f90 sourcefile~tetrahedron.f90 tetrahedron.F90 sourcefile~berry.f90->sourcefile~tetrahedron.f90 sourcefile~boltzwann.f90 boltzwann.F90 sourcefile~boltzwann.f90->sourcefile~error.f90 sourcefile~dos.f90 dos.F90 sourcefile~boltzwann.f90->sourcefile~dos.f90 sourcefile~boltzwann.f90->sourcefile~get_oper.f90 sourcefile~readwrite.f90 readwrite.F90 sourcefile~boltzwann.f90->sourcefile~readwrite.f90 sourcefile~boltzwann.f90->sourcefile~spin.f90 sourcefile~boltzwann.f90->sourcefile~utility.f90 sourcefile~boltzwann.f90->sourcefile~wan_ham.f90 sourcefile~disentangle.f90 disentangle.F90 sourcefile~disentangle.f90->sourcefile~error.f90 sourcefile~sitesym.f90 sitesym.F90 sourcefile~disentangle.f90->sourcefile~sitesym.f90 sourcefile~disentangle.f90->sourcefile~utility.f90 sourcefile~dos.f90->sourcefile~error.f90 sourcefile~dos.f90->sourcefile~get_oper.f90 sourcefile~dos.f90->sourcefile~postw90_common.f90 sourcefile~dos.f90->sourcefile~spin.f90 sourcefile~dos.f90->sourcefile~utility.f90 sourcefile~dos.f90->sourcefile~wan_ham.f90 sourcefile~geninterp.f90 geninterp.F90 sourcefile~geninterp.f90->sourcefile~error.f90 sourcefile~geninterp.f90->sourcefile~get_oper.f90 sourcefile~geninterp.f90->sourcefile~postw90_common.f90 sourcefile~geninterp.f90->sourcefile~utility.f90 sourcefile~geninterp.f90->sourcefile~wan_ham.f90 sourcefile~get_oper.f90->sourcefile~error.f90 sourcefile~get_oper.f90->sourcefile~utility.f90 sourcefile~gyrotropic.f90 gyrotropic.F90 sourcefile~gyrotropic.f90->sourcefile~error.f90 sourcefile~gyrotropic.f90->sourcefile~berry.f90 sourcefile~gyrotropic.f90->sourcefile~get_oper.f90 sourcefile~gyrotropic.f90->sourcefile~postw90_common.f90 sourcefile~gyrotropic.f90->sourcefile~spin.f90 sourcefile~gyrotropic.f90->sourcefile~utility.f90 sourcefile~gyrotropic.f90->sourcefile~wan_ham.f90 sourcefile~hamiltonian.f90 hamiltonian.F90 sourcefile~hamiltonian.f90->sourcefile~error.f90 sourcefile~hamiltonian.f90->sourcefile~utility.f90 sourcefile~kmesh.f90 kmesh.F90 sourcefile~kmesh.f90->sourcefile~error.f90 sourcefile~kmesh.f90->sourcefile~utility.f90 sourcefile~kpath.f90 kpath.F90 sourcefile~kpath.f90->sourcefile~error.f90 sourcefile~kpath.f90->sourcefile~berry.f90 sourcefile~kpath.f90->sourcefile~get_oper.f90 sourcefile~kpath.f90->sourcefile~postw90_common.f90 sourcefile~kpath.f90->sourcefile~spin.f90 sourcefile~kpath.f90->sourcefile~utility.f90 sourcefile~kslice.f90 kslice.F90 sourcefile~kslice.f90->sourcefile~error.f90 sourcefile~kslice.f90->sourcefile~berry.f90 sourcefile~kslice.f90->sourcefile~get_oper.f90 sourcefile~kslice.f90->sourcefile~postw90_common.f90 sourcefile~kslice.f90->sourcefile~spin.f90 sourcefile~kslice.f90->sourcefile~utility.f90 sourcefile~kslice.f90->sourcefile~wan_ham.f90 sourcefile~library_extra.f90 library_extra.F90 sourcefile~library_extra.f90->sourcefile~error.f90 sourcefile~library_extra.f90->sourcefile~kmesh.f90 sourcefile~library_interface.f90 library_interface.F90 sourcefile~library_extra.f90->sourcefile~library_interface.f90 sourcefile~overlap.f90 overlap.F90 sourcefile~library_extra.f90->sourcefile~overlap.f90 sourcefile~library_extra.f90->sourcefile~readwrite.f90 sourcefile~wannier90_readwrite.f90 wannier90_readwrite.F90 sourcefile~library_extra.f90->sourcefile~wannier90_readwrite.f90 sourcefile~library_interface.f90->sourcefile~error.f90 sourcefile~library_interface.f90->sourcefile~disentangle.f90 sourcefile~library_interface.f90->sourcefile~kmesh.f90 sourcefile~library_interface.f90->sourcefile~overlap.f90 sourcefile~plot.f90 plot.F90 sourcefile~library_interface.f90->sourcefile~plot.f90 sourcefile~library_interface.f90->sourcefile~readwrite.f90 sourcefile~transport.f90 transport.F90 sourcefile~library_interface.f90->sourcefile~transport.f90 sourcefile~library_interface.f90->sourcefile~wannier90_readwrite.f90 sourcefile~wannierise.f90 wannierise.F90 sourcefile~library_interface.f90->sourcefile~wannierise.f90 sourcefile~overlap.f90->sourcefile~error.f90 sourcefile~overlap.f90->sourcefile~sitesym.f90 sourcefile~overlap.f90->sourcefile~utility.f90 sourcefile~plot.f90->sourcefile~error.f90 sourcefile~plot.f90->sourcefile~hamiltonian.f90 sourcefile~plot.f90->sourcefile~utility.f90 sourcefile~ws_distance.f90 ws_distance.F90 sourcefile~plot.f90->sourcefile~ws_distance.f90 sourcefile~postw90.f90 postw90.F90 sourcefile~postw90.f90->sourcefile~error.f90 sourcefile~postw90.f90->sourcefile~berry.f90 sourcefile~postw90.f90->sourcefile~boltzwann.f90 sourcefile~postw90.f90->sourcefile~dos.f90 sourcefile~postw90.f90->sourcefile~geninterp.f90 sourcefile~postw90.f90->sourcefile~gyrotropic.f90 sourcefile~postw90.f90->sourcefile~kmesh.f90 sourcefile~postw90.f90->sourcefile~kpath.f90 sourcefile~postw90.f90->sourcefile~kslice.f90 sourcefile~postw90.f90->sourcefile~postw90_common.f90 sourcefile~postw90_readwrite.f90 postw90_readwrite.F90 sourcefile~postw90.f90->sourcefile~postw90_readwrite.f90 sourcefile~postw90.f90->sourcefile~readwrite.f90 sourcefile~postw90.f90->sourcefile~spin.f90 sourcefile~postw90_common.f90->sourcefile~error.f90 sourcefile~postw90_common.f90->sourcefile~utility.f90 sourcefile~postw90_common.f90->sourcefile~ws_distance.f90 sourcefile~postw90_readwrite.f90->sourcefile~error.f90 sourcefile~postw90_readwrite.f90->sourcefile~readwrite.f90 sourcefile~postw90_readwrite.f90->sourcefile~utility.f90 sourcefile~readwrite.f90->sourcefile~error.f90 sourcefile~readwrite.f90->sourcefile~utility.f90 sourcefile~sitesym.f90->sourcefile~error.f90 sourcefile~sitesym.f90->sourcefile~utility.f90 sourcefile~spin.f90->sourcefile~error.f90 sourcefile~spin.f90->sourcefile~get_oper.f90 sourcefile~spin.f90->sourcefile~postw90_common.f90 sourcefile~spin.f90->sourcefile~utility.f90 sourcefile~transport.f90->sourcefile~error.f90 sourcefile~transport.f90->sourcefile~hamiltonian.f90 sourcefile~utility.f90->sourcefile~error.f90 sourcefile~wan_ham.f90->sourcefile~error.f90 sourcefile~wan_ham.f90->sourcefile~get_oper.f90 sourcefile~wan_ham.f90->sourcefile~postw90_common.f90 sourcefile~wan_ham.f90->sourcefile~utility.f90 sourcefile~wannier90_readwrite.f90->sourcefile~error.f90 sourcefile~wannier90_readwrite.f90->sourcefile~readwrite.f90 sourcefile~wannier90_readwrite.f90->sourcefile~utility.f90 sourcefile~wannier_prog.f90 wannier_prog.F90 sourcefile~wannier_prog.f90->sourcefile~error.f90 sourcefile~wannier_prog.f90->sourcefile~library_extra.f90 sourcefile~wannier_prog.f90->sourcefile~library_interface.f90 sourcefile~wannier_prog.f90->sourcefile~sitesym.f90 sourcefile~wannierise.f90->sourcefile~error.f90 sourcefile~wannierise.f90->sourcefile~hamiltonian.f90 sourcefile~wannierise.f90->sourcefile~sitesym.f90 sourcefile~wannierise.f90->sourcefile~utility.f90 sourcefile~wannierise.f90->sourcefile~wannier90_readwrite.f90 sourcefile~ws_distance.f90->sourcefile~error.f90 sourcefile~ws_distance.f90->sourcefile~utility.f90 sourcefile~c_interface.f90 c_interface.F90 sourcefile~c_interface.f90->sourcefile~library_interface.f90 sourcefile~tetrahedron.f90->sourcefile~utility.f90

Source Code

!-*- mode: F90 -*-!
!------------------------------------------------------------!
! Copyright (C) 2026 Wannier Developer Group                 !
!                                                            !
! This library is free software; you can redistribute it     !
! and/or modify it under the terms of the GNU Lesser General !
! Public License as published by the Free Software           !
! Foundation; either version 2.1 of the License, or (at your !
! option) any later version.                                 !
!                                                            !
! This library is distributed in the hope that it will be    !
! useful,but WITHOUT ANY WARRANTY; without even the implied  !
! warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR    !
! PURPOSE.  See the GNU Lesser General Public License for    !
! more details.                                              !
!                                                            !
! You should have received a copy of the GNU Lesser General  !
! Public License along with this library; if not, see        !
! <https://www.gnu.org/licenses/>.                           !
!                                                            !
! The webpage of the Wannier90 code is                       !
! <https://www.wannier.org>.                                 !
!                                                            !
! The Wannier90 code is hosted on GitHub                     !
! <https://github.com/wannier-developers/wannier90>          !
!------------------------------------------------------------!

module w90_error
  !! Module to handle errors

  use w90_error_base
  use w90_comms

  implicit none

  public

  integer, parameter :: code_ok = 0

  integer, parameter :: code_fatal = 1
  integer, parameter :: code_alloc = 2
  integer, parameter :: code_dealloc = 3
  integer, parameter :: code_mpi = 4
  integer, parameter :: code_input = 5
  integer, parameter :: code_file = 6

  integer, parameter :: code_unconv = -1
  integer, parameter :: code_warning = -2 ! mostly for failing to plot something

contains

  subroutine set_error_fatal(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_fatal)
    call comms_sync_error(comm, err, code_fatal)
  end subroutine set_error_fatal

  subroutine set_error_alloc(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_alloc)
    call comms_sync_error(comm, err, code_alloc)
  end subroutine set_error_alloc

  subroutine set_error_dealloc(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_dealloc)
    call comms_sync_error(comm, err, code_dealloc)
  end subroutine set_error_dealloc

  ! note, this is not used in comms routines
  ! (otherwise circular dependency)
  subroutine set_error_mpi(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_mpi)
    call comms_sync_error(comm, err, code_mpi)
  end subroutine set_error_mpi

  subroutine set_error_input(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_input)
    call comms_sync_error(comm, err, code_input)
  end subroutine set_error_input

  subroutine set_error_file(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_file)
    call comms_sync_error(comm, err, code_file)
  end subroutine set_error_file

  subroutine set_error_unconv(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_unconv)
    call comms_sync_error(comm, err, code_unconv)
  end subroutine set_error_unconv

  subroutine set_error_warn(err, mesg, comm)
    type(w90_error_type), allocatable, intent(out) :: err
    character(len=*), intent(in) :: mesg
    type(w90_comm_type), intent(in) :: comm
    call set_base_error(err, mesg, code_warning)
    call comms_sync_error(comm, err, code_warning)
  end subroutine set_error_warn

end module w90_error