コードの改修 -- 名前付き共通領域の初期化の改善 ファイル入出力2017年07月17日 16:48

ファイル入出力に関する共通領域の初期化は、initfile()で行っていましたが、 これをdata文で静的に初期化することとします。

Ratofr版のfiles.riは以下の通りです。

# files.ri -- file interface common valiables
      common /files/finuse,fbuf,flastcr,flastcw,fmode,fnew
      integer finuse(MAXFILES)          # inuse flag
      character fbuf(MAXFILES,MAXLINE)  # I/O buffer
      integer flastcr(MAXFILES)         # characters in read buffer
      integer flastcw(MAXFILES)         # characters in write buffer
      character fmode(MAXFILES)         # READ/WIRTE flag
      integer fnew(MAXFILES)            # NEWLINE flag
      data finuse/MAXFILES*NOUSE/
      data flastcr/MAXFILES*0/
      data flastcw/MAXFILES*MAXLINE/
      data fmode/MAXFILES*READ/
      data fnew/MAXFILES*NO/
      data finuse(STDIN)/INUSE/
      data flastcr(STDIN)/MAXLINE/
      data fmode(STDIN)/READ/
      data finuse(STDOUT)/INUSE/
      data flastcw(STDOUT)/0/
      data fmode(STDOUT)/WRITE/

WATCOM fotran77版のfiles.fiは以下の通りです。

c files.fi -- file interface common valiables
      common /files/finuse,fbuf,flastcr,flastcw,fmode,fnew
      integer finuse(MAXFILES)          ! inuse flag
      integer*1 fbuf(MAXFILES,MAXLINE)  ! I/O buffer
      integer flastcr(MAXFILES)         ! characters in read buffer
      integer flastcw(MAXFILES)         ! characters in write buffer
      integer*1 fmode(MAXFILES)         ! READ/WIRTE flag
      integer fnew(MAXFILES)            ! NEWLINE flag
      data finuse/MAXFILES*NOUSE/
      data flastcr/MAXFILES*0/
      data flastcw/MAXFILES*MAXLINE/
      data fmode/MAXFILES*READ/
      data fnew/MAXFILES*NO/
      data finuse(STDIN)/INUSE/
      data flastcr(STDIN)/MAXLINE/
      data fmode(STDIN)/READ/
      data finuse(STDOUT)/INUSE/
      data flastcw(STDOUT)/0/
      data fmode(STDOUT)/WRITE/

files.ri、files.fiの変更により再コンパイルが必要になるファイルは、以下の通りです。

          fopen.for
          fclose.for
          fgetc.for
          fputc.for

これらは、macroが動き出す前のファイルですので、macroを使用する版を再掲します。

fopen()のRatofor版は以下の通りです。

# fopen.r4 -- connect internal file descripter and external file
      include ratfor.def
      integer function fopen(uid, fn, act)
      integer uid
      character fn(ARB), act
      integer i
      character*MAXLINE cfn
      character*9 cact  # for 'READ'/'WRITE'/'READWRITE'
      include files.fi

      if (act == READ)
          cact = 'READ'
      else if (act == WRITE)
          cact = 'WRITE'
      else if (act == READWRITE)
          cact = 'READWRITE'
      else {             # error
           uid = ERR
           fopen = ERR
           return
           }
      end if
      call is2cs(fn,cfn,MAXNAME)
      for (i = 1; i <= MAXFILES; i = i + 1)
          if (finuse(i) == NOUSE) {
              open(unit=i, file=cfn, action=cact, err=99)
              finuse(i) = INUSE
              uid = i
              fopen = i
              if (act == READ) {
                  flastcr(i) = MAXLINE
                  fbuf(i,MAXLINE) = NEWLINE
                  fnew(i) = NO
                  fmode(i) = act
                  }
              else if (act .eq. WRITE) {
                  flastcw(i) = 0
                  fmode(i) = act
                  }
              else if (act .eq. READWIRTE) {
                  flastcr(i) = MAXLINE
                  flastcw(i) = 0
                  fbuf(i,MAXLINE) = NEWLINE
                  fnew(i) = NO
                  fmode(i) = act
                  }
              return
              }
   99 continue
      uid = ERR
      fopen = ERR
      return
      end

fopen()のWATCOM fortran77版は以下の通りです。

