Based on the debug level input this soubroutine will output/print or skip the debug message. This subroutine is called in the starting of every other subrotune for debuging. This will be depricated in the later version.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | level | The message's debug level |
|||
character(len=*), | optional | :: | prog | Module or program name |
||
character(len=*), | optional | :: | method | Subroutine or function name |
||
character(len=*), | optional | :: | msg | Message to print |
subroutine dmsg(level, prog, method, msg)
!< Based on the debug level input this
!< soubroutine will output/print or skip the debug
!< message. This subroutine is called in the
!< starting of every other subrotune for debuging.
!< This will be depricated in the later version.
!---------------------------------------------------------------
! Print a DEBUG message
!
! Input arguments:
! level -> integer
! the message's debug level
! prog -> character
! module / program name
! method -> character
! subroutine / function name
! msg -> character
! message
!---------------------------------------------------------------
implicit none
character(len=*), optional :: prog
!< Module or program name
character(len=*), optional :: method
!< Subroutine or function name
character(len=*), optional :: msg
!< Message to print
character(len=256) :: ifmsg
integer :: level
!< The message's debug level
! if (process_id == 0) then
if (level < DEBUG_LEVEL) then
! Don't print the message
return
end if
ifmsg = ""
if (present(msg)) then
ifmsg = " >--> "//trim(msg)
end if
if (.not. present(prog) .and. .not. present(method) .and. &
.not. present(msg)) then
print *, 'Please provide atleast one of the following:'
print *, '- Module / program name'
print *, '- Subroutine / function name'
print *, '- A custom message'
stop
end if
print '(A7,I1.1,A,I2,A2,A,A2,A,A,A1)', 'Debug: ', level," id - ", process_id, ' (', &
trim(prog), ', ', trim(method), trim(ifmsg), ')'
! end if
end subroutine dmsg