more generic error codes

allow label without ID in IO_error
This commit is contained in:
Martin Diehl 2023-07-12 12:45:39 +02:00
parent d452a9ce3f
commit d9cf3983b4
2 changed files with 27 additions and 40 deletions

View File

@ -158,34 +158,34 @@ subroutine CLI_init()
print'(1x,a,/)',' Prints this message and exits'
call quit(0) ! normal Termination
case ('-g', '--geom', '--geometry')
if (.not. hasArg) call IO_error(610)
if (.not. hasArg) call IO_error(610,ext_msg='--geom')
geomArg = getArg(i+1)
case ('-l', '--load', '--loadcase')
if (.not. hasArg) call IO_error(611)
if (.not. hasArg) call IO_error(610,ext_msg='--load')
loadArg = getArg(i+1)
case ('-m', '--material', '--materialconfig')
if (.not. hasArg) call IO_error(612)
if (.not. hasArg) call IO_error(610,ext_msg='--material')
materialArg = getArg(i+1)
case ('-n', '--numerics', '--numericsconfig')
if (.not. hasArg) call IO_error(613)
if (.not. hasArg) call IO_error(610,ext_msg='--numerics')
numericsArg = getArg(i+1)
case ('-j', '--job', '--jobname')
if (.not. hasArg) call IO_error(614)
if (.not. hasArg) call IO_error(610,ext_msg='--jobname')
solverJobname = getArg(i+1)
case ('-w', '--wd', '--workingdir', '--workingdirectory')
if (.not. hasArg) call IO_error(615)
if (.not. hasArg) call IO_error(610,ext_msg='--workingdirectory')
workingDirArg = getArg(i+1)
case ('-r', '--rs', '--restart')
if (.not. hasArg) call IO_error(616)
if (.not. hasArg) call IO_error(610,ext_msg='--jobname')
arg = getArg(i+1)
read(arg,*,iostat=stat) CLI_restartInc
if (CLI_restartInc < 0 .or. stat /= 0) call IO_error(617,ext_msg=arg)
if (CLI_restartInc < 0 .or. stat /= 0) call IO_error(611,ext_msg=arg)
end select
end do
if (.not. allocated(geomArg)) call IO_error(620,ext_msg='-h for help')
if (.not. allocated(loadArg)) call IO_error(621,ext_msg='-h for help')
if (.not. allocated(materialArg)) call IO_error(622,ext_msg='-h for help')
if (.not. allocated(geomArg)) call IO_error(612,ext_msg='--help for instructions',label1='--geom')
if (.not. allocated(loadArg)) call IO_error(612,ext_msg='--help for instructions',label1='--load')
if (.not. allocated(materialArg)) call IO_error(612,ext_msg='--help for instructions',label1='--material')
call setWorkingDirectory(trim(workingDirArg))
CLI_geomFile = getPathRelCWD(geomArg,'geometry')

View File

@ -556,27 +556,11 @@ subroutine IO_error(error_ID,ext_msg,label1,ID1,label2,ID2)
case (603)
msg = 'invalid data for table'
case (610)
msg = 'missing argument for --geom'
msg = 'no argument value specified'
case (611)
msg = 'missing argument for --load'
case (612)
msg = 'missing argument for --material'
case (613)
msg = 'missing argument for --numerics'
case (614)
msg = 'missing argument for --jobname'
case (615)
msg = 'missing argument for --workingdirectory'
case (616)
msg = 'missing argument for --restart'
case (617)
msg = 'could not parse restart increment'
case (620)
msg = 'no geometry specified'
case (621)
msg = 'no load case specified'
case (622)
msg = 'no material configuration specified'
case (612)
msg = 'missing argument'
case (630)
msg = 'JOBNAME must not contain any slashes'
case (640)
@ -732,18 +716,21 @@ subroutine panel(paneltype,ID,msg,ext_msg,label1,ID1,label2,ID2)
character(len=pSTRLEN) :: formatString
integer, parameter :: panelwidth = 69
character(len=:), allocatable :: msg_,ID_
character(len=:), allocatable :: msg_,ID_,msg1,msg2
character(len=*), parameter :: DIVIDER = repeat('─',panelwidth)
if (.not. present(label1) .and. present(ID1)) error stop 'missing label for value 1'
if (.not. present(label2) .and. present(ID2)) error stop 'missing label for value 2'
if ( present(label1) .and. .not. present(ID1)) error stop 'missing value for label 1'
if ( present(label2) .and. .not. present(ID2)) error stop 'missing value for label 2'
ID_ = IO_intAsStr(ID)
if (present(label1)) msg1 = label1
if (present(label2)) msg2 = label2
if (present(ID1)) msg1 = msg1//' '//IO_intAsStr(ID1)
if (present(ID2)) msg2 = msg2//' '//IO_intAsStr(ID2)
if (paneltype == 'error') msg_ = achar(27)//'[31m'//trim(msg)//achar(27)//'[0m'
if (paneltype == 'warning') msg_ = achar(27)//'[33m'//trim(msg)//achar(27)//'[0m'
ID_ = IO_intAsStr(ID)
!$OMP CRITICAL (write2out)
write(IO_STDERR,'(/,a)') ' ┌'//DIVIDER//'┐'
write(formatString,'(a,i2,a)') '(a,24x,a,1x,i0,',max(1,panelwidth-24-len_trim(paneltype)-1-len_trim(ID_)),'x,a)'
@ -758,14 +745,14 @@ subroutine panel(paneltype,ID,msg,ext_msg,label1,ID1,label2,ID2)
write(IO_STDERR,formatString) '│ ',trim(ext_msg), '│'
end if
if (present(label1)) then
write(formatString,'(a,i3.3,a,i3.3,a)') '(1x,a7,a',max(1,len_trim(label1)),',i9,',&
max(1,panelwidth+3-len_trim(label1)-9-7),'x,a)'
write(IO_STDERR,formatString) '│ at ',trim(label1),ID1, '│'
write(formatString,'(a,i3.3,a,i3.3,a)') '(1x,a7,a',max(1,len_trim(msg1)),',',&
max(1,panelwidth+3-len_trim(msg1)-7),'x,a)'
write(IO_STDERR,formatString) '│ at ',trim(msg1), '│'
end if
if (present(label2)) then
write(formatString,'(a,i3.3,a,i3.3,a)') '(1x,a7,a',max(1,len_trim(label2)),',i9,',&
max(1,panelwidth+3-len_trim(label2)-9-7),'x,a)'
write(IO_STDERR,formatString) '│ at ',trim(label2),ID2, '│'
write(formatString,'(a,i3.3,a,i3.3,a)') '(1x,a7,a',max(1,len_trim(msg2)),',',&
max(1,panelwidth+3-len_trim(msg2)-7),'x,a)'
write(IO_STDERR,formatString) '│ at ',trim(msg2), '│'
end if
write(formatString,'(a,i2.2,a)') '(a,',max(1,panelwidth),'x,a)'
write(IO_STDERR,formatString) ' │', '│'