1

I am trying to assign 216 values from an array to a 6x6x6 matrix in Fortran. This is my code:

    y =  0
    do x = 1,6
    do z = 13,18
            do x1 = 19,24
                y = y+1
                omega_plus(x,z,x1) = omegap_sec(y)
            end do
       end do
    end do

omegap_sec is a 1d arrays having 216 values.

Is there a way to write something like this: omega_plus[1:6,13:18,19:24] = omegap_sec[1:216] in Fortran?

taylor.2317
  • 582
  • 1
  • 9
  • 23
VenuVGR
  • 11
  • 3
  • 2
    As with the linked question, you can `reshape` the rank-1 array to the rank-3 array. You'll need to reorder the elements though, so that `omega_plus` varies most rapidly in the final dimension. – francescalus Dec 15 '21 at 08:13

0 Answers0