Skip to content

Commit

Permalink
Merge pull request #111 from N-Medvedev/under_development
Browse files Browse the repository at this point in the history
MPI version implemented
  • Loading branch information
N-Medvedev authored Jul 19, 2024
2 parents 5f01374 + 7254e61 commit 1c13dc0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
21 changes: 14 additions & 7 deletions Make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ cd Source_files

:: Set the default compiler name:
SET "Compiler=ifx"
SET "Linking_options="

:: List of all program files to be compiled
SET "List_of_files=Universal_constants.f90 Objects.f90 Variables.f90 MPI_subroutines.f90 BS_Cartesian_Gaussians.f90 BS_Spherical_Gaussians.f90 Periodic_table.f90 Algebra_tools.f90 BS_Basis_sets.f90 TB_Koster_Slater.f90 Dealing_with_files.f90 Gnuplotting.f90 Little_subroutines.f90 Dealing_with_EADL.f90 Dealing_with_DFTB.f90 Dealing_with_3TB.f90 Dealing_with_BOP.f90 Dealing_with_xTB.f90 Atomic_tools.f90 Atomic_thermodynamics.f90 MC_cross_sections.f90 Electron_tools.f90 Nonadiabatic.f90 Dealing_with_POSCAR.f90 Dealing_with_mol2.f90 Dealing_with_CDF.f90 Read_input_data.f90 Van_der_Waals.f90 Coulomb.f90 ZBL_potential.f90 Exponential_wall.f90 Dealing_with_output_files.f90 Monte_Carlo.f90 TB_Fu.f90 TB_Pettifor.f90 TB_Molteni.f90 TB_NRL.f90 TB_DFTB.f90 TB_3TB.f90 TB_BOP.f90 TB_xTB.f90 TB.f90 Dealing_with_eXYZ.f90 Initial_configuration.f90 Optical_parameters.f90 TB_complex.f90 Transport.f90 XTANT_MAIN_FILE.f90"
Expand All @@ -63,7 +64,8 @@ cd Source_files
echo %Starline%

:: List compiler options
SET "Compile_options=/F9999999999 /QxHost /QaxAVX2 /fpp /Qmkl=parallel /real-size:64 /debug:all /Od /check:all /traceback /gen-interfaces /warn:interfaces /check:bounds /fpe:0 /fp:precise /standard-semantics /Qfp-stack-check"
SET "Compile_options=/F9999999999 /QxHost /QaxAVX2 /fpp /real-size:64 /debug:all /Od /check:all /traceback /gen-interfaces /warn:interfaces /check:bounds /fpe:0 /fp:precise /standard-semantics /Qfp-stack-check"
SET "Linking_options=/Qmkl=parallel"

:: Set name of the executable:
SET "Name_of_exe=XTANT_DEBUG.exe"
Expand All @@ -77,7 +79,8 @@ cd Source_files

:: List compiler options
::SET "Compile_options=/F9999999999 /QxHost /QaxAVX2 /fpp /Qmkl=parallel /Qopenmp /real-size:64 /debug:all /O1 /Qipo /traceback /gen-interfaces /warn:interfaces /check:bounds /fpe:0 /fp:precise /standard-semantics"
SET "Compile_options=/F9999999999 /QxHost /QaxAVX2 /fpp /Qmkl=parallel /Qopenmp /real-size:64 /debug:all /Od /check:all /traceback /gen-interfaces /warn:interfaces /check:bounds /fpe:0 /fp:precise /standard-semantics /Qfp-stack-check"
SET "Compile_options=/F9999999999 /QxHost /QaxAVX2 /fpp /real-size:64 /debug:all /Od /check:all /traceback /gen-interfaces /warn:interfaces /check:bounds /fpe:0 /fp:precise /standard-semantics /Qfp-stack-check"
SET "Linking_options=/Qopenmp /Qmkl=parallel"

:: Set name of the executable:
SET "Name_of_exe=XTANT_DEBUG_OMP.exe"
Expand All @@ -90,7 +93,9 @@ cd Source_files
echo %Starline%

:: List compiler options
SET "Compile_options=/F9999999999 /fpp /Qopenmp /Qmkl=parallel /real-size:64 /O1 /fpe:0 /fp:fast /Qipo /Qopt-report /standard-semantics"
SET "Compile_options=/F9999999999 /fpp /real-size:64 /O1 /fpe:0 /fp:fast /Qipo /Qopt-report /standard-semantics"
SET "Linking_options=/Qopenmp /Qmkl=parallel"

:: Set name of the executable:
SET "Name_of_exe=XTANT_OMP.exe"

Expand All @@ -104,7 +109,8 @@ cd Source_files
echo %Starline%

