!-------------------------------------- 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_crni - initialization of the common for right-hand side of
*                 equations when using a Crank-Nicholson procedure
*
#define SPY_VMM_CREATE spy_vmm_create
#include "model_macros_f.h"
*

      subroutine set_crni 1
*
      implicit none
*
*author
*     sylvie gravel - rpn - nov 1994
*
*revision
* v2_00 - Desgagne/Lee      - initial MPI version (from setcrni v1_03)
*
*object
*       This subroutine initializes the common containing the keys used 
*       by the Virtual Memory Manager to identify the right-hand-sides
*       of the equations when using a Crank-Nicholson procedure
*	
*arguments
*	none
*
*implicits
#include "glb_ld.cdk"
#include "lun.cdk"
#include "orh.cdk"
#include "schm.cdk"
*
*modules
      integer  vmmcre 
      external vmmcre
      character*80 ptaorhs
      integer   i, pnerr
**
*     _________________________________________________________________
*
*     - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      if (Lun_out.gt.0) write (Lun_out,1000)

*     Initialization of names and keys commons 

      COMMON_INIT(orh,-100)


*     Assign the name of the variables

      VMM_NAM(oru  ) = 'RUORU'
      VMM_NAM(orv  ) = 'RVORV'
      VMM_NAM(orw  ) = 'RORW'
      VMM_NAM(orvv ) = 'RORVV'
      VMM_NAM(orcn ) = 'RORCN'
      VMM_NAM(orth ) = 'RORTH'

*     Create the virtual memory for the variables 

      ptaorhs='SAVE=Y,CL=5,W=5,INIT=R' !attributes

      VMM_CREATE(oru  , LARRAY3D, 1, ptaorhs)
      VMM_CREATE(orv  , LARRAY3D, 1, ptaorhs)
      VMM_CREATE(orcn , LARRAY3D, 1, ptaorhs)
      VMM_CREATE(orth , LARRAY3D, 1, ptaorhs)

      if (.not. Schm_hydro_L) then
         VMM_CREATE(orw  , LARRAY3D, 1, ptaorhs)
         VMM_CREATE(orvv , LARRAY3D, 1, ptaorhs)
      endif 

1000  format(
     %  /,'INITIALIZATION OF CRANK-NICHOLSON COMDECK (S/R SET_CRNI)',
     %  /,'========================================================')

      return
      end