| 50 | | === 1.3 Fortran Array Implementation === |
| | 50 | === 1.3 Fortran Array Section === |
| | 51 | |
| | 52 | {{{ |
| | 53 | ... |
| | 54 | ! A section of array A is passed in. |
| | 55 | CALL UPDATE(A(L2+X:H2-Y:S2*Z, K)) |
| | 56 | ! A full array B is passed in |
| | 57 | CALL UPDATE(B) |
| | 58 | ... |
| | 59 | |
| | 60 | ! update all elements in the input array section |
| | 61 | SUBROUTINE UPDATE(S) |
| | 62 | INTEGER S(L4:H4:S4, L3:H3:S3) |
| | 63 | ... |
| | 64 | S(J,I) = ... |
| | 65 | ... |
| | 66 | END SUBROUTINE |
| | 67 | }}} |
| | 68 | |
| | 69 | => |
| | 70 | |
| | 71 | {{{ |
| | 72 | ... |
| | 73 | UPDATE( |
| | 74 | f_arr_sect( // Constructs a wrapper for array section |
| | 75 | A, // 1. The array identifier |
| | 76 | (int[3][2]){ // 2. Dimension information |
| | 77 | {L2+X, K}, // Lower-bound for each dim. |
| | 78 | {H2-Y, K}, // Upper-bound for each dim. |
| | 79 | {S2*Z, S1} // Idx. step for each dim |
| | 80 | } |
| | 81 | ) // This instance is freed in subroutine. |
| | 82 | ); |
| | 83 | UPDATE( |
| | 84 | f_arr_full(B) // Constructs a wrapper for full array arg |
| | 85 | ); |
| | 86 | ... |
| | 87 | |
| | 88 | void UPDATE(f_arr _S) { // Change to _S as an intermediate instance |
| | 89 | f_arr S = f_arr_sect( // A wrapper reshaped with new idx. sys. |
| | 90 | _S, // 1. the input array _S |
| | 91 | (int[3][2]){ // 2. new dimension info |
| | 92 | {L4, L3}, // New lower-bound for each dim. |
| | 93 | {H4, H3}, // New upper-bound for each dim. |
| | 94 | {S4, S3}. // New idx. step for each dim |
| | 95 | } |
| | 96 | ); |
| | 97 | ... |
| | 98 | *((int*)f_arr_subscript(S, (int[2]){J, I})) = ... |
| | 99 | ... |
| | 100 | // free the outer most wrapper (i.e. S) |
| | 101 | f_arr_destroy(S); |
| | 102 | // free the intermediate wrapper (i.e. _S), |
| | 103 | // whose construction is inlined in the calling statement. |
| | 104 | f_arr_destroy(_S); |
| | 105 | } |
| | 106 | }}} |
| | 107 | |
| | 108 | === 1.4 Fortran array reshape w/ diff. dim === |
| | 109 | |
| | 110 | In-progress. |
| | 111 | |
| | 112 | === 1.5 Fortran Array Implementation === |