<?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: Debug in OpenMP in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437761#M163985</link>
    <description>&lt;P&gt;The only time I've seen a case similar to this (~15 years ago) was where a piece of my errant code overwrote the instructions at or near the place where the error trap occurs. Your case is a little different in that, usually when this happens, the insertion of diagnostic code causes the error to go away or move.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you run your code with all runtime diagnostic code enabled? This will catch most index out of bounds and most/many uninitialized variable usages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, an additional measure I would use is at point of error, I'd open a Disassembly window (and registers window(s)) and examine the instruction set. nxi will have loaded into a register for use in division (or generation of reciprocal and then multiplication). The residual values within the registers may shed some light on this (at least for someone familiar with reading assembly).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
    <pubDate>Mon, 12 Dec 2022 14:41:41 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2022-12-12T14:41:41Z</dc:date>
    <item>
      <title>Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1436649#M163940</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to know how every body does debug when you use OpenMP in Fortran.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A piece of my code using OMP is shown in the end. There are many subroutines called in &lt;FONT color="#E96115"&gt;fe_element_results&lt;/FONT&gt;. In one of the subroutine, it calls a subroutine for a material model. If I use 20 processors, it always gave me an error&amp;nbsp; at the following place. The error message is "Unhandled exception at 0x00007FF6D807B9CF in bsam20_2022_09_13_59667d1.exe: 0xC000008E: &lt;FONT color="#C81326"&gt;Floating-point division by zero&lt;/FONT&gt; (parameters: 0x0000000000000000, 0x0000000000009964)."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I checked nxi, and it was never be zero (12.756). I want to know how to check the nxi value in all processors, so I can know how nxi can be zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I change to use only 1 processor, no error. The running will be done in the end successfully. So this error only showed up when multiple processors were used. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0071C5"&gt;The location where the error showed up:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;do i = 1,nstr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#C81326"&gt;enormal(i) = xi(i)/nxi&lt;/FONT&gt;&lt;BR /&gt;end do ! i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0071C5"&gt;A piece of my code using OMP:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#C81326"&gt; !$OMP PARALLEL DO PRIVATE(elem)&lt;/FONT&gt;&lt;BR /&gt;! make the element results&lt;BR /&gt;do i=1,group%elem_count&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elem =&amp;gt; group%elements(i)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call &lt;FONT color="#E96115"&gt;fe_element_results&lt;/FONT&gt;(boundary_id,elem,constit_id,temp,group%disps,ksyst)&lt;BR /&gt;end do&lt;BR /&gt;&lt;FONT color="#C81326"&gt;!$OMP END PARALLEL DO&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Carly&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 00:24:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1436649#M163940</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2022-12-08T00:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1436868#M163951</link>
      <description>&lt;P&gt;Most debuggers permit you to change the context from thread-to-thread.&lt;/P&gt;
&lt;P&gt;In MS VS there is a threads tab, click on that to view the threads, then double-click on a/each thread.&lt;/P&gt;
&lt;P&gt;gdb, eclipse, etc... have similar feature.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use this to locate the offending thread. Note, you &lt;EM&gt;may&lt;/EM&gt; need to look at each thread's dissassembly code to locate one performing a (one of) division instruction. Then with this thread in context, examine the value of the variables.&lt;/P&gt;
&lt;P&gt;Note, nxi may differ amoungst threads.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens when using OMP_NUM_THREADS=1? ...=2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 15:24:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1436868#M163951</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-12-08T15:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1436982#M163961</link>
      <description>&lt;P&gt;Hi, Jim,&lt;/P&gt;
&lt;P&gt;Thanks for your suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;OMP_NUM_THREADS=1, the running can be done successfully. However, if&amp;nbsp;OMP_NUM_THREADS is larger than 1, I have the above errors. I changed the codes in the following way to make sure nxi is larger than zero. The running still stopped at the red line with the save error message (divided by zero), but nxi is not zero. I will learn how to the nxi values in each thread. Thanks.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if (nxi.gt.1e-10) then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i = 1,nstr&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;enormal(i) = xi(i)/nxi&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end do ! i&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="sub_section_element_selectors"&gt;endif&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="sub_section_element_selectors"&gt;Carly&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 21:40:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1436982#M163961</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2022-12-08T21:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437527#M163978</link>
      <description>&lt;P&gt;Is nxi a shared variable or a private variable?&lt;/P&gt;
