simplifying

This commit is contained in:
Martin Diehl 2016-05-05 15:11:28 +02:00
parent ba0b278aca
commit 0c105658c3
3 changed files with 10 additions and 22 deletions

View File

@ -14,7 +14,7 @@ void getcurrentworkdir_c(char cwd[], int *stat ){
if(getcwd(cwd_tmp, sizeof(cwd_tmp)) == cwd_tmp){ if(getcwd(cwd_tmp, sizeof(cwd_tmp)) == cwd_tmp){
*stat = 0; *stat = 0;
strcpy(cwd, cwd_tmp); strcpy(cwd, cwd_tmp);
} }
else{ else{
*stat = 1; *stat = 1;
} }

View File

@ -185,7 +185,7 @@ subroutine DAMASK_interface_init(loadCaseParameterIn,geometryParameterIn)
call quit(1_pInt) call quit(1_pInt)
endif endif
workingDirectory = storeWorkingDirectory(trim(workingDirArg),trim(geometryArg)) workingDirectory = trim(storeWorkingDirectory(trim(workingDirArg),trim(geometryArg)))
geometryFile = getGeometryFile(geometryArg) geometryFile = getGeometryFile(geometryArg)
loadCaseFile = getLoadCaseFile(loadCaseArg) loadCaseFile = getLoadCaseFile(loadCaseArg)
@ -230,16 +230,14 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA
logical :: error logical :: error
external :: quit external :: quit
pathSep = getPathSep() pathSep = getPathSep()
wdGiven: if (len(workingDirectoryArg)>0) then wdGiven: if (len(workingDirectoryArg)>0) then
if (workingDirectoryArg(1:1) == pathSep) then ! absolute path given as command line argument absolutePath: if (workingDirectoryArg(1:1) == pathSep) then
storeWorkingDirectory = workingDirectoryArg storeWorkingDirectory = workingDirectoryArg
else else absolutePath
error = getCWD(cwd) ! relative path given as command line argument error = getCWD(cwd)
storeWorkingDirectory = trim(cwd)//pathSep//workingDirectoryArg storeWorkingDirectory = trim(cwd)//pathSep//workingDirectoryArg
endif endif absolutePath
if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory)))/= pathSep) & if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory)))/= pathSep) &
storeWorkingDirectory = trim(storeWorkingDirectory)//pathSep ! if path seperator is not given, append it storeWorkingDirectory = trim(storeWorkingDirectory)//pathSep ! if path seperator is not given, append it
if(.not. isDirectory(trim(storeWorkingDirectory))) then ! check if the directory exists if(.not. isDirectory(trim(storeWorkingDirectory))) then ! check if the directory exists
@ -255,7 +253,7 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA
geometryArg(1:scan(geometryArg,pathSep,back=.true.)) geometryArg(1:scan(geometryArg,pathSep,back=.true.))
endif endif
endif wdGiven endif wdGiven
storeWorkingDirectory = rectifyPath(storeWorkingDirectory) storeWorkingDirectory = trim(rectifyPath(storeWorkingDirectory))
end function storeWorkingDirectory end function storeWorkingDirectory
@ -302,14 +300,10 @@ 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
character :: pathSep character :: pathSep
logical :: error logical :: error
@ -321,8 +315,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
error = getCWD(cwd) getGeometryFile = rectifyPath(trim(workingDirectory)//pathSep//getGeometryFile)
getGeometryFile = rectifyPath(trim(cwd)//pathSep//getGeometryFile)
else else
getGeometryFile = rectifyPath(getGeometryFile) getGeometryFile = rectifyPath(getGeometryFile)
endif endif
@ -336,14 +329,10 @@ 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 logical :: error
character :: pathSep character :: pathSep
@ -355,8 +344,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
error = getCWD(cwd) getLoadCaseFile = rectifyPath(trim(workingDirectory)//pathSep//getLoadCaseFile)
getLoadCaseFile = rectifyPath(trim(cwd)//pathSep//getLoadCaseFile)
else else
getLoadCaseFile = rectifyPath(getLoadCaseFile) getLoadCaseFile = rectifyPath(getLoadCaseFile)
endif endif

View File

@ -64,7 +64,7 @@ logical function getCWD(str)
character(len=1024) :: strFixedLength character(len=1024) :: strFixedLength
integer(C_INT) :: stat integer(C_INT) :: stat
str = repeat(C_NULL_CHAR,1024) str = repeat(C_NULL_CHAR,len(str))
call getCurrentWorkDir_C(strFixedLength,stat) call getCurrentWorkDir_C(strFixedLength,stat)
str = strFixedLength(1:scan(strFixedLength,C_NULL_CHAR,.True.)-1) str = strFixedLength(1:scan(strFixedLength,C_NULL_CHAR,.True.)-1)
getCWD=merge(.True.,.False.,stat /= 0_C_INT) getCWD=merge(.True.,.False.,stat /= 0_C_INT)