Re: Need help with user-written routine in SOR$
briggs_at_encompasserve.org
Date: 01/04/05
- Next message: Larry Kilgallen: "Re: Need UNIX clarification"
- Previous message: Simon Clubley: "Re: Need UNIX clarification"
- In reply to: briggs_at_encompasserve.org: "Re: Need help with user-written routine in SOR$"
- Next in thread: hoefelmeyer_at_hotmail.com: "Re: Need help with user-written routine in SOR$"
- Reply: hoefelmeyer_at_hotmail.com: "Re: Need help with user-written routine in SOR$"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 4 Jan 2005 08:15:15 -0600
In article <EBce7tBhsjo5@eisner.encompasserve.org>, briggs@encompasserve.org writes:
> I take that to mean that
>
> ADRS1 is one record contents by reference
>
> ADRS2 is the other record contents by reference
>
> LENG1 is a 16 bit word containing the length of the one record by reference
>
> LENG2 is a 16 bit word containing the length of the other record by reference
>
> CNTX is an unininterpreted argument. The type and mechanism you choose
> when you pass it in SOR$BEGIN_SORT should match the ones you use when
> you retrieve it in your user equal routine.
Testing appears to confirm this. Minimal Fortran code based on the
above interpretation follows.
I did not try to push the envelope by trying to sort records larger than
32K bytes to test whether the length words were signed nor did I try
to sort records larger than 64K bytes to test whether the length could
occupy 32 bits rather than 16.
The context argument that I chose was longword 0 by value -- the default
for a missing argument. Probably I was over-paranoid there, specifying
it explicitly a couple places rather than consistently omitting it
everywhere.
options /extend_source
implicit none
integer sor$begin_sort
integer sor$pass_files
integer sor$sort_merge
integer sor$end_sort
integer user_equal
integer user_compare
external user_equal
external user_compare
integer status
status = sor$pass_files ( 'input.dat', 'output.dat' )
if ( .not. status ) then
type *, 'pass files failed'
call sys$exit ( %val(status) )
end if
status = sor$begin_sort ( ,,,, user_compare, user_equal,,, )
if ( .not. status ) then
type *, 'begin sort failed'
call sys$exit ( %val(status) )
end if
status = sor$sort_merge ( %val(0) )
if ( .not. status ) then
type *, 'sort merge failed'
call sys$exit ( %val(status) )
end if
status = sor$end_sort ( %val(0) )
if ( .not. status ) then
type *, 'end sort failed'
call sys$exit ( %val(status) )
end if
end
integer function user_compare ( s1, s2, l1, l2, ctx )
implicit none
integer *2 l1, l2
byte s1(l1), s2(l2)
integer ctx
integer i
write ( 6, '(1x, a)' ) 'user compare'
write ( 6, '(1x, i5, 1x, <l1>a)' ) l1, (char(s1(i)), i = 1, l1 )
write ( 6, '(1x, i5, 1x, <l2>a)' ) l1, (char(s2(i)), i = 1, l2 )
user_compare = 0
return
end
integer function user_equal ( s1, s2, l1, l2, ctx )
implicit none
integer *2 l1, l2
byte s1(l1), s2(l2)
integer ctx
integer i
write ( 6, '(1x, a)' ) 'user equal'
write ( 6, '(1x, i5, 1x, <l1>a)' ) l1, (char(s1(i)), i = 1, l1 )
write ( 6, '(1x, i5, 1x, <l2>a)' ) l1, (char(s2(i)), i = 1, l2 )
user_equal = 1
return
end
Given input file:
a
ab
abc
abcd
f
This displayed:
$ r test
user compare
1 f
4 abcd
user equal
1 f
4 abcd
user compare
4 abcd
3 abc
user equal
4 abcd
3 abc
user compare
3 abc
2 ab
user equal
3 abc
2 ab
user compare
2 ab
1 a
user equal
2 ab
1 a
Reasonable results. 4 comparisons and 4 equality tests to sort a 5
record file whose records all turned out to be "equal".
John Briggs
- Next message: Larry Kilgallen: "Re: Need UNIX clarification"
- Previous message: Simon Clubley: "Re: Need UNIX clarification"
- In reply to: briggs_at_encompasserve.org: "Re: Need help with user-written routine in SOR$"
- Next in thread: hoefelmeyer_at_hotmail.com: "Re: Need help with user-written routine in SOR$"
- Reply: hoefelmeyer_at_hotmail.com: "Re: Need help with user-written routine in SOR$"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|