From d3579d78fddeb58ebbf00ee28fce0773ad3e920e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 21 Mar 2016 21:09:45 +0100 Subject: [PATCH] fixed string handling and enabled compilation (unfortunately, gfortran needs exceptions) --- code/Makefile | 20 +++++++++++++++++--- code/spectral_interface.f90 | 12 +++++------- code/system_routines.f90 | 6 ++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/code/Makefile b/code/Makefile index 00639ea52..03d486d66 100644 --- a/code/Makefile +++ b/code/Makefile @@ -628,13 +628,27 @@ DAMASK_interface.o: spectral_interface.f90 \ prec.o $(PREFIX) $(COMPILERNAME) $(COMPILE) -c $(INTERFACENAME) -o DAMASK_interface.o $(SUFFIX) +ifeq "$(F90)" "gfortran" prec.o: prec.f90 \ system_routines.o + $(PREFIX) $(COMPILERNAME) $(COMPILE) -c prec.f90 -fno-range-check -fall-intrinsics -fno-fast-math $(SUFFIX) +# fno-range-check: Disable range checking on results of simplification of constant expressions during compilation +# --> allows the definition of DAMASK_NaN +#-fall-intrinsics: all intrinsic procedures (including the GNU-specific extensions) are accepted. -Wintrinsics-std will be ignored +# and no user-defined procedure with the same name as any intrinsic will be called except when it is explicitly declared external +# --> allows the use of 'isnan' +#-fno-fast-math: +# --> otherwise, when setting -ffast-math, isnan always evaluates to false (I would call it a bug) +else -C_routines.o: C_routines.c +prec.o: prec.f90 \ + system_routines.o +endif -system_routines.o: system_routines.f90 \ - C_routines.o +system_routines.o: system_routines.f90 \ + C_routines.o + +C_routines.o: C_routines.c %.o : %.f90 diff --git a/code/spectral_interface.f90 b/code/spectral_interface.f90 index 731225884..8362a2feb 100644 --- a/code/spectral_interface.f90 +++ b/code/spectral_interface.f90 @@ -233,20 +233,20 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA pathSep = getPathSep() - if (len(workingDirectoryArg)>0) then ! got working directory as input + wdGiven: if (len(workingDirectoryArg)>0) then if (workingDirectoryArg(1:1) == pathSep) then ! absolute path given as command line argument storeWorkingDirectory = workingDirectoryArg else error = getCWD2(cwd) ! relative path given as command line argument storeWorkingDirectory = trim(cwd)//pathSep//workingDirectoryArg endif - if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory))) & ! if path seperator is not given, append it - /= pathSep) storeWorkingDirectory = trim(storeWorkingDirectory)//pathSep + if (storeWorkingDirectory(len(trim(storeWorkingDirectory)):len(trim(storeWorkingDirectory)))/= pathSep) & + storeWorkingDirectory = trim(storeWorkingDirectory)//pathSep ! if path seperator is not given, append it if(.not. isDirectory(trim(storeWorkingDirectory))) then ! check if the directory exists write(6,'(a20,a,a16)') ' working directory "',trim(storeWorkingDirectory),'" does not exist' call quit(1_pInt) endif - else ! using path to geometry file as working dir + else wdGiven if (geometryArg(1:1) == pathSep) then ! absolute path given as command line argument storeWorkingDirectory = geometryArg(1:scan(geometryArg,pathSep,back=.true.)) else @@ -254,7 +254,7 @@ character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryA storeWorkingDirectory = trim(cwd)//pathSep//& geometryArg(1:scan(geometryArg,pathSep,back=.true.)) endif - endif + endif wdGiven storeWorkingDirectory = rectifyPath(storeWorkingDirectory) end function storeWorkingDirectory @@ -264,8 +264,6 @@ end function storeWorkingDirectory !> @brief simply returns the private string workingDir !-------------------------------------------------------------------------------------------------- character(len=1024) function getSolverWorkingDirectoryName() - use system_routines, only: & - getCWD2 implicit none getSolverWorkingDirectoryName = workingDirectory diff --git a/code/system_routines.f90 b/code/system_routines.f90 index 5a8d9ef22..15107db5a 100644 --- a/code/system_routines.f90 +++ b/code/system_routines.f90 @@ -50,11 +50,13 @@ contains C_NULL_CHAR implicit none - character(len=1024), intent(out) :: str + character(len=*), intent(out) :: str + character(len=1024) :: strFixedLength integer(C_INT) :: stat str = repeat(C_NULL_CHAR,1024) - call getCurrentWorkDir_C(str,stat) + call getCurrentWorkDir_C(strFixedLength,stat) + str = strFixedLength(1:scan(strFixedLength,C_NULL_CHAR,.True.)-1) getCWD2=merge(.True.,.False.,stat /= 0_C_INT) end function getCWD2