Program structure and organization

All Xtal source code is organized in the same way. This is important for collaborative programming because styles vary greatly from author to author. For this reason the Xtal System strives for a consistent 'style' of program layout. Other aspects of the program structure are imposed by the nature of the preprocessor, and for reasons of aesthetics.

The example program XANAX (abbreviated code XX) is used here to illustrate the overall structure of Xtal software.

systemheader:(XX    )#	this signals the start of program XX
####################################################
#                                                  #
#                  ** XANAX **                     #
#                                                  #
# XANAX CALCULATES THE ...............             #
#                                                  #
####################################################
include:(XMACRO)#	system macros and system common entered here 
		<<<<macro definitions specific to XANAX go here
extrude:(XXCOMN)#	opens a file XXCOMN ready for common
		<<<type definition of common variables go here
COMMON/COMFXX/	list of real common variables
COMMON/COMIXX/	list of integer common variables
COMMON/COMCXX/	list of character common variables
endext:#	closes the file XXCOMN
#
systemheader:(XX00 )#	this signals the start of the subroutine XX00
		<<<<subroutine XX00 goes here
		<<<<subroutine XX0n goes here
		<<<<subroutine XXmn goes here
pmacro:([no:])#	purge the local macro definitions

Each subroutine in a program must also adhere to a fixed layout. Here is basic structure of the subroutine XX25 .

systemheader:(XX25)#	comment here on what it does
####################################################
#                                                  #
#                       XX25                       #
#                                                  #
####################################################
SUBROUTINE(XX25)#                   P.D.Student 1987
include:(AACOMN)#
include:(XXCOMN)#
#
		<<<<  type definition of local variables go here
		<<<<  chardata:, intdata:, realdata: followed by datastuff:
#
		<<<< active ratmac instructions go here. A comment on the
		function of each line should should be appended after a #.
		Separate blocks of code with a similar function with headers.
#
# THIS IS THE FORMAT OF SECTION HEADERS
# -------------------------------------
#
		<<<< make sure you adhere to the Xtal/ratmac conventions
		discussed above - especially the use of $( and $). 
		Remember that RFTIDY will reformat your code and comments.
RETURN#
END#