WAVEWATCH III  beta 0.0.1
yowerr Module Reference

Has some subroutine to make a nice error message. More...

Functions/Subroutines

subroutine parallel_abort (string, error)
 
subroutine abort (string, line, file, errno)
 print various error strings and exit. More...
 
subroutine warn (string, line, file)
 print warning Call this to print an warning string and optional line number, and file More...
 

Detailed Description

Has some subroutine to make a nice error message.

Function/Subroutine Documentation

◆ abort()

subroutine yowerr::abort ( character(*), intent(in), optional  string,
integer, intent(in), optional  line,
character(*), intent(in), optional  file,
integer, intent(in), optional  errno 
)

print various error strings and exit.

Call this to print an error string and optional line number, file and MPI error string

Parameters
[in]stringErrorstring
[in]lineLine number
[in]fileFilename
[in]errnoThe MPI error number which is translated into an error string

Definition at line 93 of file yowerr.F90.

93  use yowdatapool, only: comm
94  use mpi
95  implicit none
96  ! Errorstring to print
97  character(*), optional, intent(in) :: string
98  ! Linenumber to print
99  integer, optional, intent(in) :: line
100  ! Filename to print
101  character(*), optional, intent(in) :: file
102  ! MPI error number to translate
103  integer, optional, intent(in) :: errno
104  ! Linenumber as string
105  character(50) :: lineNumber
106  ! MPI_MAX_ERROR_STRING = 1024
107  ! MPI Errorstring
108  character(MPI_MAX_ERROR_STRING) :: errorstring
109  ! The rank of this thread
110  integer :: myrank
111  ! real MPI errorsting lengt
112  integer :: stringLengh
113  !
114  integer :: ierr
115 
116  ! Get rank
117  call mpi_comm_rank(comm, myrank,ierr)
118  ! if(ierr/=MPI_SUCCESS) write(*,*) "parallel_abort: ierr=", ierr
119 
120  ! Always print rank
121  write(*, '(i2,a)', advance='no') myrank, " "
122 
123  ! Print a simple "ERROR" when no MPI error number was given because the MPI error string contain an "ERROR" allready
124  if(.not. present(errno)) then
125  write(*,'(a)', advance='no' ) " ERROR "
126  endif
127 
128  ! print file and linenumber
129  if(present(file)) then
130  write(*,'(a)',advance='no' ) file
131 
132  if(present(line)) then
133  Write(linenumber, '(i10)') line
134  write(*, '(2a)', advance='no') ":", trim(adjustl(linenumber))
135  endif
136 
137  write(*, '(a)', advance='no') " "
138  endif
139 
140  ! if only linenumber is present, add an "Line:" string
141  if(.not. present(file) .and. present(line)) then
142  Write(linenumber, '(i10)') line
143  write(*, '(2a)', advance='no') "Line:", trim(adjustl(linenumber))
144  write(*, '(a)', advance='no') " "
145  endif
146 
147  ! print the errror string
148  if(present(string)) then
149  write(*,'(a)', advance='no') string
150  endif
151 
152  ! translate and print the MPI error string
153  if(present(errno) .and. errno /= mpi_success) then
154  call mpi_error_string(errno, errorstring, stringlengh, ierr)
155  write(*,'(2a)', advance='no') 'MPI ERROR: ', errorstring(1:stringlengh)
156  endif
157 
158  write(*,*)
159  stop
160 

References yowdatapool::comm.

Referenced by yowpdlibmain::exchangeghostids(), yowrankmodule::exchangeiplg(), yowexchangemodule::initnbrdomains(), yowrankmodule::initrankmodule(), yowexchangemodule::pdlib_exchange1dreal(), and yowpdlibmain::real_mpi_barrier_pdlib().

◆ parallel_abort()

subroutine yowerr::parallel_abort ( character(*), intent(in), optional  string,
integer, intent(in), optional  error 
)

Definition at line 43 of file yowerr.F90.

