avoid access to unused variable, no need for nested function

This commit is contained in:
Martin Diehl 2023-06-23 08:54:37 +02:00
parent 4e7d953fe9
commit e34ee25597
1 changed files with 31 additions and 31 deletions

View File

@ -56,7 +56,6 @@ subroutine CLI_init()
i i
integer, dimension(8) :: & integer, dimension(8) :: &
dateAndTime dateAndTime
integer :: err
external :: & external :: &
quit quit
@ -161,7 +160,6 @@ subroutine CLI_init()
call quit(1) call quit(1)
end if end if
end select end select
if (err /= 0) call quit(1)
end do end do
if (.not. all([allocated(loadcaseArg),allocated(geometryArg),allocated(materialArg)])) then if (.not. all([allocated(loadcaseArg),allocated(geometryArg),allocated(materialArg)])) then
@ -188,38 +186,38 @@ subroutine CLI_init()
if (CLI_restartInc > 0) & if (CLI_restartInc > 0) &
print'(1x,a,i6.6)', 'Restart from increment: ', CLI_restartInc print'(1x,a,i6.6)', 'Restart from increment: ', CLI_restartInc
contains
!------------------------------------------------------------------------------------------------
!> @brief Get argument from command line.
!------------------------------------------------------------------------------------------------
function getArg(n)
integer, intent(in) :: n !< number of the argument
character(len=:), allocatable :: getArg
integer :: l,err
allocate(character(len=0)::getArg)
if (n<0) then
call get_command(getArg, length=l)
else
call get_command_argument(n,getArg,length=l)
endif
deallocate(getArg)
allocate(character(len=l)::getArg)
if (n<0) then
call get_command(getArg, status=err)
else
call get_command_argument(n,getArg,status=err)
endif
if (err /= 0) call quit(1)
end function getArg
end subroutine CLI_init end subroutine CLI_init
!--------------------------------------------------------------------------------------------------
!> @brief Get argument from command line.
!--------------------------------------------------------------------------------------------------
function getArg(n)
integer, intent(in) :: n !< number of the argument
character(len=:), allocatable :: getArg
integer :: l,err
external :: quit
allocate(character(len=0)::getArg)
if (n<0) then
call get_command(getArg, length=l)
else
call get_command_argument(n,getArg,length=l)
endif
deallocate(getArg)
allocate(character(len=l)::getArg)
if (n<0) then
call get_command(getArg, status=err)
else
call get_command_argument(n,getArg,status=err)
endif
if (err /= 0) call quit(1)
end function getArg
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief extract working directory from given argument or from location of geometry file, !> @brief extract working directory from given argument or from location of geometry file,
@ -229,9 +227,11 @@ subroutine setWorkingDirectory(workingDirectoryArg)
character(len=*), intent(in) :: workingDirectoryArg !< working directory argument character(len=*), intent(in) :: workingDirectoryArg !< working directory argument
character(len=:), allocatable :: workingDirectory character(len=:), allocatable :: workingDirectory
logical :: error logical :: error
external :: quit external :: quit
absolutePath: if (workingDirectoryArg(1:1) == '/') then absolutePath: if (workingDirectoryArg(1:1) == '/') then
workingDirectory = workingDirectoryArg workingDirectory = workingDirectoryArg
else absolutePath else absolutePath