<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Can anyone help? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166415#M144489</link>
    <description>&lt;P&gt;Can anyone help?&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2017 01:00:12 GMT</pubDate>
    <dc:creator>MinGo_Jing</dc:creator>
    <dc:date>2017-12-04T01:00:12Z</dc:date>
    <item>
      <title>Segmentation fault while using libblas95.so( self build, dynamic) in MKL</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166414#M144488</link>
      <description>&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;My ifort compiler version 15.0.0, in composer_xe_2015.6.233, linux platform.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;I built libblas95.so from MKL source with two changes in published makefile (MKL/interfaces/blas95/makefile):&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;1. Add -fPIC while build %.o from %.f90;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;2. Add -fPIC -shared flag while generate libblas95.so;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;My source code(there may have some type error for i can't paste directly):&lt;/P&gt;

&lt;DIV class="syntaxhighlighter  " id="highlighter_73946" style="width: 872.188px; font-size: 13.3333px;"&gt;
	&lt;DIV class="line alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;

&lt;PRE class="brush:fortran;"&gt;MODULE mod_local_mkl_proc

USE blas95, only : dot, nrm2
USE f95_precision

IMPLICIT NONE
PUBLIC calc_dihedral

INTERFACE calc_dihedral
  MODULE PROCEDURE calc_dihedral_4
END INTERFACE

INTERFACE local_cross_product
  MODULE PROCEDURE local_vv_cp_4
END INTERFACE

CONTAINS

  SUBROUTINE local_vv_cp_4(cros, lv, rv)
    REAL(4) :: cros(3)
    REAL(4), INTENT(in) :: lv(3), rv(3)

    cros(1) = lv(2) * rv(3) - lv(3)*rv(2)
    cros(2) = lv(3) * rv(1) - lv(1)*rv(3)
    cros(3) = lv(1) * rv(2) - lv(2)*rv(1)

  END SUBROUTINE 

  SUBROUTINE calc_dihedral_4(dihedral, coor1, coor2, coor3, coor4)
    REAL(4), INTENT(inout) :: dihedral
    REAL(4), INTENT(in) :: coor1(3), coor2(3), coor3(3), coor4(3)

    ! locals
    REAL(4) :: delt12(3), delt23(3), delt34(3), len23, uni23(3), &amp;amp;
      d12, d23, norm_v1(3), norm_v2(3), orien_v(3)

    ! init
    orien_v = (/1.0, 1.0, 1.0/)
    delt23 = (/1.0, 1.0, 1.0/)

    ! omit Call math_dihedral_4, without this call, the error occurs too
    ! 

    delt12 = coor2 - coor1
    delt23 = coor3 - coor2
    delt34 = coor4 - coor3

    !
    ! ATTENTION here:
    ! without this print statement, the segmentation fault occurs.
    ! 
    PRINT *, delt23(1), delt23(2), delt23(3)

    len23 = nrm2(delt23)
    uni23 = delt23 / len23
    d12 = dot(delt12, delt23)
    d23 = dot(delt34, delt23)
    norm_v1 = delt12 - uni23 * d12 /len23
    norm_v2 = delt34 - uni23 * d23 /len23
    CALL local_cross_product(orien_v, norm_v1, norm_v2)
    orien_v = orien_v * delt23
  
    IF (orien_v(1) &amp;gt;= 0. .AND. orien_v(2) &amp;gt;= 0. .AND. orien_v(3) &amp;gt;= 0.) THEN
      dihedral = -dihedral
    END IF
    
  END SUBROUTINE 

END MODULE

PROGRAM main

USE mod_local_mkl_proc, ONLY: calc_dihedral
IMPLICIT NONE

  ! locals
  REAL(4) :: dih, coor1(3), coor2(3), coor3(3), coor4(3)

  ! init
  coor1 = (/0., 1., 0./)
  coor2 = (/0., 0., 0./)
  coor3 = (/1., 0., 0./)
  coor4 = (/1., 1., 1./)
  dih = 0
  PRINT *, "init"

  ! process
  CALL calc_dihedral(dih, coor1, coor2, coor3, coor4)
  PRINT *, dih
  PRINT *, "calc_dihedral done."

  ! end 
  PRINT *, "done."

END PROGRAM&lt;/PRE&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;The .o build options is blow:&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;ifort -g -fPIC -shared -check bound -gcc-name=gcc -I{MKL_INC_FLAGS} -O3 -c *.f90&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;The binary link flags:&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;ifort -o test.bin $^ -Wl,--start-roup $(LIB_INC_FLAGS) -lblas95 -lmkl_avx2 -lmkl_intel_lp64 \&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;-lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -Wl,--end-group&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;Error info with gdb&amp;gt; run:&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;Program received signal SIGSEGV, Segmentation fault.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;#0 0x00007fffef790606 in LInc1_X16_Loop2gas_1 () from /opt/intel/.../mkl/lib/intel64/libmkl_avx.so&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;#1 0x00007fffffffc320 in ?? ()&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;#2 0x0000000000000000 in ?? ()&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;Use ldd test.bin, stange things found:&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;test.bin does NOT require libmkl_avx.so, but require libmkl_avx2.so.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;When i delete the PRINT statement in function calc_dihedral_4, everything goes well, this really confused me.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-family: Arial, SimHei, SimSun, Tahoma, Helvetica, sans-serif; font-size: 13.3333px;"&gt;What's real problem with my code, could anyone help?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 08:05:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166414#M144488</guid>
      <dc:creator>MinGo_Jing</dc:creator>
      <dc:date>2017-12-01T08:05:10Z</dc:date>
    </item>
    <item>
      <title>Can anyone help?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166415#M144489</link>
      <description>&lt;P&gt;Can anyone help?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 01:00:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166415#M144489</guid>
      <dc:creator>MinGo_Jing</dc:creator>
      <dc:date>2017-12-04T01:00:12Z</dc:date>
    </item>
    <item>
      <title>You should probably ask in</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166416#M144490</link>
      <description>&lt;P&gt;You should probably ask in the MKL forum, but I'll comment that you're three years out of date on the product. Can you try a newer compiler and MKL? That removing the PRINT statement changes the behavior might indicate a compiler bug or might be a bug in your program referencing uninitialized storage.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 02:13:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166416#M144490</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2017-12-04T02:13:30Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Ret.)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166417#M144491</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Ret.) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;You should probably ask in the MKL forum, but I'll comment that you're three years out of date on the product. Can you try a newer compiler and MKL? That removing the PRINT statement changes the behavior might indicate a compiler bug or might be a bug in your program referencing uninitialized storage.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Thanks Steve, i'll try a new version later.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 02:49:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-while-using-libblas95-so-self-build-dynamic/m-p/1166417#M144491</guid>
      <dc:creator>MinGo_Jing</dc:creator>
      <dc:date>2017-12-04T02:49:26Z</dc:date>
    </item>
  </channel>
</rss>

