!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r set_mem - allocate a block of central memory with the Virtual
*                Memory Manager
*
#include "model_macros_f.h"
*

      subroutine set_mem 1
*
      implicit none
*
*author
*     michel roch - rpn - june 1993
*
*revision
* v2_00 - Desgagne M.       - initial MPI version (from setmem v1_03)
*
*object
*	This subroutine allocates a block of central memory
*	with the Virtual Memory Manager. This block will be used
*	by the model for the slice of integration required.
*	
*arguments
*	none
*
*implicits
#include "glb_ld.cdk"
#include "lun.cdk"
#include "mem.cdk"
#include "schm.cdk"
#include "vmmlist.cdk"
*
*modules
      integer  vmmallc
      external vmmallc
*
**
      integer err, space, nw_min
*     ---------------------------------------------------------------
*
      if (Lun_out.gt.0) write(Lun_out,1000)
*
*
*C       1.    Allocate the bloc of memory managed by VMM
*              ------------------------------------------
*
      nw_min = 25
*
*     For the model to remain totally incore (with 2 3D tracers):
*        Mem_mx3db = 52    if hydrostatic without initialization scheme
*        Mem_mx3db = 66    if hydrostatic with    initialization scheme
*        Mem_mx3db = 65    if NH          without initialization scheme
*        Mem_mx3db = 83    if NH          with    initialization scheme
*
      space = (l_maxx-l_minx+1)*(l_maxy-l_miny+1)*G_nk
      space = max(nw_min,Mem_mx3db) * space
*
      err       = vmmallc ( space )
      vmm2rstrt = 0
*
 1000 format(
     %/,'ALLOCATION OF CENTRAL MEMORY FOR VMM MANAGER (S/R SET_MEM)',
     %/,'==========================================================')
*
*     ---------------------------------------------------------------
*
      return
      end