<?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 Re: run-time error with ifort 9.1 when passing functions in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753735#M9376</link>
    <description>&lt;DIV style="margin: 0px; height: auto;"&gt;&lt;/DIV&gt;
I don't see anything wrong with the code. It could be there was a bug in 9.1 that you encountered - it isn't an issue I remember, not that that means anything. The issue you linked to is completely different - "segmentation fault" has an infinite number of possible causes. If you build with -traceback, is there more meaningful information as to where the error occurs? &lt;BR /&gt;</description>
    <pubDate>Fri, 13 Mar 2009 15:57:46 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2009-03-13T15:57:46Z</dc:date>
    <item>
      <title>run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753734#M9375</link>
      <description>Hi everybody,&lt;BR /&gt;&lt;BR /&gt;I came across this issue when using different ifort compilers. I normally use ifort 10.0.023 in which case the following code compiles and runs normally. However, I had to change to a parallel computer where ifort 9.1. is installed and this time the code compiles normally but has run-time segmentation fault. I don't see where the error might be in the code, I don't know is it because of the fact that the functions are being passed as arguments or what.&lt;BR /&gt;&lt;BR /&gt;If anybody has any ideas what the problem might be, it would be really helpful. The code is attached below. The run time error apparently occurs when function func isn't recognized in function hx. I compile with ifort -r8 -o test_ts fp_test_ts.f90.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[plain]module utl
 implicit none
 contains
  function cft(a,b,n,func)
     implicit none
     real,intent(in)    :: a,b
     integer,intent(in) :: n
     real               :: cft(0:n)
     interface
       function func(x)
         implicit none
         real,intent(in) :: x(:)
         real            :: func(size(x))
       end function func
     end interface
     real :: th(0:n)
     th = b-a
     cft = func(th)
   end function cft
end module utl

module test_mod
 implicit none
 real             :: ts(1)
 contains
  function FCD(func,t1,t2,M,N) result(Amn)
    implicit none
    real, intent(in)      :: t1,t2     
    integer,intent(in)    :: M,N 
    complex               :: Amn(-M:M,0:N)
    interface
      function func(x,t)
        real,intent(in)   :: x(:),t(:)
        real              :: func(size(t),size(x))
      end function func
    end interface   
    complex,parameter     :: i = (0.,1.)
    real                  :: tD(0:M)
    complex               :: FN(0:M,0:M)
    integer               :: j,k
    tD  = (t2-t1)*(/ (j, j=0,M) /)
    forall (j = 0:M,k = 0:M) FN(j,k) = -i*j*k
    Amn(0:M,:) = matmul(FN,Cn(tD,N))
    Amn(-1:-M:-1,:) = conjg(Amn(1:M,:))
   contains
 !----------------------------------------------------------------------------- 
    function Cn(t,N)
      use utl,  only : cft
      implicit none
      real,intent(in),dimension(:)   :: t 
      integer,intent(in)             :: N
      real                           :: Cn(size(t),0:N),x(0:N)
      integer                        :: k1      
      forall (k1 = 0:N) x(k1) = 1.0*k1/(N+1)
      do k1 = 1,size(t)
      	ts = t(k1)
        Cn(k1,:) = cft(x(0),x(N),N,hx) 
      end do
    end function Cn  
  !-----------------------------------------------------------------------------  
    function hx(x)
      implicit none
      real,intent(in),dimension(:)  :: x
      real,dimension(size(x))       :: hx 
      real                          :: dum(1,size(x))
      print *,' **** hx'
      print *,' ts = ',ts
      print *,' func(0.1,0.1) = ', func( (/0.1/), (/0.1/) )
      dum = func(x,ts)
      hx = dum(1,:)
    end function hx      
  end function FCD 
end module test_mod
!*****************************************************************************
program test_prog&lt;BR /&gt;use test_mod, only : FCD
 implicit none
 integer,parameter    :: M = 1, N = 10
 real,parameter       :: a=0.0,b=1.0
 complex              :: Amn(-M:M,0:N)
  Amn = FCD(func,a,b,M,N)
  print *, 'Amn = ',Amn
 contains
  function func(x,t)
    implicit none
    real,intent(in)  :: x(:),t(:)
    real             :: func(size(t),size(x))
    integer          :: i
    do i = 1,size(t)
      func(i,:) = sin(t(i))*cos(x)
    end do
  end function
