# Metview Macro

# **************************** LICENSE START ***********************************
#
# Copyright 2019 ECMWF. This software is distributed under the terms
# of the Apache License version 2.0. In applying this license, ECMWF does not
# waive the privileges and immunities granted to it by virtue of its status as
# an Intergovernmental Organization or submit itself to any jurisdiction.
#
# ***************************** LICENSE END ************************************

# **************************************************************************
# Function      : mxn_layout
#
# Syntax        : list mxn_layout (definition, number, number)
#                                         )
#
# Author (date) : 
#
# Category      : LAYOUT
#
# OneLineDesc   : Generates a regular grid of plot pages 
#
# Return Value  : The list of plot pages
#
# Dependencies  : 
#
# **************************************************************************


function mxn_layout (the_view, cols, rows)

	delta_x = 100 / cols
	delta_y = 100 / rows

	page_list = []
	for i = 1 to cols do
		left_pos  = delta_x * (i-1)
		right_pos = delta_x * i
		for j = 1 to rows do
			hi_pos	= delta_y * (j-1)
			lo_pos  = delta_y * j
			page    = plot_page(
					top     :  hi_pos,
					bottom  :  lo_pos,
					left    :  left_pos,
					right   :  right_pos,
					view    :  the_view
					)
			page_list = page_list & [page]
		end for
	end for

	return page_list

end mxn_layout
