• <legend id='t2iXv'><style id='t2iXv'><dir id='t2iXv'><q id='t2iXv'></q></dir></style></legend>

      1. <i id='t2iXv'><tr id='t2iXv'><dt id='t2iXv'><q id='t2iXv'><span id='t2iXv'><b id='t2iXv'><form id='t2iXv'><ins id='t2iXv'></ins><ul id='t2iXv'></ul><sub id='t2iXv'></sub></form><legend id='t2iXv'></legend><bdo id='t2iXv'><pre id='t2iXv'><center id='t2iXv'></center></pre></bdo></b><th id='t2iXv'></th></span></q></dt></tr></i><div id='t2iXv'><tfoot id='t2iXv'></tfoot><dl id='t2iXv'><fieldset id='t2iXv'></fieldset></dl></div>
          <bdo id='t2iXv'></bdo><ul id='t2iXv'></ul>
      2. <tfoot id='t2iXv'></tfoot>

        <small id='t2iXv'></small><noframes id='t2iXv'>

        Fortran 中的 STL 模拟

        时间:2024-05-11

              <bdo id='qbHLf'></bdo><ul id='qbHLf'></ul>
            • <tfoot id='qbHLf'></tfoot><legend id='qbHLf'><style id='qbHLf'><dir id='qbHLf'><q id='qbHLf'></q></dir></style></legend>
                <i id='qbHLf'><tr id='qbHLf'><dt id='qbHLf'><q id='qbHLf'><span id='qbHLf'><b id='qbHLf'><form id='qbHLf'><ins id='qbHLf'></ins><ul id='qbHLf'></ul><sub id='qbHLf'></sub></form><legend id='qbHLf'></legend><bdo id='qbHLf'><pre id='qbHLf'><center id='qbHLf'></center></pre></bdo></b><th id='qbHLf'></th></span></q></dt></tr></i><div id='qbHLf'><tfoot id='qbHLf'></tfoot><dl id='qbHLf'><fieldset id='qbHLf'></fieldset></dl></div>

                <small id='qbHLf'></small><noframes id='qbHLf'>

                  <tbody id='qbHLf'></tbody>

                  本文介绍了Fortran 中的 STL 模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  基础:我有非常大的并行 Fortran90/MPI 程序,代表复杂的物理模型.我想为其添加新功能:例如,我需要组织消息队列,在某处引入归并排序并使用哈希表.

                  Basis: i have very big parallel Fortran90/MPI program which represent complex physical model. I want to add new functionality to it: for example, i need to organize queue of messages, introduce mergesort somewhere and use hash tables.

                  问题:我自己知道如何编写哈希表、创建队列和代码归并排序,但我认为发明自行车不是一个好主意.

                  Problem: i know how write hash table, create queue and code mergesort by my self, but i don't think it is a good idea to invent a bicycle.

                  问题:在这种情况下,Fortran 大师应该怎么做?我应该从 Fortran 构建到 C++ 类的绑定并使用 STL 实现逻辑,还是您可以建议一些类似于 Fortran STL 的库?谢谢.

                  Question: what Fortran guru should do in such situation? Should i build binds to C++ classes from Fortran and realize logic there using STL or you can suggest some Fortran STL-like libraries? Thank you.

                  推荐答案

                  Fortran 中没有模板,因此也没有 STL.您可以尝试 FLIBS 获取一些通用库.它一般使用transfer()技巧来实现泛型编程.

                  There are no templates in Fortran and hence no STL. You can try FLIBS for some generic libraries. It generally uses transfer() tricks to achieve generic programming.

                  有一个预处理器,它为 Fortran 添加了一些模板并带有一些小的 STL,你也可以尝试使用它命名为 PyF95++.如果您可以通过某个图书馆访问学术论文,则可以在此处阅读相关信息.

                  There is a preprocessor which adds some templates to Fortran and comes with some small STL, you can try that too named PyF95++. If you have access to academic papers through some library, you can read about it here.

                  在这种特定情况下,我会避免将它与 C++ 混合使用,尽管它可以做到.您必须单独实例化每个案例,并使用包装器(bind(C)iso_c_binding)将其与 Fortran 接口.只有当您想要使用的算法数量非常有限时,才值得这样做.

                  I would avoid mixing it with C++ in this specific case although it can be done. You must instantiate each case separately and interface it to Fortran using a wrapper (bind(C) and iso_c_binding). Only if you have a very limited number of types you want to use the algorithms for it could be worth it.

                  您还可以尝试使用 Fortran 中的 C 预处理器来实现一些穷人的模板,对于较小的库,它可以工作,但对于复杂的事物可能变得难以维护或丑陋.作为一个例子,你可以看到我对链表的实现 https://github.com/LadaF/fortran-list .

                  You can also try to implement some poor-man's templates using the C-preprocessors in Fortran, For smaller libraries it works, but can become too difficult to maintain or ugly for complex things. As an example you can see my implementation of a linked list https://github.com/LadaF/fortran-list .

                  一般来说,没有明确正确的方法或答案,你总是要从更多的可能性中进行选择.

                  Generally, there is no clearly right approach or answer, you always have to choose from more possibilities.

                  这篇关于Fortran 中的 STL 模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:引用类型的 std::optional 特化 下一篇:为什么我不能用 std::unordered_map 替换 std::map

                  相关文章

                  <small id='7frHC'></small><noframes id='7frHC'>

                    • <bdo id='7frHC'></bdo><ul id='7frHC'></ul>

                  1. <i id='7frHC'><tr id='7frHC'><dt id='7frHC'><q id='7frHC'><span id='7frHC'><b id='7frHC'><form id='7frHC'><ins id='7frHC'></ins><ul id='7frHC'></ul><sub id='7frHC'></sub></form><legend id='7frHC'></legend><bdo id='7frHC'><pre id='7frHC'><center id='7frHC'></center></pre></bdo></b><th id='7frHC'></th></span></q></dt></tr></i><div id='7frHC'><tfoot id='7frHC'></tfoot><dl id='7frHC'><fieldset id='7frHC'></fieldset></dl></div>
                    <legend id='7frHC'><style id='7frHC'><dir id='7frHC'><q id='7frHC'></q></dir></style></legend>
                  2. <tfoot id='7frHC'></tfoot>