From 3a6d5311e3ead75f407fa1150b90a8ce79ee121c Mon Sep 17 00:00:00 2001 From: zhangc43 Date: Fri, 26 Feb 2016 12:30:57 -0500 Subject: [PATCH] auto dependency detection is not working, revert to manual --- CMakeLists.txt | 7 + code/CMakeLists.txt | 42 +- code/Makefile_bk | 699 --------------------------- code/spectral/CMakeLists.txt | 1 - code/spectral/spectral_interface.f90 | 568 ---------------------- 5 files changed, 32 insertions(+), 1285 deletions(-) delete mode 100644 code/Makefile_bk delete mode 100644 code/spectral/spectral_interface.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index a9e672c00..9b14c6efc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,13 @@ if (FEM) set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${LINK_OPTIONS_ifort} -DFEM") endif (FEM) +# set default project compiler flags +# NOTE: some file requires different flags for compiling, DAMASK_$FLAGS +# are essentially the swap for this purpose +set (DAMASK_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" ) +set (DAMASK_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set (DAMASK_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" ) + ## # ADD CODE DIRECTORY add_subdirectory(code) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 544118af7..71d373157 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,15 +1,28 @@ +# The dependency detection for Fortran is not working in CMake +# Have to define them explicitly +add_library(DAMASK_prec "prec.f90") -include_directories(${PROJECT_SRC_DIR}/code) -include_directories(${PROJECT_SRC_DIR}/code/damage) -include_directories(${PROJECT_SRC_DIR}/code/homogenization) -include_directories(${PROJECT_SRC_DIR}/code/hydrogenflux) -include_directories(${PROJECT_SRC_DIR}/code/kinematics) -include_directories(${PROJECT_SRC_DIR}/code/plastic) -include_directories(${PROJECT_SRC_DIR}/code/porosity) -include_directories(${PROJECT_SRC_DIR}/code/source) -include_directories(${PROJECT_SRC_DIR}/code/spectral) -include_directories(${PROJECT_SRC_DIR}/code/thermal) -include_directories(${PROJECT_SRC_DIR}/code/vacancyflux) +################################################################################################### + +################################################################################################### +if (SPECTRAL) + add_library(DAMASK_interface "spectral_interface.f90") + target_link_libraries(DAMASK_interface DAMASK_prec) +endif(SPECTRAL) + +add_library(DAMASK_IO "IO.f90") +target_link_libraries(DAMASK_IO DAMASK_interface) + +add_library(DAMASK_LIBS "libs.f90") +target_link_libraries(DAMASK_LIBS DAMASK_IO) + +add_library(DAMASK_NUMERICS "numerics.f90") +target_link_libraries(DAMASK_NUMERICS DAMASK_LIBS) + +add_library(DAMASK_DEBUG "debug.f90") +target_link_libraries(DAMASK_DEBUG DAMASK_NUMERICS) + +add_library(DAMASK_BASICS ALIAS DAMASK_DEBUG) # group sources for base modules # the FEM modules would require special attention @@ -22,22 +35,17 @@ set (SRC "CPFEM" "constitutive" "crystallite" "damask_hdf5" - "debug" - "FEsolving" - "IO" "lattice" - "libs" "material" "math" "mesh" - "numerics" - "prec" "quit__genmod" ) # compiler base modules foreach (p ${SRC}) add_library (${p} "${p}.f90") + target_link_libraries(${p} DAMASK_BASICS) endforeach (p) # set libraries/modules for linking diff --git a/code/Makefile_bk b/code/Makefile_bk deleted file mode 100644 index a18cbebac..000000000 --- a/code/Makefile_bk +++ /dev/null @@ -1,699 +0,0 @@ -SHELL = /bin/sh -######################################################################################## -# Makefile to compile the Material subroutine for BVP solution using spectral method -######################################################################################## -# Be sure to remove all files compiled with different options by using "make clean" -######################################################################################## -# OPTIONS = standard (alternative): meaning -#------------------------------------------------------------- -# F90 = ifort (gfortran): compiler type, choose Intel or GNU -# COMPILERNAME = name of the compiler executable (if not the same as the ype), e.g. using mpich-g90 instead of ifort -# PORTABLE = TRUE (FALSE): decision, if executable is optimized for the machine on which it was built. -# OPTIMIZATION = DEFENSIVE (OFF,AGGRESSIVE,ULTRA): Optimization mode: O2, O0, O3 + further options for most files, O3 + further options for all files -# OPENMP = TRUE (FALSE): OpenMP multiprocessor support -# PREFIX = arbitrary prefix (before compilername) -# OPTION = arbitrary option (just before file to compile) -# SUFFIX = arbitrary suffix (after file to compile) -# STANDARD_CHECK = checking for Fortran 2008, compiler dependend -######################################################################################## -# including PETSc files. PETSC_ARCH is loaded from these files. -DAMASKVERSION :=$(shell cat ../VERSION) - -include ${PETSC_DIR}/lib/petsc/conf/variables -include ${PETSC_DIR}/lib/petsc/conf/rules - -INCLUDE_DIRS := $(PETSC_FC_INCLUDES) -DPETSc -I../lib -LIBRARIES := $(PETSC_WITH_EXTERNAL_LIB) -COMPILERNAME ?= $(FC) -LINKERNAME ?= $(FLINKER) - -# -# setting up for HDF5 support (hard link for now) -# 1. Location of HDF5 binaries (with include/ and lib/ underneath) -HDF5 = /mnt/research/CMM/opt/hdf5 -# 2. Location of External Libraries (missing in the 1.8.12 version) -LIBZ = /mnt/research/CMM/opt/hdf5/lib/libz.a -LIBSZ = /mnt/research/CMM/opt/hdf5/lib/libsz.a -# 3. Set libraries for HDF5 (LIBS: shared lib, LIBZ: external lib) -HDFLIBS = -I$(HDF5)/include -L$(HDF5)/lib -HDFLIBZ = -L$(LIBZ) -L$(LIBSZ) - -# MPI compiler wrappers will tell if they are pointing to ifort or gfortran -COMPILEROUT :=$(shell $(FC) -show) -# search in FC or COMPILEROUT for gfortran/ifort if not defined -ifeq ($(strip $(F90)),) - F90 :=$(findstring gfortran,$(FC) $(COMPILEROUT)) -endif -ifeq ($(strip $(F90)),) - F90 :=$(findstring ifort,$(FC) $(COMPILEROUT)) -endif - -OPENMP ?= ON -OPTIMIZATION ?= DEFENSIVE - -ifeq "$(OPTIMIZATION)" "OFF" -OPTI := OFF -MAXOPTI := OFF -endif -ifeq "$(OPTIMIZATION)" "DEFENSIVE" -OPTI := DEFENSIVE -MAXOPTI := DEFENSIVE -endif -ifeq "$(OPTIMIZATION)" "AGGRESSIVE" -OPTI := AGGRESSIVE -MAXOPTI := DEFENSIVE -endif -ifeq "$(OPTIMIZATION)" "ULTRA" -OPTI := AGGRESSIVE -MAXOPTI := AGGRESSIVE -endif - -ifndef OPTI -OPTI := DEFENSIVE -MAXOPTI := DEFENSIVE -endif - -# settings for shared memory multicore support -ifeq "$(OPENMP)" "ON" -OPENMP_FLAG_ifort =-openmp -openmp-report0 -parallel -OPENMP_FLAG_gfortran =-fopenmp -endif - -ifdef STANDARD_CHECK -STANDARD_CHECK_ifort =$(STANDARD_CHECK) -STANDARD_CHECK_gfortran =$(STANDARD_CHECK) -endif - -STANDARD_CHECK_ifort ?=-stand f08 -standard-semantics -STANDARD_CHECK_gfortran ?=-std=f2008ts -pedantic-errors - -#-pedantic: more strict on standard, enables some warnings -# -pedantic-errors: like pedantic, but errors instead of warnings -OPTIMIZATION_OFF_ifort :=-O0 -no-ip -OPTIMIZATION_OFF_gfortran :=-O0 -OPTIMIZATION_DEFENSIVE_ifort :=-O2 -OPTIMIZATION_DEFENSIVE_gfortran :=-O2 -OPTIMIZATION_AGGRESSIVE_ifort :=-ipo -O3 -no-prec-div -fp-model fast=2 -xHost #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost -OPTIMIZATION_AGGRESSIVE_gfortran :=-O3 -ffast-math -funroll-loops -ftree-vectorize - - -LINK_OPTIONS_ifort :=-shared-intel -COMPILE_OPTIONS_ifort :=-DDAMASKVERSION=\"${DAMASKVERSION}\"\ - -fpp\ - -ftz\ - -assume byterecl,fpe_summary\ - -diag-disable 5268\ - -warn declarations\ - -warn general\ - -warn usage\ - -warn interfaces\ - -warn ignore_loc\ - -warn alignments\ - -warn unused - -################################################################################################### -#COMPILE SWITCHES -#-shared-intel: Link against shared Intel libraries instead of static ones -#-fpp: preprocessor -#-ftz: flush unterflow to zero, automatically set if O<0,1,2,3> >0 -#-assume byterecl record length is given in bytes (also set by -standard-semantics) -# fpe_summary print list of floating point exceptions occured during execution -#-fimplicit-none: assume "implicit-none" even if not present in source -#-diag-disable: disables warnings, where -# warning ID 5268: the text exceeds right hand column allowed on the line (we have only comments there) -#-warn: enables warnings, where -# declarations: any undeclared names (alternative name: -implicitnone) -# general: warning messages and informational messages are issued by the compiler -# usage: questionable programming practices -# interfaces: checks the interfaces of all SUBROUTINEs called and FUNCTIONs invoked in your compilation against an external set of interface blocks -# ignore_loc: %LOC is stripped from an actual argument -# alignments: data that is not naturally aligned -# unused: declared variables that are never used -# stderrors: warnings about Fortran standard violations are changed to errors (STANDARD_CHECK) -# -################################################################################################### -#MORE OPTIONS FOR DEBUGGING DURING COMPILATION -#-warn: enables warnings, where -# truncated_source: Determines whether warnings occur when source exceeds the maximum column width in fixed-format files. (too many warnings because we have comments beyond character 132) -# uncalled: Determines whether warnings occur when a statement function is never called -# all: -# -name as_is: case sensitive Fortran! - -DEBUG_OPTIONS_ifort :=-g\ - -traceback\ - -gen-interfaces\ - -fp-stack-check\ - -fp-model strict\ - -check bounds,format,output_conversion,pointers,uninit\ - -ftrapuv\ - -fpe-all0\ - -warn errors\ - -warn stderrors\ - -debug-parameters all - -################################################################################################### -#COMPILE SWITCHES FOR RUNTIME DEBUGGING -#-g: Generate symbolic debugging information in the object file -#-traceback: Generate extra information in the object file to provide source file traceback information when a severe error occurs at run time. -#-gen-interfaces: Generate an interface block for each routine. http://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again/ -#-fp-stack-check: Generate extra code after every function call to ensure that the floating-point (FP) stack is in the expected state. -#-ftrapuv Trap uninitalized variables -#-check: checks at runtime, where -# bounds: check if an array index is too small (<1) or too large! -# format: Checking for the data type of an item being formatted for output. -# output_conversion: Checking for the fit of data items within a designated format descriptor field. -# pointers: Checking for certain disassociated or uninitialized pointers or unallocated allocatable objects. -# uninit: Checking for uninitialized variables. -#-fpe-all0 capture all floating-point exceptions, sets -ftz automatically -#-warn: enables warnings, where -# errors: warnings are changed to errors -# stderrors: warnings about Fortran standard violations are changed to errors -# information on http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/ -################################################################################################### -#MORE OPTIONS FOR RUNTIME DEBUGGING -#-heap-arrays: should not be done for OpenMP, but set "ulimit -s unlimited" on shell. Probably it helps also to unlimit other limits -#-check: checks at runtime, where -# arg_temp_created: will cause a lot of warnings because we create a bunch of temporary arrays (performance?) -# stack: -LINK_OPTIONS_gfortran :=-Wl,-undefined,dynamic_lookup -COMPILE_OPTIONS_gfortran :=-DDAMASKVERSION=\"${DAMASKVERSION}\"\ - -xf95-cpp-input\ - -ffree-line-length-132\ - -fimplicit-none\ - -fmodule-private\ - -Wall\ - -Wextra\ - -Wcharacter-truncation\ - -Wunderflow\ - -Wsuggest-attribute=pure\ - -Wsuggest-attribute=noreturn\ - -Wconversion-extra\ - -Wimplicit-procedure\ - -Wno-unused-parameter -#-ffpe-summary=all only for newer gfortran -################################################################################################### -#COMPILE SWITCHES -#-shared -#-Wl,-undefined,dynamic_lookup:ensure to link against dynamic libraries -#-xf95-cpp-input: preprocessor -#-ffree-line-length-132: restrict line length to the standard 132 characters -#-ffpe-summary: print summary of floating point exeptions (‘invalid’, ‘zero’, ‘overflow’, ‘underflow’, ‘inexact’ and ‘denormal’) -#-fimplicit-none: assume "implicit-none" even if not present in source -#-fmodule-private: assume "private" even if not present in source -#-Wcharacter-truncation: warn if character expressions (strings) are truncated -#-Wunderflow: produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation -#-Wsuggest-attribute=pure: -#-Wsuggest-attribute=noreturn: -#-Wconversion-extra -#-Wimplicit-procedure -#-Wall: sets the following Fortran options: -# -Waliasing: warn about possible aliasing of dummy arguments. Specifically, it warns if the same actual argument is associated with a dummy argument with "INTENT(IN)" and a dummy argument with "INTENT(OUT)" in a call with an explicit interface. -# -Wampersand: checks if a character expression is continued proberly by an ampersand at the end of the line and at the beginning of the new line -# -Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime -# -Wconversion: warn about implicit conversions between different type -# -Wsurprising: warn when "suspicious" code constructs are encountered. While technically legal these usually indicate that an error has been made. -# -Wc-binding-type: -# -Wintrinsics-std: only standard intrisics are available, e.g. "call flush(6)" will cause an error -# -Wno-tabs: do not allow tabs in source -# -Wintrinsic-shadow: warn if a user-defined procedure or module procedure has the same name as an intrinsic -# -Wline-truncation: -# -Wtarget-lifetime: -# -Wreal-q-constant: warn about real-literal-constants with 'q' exponent-letter -# -Wunused: a number of unused-xxx warnings -# these are general (non -Fortran options) implied by -Wall -# -Waddress -# -Warray-bounds (only with -O2) -# -Wc++11-compat -# -Wchar-subscripts -# -Wcomment -# -Wformat -# -Wmaybe-uninitialized -# -Wnonnull -# -Wparentheses -# -Wpointer-sign -# -Wreorder -# -Wreturn-type -# -Wsequence-point -# -Wstrict-aliasing -# -Wstrict-overflow=1 -# -Wswitch -# -Wtrigraphs -# -Wuninitialized -# -Wunknown-pragmas -# -Wunused-function -# -Wunused-label -# -Wunused-value -# -Wunused-variable -# -Wvolatile-register-var -#-Wextra: sets the following Fortran options: -# -Wunuses-parameter: -# -Wcompare-reals: -# these are general (non -Fortran options) implied by -Wextra -# -Wclobbered -# -Wempty-body -# -Wignored-qualifiers -# -Wmissing-field-initializers -# -Woverride-init -# -Wsign-compare -# -Wtype-limits -# -Wuninitialized -# -Wunused-but-set-parameter (only with -Wunused or -Wall) -# -Wno-globals - -################################################################################################### -#MORE OPTIONS FOR DEBUGGING DURING COMPILATION -#-Warray-temporarieswarnings: because we have many temporary arrays (performance issue?): -#-Wimplicit-interface: no interfaces for lapack routines -#-Wunsafe-loop-optimizations: warn if the loop cannot be optimized due to nontrivial assumptions. -#-Wstrict-overflow: - -DEBUG_OPTIONS_gfortran :=-g\ - -fbacktrace\ - -fdump-core\ - -fcheck=all\ - -ffpe-trap=invalid,zero,overflow - -################################################################################################### -#COMPILE SWITCHES FOR RUNTIME DEBUGGING -#-ffpe-trap=invalid,\ stop execution if floating point exception is detected (NaN is silent) -# zero,\ -# overflow -#-fcheck=all: sets the following Fortran options: -#array-temps -#bounds -#do -#mem -#pointer -#recursion -################################################################################################### -#MORE OPTIONS FOR RUNTIME DEBUGGING -#-ffpe-trap=precision,\ -# denormal, \ -# underflow - -ifeq "$(DEBUG)" "ON" -COMPILE_OPTIONS_$(F90) +=$(DEBUG_OPTIONS_$(F90)) -LINK_OPTIONS_$(F90) +=$(DEBUG_OPTIONS_$(F90)) -endif -LINK_OPTIONS_$(F90) += $(OPTIMIZATION_$(MAXOPTI)_$(F90)) - -PRECISION_ifort :=-real-size 64 -integer-size 32 -DFLOAT=8 -DINT=4 -#-real-size 32: set precision to one of those 32/64/128 (= 4/8/16 bytes) for standard real (=8 for pReal) -#-integer-size 16: set precision to one of those 16/32/64 (= 2/4/8 bytes) for standard integer (=4 for pInt) -PRECISION_gfortran :=-fdefault-real-8 -fdefault-double-8 -DFLOAT=8 -DINT=4 -#-fdefault-real-8: set precision to 8 bytes for standard real (=8 for pReal). Will set size of double to 16 bytes as long as -fdefault-double-8 is not set -#-fdefault-double-8: set precision to 8 bytes for double real, would be 16 bytes because -fdefault-real-8 is used -#-fdefault-integer-8: Use it to set precision to 8 bytes for integer, don't use it for the standard case of pInt=4 (there is no -fdefault-integer-4) - -################################################################################################### -COMPILE =$(OPENMP_FLAG_$(F90)) $(STANDARD_CHECK_$(F90)) $(OPTIMIZATION_$(OPTI)_$(F90)) $(COMPILE_OPTIONS_$(F90)) $(INCLUDE_DIRS) $(PRECISION_$(F90)) -COMPILE_MAXOPTI =$(OPENMP_FLAG_$(F90)) $(STANDARD_CHECK_$(F90)) $(OPTIMIZATION_$(MAXOPTI)_$(F90)) $(COMPILE_OPTIONS_$(F90)) $(INCLUDE_DIRS) $(PRECISION_$(F90)) -################################################################################################### -SOURCE_FILES = \ - source_thermal_dissipation.o source_thermal_externalheat.o \ - source_damage_isoBrittle.o source_damage_isoDuctile.o source_damage_anisoBrittle.o source_damage_anisoDuctile.o \ - source_vacancy_phenoplasticity.o source_vacancy_irradiation.o source_vacancy_thermalfluc.o - -KINEMATICS_FILES = \ - kinematics_cleavage_opening.o kinematics_slipplane_opening.o \ - kinematics_thermal_expansion.o \ - kinematics_vacancy_strain.o kinematics_hydrogen_strain.o - -PLASTIC_FILES = \ - plastic_dislotwin.o plastic_disloUCLA.o plastic_isotropic.o plastic_j2.o \ - plastic_phenopowerlaw.o plastic_titanmod.o plastic_nonlocal.o plastic_none.o \ - plastic_phenoplus.o - -THERMAL_FILES = \ - thermal_isothermal.o thermal_adiabatic.o thermal_conduction.o - -DAMAGE_FILES = \ - damage_none.o damage_local.o damage_nonlocal.o - -VACANCYFLUX_FILES = \ - vacancyflux_isoconc.o vacancyflux_isochempot.o vacancyflux_cahnhilliard.o - -POROSITY_FILES = \ - porosity_none.o porosity_phasefield.o - -HYDROGENFLUX_FILES = \ - hydrogenflux_isoconc.o hydrogenflux_cahnhilliard.o - -HOMOGENIZATION_FILES = \ - homogenization_RGC.o homogenization_isostrain.o homogenization_none.o - -##################### -# Spectral Solver -##################### -DAMASK_spectral.exe: IGNORE := \# -DAMASK_spectral.exe: COMPILE += -DSpectral -DAMASK_spectral.exe: COMPILE_MAXOPTI += -DSpectral -DAMASK_spectral.exe: MESHNAME := mesh.f90 -DAMASK_spectral.exe: INTERFACENAME := spectral_interface.f90 - -DAMASK_spectral.o: IGNORE := \# -DAMASK_spectral.o: COMPILE += -DSpectral -DAMASK_spectral.o: COMPILE_MAXOPTI += -DSpectral -DAMASK_spectral.o: MESHNAME := mesh.f90 -DAMASK_spectral.o: INTERFACENAME := spectral_interface.f90 - - -SPECTRAL_SOLVER_FILES = spectral_mech_AL.o spectral_mech_Basic.o spectral_mech_Polarisation.o \ - spectral_thermal.o spectral_damage.o - -SPECTRAL_FILES = prec.o DAMASK_interface.o IO.o libs.o numerics.o debug.o math.o damask_hdf5.o \ - FEsolving.o mesh.o material.o lattice.o \ - $(SOURCE_FILES) $(KINEMATICS_FILES) $(PLASTIC_FILES) constitutive.o \ - crystallite.o \ - $(THERMAL_FILES) $(DAMAGE_FILES) $(VACANCYFLUX_FILES) $(HYDROGENFLUX_FILES) $(POROSITY_FILES) \ - $(HOMOGENIZATION_FILES) homogenization.o \ - CPFEM2.o \ - spectral_utilities.o \ - $(SPECTRAL_SOLVER_FILES) - -DAMASK_spectral.exe: DAMASK_spectral.o \ - $(SPECTRAL_FILES) - $(PREFIX) $(LINKERNAME) $(OPENMP_FLAG_$(F90)) $(LINK_OPTIONS_$(F90)) $(STANDARD_CHECK_$(F90)) $(OPTIMIZATION_$(MAXOPTI)_$(F90)) \ - -o DAMASK_spectral.exe DAMASK_spectral.o \ - $(SPECTRAL_FILES) $(LIBRARIES) $(HDFLIBS) $(HDFLIBZ) $(SUFFIX) - - -DAMASK_spectral.o: DAMASK_spectral.f90 \ - $(SPECTRAL_SOLVER_FILES) - $(PREFIX) $(COMPILERNAME) $(COMPILE_MAXOPTI) -c DAMASK_spectral.f90 $(SUFFIX) - -spectral_mech_AL.o: spectral_mech_AL.f90 \ - spectral_utilities.o - -spectral_mech_Polarisation.o: spectral_mech_Polarisation.f90 \ - spectral_utilities.o - -spectral_mech_Basic.o: spectral_mech_Basic.f90 \ - spectral_utilities.o - -spectral_thermal.o: spectral_thermal.f90 \ - spectral_utilities.o - -spectral_damage.o: spectral_damage.f90 \ - spectral_utilities.o - -spectral_utilities.o: spectral_utilities.f90 \ - CPFEM2.o - -##################### -# FEM Solver -##################### -VPATH := ../private/FEM/code -DAMASK_FEM.exe: COMPILE += -DFEM -DAMASK_FEM.exe: COMPILE_MAXOPTI += -DFEM -DAMASK_FEM.exe: MESHNAME := ../private/FEM/code/meshFEM.f90 -DAMASK_FEM.exe: INTERFACENAME := ../private/FEM/code/DAMASK_FEM_interface.f90 -DAMASK_FEM.exe: INCLUDE_DIRS += -I./ - -FEM_SOLVER_FILES = FEM_mech.o FEM_thermal.o FEM_damage.o FEM_vacancyflux.o FEM_porosity.o FEM_hydrogenflux.o - -FEM_FILES = prec.o DAMASK_interface.o FEZoo.o IO.o libs.o numerics.o debug.o math.o \ - FEsolving.o mesh.o material.o lattice.o \ - $(SOURCE_FILES) $(KINEMATICS_FILES) $(PLASTIC_FILES) constitutive.o \ - crystallite.o \ - $(THERMAL_FILES) $(DAMAGE_FILES) $(VACANCYFLUX_FILES) $(HYDROGENFLUX_FILES) $(POROSITY_FILES) \ - $(HOMOGENIZATION_FILES) homogenization.o \ - CPFEM.o \ - FEM_utilities.o $(FEM_SOLVER_FILES) - -DAMASK_FEM.exe: DAMASK_FEM_driver.o - $(PREFIX) $(LINKERNAME) $(OPENMP_FLAG_$(F90)) $(LINK_OPTIONS_$(F90)) $(STANDARD_CHECK_$(F90)) $(OPTIMIZATION_$(MAXOPTI)_$(F90)) \ - -o DAMASK_FEM.exe DAMASK_FEM_driver.o \ - $(FEM_FILES) $(LIBRARIES) $(HDFLIBS) $(HDFLIBZ) $(SUFFIX) - -DAMASK_FEM_driver.o: DAMASK_FEM_driver.f90 $(FEM_SOLVER_FILES) - $(PREFIX) $(COMPILERNAME) $(COMPILE_MAXOPTI) -c ../private/FEM/code/DAMASK_FEM_driver.f90 $(SUFFIX) - -FEM_mech.o: FEM_mech.f90 \ - FEM_utilities.o - -FEM_thermal.o: FEM_thermal.f90 \ - FEM_utilities.o - -FEM_damage.o: FEM_damage.f90 \ - FEM_utilities.o - -FEM_vacancyflux.o: FEM_vacancyflux.f90 \ - FEM_utilities.o - -FEM_porosity.o: FEM_porosity.f90 \ - FEM_utilities.o - -FEM_hydrogenflux.o: FEM_hydrogenflux.f90 \ - FEM_utilities.o - -FEM_utilities.o: FEM_utilities.f90 \ - CPFEM.o - -FEZoo.o: $(wildcard FEZoo.f90) \ - IO.o - $(IGNORE) $(PREFIX) $(COMPILERNAME) $(COMPILE) -c ../private/FEM/code/FEZoo.f90 $(SUFFIX) - touch FEZoo.o - -CPFEM.o: CPFEM.f90 \ - homogenization.o - -CPFEM2.o: CPFEM2.f90 \ - homogenization.o - -homogenization.o: homogenization.f90 \ - $(THERMAL_FILES) \ - $(DAMAGE_FILES) \ - $(VACANCYFLUX_FILES) \ - $(POROSITY_FILES) \ - $(HYDROGENFLUX_FILES) \ - $(HOMOGENIZATION_FILES) - -thermal_isothermal.o: thermal_isothermal.f90 \ - crystallite.o - -thermal_adiabatic.o: thermal_adiabatic.f90 \ - crystallite.o - -thermal_conduction.o: thermal_conduction.f90 \ - crystallite.o - -damage_none.o: damage_none.f90 \ - crystallite.o - -damage_local.o: damage_local.f90 \ - crystallite.o - -damage_nonlocal.o: damage_nonlocal.f90 \ - crystallite.o - -thermal_conduction.o: thermal_conduction.f90 \ - crystallite.o - -vacancyflux_isoconc.o: vacancyflux_isoconc.f90 \ - crystallite.o - -vacancyflux_isochempot.o: vacancyflux_isochempot.f90 \ - crystallite.o - -vacancyflux_cahnhilliard.o: vacancyflux_cahnhilliard.f90 \ - crystallite.o - -porosity_none.o: porosity_none.f90 \ - crystallite.o - -porosity_phasefield.o: porosity_phasefield.f90 \ - crystallite.o - -hydrogenflux_isoconc.o: hydrogenflux_isoconc.f90 \ - crystallite.o - -hydrogenflux_cahnhilliard.o: hydrogenflux_cahnhilliard.f90 \ - crystallite.o - -homogenization_RGC.o: homogenization_RGC.f90 \ - crystallite.o - -homogenization_isostrain.o: homogenization_isostrain.f90 \ - crystallite.o - -homogenization_none.o: homogenization_none.f90 \ - crystallite.o - -crystallite.o: crystallite.f90 \ - constitutive.o - -constitutive.o: constitutive.f90 \ - $(SOURCE_FILES) \ - $(KINEMATICS_FILES) \ - $(PLASTIC_FILES) - -source_thermal_dissipation.o: source_thermal_dissipation.f90 \ - lattice.o - -source_thermal_externalheat.o: source_thermal_externalheat.f90 \ - lattice.o - -source_damage_isoBrittle.o: source_damage_isoBrittle.f90 \ - lattice.o - -source_damage_isoDuctile.o: source_damage_isoDuctile.f90 \ - lattice.o - -source_damage_anisoBrittle.o: source_damage_anisoBrittle.f90 \ - lattice.o - -source_damage_anisoDuctile.o: source_damage_anisoDuctile.f90 \ - lattice.o - -source_vacancy_phenoplasticity.o: source_vacancy_phenoplasticity.f90 \ - lattice.o - -source_vacancy_irradiation.o: source_vacancy_irradiation.f90 \ - lattice.o - -source_vacancy_thermalfluc.o: source_vacancy_thermalfluc.f90 \ - lattice.o - -kinematics_cleavage_opening.o: kinematics_cleavage_opening.f90 \ - lattice.o - -kinematics_slipplane_opening.o: kinematics_slipplane_opening.f90 \ - lattice.o - -kinematics_thermal_expansion.o: kinematics_thermal_expansion.f90 \ - lattice.o - -kinematics_vacancy_strain.o: kinematics_vacancy_strain.f90 \ - lattice.o - -kinematics_hydrogen_strain.o: kinematics_hydrogen_strain.f90 \ - lattice.o - -plastic_nonlocal.o: plastic_nonlocal.f90 \ - lattice.o - -plastic_titanmod.o: plastic_titanmod.f90 \ - lattice.o - -plastic_disloUCLA.o: plastic_disloUCLA.f90 \ - lattice.o - -plastic_dislotwin.o: plastic_dislotwin.f90 \ - lattice.o - -plastic_phenopowerlaw.o: plastic_phenopowerlaw.f90 \ - lattice.o - -plastic_phenoplus.o: plastic_phenoplus.f90 \ - lattice.o - -plastic_isotropic.o: plastic_isotropic.f90 \ - lattice.o - -plastic_j2.o: plastic_j2.f90 \ - lattice.o - -plastic_none.o: plastic_none.f90 \ - lattice.o -ifeq "$(F90)" "gfortran" -lattice.o: lattice.f90 \ - material.o - $(PREFIX) $(COMPILERNAME) $(COMPILE) -ffree-line-length-240 -c lattice.f90 $(SUFFIX) -# long lines for interaction matrix -else -lattice.o: lattice.f90 \ - material.o -endif - -material.o: material.f90 \ - mesh.o - -mesh.o: mesh.f90 \ - $(wildcard meshFEM.f90) \ - FEsolving.o \ - math.o \ - FEZoo.o - $(PREFIX) $(COMPILERNAME) $(COMPILE) -c $(MESHNAME) -o mesh.o $(SUFFIX) - -FEsolving.o: FEsolving.f90 \ - debug.o - -math.o: math.f90 \ - debug.o - -debug.o: debug.f90 \ - numerics.o - -numerics.o: numerics.f90 \ - libs.o - -libs.o: libs.f90 \ - IO.o - -IO.o: IO.f90 \ - DAMASK_interface.o - -ifeq "$(F90)" "gfortran" -DAMASK_interface.o: spectral_interface.f90 \ - $(wildcard DAMASK_FEM_interface.f90) \ - prec.o - $(PREFIX) $(COMPILERNAME) $(COMPILE) -c $(INTERFACENAME) -fall-intrinsics -o DAMASK_interface.o $(SUFFIX) -#-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 'getcwd' -prec.o: prec.f90 - $(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 -DAMASK_interface.o: spectral_interface.f90 \ - $(wildcard DAMASK_FEM_interface.f90) \ - prec.o - $(PREFIX) $(COMPILERNAME) $(COMPILE) -c $(INTERFACENAME) -diag-remark 7410 -stand none -warn nostderrors -o DAMASK_interface.o $(SUFFIX) -# -diag-disable 7410 should disable warning about directory statement in inquire function, but does not work. hence the other 2 statements -prec.o: prec.f90 - $(PREFIX) $(COMPILERNAME) $(COMPILE) -c prec.f90 $(SUFFIX) - -damask_hdf5.o: damask_hdf5.f90 \ - prec.o \ - IO.o - $(PREFIX) $(COMPILERNAME) $(HDFLIBS) $(HDFLIBZ) -c damask_hdf5.f90 $(SUFFIX) -lm -endif - -%.o : %.f90 - $(PREFIX) $(COMPILERNAME) $(COMPILE) -c $< $(SUFFIX) - -.PHONY: tidy -tidy: - @rm -rf *.o - @rm -rf *.mod - @rm -rf *.inst.f90 # for instrumentation - @rm -rf *.pomp.f90 # for instrumentation - @rm -rf *.pp.f90 # for instrumentation - @rm -rf *.pdb # for instrumnentation - @rm -rf *.opari.inc # for instrumnentation - -.PHONY: cleanDAMASK -cleanDAMASK: - @rm -rf *.exe - @rm -rf *.marc - @rm -rf *.o - @rm -rf *.mod - @rm -rf *.inst.f90 # for instrumentation - @rm -rf *.pomp.f90 # for instrumentation - @rm -rf *.pp.f90 # for instrumentation - @rm -rf *.pdb # for instrumentation - @rm -rf *.opari.inc # for instrumentation - -.PHONY: help -help: - F90="$(F90)" - COMPILERNAME="$(COMPILERNAME)" - COMPILEROUT="$(COMPILEROUT)" - diff --git a/code/spectral/CMakeLists.txt b/code/spectral/CMakeLists.txt index 1e16c00c5..136d1ad88 100644 --- a/code/spectral/CMakeLists.txt +++ b/code/spectral/CMakeLists.txt @@ -1,6 +1,5 @@ # group source for sepctral solver driver set (SPECTRAL "spectral_damage" - "spectral_interface" "spectral_mech_AL" "spectral_mech_Basic" "spectral_mech_Polarisation" diff --git a/code/spectral/spectral_interface.f90 b/code/spectral/spectral_interface.f90 deleted file mode 100644 index b24c5f747..000000000 --- a/code/spectral/spectral_interface.f90 +++ /dev/null @@ -1,568 +0,0 @@ -!-------------------------------------------------------------------------------------------------- -! $Id$ -!-------------------------------------------------------------------------------------------------- -!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH -!> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH -!> @brief Interfacing between the spectral solver and the material subroutines provided -!! by DAMASK -!> @details Interfacing between the spectral solver and the material subroutines provided -!> by DAMASK. Interpretating the command line arguments or, in case of called from f2py, -!> the arguments parsed to the init routine to get load case, geometry file, working -!> directory, etc. -!-------------------------------------------------------------------------------------------------- -module DAMASK_interface - use prec, only: & - pInt - - implicit none - private -#ifdef PETSc -#include -#endif - logical, public, protected :: appendToOutFile = .false. !< Append to existing spectralOut file (in case of restart, not in case of regridding) - integer(pInt), public, protected :: spectralRestartInc = 1_pInt !< Increment at which calculation starts - character(len=1024), public, protected :: & - geometryFile = '', & !< parameter given for geometry file - loadCaseFile = '' !< parameter given for load case file - character(len=1024), private :: workingDirectory !< accessed by getSolverWorkingDirectoryName for compatibility reasons - - public :: & - getSolverWorkingDirectoryName, & - getSolverJobName, & - DAMASK_interface_init - private :: & - storeWorkingDirectory, & - getGeometryFile, & - getLoadCaseFile, & - rectifyPath, & - makeRelativePath, & - getPathSep, & - IIO_stringValue, & - IIO_intValue, & - IIO_lc, & - IIO_stringPos - -contains - -!-------------------------------------------------------------------------------------------------- -!> @brief initializes the solver by interpreting the command line arguments. Also writes -!! information on computation to screen -!-------------------------------------------------------------------------------------------------- -subroutine DAMASK_interface_init(loadCaseParameterIn,geometryParameterIn) - use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment) - - implicit none - character(len=1024), optional, intent(in) :: & - loadCaseParameterIn, & !< if using the f2py variant, the -l argument of DAMASK_spectral.exe - geometryParameterIn !< if using the f2py variant, the -g argument of DAMASK_spectral.exe - character(len=1024) :: & - commandLine, & !< command line call as string - loadCaseArg ='', & !< -l argument given to DAMASK_spectral.exe - geometryArg ='', & !< -g argument given to DAMASK_spectral.exe - workingDirArg ='', & !< -w argument given to DAMASK_spectral.exe - hostName, & !< name of machine on which DAMASK_spectral.exe is execute (might require export HOSTNAME) - userName, & !< name of user calling DAMASK_spectral.exe - tag - integer :: & - i, & - worldrank = 0 - integer, allocatable, dimension(:) :: & - chunkPos - integer, dimension(8) :: & - dateAndTime ! type default integer -#ifdef PETSc - PetscErrorCode :: ierr -#endif - external :: & - quit,& - MPI_Comm_rank,& - PETScInitialize, & - MPI_abort - -!-------------------------------------------------------------------------------------------------- -! PETSc Init -#ifdef PETSc - call PetscInitialize(PETSC_NULL_CHARACTER,ierr) ! according to PETSc manual, that should be the first line in the code - CHKERRQ(ierr) ! this is a macro definition, it is case sensitive - - open(6, encoding='UTF-8') ! modern fortran compilers (gfortran >4.4, ifort >11 support it) - call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,ierr);CHKERRQ(ierr) -#endif - mainProcess: if (worldrank == 0) then - call date_and_time(values = dateAndTime) - write(6,'(/,a)') ' <<<+- DAMASK_spectral -+>>>' - write(6,'(/,a)') ' Version: '//DAMASKVERSION - write(6,'(a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',& - dateAndTime(2),'/',& - dateAndTime(1) - write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':',& - dateAndTime(6),':',& - dateAndTime(7) - write(6,'(/,a)') ' <<<+- DAMASK_interface init -+>>>' -#include "compilation_info.f90" - endif mainProcess - - if ( present(loadcaseParameterIn) .and. present(geometryParameterIn)) then ! both mandatory parameters given in function call - geometryArg = geometryParameterIn - loadcaseArg = loadcaseParameterIn - commandLine = 'n/a' - else if ( .not.( present(loadcaseParameterIn) .and. present(geometryParameterIn))) then ! none parameters given in function call, trying to get them from command line - call get_command(commandLine) - chunkPos = IIO_stringPos(commandLine) - do i = 1, chunkPos(1) - tag = IIO_lc(IIO_stringValue(commandLine,chunkPos,i)) ! extract key - select case(tag) - case ('-h','--help') - mainProcess2: if (worldrank == 0) then - write(6,'(a)') ' #######################################################################' - write(6,'(a)') ' DAMASK_spectral:' - write(6,'(a)') ' The spectral method boundary value problem solver for' - write(6,'(a)') ' the Düsseldorf Advanced Material Simulation Kit' - write(6,'(a,/)')' #######################################################################' - write(6,'(a,/)')' Valid command line switches:' - write(6,'(a)') ' --geom (-g, --geometry)' - write(6,'(a)') ' --load (-l, --loadcase)' - write(6,'(a)') ' --workingdir (-w, --wd, --workingdirectory, -d, --directory)' - write(6,'(a)') ' --restart (-r, --rs)' - write(6,'(a)') ' --regrid (--rg)' - write(6,'(a)') ' --help (-h)' - write(6,'(/,a)')' -----------------------------------------------------------------------' - write(6,'(a)') ' Mandatory arguments:' - write(6,'(/,a)')' --geom PathToGeomFile/NameOfGeom.geom' - write(6,'(a)') ' Specifies the location of the geometry definition file,' - write(6,'(a)') ' if no extension is given, .geom will be appended.' - write(6,'(a)') ' "PathToGeomFile" will be the working directory if not specified' - write(6,'(a)') ' via --workingdir.' - write(6,'(a)') ' Make sure the file "material.config" exists in the working' - write(6,'(a)') ' directory.' - write(6,'(a)') ' For further configuration place "numerics.config"' - write(6,'(a)')' and "numerics.config" in that directory.' - write(6,'(/,a)')' --load PathToLoadFile/NameOfLoadFile.load' - write(6,'(a)') ' Specifies the location of the load case definition file,' - write(6,'(a)') ' if no extension is given, .load will be appended.' - write(6,'(/,a)')' -----------------------------------------------------------------------' - write(6,'(a)') ' Optional arguments:' - write(6,'(/,a)')' --workingdirectory PathToWorkingDirectory' - write(6,'(a)') ' Specifies the working directory and overwrites the default' - write(6,'(a)') ' "PathToGeomFile".' - write(6,'(a)') ' Make sure the file "material.config" exists in the working' - write(6,'(a)') ' directory.' - write(6,'(a)') ' For further configuration place "numerics.config"' - write(6,'(a)')' and "numerics.config" in that directory.' - write(6,'(/,a)')' --restart XX' - write(6,'(a)') ' Reads in total increment No. XX-1 and continues to' - write(6,'(a)') ' calculate total increment No. XX.' - write(6,'(a)') ' Appends to existing results file ' - write(6,'(a)') ' "NameOfGeom_NameOfLoadFile.spectralOut".' - write(6,'(a)') ' Works only if the restart information for total increment' - write(6,'(a)') ' No. XX-1 is available in the working directory.' - write(6,'(/,a)')' --regrid XX' - write(6,'(a)') ' Reads in total increment No. XX-1 and continues to' - write(6,'(a)') ' calculate total increment No. XX.' - write(6,'(a)') ' Attention: Overwrites existing results file ' - write(6,'(a)') ' "NameOfGeom_NameOfLoadFile.spectralOut".' - write(6,'(a)') ' Works only if the restart information for total increment' - write(6,'(a)') ' No. XX-1 is available in the working directory.' - write(6,'(/,a)')' -----------------------------------------------------------------------' - write(6,'(a)') ' Help:' - write(6,'(/,a)')' --help' - write(6,'(a,/)')' Prints this message and exits' - call quit(0_pInt) ! normal Termination - endif mainProcess2 - case ('-l', '--load', '--loadcase') - loadcaseArg = IIO_stringValue(commandLine,chunkPos,i+1_pInt) - case ('-g', '--geom', '--geometry') - geometryArg = IIO_stringValue(commandLine,chunkPos,i+1_pInt) - case ('-w', '-d', '--wd', '--directory', '--workingdir', '--workingdirectory') - workingDirArg = IIO_stringValue(commandLine,chunkPos,i+1_pInt) - case ('-r', '--rs', '--restart') - spectralRestartInc = IIO_IntValue(commandLine,chunkPos,i+1_pInt) - appendToOutFile = .true. - case ('--rg', '--regrid') - spectralRestartInc = IIO_IntValue(commandLine,chunkPos,i+1_pInt) - appendToOutFile = .false. - end select - enddo - endif - - if (len(trim(loadcaseArg)) == 0 .or. len(trim(geometryArg)) == 0) then - write(6,'(a)') ' Please specify geometry AND load case (-h for help)' - call quit(1_pInt) - endif - - workingDirectory = storeWorkingDirectory(trim(workingDirArg),trim(geometryArg)) - geometryFile = getGeometryFile(geometryArg) - loadCaseFile = getLoadCaseFile(loadCaseArg) - - call get_environment_variable('HOSTNAME',hostName) - call get_environment_variable('USER',userName) - mainProcess3: if (worldrank == 0) then - write(6,'(a,a)') ' Host name: ', trim(hostName) - write(6,'(a,a)') ' User name: ', trim(userName) - write(6,'(a,a)') ' Path separator: ', getPathSep() - write(6,'(a,a)') ' Command line call: ', trim(commandLine) - if (len(trim(workingDirArg))>0) & - write(6,'(a,a)') ' Working dir argument: ', trim(workingDirArg) - write(6,'(a,a)') ' Geometry argument: ', trim(geometryArg) - write(6,'(a,a)') ' Loadcase argument: ', trim(loadcaseArg) - write(6,'(a,a)') ' Working directory: ', trim(getSolverWorkingDirectoryName()) - write(6,'(a,a)') ' Geometry file: ', trim(geometryFile) - write(6,'(a,a)') ' Loadcase file: ', trim(loadCaseFile) - write(6,'(a,a)') ' Solver job name: ', trim(getSolverJobName()) - if (SpectralRestartInc > 1_pInt) & - write(6,'(a,i6.6)') ' Restart at increment: ', spectralRestartInc - write(6,'(a,l1,/)') ' Append to result file: ', appendToOutFile - endif mainProcess3 - -end subroutine DAMASK_interface_init - - -!-------------------------------------------------------------------------------------------------- -!> @brief extract working directory from given argument or from location of geometry file, -!! possibly converting relative arguments to absolut path -!> @todo change working directory with call chdir(storeWorkingDirectory)? -!-------------------------------------------------------------------------------------------------- -character(len=1024) function storeWorkingDirectory(workingDirectoryArg,geometryArg) -#ifdef __INTEL_COMPILER - use IFPORT -#endif - - implicit none - character(len=*), intent(in) :: workingDirectoryArg !< working directory argument - character(len=*), intent(in) :: geometryArg !< geometry argument - character(len=1024) :: cwd - character :: pathSep - logical :: dirExists - external :: quit - integer :: error - - pathSep = getPathSep() - if (len(workingDirectoryArg)>0) then ! got working directory as input - if (workingDirectoryArg(1:1) == pathSep) then ! absolute path given as command line argument - storeWorkingDirectory = workingDirectoryArg - else - error = getcwd(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 -#ifdef __INTEL_COMPILER - inquire(directory = trim(storeWorkingDirectory)//'.', exist=dirExists) -#else - inquire(file = trim(storeWorkingDirectory), exist=dirExists) -#endif - if(.not. dirExists) 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 - if (geometryArg(1:1) == pathSep) then ! absolute path given as command line argument - storeWorkingDirectory = geometryArg(1:scan(geometryArg,pathSep,back=.true.)) - else - error = getcwd(cwd) ! relative path given as command line argument - storeWorkingDirectory = trim(cwd)//pathSep//& - geometryArg(1:scan(geometryArg,pathSep,back=.true.)) - endif - endif - storeWorkingDirectory = rectifyPath(storeWorkingDirectory) - -end function storeWorkingDirectory - - -!-------------------------------------------------------------------------------------------------- -!> @brief simply returns the private string workingDir -!-------------------------------------------------------------------------------------------------- -character(len=1024) function getSolverWorkingDirectoryName() - - implicit none - getSolverWorkingDirectoryName = workingDirectory - -end function getSolverWorkingDirectoryName - - -!-------------------------------------------------------------------------------------------------- -!> @brief solver job name (no extension) as combination of geometry and load case name -!-------------------------------------------------------------------------------------------------- -character(len=1024) function getSolverJobName() - - implicit none - integer :: posExt,posSep - character :: pathSep - character(len=1024) :: tempString - - pathSep = getPathSep() - - tempString = geometryFile - posExt = scan(tempString,'.',back=.true.) - posSep = scan(tempString,pathSep,back=.true.) - - getSolverJobName = tempString(posSep+1:posExt-1) - - tempString = loadCaseFile - posExt = scan(tempString,'.',back=.true.) - posSep = scan(tempString,pathSep,back=.true.) - - getSolverJobName = trim(getSolverJobName)//'_'//tempString(posSep+1:posExt-1) - -end function getSolverJobName - - -!-------------------------------------------------------------------------------------------------- -!> @brief basename of geometry file with extension from command line arguments -!-------------------------------------------------------------------------------------------------- -character(len=1024) function getGeometryFile(geometryParameter) -#ifdef __INTEL_COMPILER - use IFPORT -#endif - - implicit none - character(len=1024), intent(in) :: & - geometryParameter - character(len=1024) :: & - cwd - integer :: posExt, posSep - character :: pathSep - integer :: error - - getGeometryFile = geometryParameter - pathSep = getPathSep() - posExt = scan(getGeometryFile,'.',back=.true.) - posSep = scan(getGeometryFile,pathSep,back=.true.) - - if (posExt <= posSep) getGeometryFile = trim(getGeometryFile)//('.geom') ! no extension present - if (scan(getGeometryFile,pathSep) /= 1) then ! relative path given as command line argument - error = getcwd(cwd) - getGeometryFile = rectifyPath(trim(cwd)//pathSep//getGeometryFile) - else - getGeometryFile = rectifyPath(getGeometryFile) - endif - - getGeometryFile = makeRelativePath(getSolverWorkingDirectoryName(), getGeometryFile) - -end function getGeometryFile - - -!-------------------------------------------------------------------------------------------------- -!> @brief relative path of loadcase from command line arguments -!-------------------------------------------------------------------------------------------------- -character(len=1024) function getLoadCaseFile(loadCaseParameter) -#ifdef __INTEL_COMPILER - use IFPORT -#endif - - implicit none - character(len=1024), intent(in) :: & - loadCaseParameter - character(len=1024) :: & - cwd - integer :: posExt, posSep, error - character :: pathSep - - getLoadCaseFile = loadcaseParameter - pathSep = getPathSep() - posExt = scan(getLoadCaseFile,'.',back=.true.) - posSep = scan(getLoadCaseFile,pathSep,back=.true.) - - if (posExt <= posSep) getLoadCaseFile = trim(getLoadCaseFile)//('.load') ! no extension present - if (scan(getLoadCaseFile,pathSep) /= 1) then ! relative path given as command line argument - error = getcwd(cwd) - getLoadCaseFile = rectifyPath(trim(cwd)//pathSep//getLoadCaseFile) - else - getLoadCaseFile = rectifyPath(getLoadCaseFile) - endif - - getLoadCaseFile = makeRelativePath(getSolverWorkingDirectoryName(), getLoadCaseFile) - -end function getLoadCaseFile - - -!-------------------------------------------------------------------------------------------------- -!> @brief remove ../ and /./ from path -!-------------------------------------------------------------------------------------------------- -function rectifyPath(path) - - implicit none - character(len=*) :: path - character(len=len_trim(path)) :: rectifyPath - character :: pathSep - integer :: i,j,k,l ! no pInt - - pathSep = getPathSep() - -!-------------------------------------------------------------------------------------------------- -! remove /./ from path - l = len_trim(path) - rectifyPath = path - do i = l,3,-1 - if (rectifyPath(i-2:i) == pathSep//'.'//pathSep) & - rectifyPath(i-1:l) = rectifyPath(i+1:l)//' ' - enddo - -!-------------------------------------------------------------------------------------------------- -! remove ../ and corresponding directory from rectifyPath - l = len_trim(rectifyPath) - i = index(rectifyPath(i:l),'..'//pathSep) - j = 0 - do while (i > j) - j = scan(rectifyPath(1:i-2),pathSep,back=.true.) - rectifyPath(j+1:l) = rectifyPath(i+3:l)//repeat(' ',2+i-j) - if (rectifyPath(j+1:j+1) == pathSep) then !search for '//' that appear in case of XXX/../../XXX - k = len_trim(rectifyPath) - rectifyPath(j+1:k-1) = rectifyPath(j+2:k) - rectifyPath(k:k) = ' ' - endif - i = j+index(rectifyPath(j+1:l),'..'//pathSep) - enddo - if(len_trim(rectifyPath) == 0) rectifyPath = pathSep - -end function rectifyPath - - -!-------------------------------------------------------------------------------------------------- -!> @brief relative path from absolute a to absolute b -!-------------------------------------------------------------------------------------------------- -character(len=1024) function makeRelativePath(a,b) - - implicit none - character (len=*) :: a,b - character :: pathSep - integer :: i,posLastCommonSlash,remainingSlashes !no pInt - - pathSep = getPathSep() - posLastCommonSlash = 0 - remainingSlashes = 0 - - do i = 1, min(1024,len_trim(a),len_trim(b)) - if (a(i:i) /= b(i:i)) exit - if (a(i:i) == pathSep) posLastCommonSlash = i - enddo - do i = posLastCommonSlash+1,len_trim(a) - if (a(i:i) == pathSep) remainingSlashes = remainingSlashes + 1 - enddo - makeRelativePath = repeat('..'//pathSep,remainingSlashes)//b(posLastCommonSlash+1:len_trim(b)) - -end function makeRelativePath - - -!-------------------------------------------------------------------------------------------------- -!> @brief counting / and \ in $PATH System variable the character occuring more often is assumed -! to be the path separator -!-------------------------------------------------------------------------------------------------- -character function getPathSep() - - implicit none - character(len=2048) :: & - path - integer(pInt) :: & - backslash = 0_pInt, & - slash = 0_pInt - integer :: i - - call get_environment_variable('PATH',path) - do i=1, len(trim(path)) - if (path(i:i)=='/') slash = slash + 1_pInt - if (path(i:i)=='\') backslash = backslash + 1_pInt - enddo - - if (backslash>slash) then - getPathSep = '\' - else - getPathSep = '/' - endif - -end function getPathSep - - -!-------------------------------------------------------------------------------------------------- -!> @brief taken from IO, check IO_stringValue for documentation -!-------------------------------------------------------------------------------------------------- -pure function IIO_stringValue(string,chunkPos,myChunk) - - implicit none - integer(pInt), dimension(:), intent(in) :: chunkPos !< positions of start and end of each tag/chunk in given string - integer(pInt), intent(in) :: myChunk !< position number of desired chunk - character(len=1+chunkPos(myChunk*2+1)-chunkPos(myChunk*2)) :: IIO_stringValue - character(len=*), intent(in) :: string !< raw input with known start and end of each chunk - - - valuePresent: if (myChunk > chunkPos(1) .or. myChunk < 1_pInt) then - IIO_stringValue = '' - else valuePresent - IIO_stringValue = string(chunkPos(myChunk*2):chunkPos(myChunk*2+1)) - endif valuePresent - -end function IIO_stringValue - - -!-------------------------------------------------------------------------------------------------- -!> @brief taken from IO, check IO_intValue for documentation -!-------------------------------------------------------------------------------------------------- -integer(pInt) pure function IIO_intValue(string,chunkPos,myChunk) - - implicit none - character(len=*), intent(in) :: string !< raw input with known start and end of each chunk - integer(pInt), intent(in) :: myChunk !< position number of desired sub string - integer(pInt), dimension(:), intent(in) :: chunkPos !< positions of start and end of each tag/chunk in given string - - - valuePresent: if (myChunk > chunkPos(1) .or. myChunk < 1_pInt) then - IIO_intValue = 0_pInt - else valuePresent - read(UNIT=string(chunkPos(myChunk*2):chunkPos(myChunk*2+1)),ERR=100,FMT=*) IIO_intValue - endif valuePresent - return -100 IIO_intValue = huge(1_pInt) - -end function IIO_intValue - - -!-------------------------------------------------------------------------------------------------- -!> @brief taken from IO, check IO_lc for documentation -!-------------------------------------------------------------------------------------------------- -pure function IIO_lc(string) - - implicit none - character(len=*), intent(in) :: string !< string to convert - character(len=len(string)) :: IIO_lc - - character(26), parameter :: LOWER = 'abcdefghijklmnopqrstuvwxyz' - character(26), parameter :: UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - - integer :: i,n ! no pInt (len returns default integer) - - IIO_lc = string - do i=1,len(string) - n = index(UPPER,IIO_lc(i:i)) - if (n/=0) IIO_lc(i:i) = LOWER(n:n) - enddo - -end function IIO_lc - - -!-------------------------------------------------------------------------------------------------- -!> @brief taken from IO, check IO_stringPos for documentation -!-------------------------------------------------------------------------------------------------- -pure function IIO_stringPos(string) - - implicit none - integer(pInt), dimension(:), allocatable :: IIO_stringPos - character(len=*), intent(in) :: string !< string in which chunks are searched for - - character(len=*), parameter :: SEP=achar(44)//achar(32)//achar(9)//achar(10)//achar(13) ! comma and whitespaces - integer :: left, right ! no pInt (verify and scan return default integer) - - allocate(IIO_stringPos(1), source=0_pInt) - right = 0 - - do while (verify(string(right+1:),SEP)>0) - left = right + verify(string(right+1:),SEP) - right = left + scan(string(left:),SEP) - 2 - if ( string(left:left) == '#' ) exit - IIO_stringPos = [IIO_stringPos,int(left, pInt), int(right, pInt)] - IIO_stringPos(1) = IIO_stringPos(1)+1_pInt - enddo - -end function IIO_stringPos - - -end module