c fopen.f -- connect internal file descripter and external file
      include ratfor.def
      integer function fopen(uid, fn, act)
      integer uid
      integer*1 fn(ARB), act
      integer i
      character*MAXLINE cfn
      character*9 cact                  ! READ WRITE
      include files.fi

      if (act .eq. READ) then
          cact = 'READ'
      else if (act .eq. WRITE) then
          cact = 'WRITE'
      else if (act .eq. READWRITE) then
          cact = 'READWRITE'
      else                              ! error
           uid = ERR
           fopen = ERR
           return
      end if
      call is2cs(fn,cfn,MAXNAME)
      i = 1
      while (i .le. MAXFILES) do
          if (finuse(i) .eq. NOUSE) then
              open(unit=i, file=cfn, action=cact, err=99)
              finuse(i) = INUSE
              uid = i
              fopen = i
              if (act .eq. READ) then
                  flastcr(i) = MAXLINE
                  fbuf(i,MAXLINE) = NEWLINE
                  fnew(i) = NO
                  fmode(i) = act
              else if (act .eq. WRITE) then
                  flastcw(i) = 0
                  fmode(i) = act
              else if (act .eq. READWIRTE) then
                  flastcr(i) = MAXLINE
                  flastcw(i) = 0
                  fbuf(i,MAXLINE) = NEWLINE
                  fnew(i) = NO
                  fmode(i) = act
              end if
              return
          endif
          i = i + 1
      end while
   99 continue
      uid = ERR
      fopen = ERR
      return
      end

fclose()のRatofor版は以下の通りです。

# fclose.r4 -- disconnect internal filedescripter and extenal file
      include ratfor.def
      subroutine fclose(uid)
      integer uid
      include files.fi

      if (!(uid == STDIN) | (uid == STDOUT))) then
          if (fmode(uid) == WRITE) then
              call fputc(uid,EOF)        ! flush buffer
          end if
          close(unit=uid, status='keep')
          finuse(uid) = NOUSE
          uid = 0
      end if
      return
      end

fclose()のWATCOM fortran77版は以下の通りです。

c fclose.f-- disconnect internal filedescripter and extenal file
      include ratfor.def
      subroutine fclose(uid)
      integer uid
      include files.fi

      if (.not. ((uid .eq. STDIN) .or. (uid .eq. STDOUT))) then
          if (fmode(uid) .eq. WRITE) then
              call fputc(uid,EOF)        ! flush buffer
          end if
          close(unit=uid, status='keep')
          finuse(uid) = NOUSE
          uid = 0
      end if
      return
      end

fgetc()のRatofor版は以下の通りです。

c fgetc.f -- (extended version) get character from unit u
# fgetc.r4 -- (extended version) get character from unit u
      include ratfor.def
      character function fgetc(u,c)
      integer u
      character c
      integer i
      include files.fi

      flastcr(u) = flastcr(u) + 1
      if ((flastcr(u) > MAXLINE) | (fnew(u) == YES)) {
          read(u,10,end=9) (fbuf(u,i),i=1,MAXCARD)
   10     format(MAXCARD a1)
          flastcr(u) = 1
          fnew(u) = NO
          for (i = MAXCARD; (fbuf(u,i) == BLANK); i = i - 1)
              ;
          fbuf(u,i + 1) = NEWLINE
          }
      c = fbuf(u,flastcr(u))
      fgetc = fbuf(u,flastcr(u))
      if (c == NEWLINE)
          fnew(u) = YES
      return
    9 continue
      c = EOF
      fgetc = EOF
      return
      end

fgetc()のWATCOM fortran77版は以下の通りです。

c fgetc.f -- (extended version) get character from unit u
      include ratfor.def
      integer*1 function fgetc(u,c)
      integer u
      integer*1 c
      integer i
      include files.fi

      flastcr(u) = flastcr(u) + 1
      if ((flastcr(u) .gt. MAXLINE) .or. (fnew(u) .eq. YES)) then
          read(u,10,end=9) (fbuf(u,i),i=1,MAXCARD)
   10     format(MAXCARD a1)
          flastcr(u) = 1
          fnew(u) = NO
          i = MAXCARD
          while (fbuf(u,i) .eq. BLANK) do
              i = i - 1
          end while
          fbuf(u,i + 1) = NEWLINE
      endif
      c = fbuf(u,flastcr(u))
      fgetc = fbuf(u,flastcr(u))
      if (c .eq. NEWLINE) then
          fnew(u) = YES
      end if
      return
    9 continue
      c = EOF
      fgetc = EOF
      return
      end

