the working directory and pathes of load and geometry files are now consistent.

This commit is contained in:
Jaeyong Jung 2018-06-29 15:36:12 +02:00
parent a8c69dfcad
commit 613e976a86
2 changed files with 24 additions and 48 deletions

@ -1 +1 @@
Subproject commit cd02f6c1a481491eb4517651516b8311348b4777 Subproject commit 798facf8e983c26dd635aca6a4b2c0b7ae3568fc

View File

@ -222,7 +222,6 @@ end subroutine DAMASK_interface_init
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @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,
!! possibly converting relative arguments to absolut path !! possibly converting relative arguments to absolut path
!> @todo change working directory with call chdir(storeWorkingDirectory)?
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
character(len=1024) function storeWorkingDirectory(workingDirectoryArg) character(len=1024) function storeWorkingDirectory(workingDirectoryArg)
use system_routines, only: & use system_routines, only: &
@ -231,7 +230,6 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg)
implicit none implicit none
character(len=*), intent(in) :: workingDirectoryArg !< working directory argument character(len=*), intent(in) :: workingDirectoryArg !< working directory argument
character(len=1024) :: cwd
logical :: error logical :: error
external :: quit external :: quit
@ -239,16 +237,13 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg)
absolutePath: if (workingDirectoryArg(1:1) == '/') then absolutePath: if (workingDirectoryArg(1:1) == '/') then
storeWorkingDirectory = workingDirectoryArg storeWorkingDirectory = workingDirectoryArg
else absolutePath else absolutePath
error = getCWD(cwd) error = getCWD(storeWorkingDirectory)
if (error) call quit(1_pInt) if (error) call quit(1_pInt)
storeWorkingDirectory = trim(cwd)//'/'//workingDirectoryArg storeWorkingDirectory = trim(storeWorkingDirectory)//'/'//workingDirectoryArg
endif absolutePath endif absolutePath
if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory))) /= '/') &
storeWorkingDirectory = trim(storeWorkingDirectory)//'/' ! if path seperator is not given, append it
else wdGiven else wdGiven
error = getCWD(cwd) ! relative path given as command line argument error = getCWD(storeWorkingDirectory) ! relative path given as command line argument
if (error) call quit(1_pInt) if (error) call quit(1_pInt)
storeWorkingDirectory = trim(cwd)//'/'
endif wdGiven endif wdGiven
storeWorkingDirectory = trim(rectifyPath(storeWorkingDirectory)) storeWorkingDirectory = trim(rectifyPath(storeWorkingDirectory))
@ -257,6 +252,9 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg)
call quit(1_pInt) call quit(1_pInt)
endif endif
if (storeWorkingDirectory(len_trim(storeWorkingDirectory):len_trim(storeWorkingDirectory)) /= '/') &
storeWorkingDirectory = trim(storeWorkingDirectory)//'/' ! if path seperator is not given, append it
end function storeWorkingDirectory end function storeWorkingDirectory
@ -301,35 +299,23 @@ end function getSolverJobName
!> @brief basename of geometry file with extension from command line arguments !> @brief basename of geometry file with extension from command line arguments
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
character(len=1024) function getGeometryFile(geometryParameter) character(len=1024) function getGeometryFile(geometryParameter)
use system_routines, only: &
getCWD
implicit none implicit none
character(len=1024), intent(in) :: & character(len=1024), intent(in) :: &
geometryParameter geometryParameter
character(len=1024) :: &
cwd
integer :: posExt, posSep integer :: posExt, posSep
logical :: error
external :: quit external :: quit
getGeometryFile = geometryParameter getGeometryFile = trim(geometryParameter)
posExt = scan(getGeometryFile,'.',back=.true.) posExt = scan(getGeometryFile,'.',back=.true.)
posSep = scan(getGeometryFile,'/',back=.true.) posSep = scan(getGeometryFile,'/',back=.true.)
if (posExt <= posSep) getGeometryFile = trim(getGeometryFile)//('.geom') ! no extension present if (posExt <= posSep) getGeometryFile = trim(getGeometryFile)//('.geom')
if (scan(getGeometryFile,'/') /= 1) then ! relative path given as command line argument if (scan(getGeometryFile,'/') /= 1) &
! error = getcwd(cwd) getGeometryFile = trim(getSolverWorkingDirectoryName())//trim(getGeometryFile)
! if (error) call quit(1_pInt)
! getGeometryFile = rectifyPath(trim(workingDirectory)//'/'//getGeometryFile) getGeometryFile = makeRelativePath(getSolverWorkingDirectoryName(), rectifyPath(getGeometryFile))
getGeometryFile = rectifyPath(trim(getSolverWorkingDirectoryName())//trim(getGeometryFile))
else
getGeometryFile = rectifyPath(getGeometryFile)
endif
write(*,*) 'getsolv.. ', (getSolverWorkingDirectoryName())
write(*,*) 'getGeometryFile.. ', (getGeometryFile)
getGeometryFile = makeRelativePath(getSolverWorkingDirectoryName(), getGeometryFile)
end function getGeometryFile end function getGeometryFile
@ -338,39 +324,29 @@ end function getGeometryFile
!> @brief relative path of loadcase from command line arguments !> @brief relative path of loadcase from command line arguments
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
character(len=1024) function getLoadCaseFile(loadCaseParameter) character(len=1024) function getLoadCaseFile(loadCaseParameter)
use system_routines, only: &
getCWD
implicit none implicit none
character(len=1024), intent(in) :: & character(len=1024), intent(in) :: &
loadCaseParameter loadCaseParameter
character(len=1024) :: &
cwd
integer :: posExt, posSep integer :: posExt, posSep
logical :: error
external :: quit external :: quit
getLoadCaseFile = loadcaseParameter getLoadCaseFile = trim(loadCaseParameter)
posExt = scan(getLoadCaseFile,'.',back=.true.) posExt = scan(getLoadCaseFile,'.',back=.true.)
posSep = scan(getLoadCaseFile,'/',back=.true.) posSep = scan(getLoadCaseFile,'/',back=.true.)
if (posExt <= posSep) getLoadCaseFile = trim(getLoadCaseFile)//('.load') ! no extension present if (posExt <= posSep) getLoadCaseFile = trim(getLoadCaseFile)//('.load')
if (scan(getLoadCaseFile,'/') /= 1) then ! relative path given as command line argument if (scan(getLoadCaseFile,'/') /= 1) &
! error = getcwd(cwd) getLoadCaseFile = trim(getSolverWorkingDirectoryName())//trim(getLoadCaseFile)
! if (error) call quit(1_pInt)
! getLoadCaseFile = rectifyPath(trim(workingDirectory)//'/'//getLoadCaseFile)
getLoadCaseFile = rectifyPath(trim(getSolverWorkingDirectoryName())//trim(getLoadCaseFile))
else
getLoadCaseFile = rectifyPath(getLoadCaseFile)
endif
getLoadCaseFile = makeRelativePath(getSolverWorkingDirectoryName(), getLoadCaseFile) getLoadCaseFile = makeRelativePath(getSolverWorkingDirectoryName(), rectifyPath(getLoadCaseFile))
end function getLoadCaseFile end function getLoadCaseFile
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief remove ../ and /./ from path !> @brief remove ../ and /./ from path.
!> @details works only if absolute path is given
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
function rectifyPath(path) function rectifyPath(path)
@ -384,14 +360,14 @@ function rectifyPath(path)
l = len_trim(path) l = len_trim(path)
rectifyPath = path rectifyPath = path
do i = l,3,-1 do i = l,3,-1
if (rectifyPath(i-2:i) == '/'//'.'//'/') & if (rectifyPath(i-2:i) == '/./') &
rectifyPath(i-1:l) = rectifyPath(i+1:l)//' ' rectifyPath(i-1:l) = rectifyPath(i+1:l)//' '
enddo enddo
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! remove ../ and corresponding directory from rectifyPath ! remove ../ and corresponding directory from rectifyPath
l = len_trim(rectifyPath) l = len_trim(rectifyPath)
i = index(rectifyPath(i:l),'..'//'/') i = index(rectifyPath(i:l),'../')
j = 0 j = 0
do while (i > j) do while (i > j)
j = scan(rectifyPath(1:i-2),'/',back=.true.) j = scan(rectifyPath(1:i-2),'/',back=.true.)
@ -401,7 +377,7 @@ function rectifyPath(path)
rectifyPath(j+1:k-1) = rectifyPath(j+2:k) rectifyPath(j+1:k-1) = rectifyPath(j+2:k)
rectifyPath(k:k) = ' ' rectifyPath(k:k) = ' '
endif endif
i = j+index(rectifyPath(j+1:l),'..'//'/') i = j+index(rectifyPath(j+1:l),'../')
enddo enddo
if(len_trim(rectifyPath) == 0) rectifyPath = '/' if(len_trim(rectifyPath) == 0) rectifyPath = '/'