Defining the type in the types.foo file

Once you have decided what is data and what should be a routine, you will need to define a type to hold that data.

You need to decide a name for the type (which will be the name of the module also) and the names of all the pieces of data that are held by that type. For example, below is the definition of the BUFFER type:

   type buffer_type

   INT :: pos
   ! The position of the last character of the last item processed in
   ! buffer_str

   INT :: item
   ! The item number of the last item processed in buffer_str

   INT :: n_items
   ! The total number of items in the buffer_str

   BIN :: analysed
   ! True, if the buffer_str has been analysed

   STR :: comment_chars
   ! The comment character symbols (concatenated) to be used in the
   ! buffer_str

   BSTR :: buffer_str
   ! The actual buffer string

   end 
This type contains only simple data types, such as integers, strings, and logical variables. Notice how the intended meaning of each variable is fully described below its declaration. Notice also how long and descriptive names are used when neccesary. This is important. Notice that the BUFFER type is actually declared as buffer_type.

The above type definition is placed in the types.foo file. It must be placed after all the types which it uses, and before all the types which use it it their definition.