This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

transfer of the record length for io from internal files


Feng Wang has opened the door to full use of internal files with his recent hollerith patches. There remains, however a need to transfer the record length, aka the character length, and to use it it the library io routines.

The enclosed patch accomplishes the transfer. It has been regtested on RH9/Athlon.

This

program test
 character*80   ::  a(4)
 write(a, *) "hello, welcome to Jamaica, have a nice day"
end program test

produces

MAIN__ ()
{
 char a[4][1:80];

_gfortran_filename = "test.f90";
_gfortran_line = 3;
_gfortran_ioparm.internal_unit = (char *) &a;
_gfortran_ioparm.internal_unit_len = 320;
_gfortran_ioparm.recl_in = 80;
_gfortran_ioparm.list_format = 1;
_gfortran_st_write ();
_gfortran_transfer_character ("hello, welcome to Jamaica, have a nice day", 42);
_gfortran_st_write_done ();
}


I have checked that the record length really is correctly picked up in the library as ioparm.recl_in.

thus, we now need the modifications to the library, to recognise and signal eor's, \n, \r and all the other good stuff.

I am open to changing the order of the arguments of set_string to making it more pleasing to the eye. It was convenient to do it this way. Are there any other ioparm string options that should be using the character length? I have tested one or two and they seem to be protected by the parser. For example, status will not accept an array as its value. If only the one option uses ts->cl, should the few lines of code be removed from set_string and deposited in build_dt?

Anyhow, over to you Jerry!

Best regards

Paul T
Index: gcc/gcc/fortran/trans-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-io.c,v
retrieving revision 1.38
diff -r1.38 trans-io.c
431c431,433
<    ioparm structure.  */
---
>    ioparm structure.  In the case that the string is an array,
>    it is sometimes necessary that that the character length be
>    available too.  This is the purpose of the last argument.  */
435c437
< 	    tree var_len, gfc_expr * e)
---
> 	    tree var_len, gfc_expr * e, tree recl)
441a444
>   tree char_len = NULL_TREE;
447a451,453
>   if (recl != NULL_TREE)
>     char_len = build3 (COMPONENT_REF, TREE_TYPE (recl), ioparm_var,
> 		       recl, NULL_TREE);
476a483,490
>       if (recl != NULL_TREE)
> 	{
> 	  if (e->ts.cl)
> 	    tmp = e->ts.cl->backend_decl;
> 	  else
> 	    tmp = e->symtree->n.sym->ts.cl->backend_decl;
> 	  gfc_add_modify_expr (&se.pre, char_len, tmp);
> 	}
604c618,619
<     set_string (&block, &post_block, ioparm_file, ioparm_file_len, p->file);
---
>     set_string (&block, &post_block, ioparm_file,
>     ioparm_file_len, p->file, NULL_TREE);
608c623
< 		ioparm_status_len, p->status);
---
> 		ioparm_status_len, p->status, NULL_TREE);
612c627
< 		ioparm_access_len, p->access);
---
> 		ioparm_access_len, p->access, NULL_TREE);
615c630,631
<     set_string (&block, &post_block, ioparm_form, ioparm_form_len, p->form);
---
>     set_string (&block, &post_block, ioparm_form,
> 		ioparm_form_len, p->form, NULL_TREE);
622c638
< 		p->blank);
---
> 		p->blank, NULL_TREE);
626c642
< 		ioparm_position_len, p->position);
---
> 		ioparm_position_len, p->position, NULL_TREE);
630c646
< 		ioparm_action_len, p->action);
---
> 		ioparm_action_len, p->action, NULL_TREE);
634c650
< 		p->delim);
---
> 		p->delim, NULL_TREE);
637c653,654
<     set_string (&block, &post_block, ioparm_pad, ioparm_pad_len, p->pad);
---
>     set_string (&block, &post_block, ioparm_pad,
> 		ioparm_pad_len, p->pad, NULL_TREE);
676c693
< 		ioparm_status_len, p->status);
---
> 		ioparm_status_len, p->status, NULL_TREE);
777c794,795
<     set_string (&block, &post_block, ioparm_file, ioparm_file_len, p->file);
---
>     set_string (&block, &post_block, ioparm_file,
> 		ioparm_file_len, p->file, NULL_TREE);
795c813,814
<     set_string (&block, &post_block, ioparm_name, ioparm_name_len, p->name);
---
>     set_string (&block, &post_block, ioparm_name,
> 		ioparm_name_len, p->name, NULL_TREE);
799c818
< 		ioparm_access_len, p->access);
---
> 		ioparm_access_len, p->access, NULL_TREE);
803c822
< 		ioparm_sequential_len, p->sequential);
---
> 		ioparm_sequential_len, p->sequential, NULL_TREE);
807c826
< 		ioparm_direct_len, p->direct);
---
> 		ioparm_direct_len, p->direct, NULL_TREE);
810c829,830
<     set_string (&block, &post_block, ioparm_form, ioparm_form_len, p->form);
---
>     set_string (&block, &post_block, ioparm_form,
> 		ioparm_form_len, p->form, NULL_TREE);
814c834
< 		ioparm_formatted_len, p->formatted);
---
> 		ioparm_formatted_len, p->formatted, NULL_TREE);
818c838
< 		ioparm_unformatted_len, p->unformatted);
---
> 		ioparm_unformatted_len, p->unformatted, NULL_TREE);
828c848
< 		p->blank);
---
> 		p->blank, NULL_TREE);
832c852
< 		ioparm_position_len, p->position);
---
> 		ioparm_position_len, p->position, NULL_TREE);
836c856
< 		ioparm_action_len, p->action);
---
> 		ioparm_action_len, p->action, NULL_TREE);
839c859,860
<     set_string (&block, &post_block, ioparm_read, ioparm_read_len, p->read);
---
>     set_string (&block, &post_block, ioparm_read,
> 		ioparm_read_len, p->read, NULL_TREE);
843c864
< 		ioparm_write_len, p->write);
---
> 		ioparm_write_len, p->write, NULL_TREE);
847c868
< 		ioparm_readwrite_len, p->readwrite);
---
> 		ioparm_readwrite_len, p->readwrite, NULL_TREE);
850,851c871,872
<     set_string (&block, &post_block, ioparm_delim, ioparm_delim_len,
< 		p->delim);
---
>     set_string (&block, &post_block, ioparm_delim,
> 		ioparm_delim_len, p->delim, NULL_TREE);
854,855c875,876
<     set_string (&block, &post_block, ioparm_pad, ioparm_pad_len,
<                 p->pad); 
---
>     set_string (&block, &post_block, ioparm_pad,
> 		ioparm_pad_len, p->pad, NULL_TREE); 
1136c1157
< 		      ioparm_internal_unit_len, dt->io_unit);
---
> 		      ioparm_internal_unit_len, dt->io_unit, ioparm_recl_in);
1147c1168
< 		dt->advance);
---
> 		dt->advance, NULL_TREE);
1151c1172
< 		dt->format_expr);
---
> 		dt->format_expr, NULL_TREE);
1158,1159c1179,1180
<         set_string (&block, &post_block, ioparm_format,
< 		    ioparm_format_len, dt->format_label->format);
---
>         set_string (&block, &post_block, ioparm_format, ioparm_format_len,
> 		    dt->format_label->format, NULL_TREE);
1185c1206
< 		  ioparm_namelist_name_len, nmlname);
---
> 		  ioparm_namelist_name_len, nmlname, NULL_TREE);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]