&lt;P&gt;If shared, is it modified within a parallel region (or by other process non-OpenMP thread)?&lt;/P&gt;
&lt;P&gt;Have you run Debug build with full runtime checks?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 21:10:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437527#M163978</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-12-11T21:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437540#M163979</link>
      <description>&lt;P&gt;Circa 1968, print out the thread number, i and nxi before the equation and then trap the zero.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 23:54:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437540#M163979</guid>
      <dc:creator>JohnNichols</dc:creator>
      <dc:date>2022-12-11T23:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437561#M163980</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;Only the subroutine "fe_element_results" is called when OMP is activated, and only the data structure "elem" is set to be private. Inside of the subroutine "fe_element_results", there are many subroutines are called at different levels.&lt;/P&gt;
&lt;P&gt;The subroutine "mises" is called very late. Inside of the subroutine "mises", "nxi" is a local variable, which is a norm of the vector. I set a condition to run the problematic code only when "nxi" is larger than zero, but I still have the "divided by zero" mistake. I took John's suggestion, and printed out the thread ID and "nxi" values as follows.&lt;/P&gt;
&lt;P&gt;A screen shot of the error message is included in this message. Only thread 0 is used, even though I set the max thread number is 2. And there is no zero values for "nxi". The information from the screen is also shown below. I didn't put all the print-out of "nxi", but I pretty sure there all "nxi" are positive. When the running stopped, "i" is equal to 4, and the values xi(i) are normal. However, the values for enormal(1:3) are all zeros. I don't think the code runs for i=1~3.&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;!$OMP PARALLEL DO PRIVATE(elem)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;! make the element results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;do i=1,group%elem_count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elem =&amp;gt; group%elements(i)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;fe_element_results&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class="sub_section_element_selectors"&gt;(boundary_id,elem,constit_id,temp,group%disps,ksyst)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;end do&lt;/SPAN&gt;&lt;BR /&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;!$OMP END PARALLEL DO&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#0000FF"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;The location where the running stopped:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#000000"&gt;&lt;SPAN class="sub_section_element_selectors"&gt; do i = 1,nstr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;write(*,*) "Hello from process: ", OMP_GET_THREAD_NUM(),nxi&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;enormal(i) = xi(i)/nxi&lt;BR /&gt;end do ! i&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#0000FF"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;The information on the screen:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#0000FF"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#0000FF"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#0000FF"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Hello from process: 0 3.93085348357440&lt;BR /&gt;Hello from process: 0 3.37072760756458&lt;BR /&gt;Hello from process: 0 3.25511677539116&lt;BR /&gt;Hello from process: 0 3.24071910804205&lt;BR /&gt;Hello from process: 0 4.59724023178906&lt;BR /&gt;Hello from process: 0 4.59370775225122&lt;BR /&gt;Hello from process: 0 4.56246536667898&lt;BR /&gt;Hello from process: 0 4.54824517293683&lt;BR /&gt;Hello from process: 0 4.55925767089883&lt;BR /&gt;Hello from process: 0 4.46978041023899&lt;BR /&gt;Hello from process: 0 4.52182459800371&lt;BR /&gt;Hello from process: 0 4.46638424757439&lt;BR /&gt;Hello from process: 0 4.46644457574595&lt;BR /&gt;Hello from process: 0 4.38515075169356&lt;BR /&gt;Hello from process: 0 4.32231049267378&lt;BR /&gt;forrtl: error (73): floating divide by zero&lt;BR /&gt;Image PC Routine Line Source&lt;BR /&gt;bsam20_2022_10_21 00007FF63BCDFACA Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BCC8DC0 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BC9CE28 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BAF6504 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BAE01A8 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BA3D250 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BA01F9A Unknown Unknown Unknown&lt;BR /&gt;libiomp5md.dll 00007FFB02BC0653 Unknown Unknown Unknown&lt;BR /&gt;libiomp5md.dll 00007FFB02B20A97 Unknown Unknown Unknown&lt;BR /&gt;libiomp5md.dll 00007FFB02B21E4E Unknown Unknown Unknown&lt;BR /&gt;libiomp5md.dll 00007FFB02AD8D21 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BA01BDD Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BC02DBA Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63BA64797 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63B8B973E Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63B74DB6B IBN_INI 735 ibn_ini.f&lt;BR /&gt;bsam20_2022_10_21 00007FF63BCE9A8E Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63C1EC0D9 Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63C1EBF7E Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63C1EBE3E Unknown Unknown Unknown&lt;BR /&gt;bsam20_2022_10_21 00007FF63C1EC16E Unknown Unknown Unknown&lt;BR /&gt;KERNEL32.DLL 00007FFB2A9B4ED0 Unknown Unknown Unknown&lt;BR /&gt;ntdll.dll 00007FFB2BBBE40B Unknown Unknown Unknown&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 01:45:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437561#M163980</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2022-12-12T01:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437761#M163985</link>
      <description>&lt;P&gt;The only time I've seen a case similar to this (~15 years ago) was where a piece of my errant code overwrote the instructions at or near the place where the error trap occurs. Your case is a little different in that, usually when this happens, the insertion of diagnostic code causes the error to go away or move.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you run your code with all runtime diagnostic code enabled? This will catch most index out of bounds and most/many uninitialized variable usages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, an additional measure I would use is at point of error, I'd open a Disassembly window (and registers window(s)) and examine the instruction set. nxi will have loaded into a register for use in division (or generation of reciprocal and then multiplication). The residual values within the registers may shed some light on this (at least for someone familiar with reading assembly).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 14:41:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1437761#M163985</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-12-12T14:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440344#M164142</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am still trying to learn how to check register. However, I found the code will stop for different reasons if I run multiple times. If the error is "Floating-point division by zero (parameters: 0x0000000000000000, 0x0000000000009964).", nxi is really zero in some thread, which should be impossible for the code. I caught this after I wrote everything into a file, not on screen.&lt;/P&gt;
