<div dir="ltr"><div><div><div><div><div><div><div>Hello,<br><br></div></div></div>The core NCL developers are trying to get  NCL-6.5.0 out-the-door. <br><br></div>A ticket:  NCL-2743<br><br></div>has been created. Likely, 6.5.1 or 6.6.0<br><br></div>THX <br></div><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 9, 2018 at 9:25 PM, Martin Otte <span dir="ltr"><<a href="mailto:martinjotte@gmail.com" target="_blank">martinjotte@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello,<div><br></div><div>Compiling NCL_NCARG 6.4 on OSX with Intel ifort resulted in random crashes for me. Debugging the code, I saw that ncl was crashing where C code was accessing fortran strings. As explained in this note by Intel:</div><div><br></div><div> <a href="https://software.intel.com/en-us/articles/passing-character-string-in-intel-64-mixed-fortranc-project" target="_blank">https://software.intel.com/<wbr>en-us/articles/passing-<wbr>character-string-in-intel-64-<wbr>mixed-fortranc-project</a></div><div><br></div><div>the hidden string length with Intel fortran is 8 bytes for x86_64 and 4 bytes for 32-bit code. In the NCL source code, size_t should therefore be used when passing string lengths between C and Fortran when using the Intel fortran compiler.</div><div><br></div><div>Gfortran always uses 4 byte integers for the string length, so the current NCL code works with gfortran.</div><div><br></div><div>So, for example, in ni/src/lib/hlu/Format.c, the code:</div><div><br></div><div><div>        NGCALLF(cpinrc,CPINRC)();</div><div><br></div><div>        {</div><div>                int len1,len2,len3,len4;</div><div>                NGstring cex1_f;</div><div>                NGstring cex2_f;</div><div>                NGstring cex3_f;</div><div>                NGstring cbuf_f;</div><div>                char *cbuf_c;</div><div>                len1 = NGSTRLEN(cex1);</div><div>                len2 = NGSTRLEN(cex2);</div><div>                len3 = NGSTRLEN(cex3);</div><div>                len4 = 128;</div><div>                cex1_f = NGCstrToFstr(cex1,len1);</div><div>                cex2_f = NGCstrToFstr(cex2,len2);</div><div>                cex3_f = NGCstrToFstr(cex3,len3);</div><div>                cbuf_f = NGCstrToFstr(cbuf,len4);</div><div>                NGCALLF(cpnumb,CPNUMB)(&value,<wbr>&ndgd,&lmsd,&iexp,&lexp,</div><div>                               cex1_f,cex2_f,cex3_f,</div><div>                               &lex1[ix],&lex2[ix],&lex3[ix]<wbr>,</div><div>                               &ioma,&iodp,&iotz,cbuf_f,&<wbr>nbuf,&ndgs,&ieva,</div><div>                               len1,len2,len3,len4);</div></div><div><br></div><div><br></div><div>should be</div><div><br></div><div><div>        NGCALLF(cpinrc,CPINRC)();</div><div><br></div><div>        {</div><div>                size_t len1,len2,len3,len4;</div><div>                NGstring cex1_f;</div><div>                NGstring cex2_f;</div><div>                NGstring cex3_f;</div><div>                NGstring cbuf_f;</div><div>                char *cbuf_c;</div><div>                len1 = NGSTRLEN(cex1);</div><div>                len2 = NGSTRLEN(cex2);</div><div>                len3 = NGSTRLEN(cex3);</div><div>                len4 = 128;</div><div>                cex1_f = NGCstrToFstr(cex1,len1);</div><div>                cex2_f = NGCstrToFstr(cex2,len2);</div><div>                cex3_f = NGCstrToFstr(cex3,len3);</div><div>                cbuf_f = NGCstrToFstr(cbuf,len4);</div><div>                NGCALLF(cpnumb,CPNUMB)(&value,<wbr>&ndgd,&lmsd,&iexp,&lexp,</div><div>                               cex1_f,cex2_f,cex3_f,</div><div>                               &lex1[ix],&lex2[ix],&lex3[ix]<wbr>,</div><div>                               &ioma,&iodp,&iotz,cbuf_f,&<wbr>nbuf,&ndgs,&ieva,</div><div>                               len1,len2,len3,len4);</div></div><div><br></div><div>for the Intel compiler. Changing some of these resulting in a working NCL for me.</div><div><br></div><div>Although passing the wrong size argument on OSX causes crashes, Linux seems more forgiving and the code doesn’t crash (although it’s still incorrect).</div><div><br></div><div>Maybe the type for fortran string sizes should be a preprocessing symbol that gets set before compilation to “size_t” or “int” depending on if one is using ifort or gfortran?</div><div><br></div><div>Thanks and I hope this is helpful,</div><div><br></div><div>Martin</div><div><br></div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>