Showing results for 
Search instead for 
Did you mean: 

Error (157) when trying to compiler program with Intel Compilers

Hi all,


I am trying to compile the open-source program XTB ( with Intel compilers (I have Intel Parallel Studio XE 2020 and MS Visual Studio 2017). The program compiles natively and runs successfully with the mingw64-gnu compilers on windows. It is also known to compile with Intel Parallel Studio on Linux (and has been reported to be compiled with Intel Compilers on Windows as well, but there are no available guides).

The problem with mingw64 compilers is the poor speed, so I want to shift to using Intel Compilers. The authors of the program can't provide much help with Windows compilation so I am forced to ask for help here.

This is a summary of what I am doing:

1) The program is built using the meson build system ( To run on windows I modified the meson build file (basically converted the linux ifort arguments to windows ifort arguments and added extra -fpp and -check:bounds option). I modified two files, one in the main folder (/ and the other is the meson/ I also had to change the return date command as windows does not have a date executable.(They are both attached as txt files).

I set-up the build with

psxevars.bat intel64
meson setup build --buildtype debug -Dla_backend=mkl

 (static linking does not work on windows)

Then compiled with

ninja -C build


2) The compilation goes successfully, at least I can't see any errors. An executable xtb.exe is generated. Running it gives

forrtl: severe (157): Program Exception - access violation
Image              PC                Routine            Line        Source
libifportMD.dll    00007FFA97D46C60  Unknown               Unknown  Unknown
xtb.exe            00007FF7EE88101A  Unknown               Unknown  Unknown
xtb.exe            00007FF7EE3D02DF  Unknown               Unknown  Unknown
xtb.exe            00007FF7F15F7D8E  Unknown               Unknown  Unknown
xtb.exe            00007FF7F1831AE8  Unknown               Unknown  Unknown
KERNEL32.DLL       00007FFABEA77034  Unknown               Unknown  Unknown
ntdll.dll          00007FFAC023D0D1  Unknown               Unknown  Unknown


3) I tried debugging it with >devenv /debugexe xtb.exe. This shows that the problem is coming from /mctc_init.f90 at the line call start_timing_run (see attached image below).


I have little experience with Fortran programming so I am not sure what is causing the problem. But I feel like it's due to something simple that I have missed. Any help is appreciated.

0 Kudos
8 Replies
Black Belt

