Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Shifting array in the vertical direction

Shifting array in the vertical direction

Shifting array in the vertical direction


I have the following array
a(1,:)=(/2.144999981, 2.144999981, 2.144999981/)
a(2,:)=(/2.144999981, 2.144999981, 6.434999943/)
a(3,:)=(/2.144999981, 6.434999943, 2.144999981/)
a(4,:)=(/2.144999981, 6.434999943, 6.434999943/)
a(5,:)=(/6.434999943, 2.144999981, 2.144999981/)
a(6,:)=(/6.434999943, 2.144999981, 6.434999943/)
a(7,:)=(/6.434999943, 6.434999943, 2.144999981/)
a(8,:)=(/6.434999943, 6.434999943, 6.434999943/)

and in FORTRAN there's an option for horizontal shifting called CSHIFT, but I need to perform a vertical shift (up and down) of the previous array.
Is there an intrinsic function that does it? or someone knows a way.

Thanks and regards,

RE: Shifting array in the vertical direction

And what about TRANSPOSE, CSHIFT and then TRANSPOSE again ?

RE: Shifting array in the vertical direction

Can't you use CSHIFT(ARRAY, 1, 1)

The third parameter says which index to shift. 1 specifies the row, 2 specifies the column


program main
    integer:: aa(3, 2), bb(3, 2)

    aa(1,:) = (/ 1, 2 /)
    aa(2,:) = (/ 3, 4 /)
    aa(3,:) = (/ 5, 6 /)

    write(*,*) 'Shift of 1'
    bb = cshift(aa, 1, 1)
    write(*, '(2I5)')((bb(ii,jj), jj = 1, 2), ii=1,3)
    write(*,*) 'Shift of 2'
    bb = cshift(aa, 1, 2)
    write(*, '(2I5)')((bb(ii,jj), jj = 1, 2), ii=1,3)
end program 


Shift of 1
    3    4
    5    6
    1    2
 Shift of 2
    2    1
    4    3
    6    5 

RE: Shifting array in the vertical direction


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close