fclose()のRatofor版は以下の通りです。

# fputc.r4 (extended version) -- put character on file
      include ratfor.def
      subroutine fputc(u,c)
      integer i,u
      character c
      include files.fi

      if ((c == EOF) & (flastcw(u) == 0))
          return                        ! buffer is empty, nothing to do
      if (flastcw(u) >= MAXCARD | c == NEWLINE | c == EOF) {
          write(u,10) (fbuf(u,i),i=1,flastcw(u))
   10     format(MAXCARD a1)
          flastcw(u) = 0
          }
      if (c != NEWLINE) {
          flastcw(u) = flastcw(u) + 1
          fbuf(u,flastcw(u)) = c
          }
      return
      end

fclose()のWATCOM fortran77版は以下の通りです。

c fputc.f (extended version) -- put character on file
      include ratfor.def
      subroutine fputc(u,c)
      integer i,u
      integer*1 c
      include files.fi

      if ((c .eq. EOF) .and. (flastcw(u) .eq. 0)) then
          return                        ! buffer is empty, nothing to do
      end if
      if (flastcw(u) .ge. MAXCARD .or. c .eq. NEWLINE .or. c .eq. EOF) then
          write(u,10) (fbuf(u,i),i=1,flastcw(u))
   10     format(MAXCARD a1)
          flastcw(u) = 0
      end if
      if (c .ne. NEWLINE) then
          flastcw(u) = flastcw(u) + 1
          fbuf(u,flastcw(u)) = c
      end if
      return
      end

また、initfile()が不要になることで修正・再コンパイルが必要になるファイルは、 以下の通りです。

          archive.for
          change.for
          compare2.for
          concat.for
          copy.for
          copyfile.for
          define.f
          edit.f
          find.for
          include.for
          macro.f
          makecopy.for
          ratfor.f
          sort.for
          typex.for
          unique.for
          xformat.f
          xprint.for

実際の変更点については割愛します。

コメント

_ How long does it take to recover from Achilles injury? ― 2017年07月30日 16:15

What&#39;s up, after reading this awesome article i am too delighted to share my familiarity here with friends.

_ instacart coupon ― 2017年08月27日 12:23

I like the valuable information you supply to your articles.

I&#39;ll bookmark your weblog and check once more here frequently.
I&#39;m reasonably sure I will learn many new stuff proper
here! Good luck for the following!

_ publix grocery delivery service ― 2017年09月28日 11:26

I&#39;m really loving the theme/design of your web site.
Do you ever run into any browser compatibility problems? A few of my
blog audience have complained about my site not working correctly in Explorer but looks
great in Chrome. Do you have any solutions to help fix this issue?

_ publix deli online ordering ― 2017年09月28日 23:17

This is my first time go to see at here and i
am actually impressed to read all at single place.

_ publix home delivery service ― 2017年09月29日 04:23

My brother suggested I might like this blog. He was once totally right.
This post actually made my day. You cann&#39;t believe just how much
time I had spent for this info! Thanks!

_ publix online ― 2017年09月29日 06:16

Have you ever thought about adding a little bit more than just your articles?

I mean, what you say is important and everything.

However just imagine if you added some great images or video clips
to give your posts more, &quot;pop&quot;! Your content is excellent but with pics and
clips, this blog could definitely be one of the best in its
niche. Wonderful blog!

_ publix grocery delivery service ― 2017年09月29日 19:10

Hello mates, fastidious article and pleasant arguments commented at this place,
I am actually enjoying by these.

_ publix home delivery ― 2017年09月30日 14:17

Hello it&#39;s me, I am also visiting this site on a regular
basis, this site is actually pleasant and the people are in fact sharing nice thoughts.

_ publix grocery delivery service ― 2017年09月30日 19:44

Hello all, here every one is sharing these kinds of know-how, so it&#39;s good to read this weblog, and I used to pay a visit this website daily.

_ publix.com/delivery ― 2017年09月30日 23:15

I like what you guys are usually up too. This type of clever
work and reporting! Keep up the awesome works guys I&#39;ve added you guys to our blogroll.