:: List compiler options
SET "Compile_options=/F9999999999 /fpp /Qopenmp /Qmkl=parallel /real-size:64 /O3 /Qipo /standard-semantics /assume:nofpe_summary"
SET "Compile_options=/F9999999999 /fpp /real-size:64 /O3 /Qipo /standard-semantics /assume:nofpe_summary"
SET "Linking_options=/Qopenmp /Qmkl=parallel"

:: Set name of the executable:
SET "Name_of_exe=XTANT.exe"
Expand All @@ -118,7 +124,8 @@ cd Source_files
echo %Starline%

:: List compiler options (for release):
SET "Compile_options=/F9999999999 /fpp /D MPI_USED /Qmkl=cluster /real-size:64 /O3 /Qip /fp:precise /standard-semantics /assume:nofpe_summary /gen-interfaces"
SET "Compile_options=/F9999999999 /fpp /D MPI_USED /Qmkl=cluster /real-size:64 /O3 /Qip /fp:precise /standard-semantics /assume:nofpe_summary /gen-interfaces"'
SET Linking_options= /NODEFAULTLIB:"mkl_intel_ilp64_dll.lib"

:: List compiler options (for debug):
::SET Compile_options=/F9999999999 /QxHost /QaxAVX2 /fpp /D MPI_USED /Qmkl=cluster /real-size:64 /debug:all /Od /check:all /traceback /gen-interfaces /warn:interfaces /check:bounds /fpe:0 /fp:precise /standard-semantics /Qfp-stack-check
Expand All @@ -135,7 +142,7 @@ cd Source_files
IF /I not %arg1%==clean (
FOR %%A IN (%List_of_files%) DO (
:: Construct the command line for compilation of the current module:
SET "Output=%Compiler% -c %Compile_options% %%A 2>&1"
SET "Output=%Compiler% -c %Compile_options% %%A !Linking_options! 2>&1"
echo * Compilation : !Output!
IF ERRORLEVEL 1 (
echo Error compiling %%A! See Captured Output above. Exiting...
Expand All @@ -154,7 +161,7 @@ cd Source_files
:: Assemble the code from all created obj-files
:: ifx.exe %Compile_options% *.obj /exe:%Name_of_exe%
:: Construct the command line for creation fo executable:
SET "Output=%Compiler% %Compile_options% *.obj /exe:%Name_of_exe% 2>&1"
SET "Output=%Compiler% %Compile_options% *.obj /exe:%Name_of_exe% !Linking_options! 2>&1"
IF ERRORLEVEL 1 (
echo Error compiling %%A! See Captured Output above. Exiting...
EXIT /B 1
Expand Down
28 changes: 13 additions & 15 deletions Source_files/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ LD = ld
ifeq ($(c),gf)
F90 = gfortran
F90FLAGS = -ffree-line-length-0 -fdec-format-defaults -cpp -fdefault-real-8 -fdefault-double-8 -O2
LDFLAGS = -lblas -llapack -fopenmp
LDFLAGS += -lblas -llapack -fopenmp
# need to link OpenMP, ^^^^^^^ even for non OpenMP compilation. Can be fixed..
ifeq (${OMP},y)
F90FLAGS += -fopenmp
endif
else ifeq ($(c),gf6)
F90 = gfortran6.1.0
F90FLAGS = -ffree-line-length-0 -fdec-format-defaults -cpp -fdefault-real-8 -fdefault-double-8 -O2
LDFLAGS = -lblas -llapack -fopenmp
LDFLAGS += -lblas -llapack -fopenmp
ifeq (${OMP},y)
F90FLAGS += -fopenmp
endif
Expand All @@ -50,24 +50,23 @@ else ifeq ($(c),if13)
F90FLAGS += -standard-semantics -assume nofpe_summary
else ifeq ($(c),mpi)
F90 = mpif90
F90FLAGS += -D MPI_USED
F90FLAGS += -D MPI_USED -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 $(pkg-config --libs mkl-dynamic-lp64-seq)
#F90FLAGS += -lscalapack-openmpi -lblacsCinit-openmpi -lblacs-openmpi -llapack -lblas
ifeq ($(db),y)
# flags for debugging
F90FLAGS += -cpp -debug all -check all -fpe0 -fp-stack-check -O0 -traceback -gen-interfaces -warn interfaces -fpp -real-size 64 -standard-semantics -assume nofpe_summary
else
# Flags for maximum performance
#F90FLAGS += -O5 -cpp -ffree-line-length-0 -fdefault-real-8 -fdefault-double-8
F90FLAGS += -O5 -fpp -cpp -real-size 64 -standard-semantics -assume nofpe_summary -ip
#LDFLAGS += -L$MKLROOT/lib/intel64 -L$MKLROOT/../../../lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -L$MKLROOT/lib/intel64 -lmkl_blacs_openmpi_lp64 -lmkl_scalapack_lp64
F90FLAGS += -O5 -fpp -cpp -real-size 64 -standard-semantics -assume nofpe_summary -ipo
endif
LDFLAGS += -mkl=cluster
F90FLAGS += -qmkl=cluster
EXE = $(EXEPATH)/XTANT_MPI.x
else ifeq ($(c),mpii)
F90 = mpiifort
F90FLAGS += -D MPI_USED
#F90FLAGS += -lscalapack-openmpi -lblacsCinit-openmpi -lblacs-openmpi -llapack -lblas
#F90FLAGS += -qmkl=cluster
F90FLAGS += -qmkl=cluster

ifeq ($(db),y)
# flags for debugging
Expand All @@ -76,26 +75,26 @@ else ifeq ($(c),mpii)
# Flags for maximum performance
F90FLAGS += -O5 -fpp -cpp -ip -real-size 64 -standard-semantics -assume nofpe_summary
endif
LDFLAGS += -mkl=cluster
#LDFLAGS += -mkl=cluster
EXE = $(EXEPATH)/XTANT_MPI.x
else
F90 = ifort
# F90 = ifort.exe

F90FLAGS = -fpp -cpp

ifneq (${OMP},) # OMP=no means no omp
F90FLAGS = -mkl
F90FLAGS += -qmkl
else # there is omp by default
F90FLAGS = -qopenmp
F90FLAGS += -mkl=parallel
F90FLAGS += -qopenmp -mkl=parallel
endif

ifeq ($(db),y)
# flags for debugging
#F90FLAGS += -g -fbounds-check
F90FLAGS += -debug all -check all -fpe0 -fp-stack-check -O0 -g -fp-model precise -traceback -gen-interfaces -warn interfaces -fpp -cpp
F90FLAGS += -debug all -check all -fpe0 -fp-stack-check -O0 -g -fp-model precise -traceback -gen-interfaces -warn interfaces
else
# Flags for maximum performance
F90FLAGS += -O5 -fpp -cpp -ipo -real-size 64
F90FLAGS += -O5 -ipo -real-size 64
endif

F90FLAGS += -standard-semantics -assume nofpe_summary
Expand Down Expand Up @@ -139,7 +138,6 @@ else
@echo "Run the code as: ./TREKIS.x"
@echo "----------------------------------------------"
endif
# @echo "Version 3"

# autoclean before the compilation
# rm -f *.o
Expand Down
14 changes: 9 additions & 5 deletions Source_files/Nonadiabatic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ subroutine Electron_ion_collision_int(Scell, numpar, nrg, Mij, wr, wr0, distre,
if ((distre_temp2(i) > 2.0d0) .OR. (distre_temp2(i) < 0.0d0)) then
N_steps = INT(N_steps*2.0d0) ! decrease time step in Boltzmann equation and recalculate
if (N_steps > 1000) then
print*, 'N_steps=', N_steps, 'SOMETHING MIGHT BE WRONG (1)'
write(*,'(i5, e25.16, e25.16, e25.16, e25.16, e25.16, e25.16)') i, dt_small, coef, coef_inv, distre_temp2(i), dfdt_e(i), dfdt_e(i)*dt_small
if (numpar%MPI_param%process_rank == 0) then ! only MPI master process does it
print*, 'N_steps=', N_steps, 'SOMETHING MIGHT BE WRONG (1)'
write(*,'(i5, e25.16, e25.16, e25.16, e25.16, e25.16, e25.16)') i, dt_small, coef, coef_inv, distre_temp2(i), dfdt_e(i), dfdt_e(i)*dt_small
endif
endif
! Recalculate with smaller time steps:
goto 110
Expand Down Expand Up @@ -198,9 +200,11 @@ subroutine Electron_ion_collision_int(Scell, numpar, nrg, Mij, wr, wr0, distre,
goto 110
else
if (print_error) then
print*, 'Trouble noticed in Electron_ion_collision_int:'
print*, 'N_steps=', N_steps, 'SOMETHING MIGHT BE WRONG (2):'
print*, N_tot_cut, Scell%Ne_low
if (numpar%MPI_param%process_rank == 0) then ! only MPI master process does it
print*, 'Trouble noticed in Electron_ion_collision_int:'
print*, 'N_steps=', N_steps, 'SOMETHING MIGHT BE WRONG (2):'
print*, N_tot_cut, Scell%Ne_low
endif
print_error = .false. ! don't repeat the same error
endif
endif
Expand Down

0 comments on commit 1c13dc0

Please sign in to comment.