|
|
Up |
|
|
  |
Author: Ron FordRon Ford Date: Aug 19, 2008 17:17
I don't know how to sort using a compiled computer syntax and wanted to
reverse this shortcoming by implementing the sort in §10 MR&C. I think
this is an example of fair use: I bought the guys' book, typed in
something close to its content as I watched the olympics and managed on my
girlfriend's laptop, and posted it on the net to work out the kinks.
I think that studying fortran and watching women's volleyball and handball
are tasks that improve the quality of the other. I must say I developed I
little crush on the handball hungarian sharpshooter Görnic and wish them
luck if they play the french tomorrow but wish for penalty cards if they
play the russians. Please punish the aggressors.
module sort
implicit none
private
public :: selection_sort
integer, parameter :: string_length = 30
type, public :: address
character(len = string_length) :: name, &
street, town, state*2...
|
| Show full article (3.17Kb) |
|
| | 16 Comments |
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Aug 19, 2008 19:06
Ron Ford wrote:
(snip)
> read (2, '(/a/a/a2,i8)',end=10) data_array(i)
I don't think this format can read the file the
way you want it read.
To start, the initial / will skip the first line.
Next, you should have four A descriptors
to match the four CHARACTER variables.
Third, the third A will read in the city, state, and zip
leaving nothing when it gets to reading the zip in I8 format.
The read will fail and on most systems will print a
message telling you that it failed.
|
| Show full article (0.97Kb) |
|
| | no comments |
|
  |
Author: Ron FordRon Ford Date: Aug 19, 2008 18:53
On Tue, 19 Aug 2008 18:06:12 -0800, glen herrmannsfeldt posted:
> Ron Ford wrote:
> (snip)
>
>> read (2, '(/a/a/a2,i8)',end=10) data_array(i)
>
> I don't think this format can read the file the
> way you want it read.
>
> To start, the initial / will skip the first line.
Alright, so I ace the initial backslash.
>
> Next, you should have four A descriptors
> to match the four CHARACTER variables.
>
> Third, the third A will read in the city, state, and zip
> leaving nothing...
|
| Show full article (1.48Kb) |
| no comments |
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Aug 19, 2008 22:03
Ron Ford wrote:
(snip)
>>>Donald Trump
>>>100 Trump Plaza
>>>New York, NY 10080
(snip)
> The read should read:
> read (2, '(a/a/a/a2,i8)',end=10) data_array(i)
and then put the state and zip code on the next line.
C has a format specifier that will allow reading up until
some set of characters appears to end on the comma.
-- glen
|
| |
| no comments |
|
  |
Author: Ron FordRon Ford Date: Aug 20, 2008 17:58
On Tue, 19 Aug 2008 21:03:22 -0800, glen herrmannsfeldt posted:
> Ron Ford wrote:
> (snip)
>
>>>>Donald Trump
>>>>100 Trump Plaza
>>>>New York, NY 10080
> (snip)
>
>> The read should read:
>> read (2, '(a/a/a/a2,i8)',end=10) data_array(i)
>
> and then put the state and zip code on the next line.
>
> C has a format specifier that will allow reading up until
> some set of characters appears to end on the comma.
>
> -- glen
|
| Show full article (2.39Kb) |
| no comments |
|
  |
|
|
  |
Author: e p chandlere p chandler Date: Aug 20, 2008 19:19
On Aug 20, 8:58 pm, Ron Ford wrote:
[snip]
Input data records are of the form:
>
> Cindy McCain
> 1000 Richie Rich
> Scottsdale,
> AZ 85250
>
Program text:
> program zippy
> use sort
> implicit none
> integer, parameter :: array_size = 100
> type (address), dimension (array_size) :: data_array
> integer :: i,n, ios
>
> open(2, file='addresses2...
|
| Show full article (2.20Kb) |
| no comments |
|
  |
Author: Ron FordRon Ford Date: Aug 21, 2008 15:44
On Wed, 20 Aug 2008 19:19:37 -0700 (PDT), e p chandler posted:
> On Aug 20, 8:58 pm, Ron Ford wrote:
>
> How about something like this?
[code elided]
Works like a charm, Elliot, thanks.
I've got one last thing I wanted to try with the zipcode sort for right
now. I thought I might write the city state and zip on one line, as is
customary. Removing the slash and adding a comma in the edit descriptor
gives:
Tim Pawlenty
500 Olson way
St. Paul, MN 56674
I tried to put St. Paul a little closer to Minnesota with:
write (3, '(/a/a/trim(a), a2,i8)') data_array(i)
, but my compiler said nix to that. Is there a(n easy) way to trim the
trailing blanks on the city?
I also had a question about the declaration of the derived type:
|
| Show full article (1.60Kb) |
| no comments |
|
  |
Author: Ron FordRon Ford Date: Aug 21, 2008 15:46
On Wed, 20 Aug 2008 20:06:41 -0500, Gary Scott posted:
> Ron Ford wrote:
>
>> On Tue, 19 Aug 2008 21:03:22 -0800, glen herrmannsfeldt posted:
>>
>>
>>>Ron Ford wrote:
>>>(snip)
>>>
>>>
>
>> Thanks, Glen. I had two errors going at the same time....
|
| Show full article (1.08Kb) |
| no comments |
|
  |
|
|
  |
Author: e p chandlere p chandler Date: Aug 21, 2008 17:13
On Aug 21, 6:44 pm, Ron Ford wrote:
> On Wed, 20 Aug 2008 19:19:37 -0700 (PDT), e p chandler posted:
>
>> On Aug 20, 8:58 pm, Ron Ford wrote:
>
>> How about something like this?
>
> [code elided]
>
> Works like a charm, Elliot, thanks.
>
> I've got one last thing I wanted to try with the zipcode sort for right
> now. I thought I might write the city state and zip on one line, as is
> customary. Removing the slash and adding a comma in the edit descriptor
> gives:
>
> Tim Pawlenty
> 500 Olson way
> St. Paul, MN 56674
> ...
|
| Show full article (2.89Kb) |
| no comments |
|
RELATED THREADS |
  |
|
|
|
|
|