<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:JA;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:JA;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:JA;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:895898157;
        mso-list-type:hybrid;
        mso-list-template-ids:-390943432 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText>Hi there,<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>I have some questions about BLAS and LAPACK in Gromacs, and how to best call these functions from inside my code.&nbsp; <o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>On my local machine, I migrated my fluctuating charge code from Gromacs 4.0.7 to 4.5.5.&nbsp; It took a bit of time, but I think the implementation is now a lot cleaner.&nbsp; At some point, I would like to create a branch on the Gromacs repository, but first I need to solve a few issues with BLAS and LAPACK. &nbsp;Basically, when I was originally writing the code I used the Intel headers and libraries, but now I want to convert this to something more compatible.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>At the top of my code, I have the following two includes:<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><span style='font-family:"Courier New"'>#include &lt;mkl_cblas.h&gt;<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>#include &lt;mkl_lapack.h&gt;<o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>When I build the executables, I need to source the Intel compiler variables and make sure to link with the following line:<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><span style='font-family:"Courier New"'>LDFLAGS=&quot;-lrt -L$INTEL_PATH/lib/intel64 -L$MKLROOT/lib/em64t -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm&quot;<o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>I understand this needs to be changed.&nbsp; I would prefer to use the BLAS and LAPACK provided by Gromacs, but I don't know how to do this most effectively, and whether this will result in a performance hit.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>In my code I call the BLAS and LAPACK functions like this (there are perhaps 100 such calls):<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><span style='font-family:"Courier New"'>cblas_dgemm(101,111,111,N,N,N,1,VT,N,A1,N,0,Ai,N);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>dgelss(&amp;N,&amp;N,&amp;nrhs,A1,&amp;N,x,&amp;N,S,&amp;rcond,&amp;rank,work,&amp;lwork,&amp;info); <o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>However, when Gromacs calls its own BLAS and LAPACK functions it looks quite different:<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><span style='font-family:"Courier New"'>#ifdef GMX_DOUBLE<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; F77_FUNC(dsyevr,DSYEVR)(jobz,&quot;I&quot;,&quot;L&quot;,&amp;n,a,&amp;n,&amp;vl,&amp;vu,&amp;index_lower,&amp;index_upper,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;abstol,&amp;m,eigenvalues,eigenvectors,&amp;n,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isuppz,&amp;w0,&amp;lwork,&amp;iw0,&amp;liwork,&amp;info);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>#else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; F77_FUNC(ssyevr,SSYEVR)(jobz,&quot;I&quot;,&quot;L&quot;,&amp;n,a,&amp;n,&amp;vl,&amp;vu,&amp;index_lower,&amp;index_upper,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;abstol,&amp;m,eigenvalues,eigenvectors,&amp;n,<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isuppz,&amp;w0,&amp;lwork,&amp;iw0,&amp;liwork,&amp;info);<o:p></o:p></span></p><p class=MsoPlainText><span style='font-family:"Courier New"'>#endif<o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>The only example I could find for this function call is in &#8220;tools/eigensolver.c&#8221; .&nbsp; I&#8217;m worried that conversion will be difficult, plus I would like to retain the option to use the Intel libraries.&nbsp; <o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>My questions are:<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText style='margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>How can I most effectively convert my BLAS / LAPACK calls in qtpie.c so that it uses the Gromacs provided libraries? (<a href="https://dl.dropbox.com/u/5381783/qtpie.c">link</a>)<o:p></o:p></p><p class=MsoPlainText style='margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>How should I write my code so that a user can compile and link using Intel headers / libraries if they want to?&nbsp; I imagine it&#8217;s related to the --use-external-blas and --use-external-lapack command line options to the configure script, but I don&#8217;t know how to use this.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Your response is greatly appreciated.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Thanks,<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>- Lee-Ping<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>