//---------------------------------------------------------------------

        public override void Run()
        {
            //if keyword == maxage
            foreach (ISpecies species in selectedSpecies)
            {
                string path = MapNameTemplates.ReplaceTemplateVars(mapNameTemplate, species.Name, modelCore.CurrentTime);
                modelCore.UI.WriteLine("   Writing maximum age map for {0} to {1} ...", species.Name, path);
                using (IOutputRaster <ShortPixel> outputRaster = modelCore.CreateRaster <ShortPixel>(path, modelCore.Landscape.Dimensions))
                {
                    ShortPixel pixel = outputRaster.BufferPixel;
                    foreach (Site site in modelCore.Landscape.AllSites)
                    {
                        if (site.IsActive)
                        {
                            pixel.MapCode.Value = SiteVars.GetMaxAge(species, (ActiveSite)site);
                        }
                        else
                        {
                            pixel.MapCode.Value = 0;
                        }

                        outputRaster.WriteBufferPixel();
                    }
                }
            }

            WriteMapWithMaxAgeAmongAll();
        }
        //---------------------------------------------------------------------

        private void WriteMapWithMaxAgeAmongAll()
        {
            //    Maximum age map for all species
            string path = MapNameTemplates.ReplaceTemplateVars(mapNameTemplate, "AllSppMaxAge", modelCore.CurrentTime);

            modelCore.UI.WriteLine("   Writing maximum age map for all species to {0} ...", path);
            using (IOutputRaster <ShortPixel> outputRaster = modelCore.CreateRaster <ShortPixel>(path, modelCore.Landscape.Dimensions))
            {
                ShortPixel pixel = outputRaster.BufferPixel;
                foreach (Site site in modelCore.Landscape.AllSites)
                {
                    if (site.IsActive)
                    {
                        pixel.MapCode.Value = SiteVars.GetMaxAge((ActiveSite)site);
                    }
                    else
                    {
                        pixel.MapCode.Value = 0;
                    }

                    outputRaster.WriteBufferPixel();
                }
            }
        }