!-------------------------------------- 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 v4d_set_bc - Initialization of the commons for control BC variables
*
#include "model_macros_f.h"
*

      subroutine v4d_set_bc 1
*
      implicit none
*
*author
*     M. Tanguay 
*
*revision
* v3_31 - Tanguay M.        - initial version 
* v3_31 - Tanguay M.        - Control BC 
*
*object
*     see id section
*	
*arguments
*	none
*
*implicits
#include "glb_ld.cdk"
#include "lun.cdk"
#include "tr3d.cdk"
#include "v4d_bc.cdk" 
#include "v4d_bc_ref.cdk" 
#include "v4d_bc_cur.cdk" 
#include "step.cdk" 
*
*modules
      integer vmmcre
      external vmmcre
      character*80 ptath
      integer i
*
*     ---------------------------------------------------------------
*
      if (Lun_out.gt.0) write (Lun_out,1000)
*
      COMMON_INIT(bc,-100)
*
*     Assign the names of the variables
*
      VMM_NAM(bc_u ) = 'BC_U'
      VMM_NAM(bc_v ) = 'BC_V'
      VMM_NAM(bc_tp) = 'BC_TP'
      VMM_NAM(bc_s ) = 'BC_S'
      VMM_NAM(bc_tr) = 'BC_TR'
*
*     Set the attributes of the variables
*
      ptath='SAVE=Y,CL=1,W=5,INIT=0,MUSTEXIST'
*
      VMM_CREATE(bc_u   , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_v   , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_tp  , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_s   , LARRAY2D, Step_total+1, ptath)

      if ( Tr3d_ntr .gt. 0 ) then
         VMM_CREATE(bc_tr , LARRAY3D, Tr3d_ntr*(Step_total+1), ptath)
      endif
*
*     ---------
*     REFERENCE
*     ---------
*
      COMMON_INIT(bc_ref,-100)
*
*       Assign the names of the variables
*
      VMM_NAM(bc_ref_u ) = 'BC_R_U'
      VMM_NAM(bc_ref_v ) = 'BC_R_V'
      VMM_NAM(bc_ref_tp) = 'BC_R_TP'
      VMM_NAM(bc_ref_s ) = 'BC_R_S'
      VMM_NAM(bc_ref_tr) = 'BC_R_TR'
*
*     Set the attributes of the variables
*
      ptath='SAVE=Y,CL=1,W=5,INIT=0,MUSTEXIST'
*
      VMM_CREATE(bc_ref_u   , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_ref_v   , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_ref_tp  , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_ref_s   , LARRAY2D, Step_total+1, ptath)

      if ( Tr3d_ntr .gt. 0 ) then
         VMM_CREATE(bc_ref_tr , LARRAY3D, Tr3d_ntr*(Step_total+1), ptath)
      endif
*
*     -------
*     CUREENT 
*     -------
*
      COMMON_INIT(bc_cur,-100)
*
*       Assign the names of the variables
*
      VMM_NAM(bc_cur_u ) = 'BC_C_U'
      VMM_NAM(bc_cur_v ) = 'BC_C_V'
      VMM_NAM(bc_cur_tp) = 'BC_C_TP'
      VMM_NAM(bc_cur_s ) = 'BC_C_S'
      VMM_NAM(bc_cur_tr) = 'BC_C_TR'
*
*     Set the attributes of the variables
*
      ptath='SAVE=Y,CL=1,W=5,INIT=0,MUSTEXIST'
*
      VMM_CREATE(bc_cur_u   , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_cur_v   , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_cur_tp  , LARRAY3D, Step_total+1, ptath)
      VMM_CREATE(bc_cur_s   , LARRAY2D, Step_total+1, ptath)

      if ( Tr3d_ntr .gt. 0 ) then
         VMM_CREATE(bc_cur_tr , LARRAY3D, Tr3d_ntr*(Step_total+1), ptath)
      endif
*
 1000 format(
     +/,'INITIALIZATION OF CONTROL BC VARIABLE COMDECKS (S/R V4D_SET_BC)',
     +/,'===============================================================')
*
*     ---------------------------------------------------------------
*
      return
      end