_ publix.com/delivery ― 2017年10月01日 02:08

always i used to read smaller articles that also clear
their motive, and that is also happening with this
post which I am reading here.

_ publix.com/delivery ― 2017年10月01日 02:33

Hi there Dear, are you truly visiting this web site on a regular basis, if so after that you will
without doubt take pleasant know-how.

_ instacart promo code ― 2017年10月02日 11:00

whoah this blog is great i love studying your articles. Stay up the good work!

You realize, lots of people are hunting round for this
info, you could help them greatly.

_ instacart coupon 2017 ― 2017年10月02日 23:10

Hey there! I just wish to offer you a huge thumbs up for your excellent info you have got here on this post.
I am coming back to your website for more soon.

_ instacart coupon october ― 2017年10月04日 02:00

Keep this going please, great job!

_ tinder dating ― 2017年10月07日 09:16

An impressive share! I&#39;ve just forwarded this onto a colleague who was conducting a little research on this.
And he in fact bought me dinner due to the fact that I stumbled upon it for
him... lol. So let me reword this.... Thanks for the meal!!
But yeah, thanx for spending some time to discuss this
matter here on your blog.

_ tender dating site ― 2017年10月07日 14:14

You have made some good points there. I checked on the web to find out
more about the issue and found most people will go along with your views on this website.

_ tinder dating ― 2017年10月07日 14:28

I do trust all of the concepts you&#39;ve presented to your post.
They&#39;re very convincing and will certainly work. Nonetheless, the posts are too short for newbies.
May you please prolong them a little from next time?
Thank you for the post.

_ tinder dating ― 2017年10月07日 23:04

Hello there, just became alert to your blog through Google,
and found that it&#39;s truly informative. I am gonna watch out for brussels.
I will be grateful if you continue this in future.
Lots of people will be benefited from your writing.

Cheers!

_ tinder dating ― 2017年10月08日 09:33

I am genuinely delighted to read this webpage posts which carries tons
of useful information, thanks for providing these kinds of information.

_ tender dating ― 2017年10月09日 08:00

Asking questions are genuinely fastidious thing if you are not
understanding anything completely, but this paragraph presents good understanding yet.

_ tender ― 2017年10月09日 08:37

Wow, superb blog layout! How long have you been blogging for?
you made blogging look easy. The overall look of your site is great, let alone
the content!

_ tender ― 2017年10月10日 15:28

Yes! Finally something about tinder dating.

_ tinder ― 2017年10月10日 17:20

hello!,I love your writing so so much! proportion we keep in touch more about your post on AOL?
I require a specialist on this house to unravel my problem.
Maybe that is you! Having a look ahead to peer you.

_ tinder ― 2017年10月11日 09:09

I must thank you for the efforts you&#39;ve put in penning this blog.
I am hoping to see the same high-grade blog posts by you later on as well.
In fact, your creative writing abilities has inspired me to get my own site now ;)

_ tinder dating site free ― 2017年10月11日 16:43

Hello would you mind stating which blog platform you&#39;re
working with? I&#39;m planning to start my own blog in the near
future but I&#39;m having a hard time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.

The reason I ask is because your layout seems different
then most blogs and I&#39;m looking for something unique.
P.S My apologies for getting off-topic but I had to ask!

_ tinder dating ― 2017年10月12日 00:57

Hello There. I found your weblog the usage
of msn. This is a very smartly written article. I&#39;ll make sure to bookmark it and return to read extra of
your useful info. Thanks for the post. I will definitely comeback.

_ tinder dating site free ― 2017年10月13日 06:58

It&#39;s really a nice and useful piece of information. I am glad that you just shared
this useful information with us. Please stay us up to date like this.

Thanks for sharing.

_ tinder dating site free ― 2017年10月13日 16:50

bookmarked!!, I love your site!

_ tinder dating site free ― 2017年10月13日 17:15

When some one searches for his required thing, thus he/she wishes to be available that in detail, so that thing is maintained over
here.

_ tinder ― 2017年10月14日 07:12

Hey would you mind sharing which blog platform you&#39;re using?

I&#39;m looking to start my own blog soon but I&#39;m having a difficult time selecting between BlogEngine/Wordpress/B2evolution and
Drupal. The reason I ask is because your layout seems different
then most blogs and I&#39;m looking for something completely unique.

