{"id":3368,"date":"2012-04-21T17:15:31","date_gmt":"2012-04-20T23:15:31","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/3368"},"modified":"2012-04-21T17:19:03","modified_gmt":"2012-04-21T08:19:03","slug":"fortran%e3%81%a7%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e8%aa%ad%e3%81%bf%e6%9b%b8%e3%81%8dreadwrite%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/3368","title":{"rendered":"Fortran\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304dRead\/Write\u3059\u308b"},"content":{"rendered":"<p>\nFortran\u5165\u9580: \u30c7\u30fc\u30bf\u5165\u51fa\u529b<br \/>\n<a href=\"http:\/\/www.nag-j.co.jp\/fortran\/FI_14.html\">http:\/\/www.nag-j.co.jp\/fortran\/FI_14.html<\/a><br \/>\nformat\u6587 (Fortran\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5165\u9580\u30de\u30cb\u30e5\u30a2\u30eb | Fortran \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u5165\u9580 \u8b1b\u5ea7)<br \/>\n<a href=\"http:\/\/harukin.la.coocan.jp\/fortran\/004\/format.html\">http:\/\/harukin.la.coocan.jp\/fortran\/004\/format.html<\/a>\n<\/p>\n<p>\nFortran\u306e\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u66f8\u304d\uff06\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u6587\u306b\u95a2\u3057\u3066\u306f\u4e0a\u8a18\u3092\u53c2\u7167\u3002<br \/>\n\u305f\u3060\u3057\u3001Fortran77 \u306e\u6642\u3082\u305d\u3046\u3060\u3063\u305f\u306e\u3060\u304c\u3001Fortran \u3067\u66f8\u304d\u51fa\u3057\u3066\u3001Fortran \u3067\u8aad\u307f\u8fbc\u3080\u5206\u306b\u306f\u3055\u307b\u3069\u66f8\u5f0f\u306b\u6c17\u3092\u9063\u308f\u306a\u304f\u3066\u3044\u3044&#8230;\u3068\u3044\u3046\u304b\u3001\u9069\u5f53\u306b write(*,*) \u3067\u66f8\u304d\u51fa\u3057\u3066\u3001read(*,*) \u3067\u8aad\u307f\u8fbc\u3081\u308b\u3063\u3066\u306e\u304c Fortran \u306e\u4fbf\u5229\u306a\u3068\u3053\u308d\u3002\n<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nprogram Console1\r\n    implicit none\r\n    integer count\r\n    integer readdata\r\n    character*80 fname\r\n\r\n    ! \u30d5\u30a1\u30a4\u30eb\u51fa\u529b\r\n    open(10,file='sample.txt',status='replace')\r\n    write (10,*) 'Hello', x, y \r\n    close(10)\r\n    print *, 'write sample.txt'\r\n\r\n\t! \u4e00\u5fdc\u521d\u671f\u5316    \r\n    x = 0 \r\n    y = 0\r\n\r\n    ! \u30d5\u30a1\u30a4\u30eb\u5165\u529b\r\n    open(11,file='sample.txt',status='old')\r\n    read(11,*), str, x, y\r\n    close(11)\r\n    \r\n    print *, 'read sample.txt'\r\n    print *, 'read:', str, x, y\r\n    \r\n    fname = 'sample2.txt'\r\n    count = readdata(fname)\r\n    print *,'read count:', count \r\nend program Console1\r\n<\/pre>\n<p>\n\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u6c7a\u3081\u305a\u306b write \u3057\u305f\u5f8c\u306b read \u3059\u308b\u4f8b\u3002\u5358\u7d14\u306b\u3001\u5909\u6570\u3092\u4e26\u3079\u3066 write \u3059\u308c\u3070\u826f\u3057\u306a\u306b\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002\u56fa\u5b9a\u306e\u30c7\u30fc\u30bf\u6570\u3084\u914d\u5217\u306e\u5834\u5408\u306b\u306f\u3001\u3061\u307e\u3061\u307e\u66f8\u304f\u304b\u3001do \u30eb\u30fc\u30d7\u3092\u4f7f\u3063\u3066\u56fa\u5b9a\u6570\u5206\u8aad\u307f\u66f8\u304d\u3059\u308c\u3070\u3088\u3044\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n    ! \u30c7\u30fc\u30bf\u3092\u7d42\u7aef &quot;END&quot; \u307e\u3067\u8aad\u307f\u8fbc\u3080\r\n    integer function readdata(fname)\r\n        implicit none\r\n        ! character*80 :: fname\r\n        character(*), intent(in) :: fname\r\n        integer :: count\r\n        character*20 :: mark\r\n        integer :: x, y\r\n        count = 0\r\n        \r\n        print *,'fname:', fname\r\n        open(10,file=fname,status='old')\r\n        do \r\n            read(10,*,end=100), mark, x, y\r\n            count = count + 1\r\n            if ( mark == 'end' ) then\r\n                exit\r\n            end if\r\n            print *, 'read:',x,y\r\n        end do\r\n100     close(11)        \r\n        readdata = count\r\n    end function readdata\r\n<\/pre>\n<p>\n\u3053\u306e do \u30eb\u30fc\u30d7\u306e\u90e8\u5206\u306f\u5b9a\u756a\u3067\u3059\u3002read \u306e\u6642\u306b end=100 \u306e\u3088\u3046\u306b\u884c\u756a\u53f7\u3067\u98db\u3070\u3059\u306e\u306f\u3001Fortran90 \u306e\u30b9\u30bf\u30a4\u30eb\u3067\u306f\u3069\u3046\u306a\u306e\u3060\u308d\u3046\uff1f\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001\u3072\u3068\u307e\u305a\u3053\u308c\u3067\u3002\u30d5\u30a1\u30a4\u30eb\u756a\u53f7\u3092\u4ed8\u3051\u308b\u306e\u306f\u3001VB6 \u3068\u540c\u3058\u3067\u3059\u3002\u9069\u5f53\u306b\u30c0\u30d6\u3089\u306a\u3044\u756a\u53f7\u3092\u4ed8\u3051\u308c\u3070 OK \u3067\u3059\u3002\u305f\u3060\u3057\u3001\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u304b\u3089\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u3001\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u756a\u53f7\u304c\u30c0\u30d6\u3063\u305f\u5834\u5408\u3069\u3046\u306a\u308b\u306e\u304b\u306f\u4e0d\u660e\u3002\u306a\u306e\u3067\u3001open\/close \u81ea\u4f53\u306f\u3061\u3087\u3063\u3068\u6ce8\u610f\u3057\u306a\u3044\u3068\u3002\n<\/p>\n<p>\n\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001\u6587\u5b57\u5217\u306e\u5148\u982d\u304c\u300cend\u300d\u3067\u7d42\u308f\u3063\u305f\u3068\u304d\u306b\u7d42\u7aef\u3068\u5224\u65ad\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u6570\u5024\u304c\u300c-1\u300d\u306e\u6642\u3068\u3044\u3046\u306e\u3082\u5b9a\u756a\u306a\u52d5\u4f5c\u3067\u3059\u3002C++\u306e\u5834\u5408\u306f\u30011\u884c\u8aad\u307f\u8fbc\u3093\u3060\u5f8c\u306b\u3001\u5148\u982d\u304c\u300cend\u300d\u306a\u306e\u304b\u3001\u6709\u52b9\u306a\u6570\u5b57\u306a\u306e\u304b\u3068\u3044\u3046\u5224\u65ad\u3092\u3057\u307e\u3059\u304c\u3001Fortran\u306e\u5834\u5408\u306f\u3001\u6587\u5b57\u5217\u3092\u6570\u5024\u3092\u6df7\u5728\u3055\u305b\u308b\u306e\u306f\u9762\u5012\u306a\u306e\u3067\u3001\u6700\u521d\u306e\u30ab\u30e9\u30e0\u304c\u6570\u5024\u306a\u3089\u3070\u300c-1\u300d\u3067\u3001\u6587\u5b57\u5217\u306b\u3059\u308b\u306a\u3089\u3070\u300cend\u300d\u3067\u3068\u3044\u3046\u4f7f\u3044\u5206\u3051\u3092\u3057\u305f\u307b\u3046\u304c\u826f\u3044\u3067\u3057\u3087\u3046&#8230;\u3068 fortran90 \u521d\u5fc3\u8005\u306f\u601d\u3046\u8a33\u3067\u3059\uff08fortran77\u306f\u6614\u3084\u3063\u305f\u3053\u3068\u304c\u3042\u308b\u3051\u3069\uff09\u3002\u300cend\u300d\u3092\u7d42\u7aef\u306b\u3059\u308b\u5834\u5408\u306f\u3001\u5148\u982d\u306e\u30ab\u30e9\u30e0\u306e\u6587\u5b57\u5217\u306f\u6368\u3066\u30ab\u30e9\u30e0\u306b\u3059\u308b\u306e\u304c\u826f\u3044\u3067\u3059\u306d\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\ndata\t10\t21\r\ndata\t11\t22\r\ndata\t12\t23\r\ndata\t13\t24\r\nend\r\n<\/pre>\n<p>\n\u306e\u3088\u3046\u306b\u3001\u5148\u982d\u306e\u30ab\u30e9\u30e0\u3092\u6368\u3066\u3066\u3057\u307e\u3046\u308f\u3051\u3067\u3059\u3002\u5b9f\u306f\u3001\u3053\u308c\u304c\u4fbf\u5229\u306a\u306e\u306f\u5148\u982d\u304c\u300cdata\u300d\u306e\u6642\u306f\u30c7\u30fc\u30bf\u884c\u3092\u3042\u3089\u308f\u3057\u3066\u300cend\u300d\u306e\u5834\u5408\u306f\u7d42\u7aef\u3001\u3068\u3044\u3046\u5f62\u30671\u884c\u3092\u8aad\u307f\u8fbc\u3093\u3060\u3068\u304d\u306b\u5224\u65ad\u304c\u4ed8\u304f\u3068\u3053\u308d\u3067\u3059\u3002perl \u3067\u51e6\u7406\u3059\u308b\u6642\u306b\u697d\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3002\u5927\u5b66\u306e\u9803\u306f\u3001\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u524d\u51e6\u7406\u3092 perl \u3067\u3084\u3063\u3066\u3001\u6700\u7d42\u7684\u306b fortran \u3067\u8aad\u307f\u8fbc\u307e\u305b\u308b\u65b9\u6cd5\u3092\u53d6\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fortran\u5165\u9580: \u30c7\u30fc\u30bf\u5165\u51fa\u529b http:\/\/www.nag-j.co.jp\/fortran\/FI_14.html format\u6587 (Fortran\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5165\u9580\u30de\u30cb\u30e5\u30a2\u30eb | Fortran \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 \u5165 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/3368\">\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-3368","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\/3368","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=3368"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3368\/revisions"}],"predecessor-version":[{"id":3369,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3368\/revisions\/3369"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=3368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=3368"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=3368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}