1! { dg-do run } 2! { dg-options "-ffrontend-optimize" } 3! PR 86837 - this was mis-optimized by trying to turn this into an 4! array I/O statement. 5! Original test case by "Pascal". 6 7Program read_loop 8 9 implicit none 10 11 integer :: i, j 12 13 ! number of values per column 14 integer, dimension(3) :: nvalues 15 data nvalues / 1, 2, 4 / 16 17 ! values in a 1D array 18 real, dimension(7) :: one_d 19 data one_d / 1, 11, 12, 21, 22, 23, 24 / 20 21 ! where to store the data back 22 real, dimension(4, 3) :: two_d 23 24 ! 1 - write our 7 values in one block 25 open(unit=10, file="loop.dta", form="unformatted") 26 write(10) one_d 27 close(unit=10) 28 29 ! 2 - read them back in chosen cells of a 2D array 30 two_d = -9 31 open(unit=10, file="loop.dta", form="unformatted", status='old') 32 read(10) ((two_d(i,j), i=1,nvalues(j)), j=1,3) 33 close(unit=10, status='delete') 34 35 ! 4 - print the whole array, just in case 36 37 if (any(reshape(two_d,[12]) /= [1.,-9.,-9.,-9.,11.,12.,-9.,-9.,21.,22.,23.,24.])) call abort 38 39end Program read_loop 40