P.S My apologies for getting off-topic but I had to ask!

_ tinder dating ― 2017年10月14日 07:13

Hi, I do believe this is an excellent blog.
I stumbledupon it ;) I will return once again since i have book-marked it.
Money and freedom is the greatest way to change, may you be rich and continue to help others.

_ tinder dating ― 2017年10月25日 04:09

Thanks for another wonderful article. Where else may just anybody
get that kind of information in such a perfect manner of writing?
I&#39;ve a presentation next week, and I&#39;m at the look for such info.

_ tinder dating site ― 2017年10月25日 18:35

I am really loving the theme/design of your website. Do you ever run into any web browser
compatibility issues? A small number of my blog readers have complained about my website not operating correctly in Explorer
but looks great in Chrome. Do you have any recommendations to help fix this issue?

_ tinder ― 2017年10月26日 19:25

Excellent pieces. Keep writing such kind of information on your page.
Im really impressed by your site.
Hey there, You&#39;ve performed a great job. I will certainly digg it and for
my part suggest to my friends. I am confident they will be benefited from this website.

_ tinder ― 2017年10月28日 02:59

You&#39;ve made some decent points there. I checked on the
internet for more info about the issue and found most people will go along with your views on this site.

_ tinder dating ― 2017年10月28日 22:44

Its not my first time to pay a quick visit this web site,
i am visiting this site dailly and get nice data from here daily.

_ tinder ― 2017年10月29日 06:07

Good day! I simply want to give you a huge thumbs up for your great information you&#39;ve got right here on this post.
I will be returning to your blog for more soon.

_ tinder ― 2017年10月29日 11:06

If you are going for best contents like myself, only pay a visit this web site every day
since it provides quality contents, thanks

_ tinder dating ― 2017年10月29日 12:46

Everything is very open with a clear explanation of the issues.
It was definitely informative. Your site is extremely helpful.
Many thanks for sharing!

_ tinder dating site ― 2017年10月29日 15:37

I&#39;ll right away snatch your rss feed as I can&#39;t to find your
e-mail subscription hyperlink or newsletter service.
Do you&#39;ve any? Kindly let me understand so that I may just subscribe.
Thanks.

_ tinder ― 2017年10月29日 16:42

Hey! This is my first visit to your blog! We are a team of
volunteers and starting a new initiative in a community in the same niche.
Your blog provided us useful information to work on. You
have done a outstanding job!

_ tinder dating site ― 2017年10月29日 19:48

No matter if some one searches for his essential thing, thus he/she wants to be
available that in detail, thus that thing is maintained over here.

_ tinyurl.com ― 2017年12月02日 10:57

I am not sure where you&#39;re getting your information, but great topic.
I needs to spend some time learning much more or understanding
more. Thanks for fantastic information I was looking for this info for my mission.

_ http://tinyurl.com/ycrxdjxw ― 2017年12月03日 01:02

This post will assist the internet viewers for creating new webpage or even a blog from start
to end.

_ http://tinyurl.com/ ― 2017年12月03日 02:23

Great blog here! Also your website loads up very fast!
What host are you using? Can I get your affiliate link to your host?

I wish my web site loaded up as quickly as yours lol

_ tinyurl.com ― 2017年12月03日 05:59

Very energetic blog, I loved that bit. Will there be a part
2?

_ http://tinyurl.com/y7m86m6w ― 2017年12月03日 09:58

Hey! Do you know if they make any plugins to safeguard against hackers?
I&#39;m kinda paranoid about losing everything I&#39;ve worked hard on. Any
tips?

_ tinyurl.com ― 2017年12月03日 11:56

Hello! Do you know if they make any plugins to assist with Search Engine Optimization? I&#39;m trying to get my blog to rank
for some targeted keywords but I&#39;m not seeing very good success.

If you know of any please share. Thanks!

_ http://tinyurl.com/y7fcs2x7 ― 2017年12月03日 14:09

Howdy! This is my first visit to your blog! We are a team of volunteers
and starting a new initiative in a community in the same niche.
Your blog provided us useful information to work on. You have done a wonderful job!

※コメントの受付件数を超えているため、この記事にコメントすることができません。

トラックバック

このエントリのトラックバックURL: http://kida.asablo.jp/blog/2017/07/17/8622377/tb