function version seems to be quasei-standard, not subroutine for getcwd

This commit is contained in:
Martin Diehl 2014-02-14 19:59:37 +00:00
parent 0cb676f41f
commit 8bbba55506
1 changed files with 16 additions and 5 deletions

View File

@ -234,6 +234,9 @@ end subroutine DAMASK_interface_init
!> @todo change working directory with call chdir(storeWorkingDirectory)? !> @todo change working directory with call chdir(storeWorkingDirectory)?
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryArg) character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryArg)
#ifdef __INTEL_COMPILER
use IFPORT
#endif
implicit none implicit none
character(len=*), intent(in) :: workingDirectoryArg !< working directory argument character(len=*), intent(in) :: workingDirectoryArg !< working directory argument
@ -242,13 +245,14 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA
character :: pathSep character :: pathSep
logical :: dirExists logical :: dirExists
external :: quit external :: quit
integer :: error
pathSep = getPathSep() pathSep = getPathSep()
if (len(workingDirectoryArg)>0) then ! got working directory as input if (len(workingDirectoryArg)>0) then ! got working directory as input
if (workingDirectoryArg(1:1) == pathSep) then ! absolute path given as command line argument if (workingDirectoryArg(1:1) == pathSep) then ! absolute path given as command line argument
storeWorkingDirectory = workingDirectoryArg storeWorkingDirectory = workingDirectoryArg
else else
call getcwd(cwd) ! relative path given as command line argument error = getcwd(cwd) ! relative path given as command line argument
storeWorkingDirectory = trim(cwd)//pathSep//workingDirectoryArg storeWorkingDirectory = trim(cwd)//pathSep//workingDirectoryArg
endif endif
if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory))) & ! if path seperator is not given, append it if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory))) & ! if path seperator is not given, append it
@ -262,7 +266,7 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA
if (geometryArg(1:1) == pathSep) then ! absolute path given as command line argument if (geometryArg(1:1) == pathSep) then ! absolute path given as command line argument
storeWorkingDirectory = geometryArg(1:scan(geometryArg,pathSep,back=.true.)) storeWorkingDirectory = geometryArg(1:scan(geometryArg,pathSep,back=.true.))
else else
call getcwd(cwd) ! relative path given as command line argument error = getcwd(cwd) ! relative path given as command line argument
storeWorkingDirectory = trim(cwd)//pathSep//& storeWorkingDirectory = trim(cwd)//pathSep//&
geometryArg(1:scan(geometryArg,pathSep,back=.true.)) geometryArg(1:scan(geometryArg,pathSep,back=.true.))
endif endif
@ -314,6 +318,9 @@ 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)
#ifdef __INTEL_COMPILER
use IFPORT
#endif
implicit none implicit none
character(len=1024), intent(in) :: & character(len=1024), intent(in) :: &
@ -322,6 +329,7 @@ character(len=1024) function getGeometryFile(geometryParameter)
cwd cwd
integer :: posExt, posSep integer :: posExt, posSep
character :: pathSep character :: pathSep
integer :: error
getGeometryFile = geometryParameter getGeometryFile = geometryParameter
pathSep = getPathSep() pathSep = getPathSep()
@ -330,7 +338,7 @@ character(len=1024) function getGeometryFile(geometryParameter)
if (posExt <= posSep) getGeometryFile = trim(getGeometryFile)//('.geom') ! no extension present if (posExt <= posSep) getGeometryFile = trim(getGeometryFile)//('.geom') ! no extension present
if (scan(getGeometryFile,pathSep) /= 1) then ! relative path given as command line argument if (scan(getGeometryFile,pathSep) /= 1) then ! relative path given as command line argument
call getcwd(cwd) error = getcwd(cwd)
getGeometryFile = rectifyPath(trim(cwd)//pathSep//getGeometryFile) getGeometryFile = rectifyPath(trim(cwd)//pathSep//getGeometryFile)
else else
getGeometryFile = rectifyPath(getGeometryFile) getGeometryFile = rectifyPath(getGeometryFile)
@ -345,13 +353,16 @@ 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)
#ifdef __INTEL_COMPILER
use IFPORT
#endif
implicit none implicit none
character(len=1024), intent(in) :: & character(len=1024), intent(in) :: &
loadCaseParameter loadCaseParameter
character(len=1024) :: & character(len=1024) :: &
cwd cwd
integer :: posExt, posSep integer :: posExt, posSep, error
character :: pathSep character :: pathSep
getLoadCaseFile = loadcaseParameter getLoadCaseFile = loadcaseParameter
@ -361,7 +372,7 @@ character(len=1024) function getLoadCaseFile(loadCaseParameter)
if (posExt <= posSep) getLoadCaseFile = trim(getLoadCaseFile)//('.load') ! no extension present if (posExt <= posSep) getLoadCaseFile = trim(getLoadCaseFile)//('.load') ! no extension present
if (scan(getLoadCaseFile,pathSep) /= 1) then ! relative path given as command line argument if (scan(getLoadCaseFile,pathSep) /= 1) then ! relative path given as command line argument
call getcwd(cwd) error = getcwd(cwd)
getLoadCaseFile = rectifyPath(trim(cwd)//pathSep//getLoadCaseFile) getLoadCaseFile = rectifyPath(trim(cwd)//pathSep//getLoadCaseFile)
else else
getLoadCaseFile = rectifyPath(getLoadCaseFile) getLoadCaseFile = rectifyPath(getLoadCaseFile)