namelist array objects in subprograms

Paul Thomas paulthomas2@wanadoo.fr
Mon Jan 24 18:39:00 GMT 2005


>Anything that needs to handle array values expressons must do so 
>explicitly.
>See gfc_conv_intrinsic_transfer and gfc_conv_function_call for examples.

I took a long look at these functions and found that they only partially 
applied because get_new_var_expr does not fill the expr->ref, making the 
tree walk impossible.  Of course, as in these two functions, the array dummy 
argument, added to a namelist, has to be an indirect reference.  Since all 
that one has in the transfer of the namelist elements is the gfc_symbol,  I 
detected the need for an indirect reference on (sym->attr.dummy && 
sym->as->rank).  Thus:

 for (nml = dt->namelist->namelist; nml; nml = nml->next)
   {
     gfc_init_se (&se, NULL);
     gfc_init_se (&se2, NULL);
     nmlvar = get_new_var_expr (nml->sym);
     nmlname = gfc_new_nml_name_expr (nml->sym->name);
     gfc_conv_expr_reference (&se2, nmlname);
     gfc_conv_expr_reference (&se, nmlvar);
     gfc_evaluate_now (se.expr, &se.pre);
     if  ( nml->sym->attr.dummy && nml->sym->as && nml->sym->as->rank)
         se.expr = gfc_build_indirect_ref (se.expr);
    transfer_namelist_element (&block, &nml->sym->ts, nml->sym->as, se.expr,
                                               se2.expr, se2.string_length, 
nml->sym->name);
   }

It works correctly, does not cause any regressions but is it acceptable?

Paul T




More information about the Fortran mailing list