Exercises for Array Constructs ============================== 1. Run the program matrix.f90 which declares a 2-dimensional integer array, with extents (n,n), where n is set to 9 in a PARAMETER statement. This program uses DO loops to assign elements of the array to have values r c, where r is the row number and c is the column number, e.g., a(3,2) = 32, a(5,7) = 57. It writes the resulting array to the file matrix.dat for later uses. 2. From the array constructed in exercise 1, use array sections to write out: (a) the first row (b) the fifth column (c) every second element of each row and column, columnwise ( a(1,1), a(3,1),...) (d) every second element of each row and column, rowwise ( a1,1), a(1,3),...) (e) the 3 non-overlapping 3x3 sub-matrices in columns 4 to 6 (section.f90) 3. Write a program which generates an 8x8 chequerboard, with 'B' and 'W' in alternate positions. Assume the first position is 'B'. (board.f90) 4. From the array constructed in exercise 1, use the WHERE construct to create an array containing all of the odd values and 0 elsewhere (use elemental function, MOD). (where.f90) 5. Declare a vector subscript, iv, with extent 5. From the array constructed in exercise 1 create a 5x5 array containing only the odd values. (vec_subs.f90) 6. Generate the array constructed in exercise 1 using a single array constructor. (reshape.f90) 7. Look at the Fortran 77 code sum2.f. Rewrite it using Fortran 90 with allocatable and assumed-shape arrays. (sum4.f90) Is there any instrinsic function which can simplify the same job? (sum5.f90) 8. Create an integer array whose size is allocated dynamically (read size from terminal). Assign odd and even values to the array (same as matrix.f90). Pass the array to a subroutine which uses an assumed shape argument and returns all odd values of the array and 0 elsewhere. (odd_val.f90) 9. Run the program spread1.f90. Modify it to create an real array with element values 1.0/REAL(i+j+1), where i is the row number and j is the column number. (spread2.f90) Can you find another way using Fortran 90 array? 10. Look at the program m_basis.f90. Modify it to select all values greater than 3000 and find the number of them, the maximum, the minimum and the average. (munro.f90)