Help fixing a multifile Monte Carlo simulation

Ive been using a montecarlo simulation with a square well potencial, the simulation was working correctly but now I have to use a Yukawa potential. I only change the potential part of my code but now its not working. This is the square well potential which was working fine

if (rij2 .lt. 1.0) then
uij = 10000.0d0
elseif (rij2 .lt. xlam) then
uij = -1.0d0
else
uij = 0.0d0
endif

and this is the change I made

if (rij2 .lt. 1.0) then
uij = 10000.0d0
elseif (rij2 .lt. xlam) then
uij = -1.0d0
else
rij = dsqrt(rij2)
uij = 0.5d0dexp(-zk(rij - xlam1))/rij
endif

Im only using -fast while compiling, it does compile if I compile not using -fast but the result is completly wrong. Compiling using -fast gives me the next error messages


ifort: error #10105: /home/dan/intel/oneapi/compiler/2024.1/bin/ā€¦/bin/fortcom: core dumped
ifort: warning #10102: unknown signal(-1258684640)
ifort: error #10106: Fatal error in /home/dan/intel/oneapi/compiler/2024.1/bin/ā€¦/bin/fortcom, terminated by unknown
ifort: error #10014: problem during multi-file optimization compilation (code 1)


I tried using ā€œulimit -s unlimitedā€ and after that I get


ifort: error #10106: Fatal error in /home/dan/intel/oneapi/compiler/2024.1/bin/ā€¦/bin/fortcom, terminated by kill signal
ifort: error #10014: problem during multi-file optimization compilation (code 1)


Im new in fortran so I dont really know what to do. Any help is appreciated please

You can try replacing ifort with ifx.

By the way, -fast might conceal some errors, such as ā€˜array bounds exceededā€™. Therefore, the best approach is to use the options -check all -traceback -g to debug the code.

2 Likes

Try using the base intrinsics for dsqrt and desp. sqrt and exp will return the same type as itā€™s arguments, so calling the double precision version is redundant. Also, eliminate the initial multiply by 0.5d0 and replace the divide by rij with ā€œ/(2.0d0*rij)ā€. this will alter the order of execution and may provide better diagnostics. also check that (rij-xlam1) is within the bounds of the array and check that zk(rij-xlam1) actually has a defined value in it and not a NaN or a value too big to exponentiate. Just add some print statements to check the values.

hi thanks for answering, I tried using ifx but it doesnt compile if I use -fast and I get this error


structure.f: error #5544: Unknown target CPU ā€˜nativeā€™. Valid CPU targets: alderlake amdfam10 arrowlake arrowlake-s athlon-fx athlon64 athlon64-sse3 atom barcelona bdver1 bdver2 bdver3 bdver4 bonnell broadwell btver1 btver2 cannonlake cascadelake clearwaterforest common-avx512 cooperlake core-avx-i core-avx2 core2 corei7 corei7-avx emeraldrapids goldmont goldmont-plus gracemont grandridge graniterapids graniterapids-d haswell icelake-client icelake-server ivybridge k8 k8-sse3 lunarlake meteorlake nehalem nocona opteron opteron-sse3 pantherlake penryn raptorlake rocketlake sandybridge sapphirerapids sierraforest silvermont skx skylake skylake-avx512 slm tigerlake tremont westmere x86-64 x86-64-v2 x86-64-v3 x86-64-v4 znver1 znver2 znver3 znver4.
compilation aborted for structure.f (code 1)


Im using -march=zen3 which works except when Im using -fast too, I did use -check all and -traceback -g too.

Is the below link help?

Perhaps turn off the multi-file optimization to begin with. It is possible that you other parts of code already has bugs but intel compiler did not report error, and your changes triggered something and intel compiler report the error.

If intel compiler cannot give you more info, you can use gfortran to compile and build and see what error messages gfortran give you, that can be helpful.

It is best if you could share a minimal working example which can replicate the issue.

BTW, are you missing a * between 0.5d0 and exp(ā€¦), and a * after zk?
uij = 0.5d0 * dexp(-zk*(rij - xlam1))/rij

PS.
For those potentials U(r) which is a 1D function of r, you can pre-calculate and store a table of U(r) vs. r.
Then in the code, for a given r, you can use Lagrange 4-point interpolation to get U(r) based on the nearest 4 points in the table that are around the given r, instead of calculating a possibly very complicated and time-consuming exact U(r).

To be honest, Iā€™m surprised that you only get this error at -fast, given that zen3 is not in the supported list of options. What processor are you compiling for?

It looks like your issue is related to IPO, which is enabled by -fast (see https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2025-0/fast.html ). Iā€™d try ā€œreducingā€ down to -O3 as a first step and see if that works.

Iā€™ll also mention that while ifort and ifx are ordinarily binary compatible, IPO between the two binaries types is not supported as the optimization backends are fundamentally different beasts, which may be relevant if youā€™ve switched partway between ifx and ifort in the same repo.