&lt;P&gt;I put the main frame of the code as follows. I still don't understand why all the errors are related to nxi, a local variable. The errors always happened in the following 3 places which are marked in red. If it happened in the first place, the error is "invalid floating operation. For the 2nd places, the error is "Floating-point division by zero". For the 3rd place, either "Floating-point division by zero" or "0xC0000090: Floating-point invalid operation (parameters: 0x0000000000000000, 0x0000000000009961).".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A screenshot of the error for the current run is attached in the message. At this time, the error showed up at the 2nd place. However, there is no&amp;nbsp;nxi values written into the file from the 2nd place. Instead, all the nxi written into the file are from the 3rd place. nxi is zero only once. The running didn't stop when nxi is zero immediately. It stopped in the next iteration loop.&lt;/P&gt;
&lt;P&gt;the frame of the code:&lt;/P&gt;
&lt;P&gt;compute nxi=xi(1)*xi(1)+xi(2)*xi(i)+....xi(6)*xi(6)&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;nxi = dsqrt(nxi)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;if (nxi.gt.1e-10.and.....) then&lt;FONT color="#008000"&gt; !I don't understand how nxi can be zero because of this condition.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;do i = 1,nstr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(nxi.lt.1e-5) write(iunit,*) "enormal Hello from process: ", OMP_GET_THREAD_NUM(),nxi&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;enormal(i) = xi(i)/nxi&lt;/FONT&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end do ! i&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if(lambda.gt.0.0d0) then&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; write(iunit,*) "Hello from process: ", OMP_GET_THREAD_NUM(),nxi&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#FF0000"&gt;ct2 = twog*lambda/nxi&lt;/FONT&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ct1 = twog*(1.d0 - ct2)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ct2 = twog*(ct2 - twog/(lam1 + lam2*expbl))&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;else ! &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ct1 = twog&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ct2 = 0.0d0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;endif&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;endif&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nxi value written into a file:&lt;/P&gt;
&lt;P&gt;Hello from process: 0 27.5011288096126 &lt;BR /&gt;Hello from process: 0 23.4530657556719 &lt;BR /&gt;Hello from process: 0 16.8064387718508 &lt;BR /&gt;&lt;FONT color="#008000"&gt;Hello from process: 0 0.000000000000000E+000&lt;/FONT&gt;&lt;BR /&gt;Hello from process: 0 19.3280241275060&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="error.PNG" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/36379i8A662448B906F5B4/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="error.PNG" alt="error.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 05:38:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440344#M164142</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2022-12-21T05:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440478#M164146</link>
      <description>&lt;P&gt;&lt;STRONG&gt;For the error trapping source file&lt;/STRONG&gt;, set the Floating Point Model to Precise, and Floating Point Speculation to Off&lt;/P&gt;