43  use yowdatapool, only: comm
44  use mpi
45  implicit none
46 
47  character(*),optional,intent(in) :: string !string to print
48  integer,optional,intent(in) :: error !mpi errorcode
49  integer :: ierr,i
50  logical :: lopen
51  integer :: sl
52  ! MPI_MAX_ERROR_STRING = 1024
53  character(1024) :: errorstring
54  integer :: myrank
55 
56  ! Get rank
57  call mpi_comm_rank(comm, myrank,ierr)
58  if(ierr/=mpi_success) write(*,*) "parallel_abort: ierr=", ierr
59 
60  inquire(11,opened=lopen)
61 
62  if(present(string)) then
63  write(*,'(i4,2a)') myrank,': ABORT: ',string
64  if(lopen) write(11,'(i4,2a)') myrank,': ABORT: ',string
65  endif
66 
67  if(present(error)) then
68  if(error /= mpi_success) then
69  ! get errorstring associatet fuer errorcode err
70  call mpi_error_string(error, errorstring, sl, ierr)
71  if(ierr/=mpi_success) write(*,*) "parallel_abort: ierr=", ierr
72  write(*,'(i4,2a)') myrank,': MPI ERROR: ', errorstring(1:sl)
73  if(lopen) write(11,'(i4,2a)') myrank,': MPI ERROR: ', errorstring
74  endif
75  do i=1,200; inquire(i,opened=lopen); if(lopen) close(i); enddo;
76  call mpi_abort(comm, error,ierr)
77  if(ierr/=mpi_success) write(*,*) "parallel_abort: ierr=", ierr
78  else
79  do i=1,200; inquire(i,opened=lopen); if(lopen) close(i); enddo;
80  call mpi_abort(comm, 0,ierr)
81  if(ierr/=mpi_success) write(*,*) "parallel_abort: ierr=", ierr
82  endif

References yowdatapool::comm.

Referenced by yowpdlibmain::assignmesh(), yowpdlibmain::computetria_ien_si_ccon(), yowexchangemodule::creatempitype(), yowpdlibmain::element_crosses_dateline(), yowpdlibmain::exchangeghostids(), yowrankmodule::exchangeiplg(), yowexchangemodule::finalizeexchangemodule(), yowpdlibmain::findconndomains(), yowpdlibmain::findconnnodes(), yowpdlibmain::findghostnodes(), yowexchangemodule::pdlib_exchange1dreal(), yowexchangemodule::pdlib_exchange2dreal(), yowexchangemodule::pdlib_exchange2dreal_zero(), yowpdlibmain::postpartition(), yowpdlibmain::postpartition2(), yowpdlibmain::prepartition(), yowpdlibmain::real_mpi_barrier_pdlib(), and yowpdlibmain::runparmetis().

◆ warn()

subroutine yowerr::warn ( character(*), intent(in), optional  string,
integer, intent(in), optional  line,
character(*), intent(in), optional  file 
)

print warning Call this to print an warning string and optional line number, and file

Parameters
[in]stringwarnstring
[in]lineLine number
[in]fileFilename

Definition at line 169 of file yowerr.F90.

169  use yowdatapool, only: comm
170  use mpi
171  implicit none
172  ! Errorstring to print
173  character(*), optional, intent(in) :: string
174  ! Linenumber to print
175  integer, optional, intent(in) :: line
176  ! Filename to print
177  character(*), optional, intent(in) :: file
178  ! Linenumber as string
179  character(50) :: lineNumber
180  ! The rank of this thread
181  integer :: myrank
182  !
183  integer :: ierr
184 
185  ! Get rank
186  call mpi_comm_rank(comm, myrank,ierr)
187  ! if(ierr/=MPI_SUCCESS) write(*,*) "parallel_abort: ierr=", ierr
188 
189  ! Always print rank
190  write(*, '(i2,a)', advance='no') myrank, " "
191 
192  write(*,'(a)', advance='no' ) " WARN "
193 
194  ! print file and linenumber
195  if(present(file)) then
196  write(*,'(a)',advance='no' ) file
197 
198  if(present(line)) then
199  Write(linenumber, '(i10)') line
200  write(*, '(2a)', advance='no') ":", trim(adjustl(linenumber))
201  endif
202 
203  write(*, '(a)', advance='no') " "
204  endif
205 
206  ! if only linenumber is present, add an "Line:" string
207  if(.not. present(file) .and. present(line)) then
208  Write(linenumber, '(i10)') line
209  write(*, '(2a)', advance='no') "Line:", trim(adjustl(linenumber))
210  write(*, '(a)', advance='no') " "
211  endif
212 
213  ! print the errror string
214  if(present(string)) then
215  write(*,'(a)', advance='no') string
216  endif
217 
218  write(*,*)

References yowdatapool::comm.

yowdatapool
Has fancy data.
Definition: yowdatapool.F90:39