better use intrinsic F2003 features
This commit is contained in:
parent
702230adee
commit
c1d4b64b13
|
@ -29,10 +29,7 @@ module DAMASK_interface
|
||||||
getGeometryFile, &
|
getGeometryFile, &
|
||||||
getLoadCaseFile, &
|
getLoadCaseFile, &
|
||||||
rectifyPath, &
|
rectifyPath, &
|
||||||
makeRelativePath, &
|
makeRelativePath
|
||||||
IIO_stringValue, &
|
|
||||||
IIO_intValue, &
|
|
||||||
IIO_stringPos
|
|
||||||
contains
|
contains
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
@ -93,11 +90,13 @@ subroutine DAMASK_interface_init()
|
||||||
implicit none
|
implicit none
|
||||||
character(len=1024) :: &
|
character(len=1024) :: &
|
||||||
commandLine, & !< command line call as string
|
commandLine, & !< command line call as string
|
||||||
loadcaseArg = '', & !< -l argument given to the executable
|
arg, & !< individual argument
|
||||||
|
loadCaseArg = '', & !< -l argument given to the executable
|
||||||
geometryArg = '', & !< -g argument given to the executable
|
geometryArg = '', & !< -g argument given to the executable
|
||||||
workingDirArg = '', & !< -w argument given to the executable
|
workingDirArg = '', & !< -w argument given to the executable
|
||||||
userName !< name of user calling the executable
|
userName !< name of user calling the executable
|
||||||
integer :: &
|
integer :: &
|
||||||
|
stat, &
|
||||||
i, &
|
i, &
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
threadLevel, &
|
threadLevel, &
|
||||||
|
@ -105,8 +104,6 @@ subroutine DAMASK_interface_init()
|
||||||
worldrank = 0, &
|
worldrank = 0, &
|
||||||
worldsize = 0, &
|
worldsize = 0, &
|
||||||
typeSize
|
typeSize
|
||||||
integer, allocatable, dimension(:) :: &
|
|
||||||
chunkPos
|
|
||||||
integer, dimension(8) :: &
|
integer, dimension(8) :: &
|
||||||
dateAndTime
|
dateAndTime
|
||||||
integer :: mpi_err
|
integer :: mpi_err
|
||||||
|
@ -198,10 +195,9 @@ subroutine DAMASK_interface_init()
|
||||||
call quit(1)
|
call quit(1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call get_command(commandLine)
|
do i = 1, command_argument_count()
|
||||||
chunkPos = IIO_stringPos(commandLine)
|
call get_command_argument(i,arg)
|
||||||
do i = 2, chunkPos(1)
|
select case(trim(arg)) ! extract key
|
||||||
select case(IIO_stringValue(commandLine,chunkPos,i)) ! extract key
|
|
||||||
case ('-h','--help')
|
case ('-h','--help')
|
||||||
write(6,'(a)') ' #######################################################################'
|
write(6,'(a)') ' #######################################################################'
|
||||||
write(6,'(a)') ' DAMASK Command Line Interface:'
|
write(6,'(a)') ' DAMASK Command Line Interface:'
|
||||||
|
@ -240,14 +236,17 @@ subroutine DAMASK_interface_init()
|
||||||
write(6,'(a,/)')' Prints this message and exits'
|
write(6,'(a,/)')' Prints this message and exits'
|
||||||
call quit(0) ! normal Termination
|
call quit(0) ! normal Termination
|
||||||
case ('-l', '--load', '--loadcase')
|
case ('-l', '--load', '--loadcase')
|
||||||
if ( i < chunkPos(1)) loadcaseArg = trim(IIO_stringValue(commandLine,chunkPos,i+1))
|
call get_command_argument(i+1,loadCaseArg)
|
||||||
case ('-g', '--geom', '--geometry')
|
case ('-g', '--geom', '--geometry')
|
||||||
if (i < chunkPos(1)) geometryArg = trim(IIO_stringValue(commandLine,chunkPos,i+1))
|
call get_command_argument(i+1,geometryArg)
|
||||||
case ('-w', '-d', '--wd', '--directory', '--workingdir', '--workingdirectory')
|
case ('-w', '-d', '--wd', '--directory', '--workingdir', '--workingdirectory')
|
||||||
if (i < chunkPos(1)) workingDirArg = trim(IIO_stringValue(commandLine,chunkPos,i+1))
|
call get_command_argument(i+1,workingDirArg)
|
||||||
case ('-r', '--rs', '--restart')
|
case ('-r', '--rs', '--restart')
|
||||||
if (i < chunkPos(1)) then
|
call get_command_argument(i+1,arg)
|
||||||
interface_restartInc = IIO_IntValue(commandLine,chunkPos,i+1)
|
read(arg,*,iostat=stat) interface_restartInc
|
||||||
|
if (interface_restartInc < 0 .or. stat /=0) then
|
||||||
|
write(6,'(a)') ' Could not parse restart increment: '//trim(arg)
|
||||||
|
call quit(1)
|
||||||
endif
|
endif
|
||||||
end select
|
end select
|
||||||
enddo
|
enddo
|
||||||
|
@ -261,6 +260,7 @@ subroutine DAMASK_interface_init()
|
||||||
geometryFile = getGeometryFile(geometryArg)
|
geometryFile = getGeometryFile(geometryArg)
|
||||||
loadCaseFile = getLoadCaseFile(loadCaseArg)
|
loadCaseFile = getLoadCaseFile(loadCaseArg)
|
||||||
|
|
||||||
|
call get_command(commandLine)
|
||||||
call get_environment_variable('USER',userName)
|
call get_environment_variable('USER',userName)
|
||||||
! ToDo: https://stackoverflow.com/questions/8953424/how-to-get-the-username-in-c-c-in-linux
|
! ToDo: https://stackoverflow.com/questions/8953424/how-to-get-the-username-in-c-c-in-linux
|
||||||
write(6,'(/,a,i4.1)') ' MPI processes: ',worldsize
|
write(6,'(/,a,i4.1)') ' MPI processes: ',worldsize
|
||||||
|
@ -498,67 +498,4 @@ subroutine setSIGUSR2(signal) bind(C)
|
||||||
|
|
||||||
end subroutine setSIGUSR2
|
end subroutine setSIGUSR2
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief taken from IO, check IO_stringValue for documentation
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
pure function IIO_stringValue(string,chunkPos,myChunk)
|
|
||||||
|
|
||||||
implicit none
|
|
||||||
integer, dimension(:), intent(in) :: chunkPos !< positions of start and end of each tag/chunk in given string
|
|
||||||
integer, intent(in) :: myChunk !< position number of desired chunk
|
|
||||||
character(len=chunkPos(myChunk*2+1)-chunkPos(myChunk*2)+1) :: IIO_stringValue
|
|
||||||
character(len=*), intent(in) :: string !< raw input with known start and end of each chunk
|
|
||||||
|
|
||||||
IIO_stringValue = string(chunkPos(myChunk*2):chunkPos(myChunk*2+1))
|
|
||||||
|
|
||||||
end function IIO_stringValue
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief taken from IO, check IO_intValue for documentation
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
integer pure function IIO_intValue(string,chunkPos,myChunk)
|
|
||||||
|
|
||||||
implicit none
|
|
||||||
character(len=*), intent(in) :: string !< raw input with known start and end of each chunk
|
|
||||||
integer, intent(in) :: myChunk !< position number of desired sub string
|
|
||||||
integer, dimension(:), intent(in) :: chunkPos !< positions of start and end of each tag/chunk in given string
|
|
||||||
|
|
||||||
|
|
||||||
valuePresent: if (myChunk > chunkPos(1) .or. myChunk < 1) then
|
|
||||||
IIO_intValue = 0
|
|
||||||
else valuePresent
|
|
||||||
read(UNIT=string(chunkPos(myChunk*2):chunkPos(myChunk*2+1)),ERR=100,FMT=*) IIO_intValue
|
|
||||||
endif valuePresent
|
|
||||||
return
|
|
||||||
100 IIO_intValue = huge(1)
|
|
||||||
|
|
||||||
end function IIO_intValue
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief taken from IO, check IO_stringPos for documentation
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
pure function IIO_stringPos(string)
|
|
||||||
|
|
||||||
implicit none
|
|
||||||
integer, dimension(:), allocatable :: IIO_stringPos
|
|
||||||
character(len=*), intent(in) :: string !< string in which chunks are searched for
|
|
||||||
|
|
||||||
character(len=*), parameter :: SEP=achar(44)//achar(32)//achar(9)//achar(10)//achar(13) ! comma and whitespaces
|
|
||||||
integer :: left, right
|
|
||||||
|
|
||||||
allocate(IIO_stringPos(1), source=0)
|
|
||||||
right = 0
|
|
||||||
|
|
||||||
do while (verify(string(right+1:),SEP)>0)
|
|
||||||
left = right + verify(string(right+1:),SEP)
|
|
||||||
right = left + scan(string(left:),SEP) - 2
|
|
||||||
IIO_stringPos = [IIO_stringPos,left, right]
|
|
||||||
IIO_stringPos(1) = IIO_stringPos(1)+1
|
|
||||||
enddo
|
|
||||||
|
|
||||||
end function IIO_stringPos
|
|
||||||
|
|
||||||
end module
|
end module
|
||||||
|
|
Loading…
Reference in New Issue