end program test_prog[/plain]&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The error I get is the following:&lt;BR /&gt;&lt;BR /&gt;forrtl: severe (174): SIGSEGV, segmentation fault occurred&lt;BR /&gt;Image              PC                Routine            Line        Source&lt;BR /&gt;test_ts            0000000000403775  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            0000000000403453  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            0000000000403250  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            0000000000402C2E  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            00000000004027D3  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            00000000004026AA  Unknown               Unknown  Unknown&lt;BR /&gt;libc.so.6          00002B406E87F154  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            00000000004025E9  Unknown               Unknown  Unknown&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I found a similar discussion on forum &lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=51159" target="_blank"&gt;http://software.intel.com/en-us/forums/showthread.php?t=51159&lt;/A&gt; where Steve said that there is a bug in the process of being fixed. Is this the case of the same/similar bug that has been fixed in newer versions of ifort?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Grgur</description>
      <pubDate>Fri, 13 Mar 2009 15:39:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753734#M9375</guid>
      <dc:creator>gtokic</dc:creator>
      <dc:date>2009-03-13T15:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753735#M9376</link>
      <description>&lt;DIV style="margin: 0px; height: auto;"&gt;&lt;/DIV&gt;
I don't see anything wrong with the code. It could be there was a bug in 9.1 that you encountered - it isn't an issue I remember, not that that means anything. The issue you linked to is completely different - "segmentation fault" has an infinite number of possible causes. If you build with -traceback, is there more meaningful information as to where the error occurs? &lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 15:57:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753735#M9376</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-03-13T15:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753736#M9377</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;I've tried compiling with traceback, and this time it doesn't compile. This is the error I get, i must say I don't understand much of it.&lt;BR /&gt;&lt;BR /&gt;test_ts: In function `__data_start':&lt;BR /&gt;(.data+0x8): multiple definition of `__dso_handle'&lt;BR /&gt;/usr/lib64/gcc/x86_64-suse-linux/4.1.0/crtbegin.o:(.data+0x0): first defined here&lt;BR /&gt;test_ts: In function `_init':&lt;BR /&gt;/usr/src/packages/BUILD/glibc-2.4/cc-nptl/csu/crti.S:25: multiple definition of `_init'&lt;BR /&gt;/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/../lib64/crti.o:/usr/src/packages/BUILD/glibc-2.4/cc-nptl/csu/crti.S:11: first defined here&lt;BR /&gt;test_ts: In function `_start':&lt;BR /&gt;(.text+0x0): multiple definition of `_start'&lt;BR /&gt;/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/../lib64/crt1.o:init.c:(.text+0x0): first defined here&lt;BR /&gt;test_ts: In function `main':&lt;BR /&gt;(.text+0xb8): multiple definition of `main'&lt;BR /&gt;/opt/intel/fce/9.1.040/lib/for_main.o:(.text+0x0): first defined here&lt;BR /&gt;test_ts: In function `_fini':&lt;BR /&gt;/usr/src/packages/BUILD/glibc-2.4/cc-nptl/csu/crti.S:37: multiple definition of `_fini'&lt;BR /&gt;/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/../lib64/crti.o:/usr/src/packages/BUILD/glibc-2.4/cc-nptl/csu/crti.S:11: first defined here&lt;BR /&gt;test_ts:(.rodata+0x9b08): multiple definition of `_IO_stdin_used'&lt;BR /&gt;/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/../lib64/crt1.o:(.rodata.cst4+0x0): first defined here&lt;BR /&gt;test_ts: In function `__data_start':&lt;BR /&gt;(.data+0x0): multiple definition of `__data_start'&lt;BR /&gt;/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/../lib64/crt1.o:init.c:(.data+0x0): first defined here&lt;BR /&gt;/tmp/ifortHF5NDF.o: In function `MAIN__':&lt;BR /&gt;fp_test_ts.f90:(.text+0x0): multiple definition of `MAIN__'&lt;BR /&gt;test_ts:(.text+0x100): first defined here&lt;BR /&gt;/tmp/ifortHF5NDF.o: In function `test_mod_mp_fcd_':&lt;BR /&gt;fp_test_ts.f90:(.text+0x1e6): multiple definition of `test_mod_mp_fcd_'&lt;BR /&gt;test_ts:(.text+0x2e6): first defined here&lt;BR /&gt;/tmp/ifortHF5NDF.o: In function `utl_mp_cft_':&lt;BR /&gt;fp_test_ts.f90:(.text+0xc12): multiple definition of `utl_mp_cft_'&lt;BR /&gt;test_ts:(.text+0xd12): first defined here&lt;BR /&gt;/tmp/ifortHF5NDF.o: In function `utl._':&lt;BR /&gt;fp_test_ts.f90:(.text+0xde2): multiple definition of `utl._'&lt;BR /&gt;test_ts:(.text+0xee2): first defined here&lt;BR /&gt;/tmp/ifortHF5NDF.o: In function `test_mod._':&lt;BR /&gt;fp_test_ts.f90:(.text+0xde4): multiple definition of `test_mod._'&lt;BR /&gt;test_ts:(.text+0xee4): first defined here&lt;BR /&gt;&lt;BR /&gt;Is it helpful? I have compiled with ifort -r8 -o -traceback test_ts fp_test_ts.f90. &lt;BR /&gt;&lt;BR /&gt;Grgur&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 16:07:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753736#M9377</guid>
      <dc:creator>gtokic</dc:creator>
      <dc:date>2009-03-13T16:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753737#M9378</link>
      <description>You want instead:&lt;BR /&gt;&lt;BR /&gt;ifort -r8 -traceback -o test_ts fp_test_ts.f90&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 17:13:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753737#M9378</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-03-13T17:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753738#M9379</link>
      <description>Sorry for that. Now the run-time error shows&lt;BR /&gt;&lt;BR /&gt;forrtl: severe (174): SIGSEGV, segmentation fault occurred&lt;BR /&gt;Image              PC                Routine            Line        Source&lt;BR /&gt;test_ts            0000000000403785  test_modfcd_mp_hx          68  fp_test_ts.f90&lt;BR /&gt;test_ts            0000000000403453  utl_mp_cft_                18  fp_test_ts.f90&lt;BR /&gt;test_ts            0000000000403250  test_modfcd_mp_cn          57  fp_test_ts.f90&lt;BR /&gt;test_ts            0000000000402C2E  test_mod_mp_fcd_           43  fp_test_ts.f90&lt;BR /&gt;test_ts            00000000004027D3  MAIN__                     85  fp_test_ts.f90&lt;BR /&gt;test_ts            00000000004026AA  Unknown               Unknown  Unknown&lt;BR /&gt;libc.so.6          00002B66161DF154  Unknown               Unknown  Unknown&lt;BR /&gt;test_ts            00000000004025E9  Unknown               Unknown  Unknown&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This is more understandable, and it points to the lines where function func is called. Any ideas?&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 18:28:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753738#M9379</guid>
      <dc:creator>gtokic</dc:creator>
      <dc:date>2009-03-13T18:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753739#M9380</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Again, it looks as if it may be a compiler bug since fixed. The solution is obviously to update the compiler.&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 19:30:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753739#M9380</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-03-13T19:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: run-time error with ifort 9.1 when passing functions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753740#M9381</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Thanks Steve, at least I know I didn't go that crazy. I'll try to get it updated.&lt;BR /&gt;&lt;BR /&gt;Grgur&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 19:41:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/run-time-error-with-ifort-9-1-when-passing-functions/m-p/753740#M9381</guid>
      <dc:creator>gtokic</dc:creator>
      <dc:date>2009-03-13T19:41:11Z</dc:date>
    </item>
  </channel>
</rss>

