<?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 Code resulting infinity values in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423740#M163223</link>
    <description>&lt;P&gt;Hello, everyone.&lt;/P&gt;
&lt;P&gt;Please, could somebody help-me with the code below? It is resulting in infinity value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;            PROGRAM MR
!============================================================
!DECLARACAO DAS VARIAVEIS
!============================================================
            IMPLICIT NONE
            REAL, EXTERNAL::F
            INTEGER, PARAMETER :: N=6, NPC=4
            INTEGER I, J
            REAL :: X(0:N),Y(0:N),A(0:6),B(0:6),HP,XP(0:NPC),P(0:NPC)

            OPEN(UNIT=20, FILE="FUNCA.txt", STATUS="UNKNOWN")
!============================================================
!DADOS DA FUNCAO INTERPOLADA
!============================================================
            PRINT*, "DADOS DA FUNCAO"
            DO I=0, N
                X=X(I)+1
                Y(I)=F(X)
                WRITE(20,*)X(I),Y(I)
                WRITE(*,*)I,X(I),Y(I)
            END DO
!============================================================
!COEFICIENTES DAS FUNCOES INTERPOLADAS
!============================================================
            PRINT*, "COEFICIENTE DAS FUNCOES"
            DO I=0, N-1
                A(I)=(Y(I+1)-Y(I))/(X(I+1)-X(I))
                B(I)=(Y(I)*X(I+1)-(I)*Y(I+1))/(X(I+1)-X(I))
            WRITE (*,*)I,A(I),B(I)
            END DO

            END PROGRAM MR
!============================================================
!FUNCAO
!============================================================
            REAL FUNCTION F(X)
            IMPLICIT NONE
            REAL*4::x
            F = SIN(X/2)
            END
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; DADOS DA FUNCAO
           0   1.00000000      0.479425550
           1   2.00000000      0.841470957
           2   3.00000000      0.997494996
           3   4.00000000      0.909297407
           4   5.00000000      0.598472118
           5   6.00000000      0.141120002
           6   7.00000000     -0.350783229
 COEFICIENTE DAS FUNCOES
           0         Infinity         Infinity
           1         Infinity         Infinity
           2        -Infinity         Infinity
           3        -Infinity         Infinity
           4        -Infinity         Infinity
           5        -Infinity         Infinity&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thank you!!&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2022 18:08:41 GMT</pubDate>
    <dc:creator>Henry26</dc:creator>
    <dc:date>2022-10-20T18:08:41Z</dc:date>
    <item>
      <title>Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423740#M163223</link>
      <description>&lt;P&gt;Hello, everyone.&lt;/P&gt;
&lt;P&gt;Please, could somebody help-me with the code below? It is resulting in infinity value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;            PROGRAM MR
!============================================================
!DECLARACAO DAS VARIAVEIS
!============================================================
            IMPLICIT NONE
            REAL, EXTERNAL::F
            INTEGER, PARAMETER :: N=6, NPC=4
            INTEGER I, J
            REAL :: X(0:N),Y(0:N),A(0:6),B(0:6),HP,XP(0:NPC),P(0:NPC)

            OPEN(UNIT=20, FILE="FUNCA.txt", STATUS="UNKNOWN")
!============================================================
!DADOS DA FUNCAO INTERPOLADA
!============================================================
            PRINT*, "DADOS DA FUNCAO"
            DO I=0, N
                X=X(I)+1
                Y(I)=F(X)
                WRITE(20,*)X(I),Y(I)
                WRITE(*,*)I,X(I),Y(I)
            END DO
!============================================================
!COEFICIENTES DAS FUNCOES INTERPOLADAS
!============================================================
            PRINT*, "COEFICIENTE DAS FUNCOES"
            DO I=0, N-1
                A(I)=(Y(I+1)-Y(I))/(X(I+1)-X(I))
                B(I)=(Y(I)*X(I+1)-(I)*Y(I+1))/(X(I+1)-X(I))
            WRITE (*,*)I,A(I),B(I)
            END DO

            END PROGRAM MR
