Changes between Version 10 and Version 11 of FortranTranslationIssues


Ignore:
Timestamp:
12/09/19 14:05:42 (6 years ago)
Author:
wuwenhao
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FortranTranslationIssues

    v10 v11  
    4848}}}
    4949
    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
     110In-progress.
     111
     112=== 1.5 Fortran Array Implementation ===
    51113
    52114`fortran-array.cvl`
     
    198260}}}
    199261
    200 === 1.4 A transformation example ===
     262=== 1.6 A transformation example ===
    201263
    202264Here is the prototype of handling Fortran array sections:
     
    286348 for (int i=1; i<=m; i++) {
    287349    for (int j=1; j<=n; j++)
    288       printf("%d%s", *((int*)f_arr_subscript(mat, (int[2]){i, j})), ", ");
     350      printf("%d%s",
     351        *((int*)f_arr_subscript(mat, (int[2]){i, j})), ", ");
    289352    printf("%s", "\n");
    290353  }
     
    355418void test_neg_stride() {
    356419  // INTEGER A(1:21:2);
    357   f_arr A = f_arr_create(sizeof(int), 1, (int[3][1]){{1}, {21}, {2}});
     420  f_arr A = f_arr_create(
     421              sizeof(int), 1, (int[3][1]){{1}, {21}, {2}});
    358422
    359423  // DO I=1, 21, 2