fortran - Characters in quotes in a print statement -


the documentation datetime subroutine in fortran-95, gives example on usage of data , time. here's code:

program test_time_and_date     character(8)  :: date     character(10) :: time     character(5)  :: zone     integer,dimension(8) :: values     ! using keyword arguments     call date_and_time(date,time,zone,values)     call date_and_time(date=date,zone=zone)     call date_and_time(time=time)     call date_and_time(values=values)     print '(a,2x,a,2x,a)', date, time, zone     print '(8i5)', values end program test_time_and_date 

in above snippet characters inside single quotes, example '(a,2x,a,2x,a, 8i5)', in print statements?

output statements take format specifier controls of displayed items. input statements use format control interpretation of input.

in print version of output (compare write) format specifier part before (unquoted) comma. in forms of i/o format may specified 1 of 3 ways:

  • using * (so-called list-directed i/o);
  • using label format statement;
  • using character expression (variable or constant).

the form in question third.

a character expression format specification made of number of parts. quotes here delimiter string.

first mandatory pair of parentheses, leading shortest format specification '()' (which prints nothing).

next, format items may be:

  • character literal constants;
  • edit descriptors;
  • control descriptors;
  • a collection of further format items.

format items may have repeat count ahead of them.

to answer question asked i'll consider edit , control descriptors of format specifications quoted. wider details of other descriptors (and more detail on ones here) , formatting may found elsewhere newly gained knowledge on search terms.

there 2 edit descriptors here: a , i. there 1 control descriptor x.

a specifies output of string , i integer. i5 says output width 5 (blank padded if integer has fewer 5 digits on output); a leads width length of character expression output.

the control descriptor x inserts blank. 2x blank repeat count 2: giving 2 spaces output.

so: first line prints out 3 strings spaces between them (here trailing blanks variables appear). second prints 8 integer elements of array each field has width of five.

each print statement gives newline.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -