sort -- テキストファイルの整列 ― 2015年07月12日 11:37
テキストファイルのソートに取り組みます。方針としては、STDINからEOFまで行単位ですべて読み込み、ソートし、 結果をSTDOUTに書き出します。
その前に、sortを作成中にgetlin()のbugを見つけました。返す値が、NEWLINE一文字分少なく返していました。修正版は下記の通り。
c getlin.for -- get line from infile integer function getlin(line,u) integer*1 line(81+1) ! MAXLINE(81)+1 integer u integer*1 c,fgetc integer col if (fgetc(u,c) .ne. -1) then ! EOF(-1) col = 0 while (c .ne. 10) do ! NEWLINE(10) col = col + 1 line(col) = c c = fgetc(u,c) end while line(col + 1) = 10 ! NEWLINE(10) line(col + 2) = -2 ! EOS(-2) getlin = col + 1 else getlin = -1 ! EOF(-1) end if return end
さて、sortのメインルーチンは下記のようになります。
RATFOR版は以下の通り。
# sort.r4 -- sort text line in memory character linbuf(MAXTEXT) integer gtext integer linptr(MAXPTR),nlines call initfile() if (gtext(linptr,nlines,linbuf,STDIN) == EOF) { call shell(linptr,nlines,linbuf) call ptext(linptr,nlines,linbuf,STDOUT) } else call error('too big to sort.') stop end
WATCOM fortran77版は、以下の通り。
c sort.for -- sort text line in memory integer*1 linbuf(500000) ! MAXTEXT(500000) integer gtext integer linptr(1000),nlines ! MAXPTR(1000) call initfile() if (gtext(linptr,nlines,linbuf,5) .eq. -1) then ! STDIN(5) EOF(-1) call shell(linptr,nlines,linbuf) call ptext(linptr,nlines,linbuf,6) ! STDOUT(6) else call error('too big to sort.') end if stop end
gtext()は、STDINからEOFまで読み込みます。すべて読み込めなかった場合(linbufがいっぱいなる場合、 または、MAXPTR行以上を読み込もうとした場合)は、EOF以外の値を返します。
RATFOR版は下記の通り。
# gtext.r4 -- get text lines into memory integer function gtext(linptr,nlines,linbuf,infile) character linbuf(MAXTEXT) integer getlin integer infile,lbp,len,linptr(MAXPTR),nlines nlines = 0 lbp = 1 repeat { len = getlin(linbuf(lbp),infile) if (len == EOF) break nlines = nlines + 1 linptr(nlines) = lbp lbp = lbp + len + 1 } until (lbp >= MAXTEXT-MAXLINE | nlines >= MAXPTR) gtext = len return end
WATCOM Fortran77版は下記の通り。
c gtext.for -- get text lines into memory integer function gtext(linptr,nlines,linbuf,infile) integer*1 linbuf(500000) ! MAXTEXT(500000) integer getlin integer infile,lbp,len,linptr(1000),nlines ! MAXPTR(1000) nlines = 0 lbp = 1 loop len = getlin(linbuf(lbp),infile) if (len .eq. -1) then ! EOF(-1) exit end if nlines = nlines + 1 linptr(nlines) = lbp lbp = lbp + len + 1 until ((lbp .ge. 500000-82) .or. (nlines .ge. 1000)) ! MAXTEXT(500000) MAXLINE(82) MAXPTR(1000) gtext = len return end
shell()は、読み込んだ行をシェルソートを使って、ソートします。 行単位の比較はcompar()で、行の交換はexchan()で行います。
shell()のRATFOR版は下記の通り。
# shell.r4 -- shell sort for character lines subroutine shell(linptr,nlines,linbuf) character linbuf(ARB) integer gap,i,ig,j,k,linptr(ARB),nlines integer compar for (gap = nlines/2; gap > 0; gap = gap/2) for (j = gap + 1; j <= nlines; j = j + 1) for (i = j - gap; i > 0; i = i - gap) { ig = i + gap if (compar(linptr(i),linptr(ig),linbuf) <= 0) break call exchan(linptr(i),linptr(ig),linbuf) } return end
shell()のWATCOM Fortran77版は下記の通り。
c shell.for -- shell sort for character lines subroutine shell(linptr,nlines,linbuf) integer*1 linbuf(*) ! ARB(*) integer gap,i,ig,j,linptr(*),nlines ! ARB(*) integer compar gap = nlines/2 while (gap .gt. 0) do j = gap + 1 while (j .le. nlines) do i = j - gap while (i .gt. 0) do ig = i + gap if (compar(linptr(i),linptr(ig),linbuf) .le. 0) then exit end if call exchan(linptr(i),linptr(ig),linbuf) i = i - gap end while j = j + 1 end while gap = gap/2 end while return end
行を比較するcompar()は、小さければ-1を等しければ0を大きければ1を返します。比較は文字コード順です。
RATFOR版は下記の通り。
# compar.r4 -- compare linbuf(lp1) with linbuf(lp2) integer function compar(lp1,lp2,linbuf) character linbuf(ARB) integer i,j,lp1,lp2 i = lp1 j = lp2 while (linbuf(i) == linbuf(j)) { if (linbuf(i) == EOS) { compar = 0 return } i = i + 1 j = j + 1 } if (linbuf(i) < linbuf(j)) compar = -1 else compar = +1 return end
WATCOM Fortran77版は下記の通り。
c compar.for -- compare linbuf(lp1) with linbuf(lp2) integer function compar(lp1,lp2,linbuf) integer*1 linbuf(*) ! ARB(*) integer i,j,lp1,lp2 i = lp1 j = lp2 while (linbuf(i) .eq. linbuf(j)) do if (linbuf(i) .eq. -2) then ! EOS(-2) compar = 0 return end if i = i + 1 j = j + 1 end while if (linbuf(i) .lt. linbuf(j)) then compar = -1 else compar = +1 end if return end
行を交換するexchan()は、対象行へのポインターを交換し、実際の行データーは動かしません。
RATFOR版は下記の通り。
# exchan.r4 -- exchange linbuf(lp1) with linbuf(lp2) subroutine exchan(lp1,lp2,linbuf) character linbuf(ARB) integer k,lp1,lp2 k = lp1 lp1 = lp2 lp2 = k return end
WATCOM Fortran77版は下記の通り。
c exchan.for -- exchange linbuf(lp1) with linbuf(lp2) subroutine exchan(lp1,lp2,linbuf) integer*1 linbuf(*) ! ARB(*) integer k,lp1,lp2 k = lp1 lp1 = lp2 lp2 = k return end
ソートした結果を書き出すptext()は、ラインポインターに基づいて、行を書き出します。
RATFOR版は下記の通り。
# ptext.r4 -- output text lines from linbuf subroutine ptext(linptr,nlines,linbuf,outfil) character linbuf(ARB) integer i,j,linptr(MAXPTR),nlines,outfil for (i = 1; i <= nlines; i = i + 1) { j = linptr(i) call putlin(linbuf(j),outfil) } return end
WATCOM Fortran77版は下記の通り。
c ptext.for -- output text lines from linbuf subroutine ptext(linptr,nlines,linbuf,outfil) integer*1 linbuf(*) ! ARB(*) integer i,j,linptr(1000),nlines,outfil ! MAXPTR(1000) i = 1 while (i .le. nlines) do j = linptr(i) call putlin(linbuf(j),outfil) i = i + 1 end while return end
コメント
_ Plenty Of Fish Dating Site Of Free Dating ― 2015年10月17日 19:30
_ quest bar change ingredients ― 2015年10月19日 01:57
_ plenty of fish dating site of free dating ― 2015年11月05日 22:46
_ plenty of fish dating site of free dating ― 2015年11月06日 18:52
I require an expert on this house to solve my problem. Maybe that is you!
Taking a look forward to peer you.
_ plenty of fish dating site of free dating ― 2015年11月07日 13:09
site came up, it looks great. I've bookmarked it in my google bookmarks.
Hi there, just changed into aware of your weblog
via Google, and found that it's really informative. I'm gonna be careful for
brussels. I'll be grateful when you proceed this in future.
Numerous other people can be benefited from your
writing. Cheers!
_ justin bieber dating ― 2015年11月09日 07:02
approximately my difficulty. You are wonderful!
Thank you!
_ justin bieber Dating ― 2015年11月09日 13:58
Shame on the search engines for not positioning this put up upper!
Come on over and talk over with my web site . Thank you =)
_ kroger digital coupons on card ― 2015年11月11日 18:01
a blogger, and I was curious about your situation; we have created some nice methods and we
are looking to exchange solutions with others, please shoot me
an email if interested.
_ kroger new coupon policy 2015 ― 2015年11月12日 12:22
thing to be aware of. I say to you, I definitely get irked while people consider worries that they just don't
know about. You managed to hit the nail upon the top and
also defined out the whole thing without having side-effects , people can take
a signal. Will likely be back to get more. Thanks
_ Www.krogerfeedback.Com ― 2015年11月12日 18:18
of the posts I realized it's new to me. Regardless, I'm certainly happy I stumbled upon it and
I'll be book-marking it and checking back frequently!
_ Kroger Plus card digital coupons ― 2015年11月17日 09:58
I have always disliked the idea because of the costs.
But he's tryiong none the less. I've been using WordPress on a number of websites for about a year and am worried about switching to another platform.
I have heard great things about blogengine.net.
Is there a way I can transfer all my wordpress posts into it?
Any kind of help would be really appreciated!
_ plenty of fish ― 2015年11月21日 18:56
It's simple, yet effective. A lot of times
it's tough to get that "perfect balance" between user friendliness and appearance.
I must say that you've done a amazing job with this.
Also, the blog loads extremely quick for me on Opera.
Superb Blog!
_ walmart Black friday 2015 ― 2015年11月25日 18:34
I'm new to the blog world but I'm trying to get started and
create my own. Do you require any coding knowledge to make your own blog?
Any help would be greatly appreciated!
_ www.krogerfeedback.com ― 2015年12月06日 13:37
I have a presentation subsequent week, and
I am at the search for such info.
_ quest bars cheap online ― 2015年12月11日 18:01
article at this site.
_ Plenty of fish dating Site Of free dating ― 2015年12月14日 22:17
also visit this website on regular basis to obtain updated from
most up-to-date news.
_ krogerfeedback ― 2015年12月15日 05:28
I'll be sure to bookmark it and return to read more of your useful information.
Thanks for the post. I'll definitely return.
_ krogerfeedback ― 2015年12月20日 14:02
idea, piece of writing is pleasant, thats why i have read it
fully
_ Descargar Firefox ;;;; ― 2016年01月06日 10:40
be up to date every day.
_ descargar firefox ; ― 2016年01月06日 12:08
and didn't know who to ask.
_ www.topsites.gr ― 2016年01月30日 04:09
Your probably wondering why I created this
article. Gossip magazines sims Never, ever place it in a plastic bag as the material will sweat and ruin.
Gossip helps them to recognize it and to go beyond what is already available.
Celebrity gossip eu pn It's most popular among a lot of teenagers and kids that
like to watch online on their computers. Most celebrities
would have paid several visits to their doctor.
_ minecraft Skins ― 2016年01月30日 07:35
Boats in Minecraft are faster than walking, but slower than minecarts.xt% minecraft servers 1.6.2
Since you obtain 1-2 seeds from every plant, your farm will grow in space as you harvest more crops in Minecraft.
Boats in Minecraft are faster than walking, but slower than minecarts.xt%
_ mattress discounters coupon ― 2016年01月30日 08:58
Clearly this sort of mattress is specifically designed for taller people.
Mattress zippered covers Check out the full line of high-quality, well-engineered Serta mattresses and discover which one
is befitting you.
When shopping around for mattresses you shouldn't be shy to put down on these phones try
them out. What normally happens will be the spring mattress does not give
enough and exerts pressure from the body of the person purchasing the mattress.
_ insignia electronics wiki us ― 2016年01月30日 10:13
need to make use of high aperiodic antennas that could be practically mounted
on the rooftops or attics. Which means, although Computer monitors side effects HDTV functionality, their unique constraints tend to
be uncovered once you use them towards read HDCP enabled content.
Insignia テレビ Even in case you are in a store or online shopping, these tips will help you buy the TV that you
need, and also save your money.
PS3, Xbox 360 and Wii U are some with the popular gaming consoles nowadays that
need HDTV to completely enjoy its graphics and hi-def performance.
Philips happens to offer some nice Philips HDTV antennas that possess a
lot of positive reviews by customers.
_ toddler bed barrier try ― 2016年01月30日 11:19
A bachelor of education (BEd) course enables you to study for the degree and handle your
initial teacher training at the same time. Regalo
swing down convertible crib rail A bachelor of education (BEd) course enables you
to study for the degree and handle your initial teacher
training at the same time.
A bachelor of education (BEd) course enables
you to study for the degree and handle your initial teacher
training at the same time. A bachelor of education (BEd) course enables you to study for the degree and handle your initial teacher training at the same time.
_ Best Cordless Drill 2015 ― 2016年01月30日 12:56
phones. With the now commonplace curvy design regularly linked
to ergonomic keyboards, this HP device is designed for comfort working.
Most durable cordless phone One of my personal favorite things to do is always to listen to books on CD
while I sew or when I am driving alone.
11b had already consumed most with the market, it was not
well received. 6 pounds, but additionally very powerful
reaching approximately 1,500 RPM under zero load.
_ does beer go bad try ― 2016年01月30日 18:15
It stimulates rapid expansion from the very young; and may be a lot of, too rapid expansion. Beer If you belong to
this category we have some tips for you to generate
it easier and cheaper for you personally and healthier for ones dog.
The more friends who send food the higher, so you is able to keep feeding
people along with your buzz score keeps going up.
The perfect skirt is quicker to find, in comparison to
a mother from the bride gowns or possibly a motherofthebridedresses.
_ sale nerf small ― 2016年01月31日 02:45
and will benefit from your lessons they teach. Toy itself is a tool for baby
expressing himself, also a far more handy "language" for them.
Top ten best nerf guns So, while picking a toy keep your infant's likes and dislikes in your mind
and attempt to gift him toys that they will really enjoy instead
of picking the most used toy for the market.
Modern male masturbator manufacturers keep personal preferences
in mind and produce a variety of stuff to boost sexual pleasure.
Such toys provide them entertainment, but moreover, they also help promote healthy
beak structure.
_ Bollywood news gossip youtube ― 2016年02月06日 21:25
articles to your blogs visitors. Julie Fuimano,
MBA, RN is dedicated to helping you break through the barriers
to your happiness and success. Celeb gossip australia Sometimes the best way to let someone know how you feel is directly.
Work when you are supposed to and save socializing, snacking, searching the Internet
and personal phone calls for break time. Online gossip girl temporada 5 No, you aren't talking
about people for their own good. They don't like entertainment news to be
deadpan as the other news features that they read.
_ garmin gps golf watch s4 ― 2016年02月06日 21:43
equipment in numerous vehicles as satnav systems.
GPS locator maps, much like Magellan, Nextar, and garmin oregon, are usually very widely
used kind of, commercial, and military functions.
This isn't the case using the Garmin 405, which requires memorizing when to use the bezel versus the buttons,
and when you should tap, hold, touch or double touch. GPS dog collars tend to be
more popular than GPS microchips because they
don't require that the dog experience any pain or discomfort.
Garmin gps latest model Garmin GPS Watch - Garmin Forerunner 405CX with Heart Rate Monitor.
_ csgrid.org ― 2016年02月08日 00:55
texting on the app market. "It's not challenging, I just find it boring," he
told Rodrigo. Celeb gossip closer You could end up in an all
out gossip war with feelings being hurt beyond repair.
Recognizing and stopping workplace mobbing has been on the minds of international groups, including the UN's International Labour Organization (ILO), for years.
Gossip news hyde Simply stated, being professional means having class and no one is born with class or professional
skills, they are developed through training, example and experience.
How long do you reckon before he cancels the entire thing.
_ are milwaukee tools any good by ― 2016年02月08日 00:58
that will not hold a cost. Locate the good and bad ends of the 1st battery to get reconditioned.
Hitachi battery drills 18v Even in case you do
not make use of a cordless phone, a cordless device being employed in a nearby home or office could
possibly be the culprit.
This device interprets baby's crying, sound frequencies, crying intervals,
etc and provide the answer on the LCD screen. If you are trying
to purchase one, you should keep a few things at heart.
_ long bed rails again ― 2016年02月08日 05:57
The Channel Tunnel can also be known as the Euro Tunnel and it can be a
rail link within the English Channel between Cheriton beside Folkestone, Kent, and Coquelles near to Calais.
Bed barrier for toddlers The Channel Tunnel can also be known as the Euro Tunnel and it can be a rail
link within the English Channel between Cheriton beside Folkestone, Kent, and
Coquelles near to Calais.
The Channel Tunnel can also be known as the
Euro Tunnel and it can be a rail link within the English Channel between Cheriton beside Folkestone,
Kent, and Coquelles near to Calais. The Channel Tunnel can also be known as the Euro Tunnel and
it can be a rail link within the English Channel between Cheriton beside Folkestone, Kent, and Coquelles near to Calais.
_ quest bars ― 2016年02月09日 07:21
_ top 5 gaming laptops or ― 2016年02月09日 12:13
houses and airports. Considering the a huge number of teenagers
and youth who tend to be into mmorpgs, high necessitates for low cost
gaming mobile computing items are continually happening more often. Best new
laptops under 1000 However, in spite of this argument
gaming laptops are growing and top brandnames like Alien ware, Falcon,
Rock.
ASUS Transformer Book Flip TP500LA-EB31T Intel Core i3 4030U (1.
The engineers only use the top parts, they don't accept anything less,
this guarantees the 96 hours straight gaming that some on the users
try to find.
_ baofung via ― 2016年02月10日 05:27
you can't remember in places you put the number.
When you refer to the book, mention why the listeners will wish to
follow through and go to your website to purchase the ebook.
Baofeng uv-5r youtube CDR is really a must have for New Vegas
fans playing over a first, second, or twentieth playthrough.
I carry vitamins around, and like I say, I go see my acupuncturist.
Baofeng walkie talkie Then step # 4 tells you to market them that product they've been seeking.
Zac Efron at "New Year's Eve" Premiere and Press
Conference in Tokyo (Pictures).
_ longshot cs6 General ― 2016年02月10日 12:49
It could be the latest addition to Nerf's product line that's release in 2008.
Most powerful nerf pistol Toy haulers may be anything, but an external
a part of vehicles (trucks, cars, SUVs, etc.
Parts are not as small, and small pieces like wheels tend to be
more difficult to remove, so that it is less likely for the wooden toy
to present a choking hazard. There are essentially millions
of toys being continually produced and distributed in the world today.
_ best wireless range extender 2014 by ― 2016年02月10日 16:52
support 802. In case you desire to end anything, you might must pay some termination fee.
Although personally, I believe that it's going to be a while one which just truly expect
that from your gaming system, although through the trailers I have seen, this technique is truly awesome.
Although personally, I believe that it will be a while before you truly expect that from a
gaming system, although through the trailers I have seen, this system is truly awesome.
Best wifi extender cnet 2015 We wish to capture this traffic inside a file that
aircrack-ng will use later to crack the WEP key.
_ calla lily meaning history ― 2016年02月12日 14:23
wants. These bulbs can be a great choice on your Houston, Texas container garden. Direct sunlight can damage the foliage, but indirect or filtered sunshine
is satisfactory.
Right before your wedding reception dinner starts, the organization holding your reception can light all of the candles adding a captivating feel for a special wedding dinner.
Eating simply a few leaves may result in symptoms, and they also typically appear within a couple of hours
after ingestion occurs, according towards the ASPCA.
_ homealarm ― 2016年02月15日 11:02
even the intruder will consider before entering the premises of your property.
Manual fire alarms are generally placed in stairwells of buildings in largely occupied buildings
to ensure occupants can exist your house safely by way
of a stairwell. Cost to install alarm system This will make it easier to determine if your finances can afford
a wholly new system, or when you will should scale
it back slightly.
When the alarm is activated the central monitoring
center is notified plus they will call you. Installation of alarm kits
is often relatively simple but make sure to adhere
to the instructions that accompanies the kit.
_ quest bars ― 2016年02月19日 21:09
having my breakfast coming over again to read other news.
_ top mattress here ― 2016年03月07日 03:51
up picking your mattress, that's why. As the dust mite allergy problem receives increasing media coverage,
the requirement for professional mattress cleaning services could only increase.
Mattress columbus ohio Clearly this form of mattress is specifically created
for taller people.
Switching to a memory foam mattress can be sure that you
don't feel cheated by it sagging or causing discomfort in the short
amount of time. Experts suggest that babies, especially newborns, go to bed
on a firm mattress to reduce the risk of SIDS.
_ garmin gps radio ― 2016年03月07日 23:40
is way better as trimness and subtlety,
as opposed to other kinds of GPS units. In summary, the Garmin nuvi 1490LMT is jam-full of useful features that make driving easier
and safer.
Some from your Garmin timepieces are lighting and slim adequate for
daily wear. With GPS rental services this revolutionary product became even more available and useful.
Garmin forerunner 10 Before since 2011 of 1989, people have
problems with indeed trusted Garmin if it pertains to their
GPS recources.
_ nerf gun for toddler was ― 2016年03月08日 01:42
toy should have:. When it comes to selling toys in shops and on stalls, the usual thing to accomplish
is shelve many items, and also have others available in a stock room or perhaps your van or vehicle.
Nerf best It is evident that toy haulers have gained immense popularity and now every vehicle owner want to have them for transportation of goods and other products.
When you get a stampede nerf, the package comes with 60 items of foam darts.
Can you merely imagine how fun it is usually to play tag and war games together with your buddies
with Longshot Nerfs as the ally of your toy.
_ What Are The best light bars ― 2016年03月09日 22:08
Emergency lights making using LEDs may also be energy efficient and hence can be powered with a simple 12V DC power supply.
Led lighting for bars The important things about warning light LED equipment include
its design that could resist heavy duty handling while also proving to become effective
in bad weather conditions.
Firstly, the sunlight emitting diodes are recognized to offer maximum brightness and lighting output with the lowest possible wattage and power consumption. In earlier times, the park were built with
a wooden coaster called Ravine Flyer.
_ 500 laptops please ― 2016年03月10日 05:49
The reality is the fact that not much could be done
with only 16 shader units along with a memory interface of 64 bits.
What is the best gaming laptop under 500 And several recently released smartphone's carry with him or her Wi - Fi connectivity, allowing that you go online wherever that you are.
And the visual abilities with the GT72 2QE causes it
to be a device that really makes it possible to appreciate
'next-gen' games. The Satellite is certainly probably the most affordable Toshiba line
with the average user, but it really packs enough power to do
all from the tasks a typical computer user enjoys with no trouble.
_ fastest diet pill open ― 2016年03月10日 07:39
on fighting to retain the weight reduction that you could have achieved.
The weightloss pills are legally recommended only for all those having
obesity. Fastest working diet pill Never use weight-loss supplements who are not
recommended for losing weight.
Article Source: that ends this review about Hazards With Weight Loss Solutions.
In fact, after we hear the term"weight loss pill", it itself carry negative connotations inside the minds of dieters searching for help.
_ what does Hit Me up mean ― 2016年03月10日 09:23
Because if they did, many Juggalos would have walked away from the Insane Clown Posse when their spiritual hip
hop song, 'The Unveiling,' hit the scene. What means lmao
It is one of several that are available ' the others are disk cleanup and disk de-fragmentation. When you share the metaphore, it helps the speaker see that you really heard them.
_ whirlpool cabrio top load washer problems ― 2016年03月10日 12:05
with a usual washer, they normally use agitator, though this machine they cannot.
Sears In my last article, I showed you where you
could look for a wringer washer.
This model is equipped with electronic controls coupled by having an LCD display.
The Environmental Protection Agency has declared the standard use of
DEET to not be of a health concern to members
with the general public, based over a 1998 review.
_ cctv ptz ― 2016年03月11日 14:34
advocates and civil libertarians. There are such CCTV cameras that supply upto
120 frames per second. Cctv zhibo Mobile devices today pack a great deal
information and still have very little security.
Remote checking is feasible in your pc as nicely as the intelligent cellphone.
Wiring: The most time-consuming and important part from a camera installation is wiring.
※コメントの受付件数を超えているため、この記事にコメントすることができません。
トラックバック
このエントリのトラックバックURL: http://kida.asablo.jp/blog/2015/07/12/7705962/tb
最近のコメント