&lt;P&gt;You also might want to experiment with&lt;/P&gt;
&lt;P&gt;/Qprec&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; improve floating-point precision&lt;BR /&gt;&lt;SPAN&gt;/Qprec-sqrt&amp;nbsp; &amp;nbsp; improve&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;square root precision&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;/Qprec-div&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;improve precision of FP divides (some speed impact)&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set the above in Command Line, Additional Options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, in MS VS you can vary the options on a file by file basis. In Solution Explorer window, Right-Click on source file and select Properties and navigate from there. After options are selected, the file icon in Solution Explorer will have a noticeable tag as a reminder that the file has different settings than the project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes regarding your Hello from...&lt;/P&gt;
&lt;P&gt;A formatted write can print 0.0 for very small non-zero numbers. Use Z edit descriptor to print the Hex value.&lt;/P&gt;
&lt;P&gt;The sqrt/dsqrt functions can be set to various precision values (fast==lesser precision)&lt;/P&gt;
&lt;P&gt;Division, fast mode, is often performed by produce reciprocal (at loss of precision) then multiply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And are you certain that variable nxi is local to the procedure .and. not shared.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 14:49:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440478#M164146</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-12-21T14:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440949#M164163</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;Thanks for your guidance. For your last question, I want to confirm when to define the private and share variables for OpenMP. Based on my understanding, the variables need to be claimed either as shared or private only when the OpenMP is activated. In my code, the OpenMP is activated in the following place, so I claimed a big data structure "elem" as a private variable. Other parameters passed into&amp;nbsp;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;fe_element_results&amp;nbsp;&lt;FONT color="#000000"&gt;are supposed to be shared by default. Then many subroutines are in&amp;nbsp;fe_element_results subroutine. And one of them eventually called the subroutine mises. "nxi" is a local variable in the subroutine mises. I searched "nxi" in the whole package. It is only used in the mises subroutine. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&lt;FONT color="#000000"&gt;For the parameters passed into the subroutines called directly or indirectly by&amp;nbsp;fe_element_results, do we need to claim their variables to be private or shared? I thought they should be private by default, because they are already in different treads when they are used.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;!$OMP PARALLEL DO PRIVATE(elem)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;! make the element results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;do i=1,group%elem_count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elem =&amp;gt; group%elements(i)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call&amp;nbsp;&lt;/SPAN&gt;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;fe_element_results&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class="sub_section_element_selectors"&gt;(boundary_id,elem,constit_id,temp,group%disps,ksyst)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;end do&lt;/SPAN&gt;&lt;BR /&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;!$OMP END PARALLEL DO&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&lt;FONT color="#000000"&gt;Subroutine&lt;/FONT&gt;&amp;nbsp;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;fe_element_results&lt;/FONT&gt;(boundary_id,elem,constit_id,temp,group%disps,ksyst)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#000000"&gt;call subroutine A(para a1, para a2, ....)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call subroutine AA&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#000000"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;end subroutine&amp;nbsp;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;fe_element_results&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#000000"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;Subroutine A&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;FONT color="#000000"&gt;(para a1, para a2, ....)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call mises(para m1, para m2,....)&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#000000"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;end subroutine A&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#000000"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;Carly&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 18:15:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440949#M164163</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2022-12-22T18:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440992#M164164</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;&lt;SPAN class="sub_section_element_selectors"&gt;call&amp;nbsp;&lt;/SPAN&gt;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;fe_element_results&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class="sub_section_element_selectors"&gt;(boundary_id,elem,constit_id,temp,group%disps,ksyst)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This will be safe (for the sketch supplied) provided:&amp;nbsp;&lt;EM&gt;&lt;SPAN class="sub_section_element_selectors"&gt;boundary_id, constit_id, temp, group%disps,ksyst&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="sub_section_element_selectors"&gt;remain unchanged during the call. I have suspicions about &lt;EM&gt;temp &lt;/EM&gt;though you verify all arguments, as well as all module and common variables remain unchanged through the call chain. (otherwise, they need to be private)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="sub_section_element_selectors"&gt;Jim Dempsey&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 20:48:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1440992#M164164</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-12-22T20:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1441046#M164166</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;I am not sure how to deal with global variables in OpenMP. I summarized the following items to make sure I got your ideas.&lt;/P&gt;
&lt;P&gt;1. if I drop "elem" from the parameter list for&amp;nbsp;&lt;SPAN&gt;fe_element_results subroutine list, should I add "i" in the parameter list and claim it private? "i" is the index for the elements. "elem" is a sub-data structure for group for element "i".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;!$OMP PARALLEL DO PRIVATE(elem)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;! make the element results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;do i=1,group%elem_count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elem =&amp;gt; group%elements(i)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call&amp;nbsp;&lt;/SPAN&gt;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;fe_element_results&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN class="sub_section_element_selectors"&gt;(boundary_id,elem,constit_id,temp,group%disps,ksyst)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sub_section_element_selectors"&gt;end do&lt;/SPAN&gt;&lt;BR /&gt;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;&lt;SPAN class="sub_section_element_selectors"&gt;!$OMP END PARALLEL DO&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="sub_section_element_selectors"&gt;2. "temp" is a double precision scalar data for an incremented temperature.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="sub_section_element_selectors"&gt;3. You mentioned for all the global variables (saved in modules), they need to be claimed as private parameters if they are changed in any place in&amp;nbsp;&lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;fe_element_results&amp;nbsp;&lt;/FONT&gt;and all other subroutines called directly or indirectly by &lt;FONT class="sub_section_element_selectors" color="#E96115"&gt;fe_element_results&lt;/FONT&gt;. I will check this carefully. I think the place to claim these global variables if needed should be still in&amp;nbsp;&lt;FONT class="sub_section_element_selectors" color="#C81326"&gt;!$OMP PARALLEL DO PRIVATE(elem,....)&lt;/FONT&gt;, right?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="sub_section_element_selectors"&gt;4. I used "&lt;SPAN&gt;write(iunit,'(A,d20.14)') "Hello from process: ", OMP_GET_THREAD_NUM(),nxi" to write the nxi values from different threads into one single file in the "mises" subroutine. "iunit" is a global IO number. I think it should be a shared variable. When one thread is writing information into the iunit file, will other threads be influenced if they want to write the data into the iunit file at the same time?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Carly&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 00:26:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1441046#M164166</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2022-12-23T00:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1441215#M164172</link>
      <description>&lt;P&gt;1) elem must be private (each thread must have unique pointer). On parallel do, the loop control variable is implicitly private. You can declare i private if you want for clarity purposes, but it is not necessary.&lt;/P&gt;
