psmile_error_common.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: psmile_error_common 
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_error_common ( ierror, char_string, ierrp, nerrp, &
00012                                 file, line )
00013 !
00014 ! !USES:
00015 !
00016       use psmile_common, dummy_interface => psmile_error_common
00017 
00018       implicit none
00019 
00020 #include "prism.inc"
00021 
00022 !
00023 ! !INPUT PARAMETERS:
00024 !
00025       integer, Intent (In)                :: ierror
00026 !
00027 !     PRISM error code
00028 !
00029       character(len=*), Intent(In)        :: char_string
00030 ! 
00031 !     Character parameter to the error code
00032 !
00033       integer, Intent (In)                :: nerrp
00034 !
00035 !     Number of error parameters
00036 !
00037       integer, Intent (In)                :: ierrp (nerrp)
00038 !
00039 !     Error parameters for the error code
00040 !
00041       character(len=*), Intent(In)        :: file
00042 !
00043 !     File name in which the error code was generated
00044 !
00045       integer, Intent (In)                :: line
00046 !
00047 !     Line number in "file" at which error code was generated
00048 !
00049 ! !LOCAL VARIABLES
00050 !
00051       integer                             :: ierr, lenstr
00052       integer                             :: char_len
00053       character(len=MPI_MAX_ERROR_STRING) :: error_string
00054       logical                             :: abort
00055 
00056       character(len=16)                   :: ch_rank
00057       integer                             :: ipos
00058 !
00059 ! !DESCRIPTION:
00060 !
00061 ! Subroutine PSMILe_Error prints error messages.
00062 !
00063 ! \begin{verbatim}
00064 ! Error classes:
00065 !
00066 !     PRISM_Error_MPI <= ierror <= 10 : Error in a MPI routine
00067 !        string    = Name of the MPI routine
00068 !        ierrp (1) = MPI error code
00069 !
00070 !        ierror = PRISM_Error_MPI :
00071 !                 General MPI error
00072 !        ierror = PRISM_Error_Send :
00073 !                 Error in a MPI_Send/MPI_Isend routine
00074 !                 ierrp (2) = Destination
00075 !                 ierrp (3) = Tag
00076 !        ierror = PRISM_Error_Recv :
00077 !                 Error in a MPI_Recv/MPI_Irecv routine
00078 !                 ierrp (2) = Source
00079 !                 ierrp (3) = Tag
00080 !
00081 !     PRISM_Error_Parameter <= ierror : Error in a PSMILe routine
00082 !
00083 !        ierror = PRISM_Error_Parameter :
00084 !                 Parameter is insufficient
00085 !                    string = Name of parameter
00086 !                    ierrp (1) = Current value
00087 !                    ierrp (2) = Required value
00088 !
00089 !        ierror = PRISM_Error_Initialized :
00090 !                 PRISM environment is not initialized.
00091 !        ierror = PRISM_Error_Alloc :
00092 !                 Error in Allocate
00093 !        ierror = PRISM_Error_Internal : Internal error
00094 ! \end{verbatim}
00095 !
00096 ! !REVISION HISTORY:
00097 !
00098 !   Date      Programmer   Description
00099 ! ----------  ----------   -----------
00100 ! (01.12.03   R. Redler    created psmile_error.F90)
00101 ! 2005-06     J. Ghattas   created from psmile_error.F90
00102 !
00103 !EOP
00104 !----------------------------------------------------------------------
00105 !
00106 !  $Id: psmile_error_common.F90 2706 2010-11-04 15:33:32Z hanke $
00107 !  $Autor$
00108 !
00109    Character(len=len_cvs_string), save :: mycvs = 
00110        '$Id: psmile_error_common.F90 2706 2010-11-04 15:33:32Z hanke $'
00111 !
00112 !----------------------------------------------------------------------
00113 !
00114 !   Flush Output
00115 !
00116       call psmile_flushstd
00117 !
00118       abort = .true.
00119 !
00120 !   Write initial line containing the id and the location
00121 !
00122       ipos = 0
00123       lenstr = len_trim (char_string)
00124       call psmile_int2char ( Appl%rank, ch_rank, ipos)
00125 
00126       write (*, 9990) ch_rank(1:ipos), trim(Appl%name), file, line
00127 
00128 !   Error in a MPI routine
00129 
00130       if ( PRISM_Error_MPI <= ierror .and. ierror <= 10 ) then
00131          call MPI_Error_string ( ierrp(1), error_string, char_len, ierr)
00132          write (*, 1010) char_string(1:lenstr), error_string(1:char_len)
00133 
00134          if (ierror == PRISM_Error_Send) then
00135             write (*, 1020) ierrp (2), ierrp (3)
00136          else if (ierror == PRISM_Error_Recv) then
00137             write (*, 1030) ierrp (2), ierrp (3)
00138          else if (nerrp > 1) then
00139             write (*, 1090) ierrp (2:nerrp)
00140          endif
00141 
00142 !   Error in a PSMILe routine
00143 
00144       else if (ierror == PRISM_Error_Parameter) then
00145 
00146          write (*, 1110) char_string(1:lenstr), ierrp (1), ierrp (2)
00147 
00148       else if (ierror == PRISM_Error_Alloc) then
00149 
00150          write (*, 1130) char_string(1:lenstr), ierrp (2)
00151 
00152       else if (ierror == PRISM_Error_Dealloc) then
00153 
00154          write (*, 1140) char_string(1:lenstr)
00155 
00156          abort = .false.
00157 
00158       else if (ierror == PRISM_Error_Arg) then
00159 
00160          write (*, 1150) char_string(1:lenstr), ierrp (1)
00161 
00162          abort = .true.
00163 
00164       else if (ierror == PRISM_Error_Invalid_Arg) then
00165 
00166          write (*, 1160) char_string(1:lenstr)
00167 
00168          abort = .true.
00169 
00170       else if (ierror == PRISM_Error_Arglist) then
00171 
00172          write (*, 1190) char_string(1:lenstr), ierrp (:)
00173 
00174          abort = .true.
00175 
00176       else
00177 
00178 !   unknown error code
00179 
00180          write (*, 9980) ierror, char_string(1:lenstr), nerrp
00181          write (*, 9970) ierrp
00182       endif
00183 
00184       call psmile_flushstd
00185 
00186 !   Abort entire application ?
00187 
00188       if (abort) call PSMILe_Abort
00189 
00190 !----------------------------------------------------------------------------
00191 !   Formats
00192 !----------------------------------------------------------------------------
00193 
00194 ! MPI errors
00195 
00196 1010  format (1x, 'Error in MPI routine ', a, ': Error message :', a)
00197 1020  format (1x, 'Error occured in Send to process', i4, ' using tag', i5)
00198 1030  format (1x, 'Error occured in Receive from process', i4, ' using tag', i5)
00199 1090  format (1x, 'Error parameters:', (1x, 10(i7, :, ',')))
00200 
00201 ! PSMILe errors
00202 
00203 1110  format (1x, 'Value of parameter ', a, ' is insufficient.', &
00204              /1x, 'Current value:', i5, '; should be ', i6)
00205 1130  format (1x, 'Cannot allocate ', a, &
00206                   '. Number of data items to be allocated was', i9)
00207 1140  format (1x, 'Cannot deallocate ', a, '.')
00208 1150  format (1x, 'Argument ', a, ' is out of range.', &
00209              /1x, 'Current value:', i5)
00210 1160  format (1x, 'Argument ', a, ' is invalid.')
00211 
00212 1190  format (1x, 'Error in argument list: ', a, (1x, 10(i7, :, ',')))
00213 
00214 
00215 ! Error in Grid definition
00216 ! statt id namen drucken
00217 
00218 
00219 !  General formats
00220 
00221 9970  format (1x, 10i7)
00222 9980  format (1x, 'Unknown error code', i4, '; string ', a, '; nerrp', i3)
00223 9990  format (1x, '[', a, '] PSMILe: Error in component: ', a, &
00224                   '; File ', a, ': line', i6 )
00225 end subroutine psmile_error_common

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1