Re: Argument of subroutine is an array of unfixed length.




<kurdayon@xxxxxxxxx> wrote in message
news:1119948286.305629.177110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hello,
>
> I would like to write subroutine which takes an one dimensional array
> and gives another where elements are of initial array are ordered in in
> inverse order.
>
> For example:
> (1,2,3,4,4,2)-> (2,4,4,3,2,1).
>
> And I would like my subroutine can perform this action for array of any
> length. Moreover I do not want gives lengths of input array explicitly
> (I would like it is determined automaticaly). How do I need to declare
> variables in this case? Something like this?
>
> subroutine reorder(input_array, output_array)
> implicit none
> input_array, allocatable?, dimension(:)?
> ???
> allocate(input_array(?))
> end subroutine reorder
>

You dont need a subroutine to do this,
below reverse array statement works no matter what array sizes are as long
as they are equal and 1-based.
! ---------------------
program test
integer :: b(6), a(6) = [1,2,3,4,4,2]

b = [a(size(a):1:-1)]

write (*,*) b ! outputs 2 4 4 3 2 1
end program


.



Relevant Pages

  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)
  • VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.basic.visual.misc)
  • Re: VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.basic.visual.misc)
  • Re: memory leak help!
    ... a loop from the main program. ... REPLACE THE NEW COMPLEX INTO ORIGINAL ARRAY x ... END OF SUBROUTINE SCEUA ... IMPLICIT NONE ...
    (comp.lang.fortran)
  • VB .Net and Intel Visual Fortran 9
    ... having is that the VB program cannot load the DLL. ... subroutine) to accept an array from VB - in my case a 2D array. ... Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double, ...
    (comp.lang.fortran)