chgres_cube  1.5.0
 All Data Structures Files Functions Variables
utils.F90
Go to the documentation of this file.
1 
4 
9  subroutine error_handler(string, rc)
10 
11  use mpi
12 
13  implicit none
14 
15  character(len=*), intent(in) :: string
16 
17  integer, intent(in) :: rc
18 
19  integer :: ierr
20 
21  print*,"- FATAL ERROR: ", string
22  print*,"- IOSTAT IS: ", rc
23  call mpi_abort(mpi_comm_world, 999, ierr)
24 
25  end subroutine error_handler
26 
31  subroutine netcdf_err( err, string )
32 
33  use mpi
34  use netcdf
35 
36  implicit none
37  integer, intent(in) :: err
38  character(len=*), intent(in) :: string
39  character(len=256) :: errmsg
40  integer :: iret
41 
42  if( err.EQ.nf90_noerr )return
43  errmsg = nf90_strerror(err)
44  print*,''
45  print*,'FATAL ERROR: ', trim(string), ': ', trim(errmsg)
46  print*,'STOP.'
47  call mpi_abort(mpi_comm_world, 999, iret)
48 
49  return
50  end subroutine netcdf_err
51 
59 function to_upper(strIn) result(strOut)
60 
61  implicit none
62 
63  character(len=*), intent(in) :: strin
64  character(len=len(strIn)) :: strout
65  integer :: i,j
66 
67  do i = 1, len(strin)
68  j = iachar(strin(i:i))
69  if (j>= iachar("a") .and. j<=iachar("z") ) then
70  strout(i:i) = achar(iachar(strin(i:i))-32)
71  else
72  strout(i:i) = strin(i:i)
73  end if
74  end do
75 
76 end function to_upper
77 
84 subroutine to_lower(strIn)
85 
86  implicit none
87 
88  character(len=*), intent(inout) :: strin
89  character(len=len(strIn)) :: strout
90  integer :: i,j
91 
92  do i = 1, len(strin)
93  j = iachar(strin(i:i))
94  if (j>= iachar("A") .and. j<=iachar("Z") ) then
95  strout(i:i) = achar(iachar(strin(i:i))+32)
96  else
97  strout(i:i) = strin(i:i)
98  end if
99  end do
100  strin(:) = strout(:)
101 end subroutine to_lower
subroutine to_lower(strIn)
Convert from upper to lowercase.
Definition: utils.F90:84
subroutine netcdf_err(err, string)
Error handler for netcdf.
Definition: utils.F90:31
character(len=len(strin)) function to_upper(strIn)
Convert string from lower to uppercase.
Definition: utils.F90:59
subroutine error_handler(string, rc)
General error handler.
Definition: utils.F90:9