{"id":3364,"date":"2012-04-20T14:12:53","date_gmt":"2012-04-20T05:12:53","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=3364"},"modified":"2012-04-20T14:12:53","modified_gmt":"2012-04-20T05:12:53","slug":"fortran%e3%81%abc%e8%a8%80%e8%aa%9e%e3%81%8b%e3%82%89%e5%9b%ba%e5%ae%9a%e9%85%8d%e5%88%97%e3%82%92%e6%b8%a1%e3%81%99","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/3364","title":{"rendered":"Fortran\u306bC\u8a00\u8a9e\u304b\u3089\u56fa\u5b9a\u914d\u5217\u3092\u6e21\u3059"},"content":{"rendered":"<p>\u79d1\u5b66\u8a08\u7b97\u306e\u5834\u5408\u3001\u884c\u5217\u5f0f\u30841\u6b21\u5143\u914d\u5217\u30012\u6b21\u5143\u914d\u5217\u304c\u983b\u7e41\u306b\u51fa\u3066\u304f\u308b&#8230;\u3068\u601d\u308f\u308c\u308b\u3002<br \/>\nFortran \u306e\u5834\u5408\u3001\u3042\u307e\u308a\u53ef\u5909\u914d\u5217\u3092\u4f7f\u308f\u305a\u306b\u3001\u3042\u3089\u304b\u3058\u3081\u30e1\u30e2\u30ea\u9818\u57df\u3092\u78ba\u4fdd\u3059\u308b\u56fa\u5b9a\u914d\u5217\u3092\u4f7f\u3046&#8230;\u3063\u3066\u305d\u3046\u3057\u3066\u3044\u305f\u306e\u3060\u304c\u3001\u6700\u8fd1\u306f\u3069\u3046\u306a\u306e\u3060\u308d\u3046\u3002\u53ef\u5909\u306b\u3059\u308b\u3068\u30e1\u30e2\u30ea\u306e\u78ba\u4fdd\u306b\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u30b9\u30d4\u30fc\u30c9\u306b\u554f\u984c\u304c\u3067\u308b\u306e\u3067\u3001\u56fa\u5b9a\u9577\u3055\u306e\u914d\u5217\u306e\u307b\u3046\u304c\u6709\u5229\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nmodule structmodule\r\n    implicit none\r\n    ! struct define\r\n    type F3D\r\n        double precision :: x,y,z\r\n    end type F3D\r\ncontains\r\n    ! one array \r\n    integer function sum1( v, count )\r\n        integer :: v(10)\r\n        integer :: i, total\r\n        integer :: count\r\n        \r\n        total = 0\r\n        do i=1,count\r\n            print *, 'in sum1: ', i, v(i) \r\n            total = total + v(i)\r\n        end do\r\n        sum1 = total\r\n    end function sum1\r\n    ! \u4e8c\u6b21\u5143\u914d\u5217\u3092\u6e21\u3059\r\n    integer function sum2( v, cnti, cntj )\r\n        integer :: v(3,4)\r\n        integer :: cnti, cntj\r\n        integer :: i,j\r\n        integer :: total\r\n        \r\n        total = 0\r\n        do i=1,cnti\r\n            do j=1,cntj\r\n                print *,i,j,v(i,j)\r\n                total = total + v(i,j)\r\n            end do\r\n        end do\r\n        sum2 = total\r\n    end function sum2\r\nend module structmodule\r\n<\/pre>\n<p>\u5f15\u304d\u6570\u3067\u914d\u5217\u306e\u6570\u3092\u6e21\u3057\u3066\u3044\u308b\u304c\u3001\u5185\u90e8\u3067\u56fa\u5b9a\u306b\u3057\u304b\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u5834\u5408\u306f\u3042\u307e\u308a\u610f\u5473\u304c\u306a\u3044\u3002<br \/>\n\u6700\u5927\u9577\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc\u306b\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u6c17\u3092\u4ed8\u3051\u308b\u3068\u304b\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nextern &quot;C&quot; {\r\n\t\/\/ 1\u6b21\u5143\u914d\u5217\r\n\tint STRUCTMODULE_mp_SUM1( int ary&#x5B;], int *count );\r\n\t\/\/ 2\u6b21\u5143\u914d\u5217\r\n\tint STRUCTMODULE_mp_SUM2( int ary&#x5B;]&#x5B;3], int *cnti, int *cntj );\r\n}\r\n<\/pre>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\tint v1&#x5B;] = {1,2,3,4,5,6,7,8,9,10};\r\n\tint count = 10;\r\n\tint sum1 = STRUCTMODULE_mp_SUM1( v1, &amp;count );\r\n\tcout &lt;&lt; &amp;quot;ans:&amp;quot; &lt;&lt; sum1 &lt;&lt; endl;\r\n\r\n\tint v2&#x5B;4]&#x5B;3] = {\r\n\t\t{1,2,3},\r\n\t\t{2,3,4},\r\n\t\t{3,4,5},\r\n\t\t{4,5,6},\r\n\t};\r\n\tint cnti = 3, cntj = 4;\r\n\tint sum2 = STRUCTMODULE_mp_SUM2( v2, &amp;cnti, &amp;cntj );\r\n\tcout &lt;&lt; &amp;quot;ans:&amp;quot; &lt;&lt; sum2 &lt;&lt; endl;\r\n<\/pre>\n<p>\u6ce8\u610f\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u306f\u3001Fortran\u306f\u300c1\u300d\u59cb\u307e\u308a\u3067\u3001C++\u306f\u300c0\u300d\u59cb\u307e\u308a\u3068\u3044\u3046\u3053\u3068\u3002\u306a\u306e\u3067\u3001Fortran\u3067\u300c3\u300d\u756a\u76ee\u306b\u30a2\u30af\u30bb\u30b9\u3092\u3059\u308b\u3068\u3001C++\u3067\u306f\u6dfb\u3048\u5b57\u306e\u300c2\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\uff080\u59cb\u307e\u308a\u306a\u306e\u3067\u30013\u756a\u76ee\u306e\u8981\u7d20\u306b\u306a\u308b\uff09\u3002\u914d\u5217\u305d\u306e\u3082\u306e\u3092\u6271\u3046\u5834\u5408\u306b\u306f\u6c17\u306b\u306a\u3089\u306a\u3044\u304c\u3001index \u3092\u6e21\u3059\u5834\u5408\u306b\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3002<br \/>\nFortran\u306e\u307b\u3046\u30920\u59cb\u307e\u308a\u306b\u3067\u304d\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3082\u3042\u308b\u3089\u3057\u3044\u306e\u3060\u304c\u3001\u5143\u306e\u30bd\u30fc\u30b9\u306b\u5408\u308f\u305b\u308b\u3068\u3059\u308b\u3068\u6a19\u6e96\u7684\u306a1\u59cb\u307e\u308a\u306e\u914d\u5217\u3092\u6271\u3046\u307b\u3046\u304c\u3088\u304b\u308d\u3046\u3002<\/p>\n<p>\u3042\u3068\u30012\u6b21\u5143\u914d\u5217\u306e\u5834\u5408\u306f\u3001\u6b21\u5143\u304c\u9006\u306e\u3088\u3046\u306b\u898b\u3048\u308b\u3002\u3053\u308c\u306f\u3001Fortran\u306e\u307b\u3046\u306b\u3042\u308f\u305b\u3066\u4f5c\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u79d1\u5b66\u8a08\u7b97\u306e\u5834\u5408\u3001\u884c\u5217\u5f0f\u30841\u6b21\u5143\u914d\u5217\u30012\u6b21\u5143\u914d\u5217\u304c\u983b\u7e41\u306b\u51fa\u3066\u304f\u308b&#8230;\u3068\u601d\u308f\u308c\u308b\u3002 Fortran \u306e\u5834\u5408\u3001\u3042\u307e\u308a\u53ef\u5909\u914d\u5217\u3092\u4f7f\u308f\u305a\u306b\u3001\u3042\u3089\u304b\u3058\u3081\u30e1\u30e2\u30ea\u9818\u57df\u3092\u78ba\u4fdd\u3059\u308b\u56fa\u5b9a\u914d\u5217\u3092\u4f7f\u3046&#8230;\u3063\u3066\u305d\u3046\u3057\u3066\u3044\u305f\u306e\u3060\u304c &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/3364\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,43],"tags":[],"class_list":["post-3364","post","type-post","status-publish","format-standard","hentry","category-dev","category-fortran"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=3364"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3364\/revisions"}],"predecessor-version":[{"id":3365,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3364\/revisions\/3365"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=3364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=3364"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=3364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}