For Programmers: Free Programming Magazines  


Home > Archive > Fortran > March 2006 > Using Orderpack...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using Orderpack...
tripplowe@gmail.com

2006-03-27, 7:02 pm

Hey Folks,

I am having some difficulties figuring out how to use some of the
ranking modules found in Orderpack (http://www.fortran-2000.com/). I
was hoping somebody could point me in the right direction.

I have a multidimensional array (trainarray) I want to rank with
respect to element 2. I have posted the code I use to read the data
and initialize the array. Orderpack contains a module called MRGRNK
I'd like to use that will rank the array. But, for the life of me, I
can not figure out how to implement it. Could somebody show me how to
use these (or similar) types of modules?

Thanks Much.
R. Lowe


program timed
INTEGER i,j,l,n
REAL, DIMENSION(1716,23)::trainarray

OPEN (UNIT=14,FILE='E:\fortran\readltm\savi_t
rainx.txt',STATUS='old')
DO i=1,1716
READ(14,*) trainarray(i,1), trainarray(i,2), trainarray(i,3),
trainarray(i,4), &
trainarray(i,5), trainarray(i,6), trainarray(i,7),
trainarray(i,8), &
trainarray(i,9), trainarray(i,10), trainarray(i,11),
trainarray(i,12), &
trainarray(i,13), trainarray(i,14), trainarray(i,15),
trainarray(i,16), &
trainarray(i,17), trainarray(i,18), trainarray(i,19),
trainarray(i,20), &
trainarray(i,21), trainarray(i,22), trainarray(i,23)
rnkarray(i,1) = trainarray(i,2)
END do
CLOSE(14)

PRINT *, trainarray(200, 21)
PRINT *, trainarray(200, 1)
end program timed

beliavsky@aol.com

2006-03-27, 7:02 pm

tripplowe@gmail.com wrote:
> Hey Folks,
>
> I am having some difficulties figuring out how to use some of the
> ranking modules found in Orderpack (http://www.fortran-2000.com/). I
> was hoping somebody could point me in the right direction.
>
> I have a multidimensional array (trainarray) I want to rank with
> respect to element 2.


You mean you want to sort according to column 2?

> I have posted the code I use to read the data
> and initialize the array. Orderpack contains a module called MRGRNK
> I'd like to use that will rank the array. But, for the life of me, I
> can not figure out how to implement it. Could somebody show me how to
> use these (or similar) types of modules?


I think the subroutine to use begins as follows.

Subroutine MRGRNK (XVALT,
IRNGT)__________________________________
__________________
! MRGRNK = Merge-sort ranking of an array
Real, Dimension (:), Intent (In) :: XVALT
Integer, Dimension (:), Intent (Out) :: IRNGT

if the array to be sorted is called "xx", you would write

call mrgrnk(xx(:,2),irank)
xx = xx(irank,:)

where irank is being used as a "vector subscript".

Please allow me to make some other comments.

In your code, 1716 and 23 should be declared as PARAMETERs,

so that the declarations are

INTEGER, PARAMETER :: nrow = 1716, ncol = 23
INTEGER i,j,l,n
REAL, DIMENSION(nrow,ncol)::trainarray

and the READ statement can be shortened to just

READ(14,*) trainarray(i,:)

I suggest reading
http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_code
..

>
> program timed
> INTEGER i,j,l,n
> REAL, DIMENSION(1716,23)::trainarray
>
> OPEN (UNIT=14,FILE='E:\fortran\readltm\savi_t
rainx.txt',STATUS='old')
> DO i=1,1716
> READ(14,*) trainarray(i,1), trainarray(i,2), trainarray(i,3),
> trainarray(i,4), &
> trainarray(i,5), trainarray(i,6), trainarray(i,7),
> trainarray(i,8), &
> trainarray(i,9), trainarray(i,10), trainarray(i,11),
> trainarray(i,12), &
> trainarray(i,13), trainarray(i,14), trainarray(i,15),
> trainarray(i,16), &
> trainarray(i,17), trainarray(i,18), trainarray(i,19),
> trainarray(i,20), &
> trainarray(i,21), trainarray(i,22), trainarray(i,23)
> rnkarray(i,1) = trainarray(i,2)
> END do
> CLOSE(14)
>
> PRINT *, trainarray(200, 21)
> PRINT *, trainarray(200, 1)
> end program timed


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com