From 8a9c5efbe707542186f3c506d8d19482646bfd65 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 5 May 2016 16:16:21 +0200 Subject: [PATCH] working for ifort --- code/C_routines.c | 2 +- code/spectral_interface.f90 | 4 ++-- code/system_routines.f90 | 16 +++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/code/C_routines.c b/code/C_routines.c index 242d5344c..7be6264d7 100644 --- a/code/C_routines.c +++ b/code/C_routines.c @@ -12,8 +12,8 @@ void getcurrentworkdir_c(char cwd[], int *stat ){ char cwd_tmp[1024]; if(getcwd(cwd_tmp, sizeof(cwd_tmp)) == cwd_tmp){ + strcpy(cwd,cwd_tmp); *stat = 0; - strcpy(cwd, cwd_tmp); } else{ *stat = 1; diff --git a/code/spectral_interface.f90 b/code/spectral_interface.f90 index 11339ccb3..e827904b9 100644 --- a/code/spectral_interface.f90 +++ b/code/spectral_interface.f90 @@ -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 diff --git a/code/system_routines.f90 b/code/system_routines.f90 index cfd326277..8d8845dad 100644 --- a/code/system_routines.f90 +++ b/code/system_routines.f90 @@ -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