The project that you are attempting to build involves scores of source files, a complex build framework, and you cannot reasonably expect help with that in this forum (there is a minuscule probability that there is a forum member who uses XTB, but don't count on that). 

There is no basis other than naivete for stating, "I have little experience with Fortran programming so I am not sure what is causing the problem. But I feel like it's due to something simple that I have missed." I have a lot of experience with Fortran programming, so I am afraid that there are potentially hundreds of causes of the problem!

You somehow succeeded in building an EXE, but the crash report shows that you did not build with sufficient debug information present to give you a useful traceback. Here is a simple program that you can try yourself.

program test_timing
use xtb_mctc_timings
call start_timing_run()
call stop_timing_run()
end program

Compile accuracy.f90, mctc_timings.f90, and this test driver:

ifort /Od /traceback accuracy.f90 mctc_timings.f90 main.f90 /Femain

I ran the resulting EXE, main.exe, and it ran and terminated normally. 

Therefore, you will need to seek help with the users, maintainers and developers of the XTB package.

Black Belt Retired Employee

The error is occurring when you run the application, not when you compile it. Unfortunately, there are countless possible reasons for an access violation error and a screenshot of a small part of code is not useful in diagnosing it.  You may want to read Don't Touch Me There - What error 157 (Access Violation) is trying to tell you - Doctor Fortran (ste... for some ideas. 

What I CAN tell you is that something passed -1 as an address, but where that came from, I don't know.

Black Belt

Just before the call to start_timing_run(), there are two calls to subroutine SIGNAL, with only two arguments in each call.

This subroutine is not part of standard Fortran. GNU Fortran provides such a subroutine in its library, but also provides a function with the same name. In Intel Fortran, the portability function SIGNAL takes three arguments. 

You cannot expect the Intel implementation to work in the same way as the GNU implementation of a non-standard subroutine or function, unless the documentation makes it clear that you can.


@mecej4 The manual of the program states that it has been checked to compile and run with Intel compilers on Linux, and I am not sure whether the implementation is different in the Windows version?  Also, the people who are developing the code are unable to help with Windows compilation, I have already mentioned that in the question.

Is there a better way to find out where the error lies, apart from the debugging that I tried to do?


@Steve_Lionel So, how do I find out where the -1 came from? I am afraid that I have little knowledge in debugging apart from running visual studio and hoping I can understand what's going wrong.

Valued Contributor I

@mecej4  and @Steve_Lionel  are two of the best Fortran programmers anywhere. 

What you are trying to do is reasonably difficult for an experienced Fortran programmer, ie some one who has written say 2 million lines of code and debugged same. 

Asking people to debug this type of code is unreasonable, this is an expensive time waster, assume that the two people above are worth about 250 per hour, not unreasonable assumption and it takes 40 hours to debug, that is 250*40 = 10,000

No one is going to give you 10000 worth of free time.  You have a reasonable expectation on this forum of a simple answer to a simple question and a longer answer if you show you have put in a good effort. 

There are people who will debug the code for you -- but you need to find them and pay them. 

Why are you moving the code, Linux is as good as Windows for running Fortran, so unless there is something to be gained stick with the one that runs.  Moving code is a perilous undertaking.  

Do not waste time unless there is a real benefit. 

Good luck. 

Valued Contributor I

Interesting challenge:

1. If you create a VS sln file and add the F90 files, one encounters 4000 errors. 

2. Starting with 

program peeq_tester
   use xtb_mctc_accuracy, only : wp
!$ use omp_lib
! ------------------------------------------------------------------------
!  general purpose library
! ------------------------------------------------------------------------
   use xtb_mctc_global
   use xtb_mctc_timings
   use xtb_mctc_systools
   use xtb_mctc_convert

   use test_hessian

   implicit none

! ------------------------------------------------------------------------
!  local variables
! ------------------------------------------------------------------------
   integer  :: testid
   integer  :: idum,nargs
   character(len=:),allocatable :: arg,sec

!! ------------------------------------------------------------------------
!!  signal processing
!! ------------------------------------------------------------------------
!   external :: wSIGTERM
!   external :: wSIGINT
!!  here two important signal handlers are installed, it seems that
!!  FORTRAN by itself cannot handle signals in the way I expected it
!!  to do, but this will force it to die when I hit CTRL^C.
!   call signal(2,wSIGINT)
!   call signal(15,wSIGTERM)

   call mctc_init('test',10,.true.)

   nargs = command_argument_count()
   if ( then
      call raise('E',"Please give the tester a test to run!")

   call rdarg(1,arg)
   call rdarg(2,sec)

   select case(arg)
      select case(sec)
      case('cluster'); call test_repulsion_cluster
      case('pbc3d'); call test_repulsion_pbc3d
      end select
      select case(sec)
      case('pbc3dneighs'); call test_ncoord_pbc3d_neighbourlist
      case('pbc3dlatp'); call test_ncoord_pbc3d_latticepoints
      end select
      select case(sec)
      case('point_0d'); call test_coulomb_point_cluster
      case('point_3d'); call test_coulomb_point_pbc3d
      case('gfn1_0d'); call test_coulomb_gfn1_cluster
      case('gfn1_3d'); call test_coulomb_gfn1_pbc3d
      case('gfn2_0d'); call test_coulomb_gfn2_cluster
      case('gfn2_3d'); call test_coulomb_gfn2_pbc3d
      case('gaussian_0d'); call test_coulomb_gaussian_cluster
      case('gaussian_3d'); call test_coulomb_gaussian_pbc3d
      end select
      select case(sec)
      case('water'); call test_eeq_water
      case('ewald'); call test_eeq_ewald
      case('gbsa');  call test_eeq_model_gbsa
      case('hbond'); call test_eeq_model_hbond
      case('salt');  call test_eeq_model_salt
      end select
      select case(sec)
      case('basic'); call test_gfn2_mindless_basic
      case('solvation'); call test_gfn2_mindless_solvation
      case('scc'); call test_gfn2_scc
      case('api'); call test_gfn2_api
      case('gbsa'); call test_gfn2gbsa_api
      case('salt'); call test_gfn2salt_api
      case('pcem'); call test_gfn2_pcem_api
      case('d-metal'); call test_gfn2_dmetal
      end select
      select case(sec)
      case('basic'); call test_gfn1_mindless_basic
      case('solvation'); call test_gfn1_mindless_solvation
      case('scc'); call test_gfn1_scc
      case('api'); call test_gfn1_api
      case('gbsa'); call test_gfn1gbsa_api
      case('pcem'); call test_gfn1_pcem_api
      case('xb'); call test_gfn1_xb
      case('pbc3d'); call test_gfn1_pbc3d
      case('ipea'); call test_ipea_indole
      end select
      call run_hessian_test(sec)
      select case(sec)
      case('basic'); call test_gfn0_mindless_basic
      case('solvation'); call test_gfn0_mindless_solvation
      case('sp');  call test_gfn0_sp
      case('api'); call test_gfn0_api
      case('srb'); call test_gfn0_api_srb
      end select
      select case(sec)
      case('basic'); call test_gfnff_mindless_basic
      case('solvation'); call test_gfnff_mindless_solvation
      case('scaleup'); call test_gfnff_scaleup
      case('pdb'); call test_gfnff_pdb
      case('sdf'); call test_gfnff_sdf
      case('sp');  call test_gfnff_sp
      case('hb');  call test_gfnff_hb
      case('gbsa');call test_gfnff_gbsa
      end select
      select case(sec)
      case('sp');  call test_peeq_sp
      case('api'); call test_peeq_api
      case('srb'); call test_peeq_api_srb
      end select
      select case(sec)
      case('pbc3dneighs'); call test_dftd3_pbc3d_neighbourlist
      case('pbc3dlatp'); call test_dftd3_pbc3d_latticepoints
      case('pbc3datmneighs'); call test_dftd3_pbc3d_threebody_neighs
      case('pbc3datmlatp'); call test_dftd3_pbc3d_threebody_latp
      end select
      select case(sec)
      case('pbc3dneighs'); call test_dftd4_pbc3d_neighbourlist
      case('pbc3dlatp'); call test_dftd4_pbc3d_latticepoints
      case('pbc3datmneighs'); call test_dftd4_pbc3d_threebody_neighs
      case('pbc3datmlatp'); call test_dftd4_pbc3d_threebody_latp
      end select
      select case(sec)
      case('coord_3d_a'); call test_geometry_reader_file_coord_CaMgCO_3d
      case('coord_3d_b'); call test_geometry_reader_file_coord_CaF2_3d
      case('coord_2d');   call test_geometry_reader_file_coord_C_2d
      case('coord_1d');   call test_geometry_reader_file_coord_C_1d
      case('coord_0d');   call test_geometry_reader_file_coord_general_0d
      case('xmol_0d');    call test_geometry_reader_file_xmol_water_0d
      case('poscar_3d');  call test_geometry_reader_file_poscar_sio2_3d
      case('molfile'); call test_geometry_reader_molfile_benzen
      case('molfile_flat'); call test_geometry_reader_molfile_benzen_flat
      case('sdfile'); call test_geometry_reader_file_sdf_h2o
      case('sdfile_flat'); call test_geometry_reader_file_sdf_h2o_flat
      case('sdfile_noh'); call test_geometry_reader_file_sdf_benzen_hquery
      case('pdb'); call test_geometry_reader_file_pdb_4qxx
      case('pdb_noh'); call test_geometry_reader_file_pdb_4qxx_noh
      case('gen'); call test_geometry_reader_file_gen
      end select
      select case(sec)
      case('convert'); call test_pbc_tools_convert
      case('cutoff');  call test_pbc_tools_cutoff
      end select
      select case(sec)
      case('mic');  call test_class_molecule_mic_distances
      case('axis'); call test_class_molecule_axis_trafo
      end select
      select case(sec)
      case('0d'); call test_wigner_seitz_0d
      case('3d'); call test_wigner_seitz_3d
      end select
      select case(sec)
      case('list'); call test_atomlist
      end select
      select case(sec)
      case('water');  call test_symmetry_water
      case('li8'); call test_symmetry_li8
      case('pcl3'); call test_symmetry_pcl3
      case('c20'); call test_symmetry_c20
      end select
      select case(sec)
      case('axis'); call test_axis
      case('calc'); call test_thermo_calc
      case('print'); call test_print_thermo
      end select
      select case(sec)
      case('pbc3d'); call test_latticepoint_pbc3d
      end select
   end select

   ! falling through the tester is always an error
   call terminate(1)

end program peeq_tester

and slowly adding the modules, one finds that there is not a consistent naming system - for teh modules which is interesting, my use of interesting is not a positive statement, so you will need a program like Fileseek to locate the modules and add and debug them slowly. 

You can then comment out all the lines and slowly debug it -- 

The code defines single precision and double precision in one module but then uses WP to pick one, but finding it is hard, so the default is not known. 

 As I said about a weeks work if you know how to code and are comfortable with modules and libraries.  


Valued Contributor I

but this will force it to die when I hit CTRL^C.

A comment in the program file - interesting comment.