WAVEWATCH III  beta 0.0.1
yowerr.F90
Go to the documentation of this file.
1 !PDLIB Software License
2 !
3 !Software, as understood herein, shall be broadly interpreted as being inclusive of algorithms,
4 !source code, object code, data bases and related documentation, all of which shall be furnished
5 !free of charge to the Licensee. Corrections, upgrades or enhancements may be furnished and, if
6 !furnished, shall also be furnished to the Licensee without charge. NOAA, however, is not
7 !required to develop or furnish such corrections, upgrades or enhancements.
8 !Roland & Partner software, whether that initially furnished or corrections or upgrades,
9 !are furnished "as is". Roland & Partner furnishes its software without any warranty
10 !whatsoever and is not responsible for any direct, indirect or consequential damages
11 !that may be incurred by the Licensee. Warranties of merchantability, fitness for any
12 !particular purpose, title, and non-infringement, are specifically negated.
13 !The Licensee is not required to develop any software related to the licensed software.
14 !However, in the event that the Licensee does so, the Licensee is required to offer same
15 !to Roland & Partner for inclusion under the instant licensing terms with Roland & Partner
16 !licensed software along with documentation regarding its principles, use and its advantages.
17 !This includes changes to the wave model proper including numerical and physical approaches
18 !to wave modeling, and boundary layer parameterizations embedded in the wave model
19 !A Licensee may reproduce sufficient software to satisfy its needs.
20 !All copies shall bear the name of the software with any version number
21 !as well as replicas of any applied copyright notice, trademark notice,
22 !other notices and credit lines. Additionally, if the copies have been modified,
23 !e.g. with deletions or additions, this shall be so stated and identified.
24 !All of Licensee's employees who have a need to use the software may have access
25 !to the software but only after reading the instant license and stating, in writing,
26 !that they have read and understood the license and have agreed to its terms.
27 !Licensee is responsible for employing reasonable efforts to assure
28 !that only those of its employees that should have access to the software, in fact, have access.
29 !The Licensee may use the software for any purpose relating to sea state prediction.
30 !No disclosure of any portion of the software, whether by means of a media or verbally,
31 !may be made to any third party by the Licensee or the Licensee's employees
32 !The Licensee is responsible for compliance with any applicable export or
33 !import control laws of the United States, the European Union and Germany.
34 !
35 !© 2009 Roland&Partner, Georgenstr.32, 64297 Germany. All rights reserved.
36 !PDLIB is a trademark of Roland & Partner. No unauthorized use without permission.
37 !
39 module yowerr
40  implicit none
41 contains
42  subroutine parallel_abort(string, error)
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
83  end subroutine parallel_abort
84 
85 
92  subroutine abort(string, line, file, errno)
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 
161  end subroutine abort
162 
168  subroutine warn(string, line, file)
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(*,*)
219  end subroutine warn
220  end module yowerr
yowerr::parallel_abort
subroutine parallel_abort(string, error)
Definition: yowerr.F90:43
yowerr
Has some subroutine to make a nice error message.
Definition: yowerr.F90:39
yowerr::warn
subroutine warn(string, line, file)
print warning Call this to print an warning string and optional line number, and file
Definition: yowerr.F90:169
yowdatapool
Has fancy data.
Definition: yowdatapool.F90:39
yowdatapool::comm
integer, save, public comm
MPI Communicator.
Definition: yowdatapool.F90:66
yowerr::abort
subroutine abort(string, line, file, errno)
print various error strings and exit.
Definition: yowerr.F90:93