!============================================================
!FUNCAO
!============================================================
            REAL FUNCTION F(X)
            IMPLICIT NONE
            REAL*4::x
            F = SIN(X/2)
            END
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; DADOS DA FUNCAO
           0   1.00000000      0.479425550
           1   2.00000000      0.841470957
           2   3.00000000      0.997494996
           3   4.00000000      0.909297407
           4   5.00000000      0.598472118
           5   6.00000000      0.141120002
           6   7.00000000     -0.350783229
 COEFICIENTE DAS FUNCOES
           0         Infinity         Infinity
           1         Infinity         Infinity
           2        -Infinity         Infinity
           3        -Infinity         Infinity
           4        -Infinity         Infinity
           5        -Infinity         Infinity&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thank you!!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 18:08:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423740#M163223</guid>
      <dc:creator>Henry26</dc:creator>
      <dc:date>2022-10-20T18:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423747#M163224</link>
      <description>&lt;P&gt;You&amp;nbsp; need to fix this error first&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-10-20 133512.png" style="width: 862px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/34373i183406C94A5A48D1/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="Screenshot 2022-10-20 133512.png" alt="Screenshot 2022-10-20 133512.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am usign the latest compiler IFX and IFORT both complain.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 18:38:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423747#M163224</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-10-20T18:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423753#M163227</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;            PRINT*, "DADOS DA FUNCAO"
            DO I=0, N
                X=X(I)+1
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two issues with the above:&lt;/P&gt;
&lt;P&gt;1) At the point of execution of line 3 (line 17 of posted code), the array X was(is) undefined.&lt;/P&gt;
&lt;P&gt;2) The statement X=X(I)+1, takes the scalar variable result of the expression "X(I)+1", and assigns it to the entire array X(0:N). In this case X(0:N) receives "undefined value at X(0) +1", and repeats this for "X(1)+1", ... "X(N)+1". And at the end of the loop,&amp;nbsp;"X(N)+1". Note, the entire array of X changes at each iteration (each iteration using undefined values including values defined using undefined values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Strike (1) the above, apparently the code snip above is missing lines that defined the values of X(0:9).&lt;/P&gt;
&lt;P&gt;Point (2) may still be of importance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 18:59:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423753#M163227</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-10-20T18:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423755#M163229</link>
      <description>&lt;P&gt;Thanks you for the answer&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/63968"&gt;@jimdempseyatthecove&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, how could I fix it? I just need to make an array from 0-N and after use the values of this array to input in a function&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 18:57:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423755#M163229</guid>
      <dc:creator>Henry26</dc:creator>
      <dc:date>2022-10-20T18:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423761#M163230</link>
      <description>&lt;P&gt;Would the following represent what you intend?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;            DO I=0, N
!**change**     X=X(I)+1
                X(I)=I+1
!**change**     Y(I)=F(X)
                Y(I)=F(X(I))
                WRITE(20,*)X(I),Y(I)
                WRITE(*,*)I,X(I),Y(I)
            END DO
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Oct 2022 19:11:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423761#M163230</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-10-20T19:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423763#M163231</link>
      <description>&lt;P&gt;Note, the second change is what JohnNichols pointed out as an error to line 18,&lt;/P&gt;
&lt;P&gt;X is a rank-1 array&lt;/P&gt;
&lt;P&gt;F(X) is a rank-1 array of SIN's of the array X.&lt;/P&gt;
&lt;P&gt;This cannot be assigned to a scalar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 19:15:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423763#M163231</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-10-20T19:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Code resulting infinity values</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423766#M163232</link>
      <description>&lt;P&gt;Now it works!! Thank you so much!!!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 19:36:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Code-resulting-infinity-values/m-p/1423766#M163232</guid>
      <dc:creator>Henry26</dc:creator>
      <dc:date>2022-10-20T19:36:48Z</dc:date>
    </item>
  </channel>
</rss>

