RATS 10.1
RATS 10.1

WRITE arrays, variables, expressions

The principal use of WRITE is to display the contents of arrays to the screen or to a file. You can also use it to display simple variables and expressions, but DISPLAY is a superior choice for such situations.

 

WRITE is the companion instruction of READ, which reads data into arrays and variables. The REPORT instruction is probably your best choice if you need to collect and display a set of estimation results, particularly if you need to export those results into another application.

Options

FORMAT=BINARY/CSV/[FREE]/HTML/PRN/RTF/TEX/TSD/WKS/XLS/XLSX/"(FORTRAN format)"

The format in which the data are to be written. A FORTRAN format should describe the format of a row of an array, not the entire array.

 

[SKIP]/NOSKIP

With FORMAT=FREE or FORMAT="(format)", SKIP (the default) puts two blank lines after each array printed. You can suppress these line skips by using NOSKIP.

 

UNIT=[OUTPUT]/COPY/other unit

I/O Unit for output

Example

declare rectangular e(3,2)

input e

 1.5,2.0,0.0,3.5,2.7,4.6

write "E" e

 

E  

    1.500000       2.000000  

    0.000000       3.500000  

    2.700000       4.600000  

Comments

WRITE does not label the arrays that it prints. You may find it helpful to include a descriptive string on the WRITE instruction as in the example.

 

WRITE always writes out arrays one at a time. DISPLAY, used within a loop, can produce output unavailable through WRITE:

 

do i=1,n

  display(unit=copy)  x1(i) x2(i) x3(i)

end do i


 

You can also use REPORT to display arrays. For instance, this will display X1, X2 and X3 in three columns, put into a common format that takes up 10 character positions.

 

report(action=define,hlabels=||"X1","X2","X3"||)

report(atrow=1,atcol=1,fillby=cols) x1

report(atrow=1,atcol=2,fillby=cols) x2

report(atrow=1,atcol=3,fillby=cols) x3

report(action=format,width=10)

report(action=show)

 

 

Finally, you can also use MEDIT to display an array in a report window, and then export the contents of the window to a file using the File–Export... operation.

 


Copyright © 2025 Thomas A. Doan