&lt;P&gt;2) temp(erature) is ok shared.&lt;/P&gt;
&lt;P&gt;3) yes. For global variables (module and common) that store intermediary results, these need to be private.&lt;/P&gt;
&lt;P&gt;*** however *** declaring these private on the parallel do will not make them private in the called procedures. Private applies only to the immediate scope of the parallel region (not to any called procedure).&lt;/P&gt;
&lt;P&gt;For temporary work variables that are global, use &lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/t-to-z/threadprivate.html" target="_self"&gt;threadprivate&lt;/A&gt; at the declaration of the variable (not on the !$omp parallel...).&lt;/P&gt;
&lt;P&gt;Note the example in the reference guide shows for named common, but you can also use threadprivate on module variables as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*** additionally *** should you have an accumulation variable in a parallel region you would use the &lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/q-to-r/reduction.html" target="_self"&gt;REDUCTION&lt;/A&gt; clause.&lt;/P&gt;
&lt;P&gt;4. shared is the default property of parallel regions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additional notes:&lt;/P&gt;
&lt;P&gt;WRITE to a file, when (potentially) executed concurrently, should be protected by a critical section. This is to prevent co-mingling of the text within/amoungst the records of all conflicting threads. Further it is recommended that you name each critical section with a unique name. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;if(nxi.lt.1e-5) then
   !$omp critical(critical_enormal) ! pre-pend critical_ to assure no name conflict with variable "enormal" if any
   write(iunit,*) "enormal Hello from process: ", OMP_GET_THREAD_NUM(),nxi
   !$omp end critical(critical_enormal)
endif&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that you can insert a debugger break point there to help catch errors (assuming nxi.lt.1e-5 should never occur).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 13:43:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1441215#M164172</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2022-12-23T13:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446149#M164435</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After getting stuck by this problem around 5 months, I finally found the reasons. The biggest problem is that I used "save" after clarifying the data types in the "mises" subroutine. This made "nxi" saved in each thread was totally messed up. After deleting "save", many cases using multithreads can be run successfully. Another issue is about how to calculate nxi. I have to explicitly compute nxi in the subroutine, rather than call a function (as the first commented line). If I call the function "dot_fl" to calculate nxi, the running will stuck in the calling place with the error message "float-point invalid operation". I still don't understand this point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, the code can run without problems now. Thanks Jim for teaching me to access the information in each thread, which helped me a lot to narrow down the problem scope.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000"&gt;! nxi = sqrt(dot_fl(xi(1:6),xi(1:nstr),6) + dot_fl(xi(4:6),xi(4:nstr),3))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;nxi = 0.0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;do ii = 1,6&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; nxi = nxi + xi(ii)*xi(ii)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;enddo&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;do ii=4,6&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; nxi = nxi + xi(ii)*xi(ii)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;enddo&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;nxi = dsqrt(nxi) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Carly&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 17:28:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446149#M164435</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2023-01-12T17:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446476#M164446</link>
      <description>&lt;P&gt;It would help if you show the function dot_fi .AND. the value of nstr.&lt;/P&gt;
&lt;P&gt;Your replacement code would indicate&lt;STRONG&gt; nstr must be 6&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;real :: dot_fi = 0.0 ! initialization of local/return variable is implicitly SAVE
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus if your function dot_fi initialized the result as part of the declaration, you would have a threading problem.&lt;/P&gt;
&lt;P&gt;Initialize your local variables as statements within the procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And Fortran has the function &lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/c-to-d/dot-product.html" target="_self"&gt;DOT_PRODUCT&lt;/A&gt;, consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;nxi = sqrt(dot_product(xi(1:6),xi(1:6) + dot_product(xi(4:6),xi(4:6))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;assuming there isn't a problem with nstr not being 6&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 16:20:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446476#M164446</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-01-13T16:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446524#M164451</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, nstr=6. I set its value in the beginning of the mises subroutine.&amp;nbsp;My dot_fl function is defined below. When I copied it here, I found the problem, I used "save" there. After I deleted it "save", put it into an external module and include it in&amp;nbsp;mises. It has no problem now. This is the way I want. Using the Fortran function "dot_product" also works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I checked some comments on line about "save" in Fortran. Somebody said it is a disaster for multithead coding. Now I fully agree with it:) Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function dot_fl(a,b,n)&lt;BR /&gt;!=======================================================================&lt;BR /&gt;!&amp;gt; @brief dot (scalar) product of two vectors&lt;BR /&gt;!&amp;gt; @details&lt;BR /&gt;!&amp;gt; Inputs:&lt;BR /&gt;!&amp;gt; a(*) - Vector 1&lt;BR /&gt;!&amp;gt; b(*) - Vector 2&lt;BR /&gt;!&amp;gt; nn - length of vectors&lt;BR /&gt;!&amp;gt; Outputs:&lt;BR /&gt;!&amp;gt; dot_fl- Scalar product&lt;BR /&gt;!=======================================================================&lt;/P&gt;
&lt;P&gt;implicit none&lt;/P&gt;
&lt;P&gt;integer ii,n&lt;BR /&gt;real(8) dot_fl, a(*),b(*)&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;save&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;dot_fl = 0.0d0&lt;BR /&gt;do ii = 1,n&lt;BR /&gt;dot_fl = dot_fl + a(ii)*b(ii)&lt;BR /&gt;end do ! i&lt;/P&gt;
&lt;P&gt;end function dot_fl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Carly&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 19:28:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446524#M164451</guid>
      <dc:creator>Carlygao</dc:creator>
      <dc:date>2023-01-13T19:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Debug in OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446623#M164454</link>
      <description>&lt;P&gt;As you highlighted, the save statement attributes all local variables (ii in this case) with SAVE thus making the procedure unsafe for threaded programming.&lt;/P&gt;
&lt;P&gt;Note, this code could potentially run in a threaded program for a long time without experiencing an error. Expect no error if a thread can get in and out of the function prior to another thread getting info the function .OR. if compiler optimization happens to registerize ii in this case. IOW you were lucky that your testing exhibited an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 22:39:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Debug-in-OpenMP/m-p/1446623#M164454</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2023-01-13T22:39:27Z</dc:date>
    </item>
  </channel>
</rss>

