ERROR: Rewrite module a bit and the way messages are printed.

Subroutine print_error() does not stop the execution anymore.  This
should be controlled by the code.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2014-01-10 11:27:39 -02:00
parent 1e7cb2a72c
commit 2ad980142b
3 changed files with 59 additions and 23 deletions

View File

@ -27,30 +27,44 @@
! !
module error module error
! module variables are not implicit by default
!
implicit none implicit none
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
!
contains contains
! !
!=============================================================================== !===============================================================================
! !
! print_error: subroutine prints error ! subroutine PRINT_ERROR:
! ----------------------
!
! Subroutine prints an error message with the module/subroutine where
! the error occured.
!
! Arguments:
!
! loc - string informing about the place where the error occured
! (for example 'module name::subroutine name:[line]');
! msg - string of the actual error message;
! !
!=============================================================================== !===============================================================================
! !
subroutine print_error(position, text) subroutine print_error(loc, msg)
! local variables are not implicit by default
!
implicit none implicit none
! input arguments ! subroutine arguments
! !
character(len=*), intent(in) :: position, text character(len=*), intent(in) :: loc, msg
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
write(*,*) write(*,*)
write(*,"('[error in ', a, ']: ', a)") trim(position), trim(text) write(*,"('[ERROR in ', a, ']: ', a)") trim(loc), trim(msg)
write(*,*)
stop
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -58,23 +72,34 @@ module error
! !
!=============================================================================== !===============================================================================
! !
! print_warning: subroutine prints warning ! subroutine PRINT_WARNING:
! ------------------------
!
! Subroutine prints a warning message with the module/subroutine where
! the warning occured.
!
! Arguments:
!
! loc - string informing about the place where the warning occured
! (for example 'module name::subroutine name:[line]');
! msg - string of the actual warning message;
! !
!=============================================================================== !===============================================================================
! !
subroutine print_warning(position, text) subroutine print_warning(loc, msg)
! local variables are not implicit by default
!
implicit none implicit none
! input arguments ! subroutine arguments
! !
character(len=*), intent(in) :: position, text character(len=*), intent(in) :: loc, msg
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
write(*,*) write(*,*)
write(*,"('[warning in ', a, ']: ', a)") trim(position), trim(text) write(*,"('[WARNING in ', a, ']: ', a)") trim(loc), trim(msg)
write(*,*)
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
@ -82,27 +107,38 @@ module error
! !
!=============================================================================== !===============================================================================
! !
! print_info: subroutine prints information ! subroutine PRINT_NOTIFICATION:
! -----------------------------
!
! Subroutine prints a notification message with the module/subroutine where
! the notification occured.
!
! Arguments:
!
! loc - string informing about the place where the notification occured
! (for example 'module name::subroutine name:[line]');
! msg - string of the actual notification message;
! !
!=============================================================================== !===============================================================================
! !
subroutine print_info(position, text) subroutine print_notification(loc, msg)
! local variables are not implicit by default
!
implicit none implicit none
! input arguments ! subroutine arguments
! !
character(len=*), intent(in) :: position, text character(len=*), intent(in) :: loc, msg
! !
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
write(*,*) write(*,*)
write(*,"('[info in ', a, ']: ', a)") trim(position), trim(text) write(*,"('[NOTIFICATION in ', a, ']: ', a)") trim(loc), trim(msg)
write(*,*)
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
end subroutine print_info end subroutine print_notification
!=============================================================================== !===============================================================================
! !

View File

@ -1180,7 +1180,7 @@ module io
use coordinates, only : nn, ng, in, jn, kn, maxlev, toplev, ir, jr, kr use coordinates, only : nn, ng, in, jn, kn, maxlev, toplev, ir, jr, kr
use coordinates, only : initialize_coordinates, finalize_coordinates use coordinates, only : initialize_coordinates, finalize_coordinates
use coordinates, only : xmin, xmax, ymin, ymax, zmin, zmax use coordinates, only : xmin, xmax, ymin, ymax, zmin, zmax
use error , only : print_error, print_warning use error , only : print_error
use evolution, only : step, time, dt, dtn use evolution, only : step, time, dt, dtn
use hdf5 , only : hid_t, hsize_t use hdf5 , only : hid_t, hsize_t
use hdf5 , only : h5gopen_f, h5gclose_f, h5aget_num_attrs_f & use hdf5 , only : h5gopen_f, h5gclose_f, h5aget_num_attrs_f &

View File

@ -462,7 +462,7 @@ module mesh
use blocks , only : get_mblocks, get_nleafs use blocks , only : get_mblocks, get_nleafs
use coordinates , only : minlev, maxlev, res use coordinates , only : minlev, maxlev, res
use domains , only : setup_domain use domains , only : setup_domain
use error , only : print_info, print_error use error , only : print_error
use mpitools , only : master, nproc, nprocs use mpitools , only : master, nproc, nprocs
use problems , only : setup_problem use problems , only : setup_problem
use refinement , only : check_refinement_criterion use refinement , only : check_refinement_criterion
@ -787,7 +787,7 @@ module mesh
use blocks , only : append_datablock, remove_datablock, link_blocks use blocks , only : append_datablock, remove_datablock, link_blocks
use coordinates , only : minlev, maxlev, toplev, im, jm, km, res use coordinates , only : minlev, maxlev, toplev, im, jm, km, res
use equations , only : nv use equations , only : nv
use error , only : print_info, print_error use error , only : print_error
#ifdef MPI #ifdef MPI
use mpitools , only : master, nprocs, nproc use mpitools , only : master, nprocs, nproc
use mpitools , only : reduce_sum_integer_array use mpitools , only : reduce_sum_integer_array