working for ifort

This commit is contained in:
Martin Diehl 2016-05-05 16:16:21 +02:00
parent e0cc66950f
commit 8a9c5efbe7
3 changed files with 14 additions and 8 deletions

View File

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

View File

@ -236,6 +236,7 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA
storeWorkingDirectory = workingDirectoryArg
else absolutePath
error = getCWD(cwd)
if (error) call quit(1_pInt)
storeWorkingDirectory = trim(cwd)//pathSep//workingDirectoryArg
endif absolutePath
if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory)))/= pathSep) &
@ -249,6 +250,7 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA
storeWorkingDirectory = geometryArg(1:scan(geometryArg,pathSep,back=.true.))
else
error = getCWD(cwd) ! relative path given as command line argument
if (error) call quit(1_pInt)
storeWorkingDirectory = trim(cwd)//pathSep//&
geometryArg(1:scan(geometryArg,pathSep,back=.true.))
endif
@ -306,7 +308,6 @@ character(len=1024) function getGeometryFile(geometryParameter)
geometryParameter
integer :: posExt, posSep
character :: pathSep
logical :: error
getGeometryFile = geometryParameter
pathSep = getPathSep()
@ -334,7 +335,6 @@ character(len=1024) function getLoadCaseFile(loadCaseParameter)
character(len=1024), intent(in) :: &
loadCaseParameter
integer :: posExt, posSep
logical :: error
character :: pathSep
getLoadCaseFile = loadcaseParameter

View File

@ -25,7 +25,7 @@ interface
use, intrinsic :: ISO_C_Binding, only: &
C_INT, &
C_CHAR
character(kind=c_char), dimension(*), intent(out) :: str
character(kind=c_char), dimension(1024), intent(out) :: str ! C string is an array
integer(C_INT),intent(out) :: stat
end subroutine getCurrentWorkDir_C
@ -58,15 +58,21 @@ logical function getCWD(str)
C_INT, &
C_CHAR, &
C_NULL_CHAR
implicit none
character(len=*), intent(out) :: str
character(len=1024) :: strFixedLength
character(kind=c_char), dimension(1024) :: strFixedLength ! C string is an array
integer(C_INT) :: stat
integer :: i
str = repeat(C_NULL_CHAR,len(str))
str = repeat('',len(str))
call getCurrentWorkDir_C(strFixedLength,stat)
str = strFixedLength(1:scan(strFixedLength,C_NULL_CHAR,.True.)-1)
do i=1,1024 ! copy array components until Null string is found
if (strFixedLength(i) /= C_NULL_CHAR) then
str(i:i)=strFixedLength(i)
else
exit
endif
enddo
getCWD=merge(.True.,.False.,stat /= 0_C_INT)
end function getCWD