• Keine Ergebnisse gefunden

The memory window in MOM 2 is a generalization of the slab approach used in MOM 1 and prior version of the model where three latitudes rows were kept in memory. This generalized approach in MOM 2 is capable of simulating the older method but allows for greater exibility.

Some of the advantages of this memory window are:

Higher order nite dierence schemes and parameterizations which require access to more than three latitude rows can be implemented in a straight forward manner.

There is a reduction in the number of names required for variables. For example, in MOM 1 and previous incarnations, tracers required three names: one for the row being computed, one for the row to the north and another for the row to the south. In MOM 2, there is only need for one name: rows to the north and south are accessed by meridional indices j-1 and j+1.

Essentially all prognostic variables are subscripted by three spatial dimensions as if innite central memory were available. However, the actual memory needed is controlled by the size of the memory window. Equations and coding looks the same, regardless of how large or small the memory window is.

Increases in speed can be realized when opening up the memory window even on a single processor. This is the case when lots of diagnostic options are enabled. The reason is less redundant computations are needed.

Substantial amounts of memory and disk space can be saved when multitasking with ne grained parallelism as compared to the coarse grained parallelism used in MOM 1.

However, it should be noted that the memory window can duplicate the coarse grained approach to multitasking used in MOM 1. Also, when the memory window is fully opened, there is no dataow between memory and disks because disks are not needed. All data is retained within the memory window.

6Referring to spatial dimensions.

nostic data on a

1 and

disk. Each disk contains two components of velocity and two tracers but others may be added. In general only two time levels are required on disk because

tau

+ 1 data can usually be written over the

tau

;1 disk area7.

Consider a longitudinal slice through all data on both disks indicated by the colored section in Figure 3.3a. When this data is read into memory, it is stored in the memory window shown in Figure 3.3b. For purposes of an example, it is opened wide enough to hold six latitudes.

The size of the memory window is arbitrary and is controlled by setting parameter jmw in le size.h ( jmw=6 for this example). The minimum size of the memory window is jmw=3 (which would mimic the slab architecture of MOM 1 and earlier versions of the model) and the maximum size is jmw=jmt. Each prognostic variable within the window is dimensioned by indices8 i,k,jto denote longitude, depth, and latitude along with a fourth index to denote prognostic component (e.g. for velocity, an index of 1 would reference the zonal component of velocity and 2 would reference the meridional component. For tracers, a 1 would reference temperature and a 2 would reference salinity) and a fth index to denote time level (e.g. either

;1,

, or

+ 1.).

A work area is also shown in the memory window. The size of this area varies depending on which options are enabled. In general, space is required to hold diusive and advective uxes of prognostic quantities dened on the faces of each cell. These uxes are also dimensioned by indices i,k,j but without a time index since they are recalculated for each prognostic variable to conserve memory. Additionally, some options require diusive coecients with spatial de-pendence. In this case, three dimensional arrays are used for diusive coecients which are also dened on cell faces.

Within the memory window, equations are solved for latitudes marked with a red color.

The latitudes marked with a blue color are used as boundary cells. Figure 3.3c is a simplied schematic of the detailed window shown in Figure 3.3b. Note that the rst row in the mem-ory window is j=1 and the last row is j=jmw but computations typically go from j=jsmw=2 through j=jemw=jmw-1. Prognostic quantities (temperature, salinity, horizontal velocity com-ponents) within the memory window are dimensioned in the meridional direction by

jmw

although not all quantities are dimensioned this way. For instance, if a quantity `q' involves meridional averages or dierences of temperature and it were dimensioned as

q

(

imtkmjmw

), then `q(i,k,jmw)' would referencer temperature at index

j

+ 1 which is out of bounds be-cause the meridional dimension of temperature is

jmw

. Such quantities are dimensioned as

`q(imt,km,1:jemw)' and can only be computed within the range 1 :

jemw

. When computing these quantities, the idea is to do so over their full dimension taking into account that it may be less than

jmw

. In many of the following gures, the memory window will be represented in its simplist form given schematically in Figure 3.3d.

3.3.2 How it works.

A formal description of dataow through a memory window of arbitrary size will now be given followed by a specic example of a minimum memory window size of

jmw

=3. The case of a memory window opened to

jmw

=5 is given as an example of ne grained multitasking in Section 3.5. To simplify gures, a memory window schematic of the form shown in Figure 3.3d is used.

7This is not case when multitasking with optioncoarse grained parallelism. In this case, a third disk is needed.

8Reasons for this ordering are given in Section 3.1.

be

jmt

latitudes arranged monotonically from south to north with

jrow

=1 representing the southernmost latitude and

jrow

=

jmt

the northernmost one. Assume an arbitrary memory window of size

jmw

with 3

jmw

jmt

. The rst usage of the memory window loads latitude rows

jrow

=1 through

jrow

=

jmw

into memory window rows

j

=1 through

j

=

jmw

. The number of rows where prognostic quantities are computed within a memory window is given by

ncrows

jmw

;2 (3

:

1)

The starting row for these computations is always

j

=2. Typically for second order accurate numerical schemes,

ncrows

=

jmw

;2 although

ncrows

may be less for higher order schemes or those needing special treatment9. If latitude rows

jrow

=1 and

jrow

=

jmt

are used only as boundary rows, then the number of memory windows

num windows

needed to update prognostic variables is given by

num windows

=

int

((

jmt

;2)

=ncrows

)+(

jmt

;3)

=

(

ncrows

(

int

((

jmt

;2)

=ncrows

))) (3

:

2) where the

int

() function represents the integer part of a quantity and the rst term is the number of full memory windows needed to update prognostic variables on latitudes

jrow

= 2 through

jrow

=

jmt

;1. To account for the last few rows, there may be an extra memory window which is only partially full and this is given by the second term in the calculation of

num windows

.

If

num windows >

1, then preparation is made for computing a second group of latitudes by copying data from the northernmost

jmw

;

ncrows

rows in the memory window into the southernmost

jmw

;

ncrows

rows in the memory window. The ordering of the copy is important else data copied in one operation will be wiped out by the next copy. A general prescription for copying data southward (equivalent to moving the memory window northward) is given by

For variables dimensioned as array(imt,km,jmw), copy all elements of i and k as follows:

array(i,k,1) =array(i,k,jemw) array(i,k,2) =array(i,k,jmw)

For variables dimensioned as array(imt,km,1:jemw),copy all elements of i and k as follows:

array(i,k,1) =array(i,k,jemw)

For variables dimensioned as array(imt,km,jsmw:jmw), copy all elements of i and k as follows:

array(i,k,jsmw) =array(i,k,jmw)

For variables dimensioned as array(imt,km,jsmw:jemw), no copy is necessary.

Latitudes within the memory window with local index

j

are related to latitudes on disk with global index

jrow

by an oset

joff

which is calculated as

joff

= (

mw

;1)

ncrows for mw

= 1

to num windows

(3

:

3)

9For example, option pressure gradient averagerequires tracers to be solved on more rows than velocities within the memory window although this is easily done.

js

+

joff

jrow

je

+

joff

(3

:

4)