!-------------------------------------- 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 itf_phy_main - Main controller for the physics interface
*
#include "model_macros_f.h"
*

      subroutine itf_phy_main (F_stepno) 2,15
*
      implicit none
*
      integer F_stepno
*
*author 
*     Michel Desgagne - Mars 2000
*
*revision
* v3_30 - Desgagne M.       - initial version
* v3_31 - Desgagne M.       - restart with physics BUSPER
*      
*object
*
*arguments
*  Name        I/O                 Description
*----------------------------------------------------------------
* F_stepno      I           step number
*----------------------------------------------------------------
*
*implicits
#include "glb_ld.cdk"
#include "lctl.cdk"
#include "cstv.cdk"
#include "dimout.cdk"
#include "xst.cdk"
#include "itf_phy_buses.cdk"
#include "itf_cpl.cdk"
#include "rstr.cdk"
#include "init.cdk"
#include "out2.cdk"
#include "v4dg.cdk"
#include "lam.cdk"
*
      logical boot_L
      integer ier,dostep(MAXSET),dostep_max
      integer   doout
      external  doout
      real prip2
      save boot_L
      data boot_L /.true./
**
*     ---------------------------------------------------------------
*
      if (F_stepno.eq.1) then
         Lctl_step = 0
        if (.not.Lam_busper_init_L) then
              call itf_phy_step (0)
         else
              call out_phy0()
         endif
         if (V4dg_conf.eq.0) call out_qc0()
         if((Init_balgm_L) .and. (.not. Rstri_idon_L) ) then
             call wlog('IOUT')
         else
             call wlog('FOUT')
         endif
         Lctl_step = 1
      endif
*
      if (boot_L) then
         if (Xst_nstat.gt.0) then
            call sergset ()
            if (F_stepno.eq.1) call sergini ()
         endif
         call zongopr( 1,0 )
         boot_L = .false.
      endif
*
      call sergoff()
      call serset('KOUNT', F_stepno, 1,  ier)
      prip2 = float(F_stepno)*Cstv_dt_8/3600.
      call serset('HEURE',  prip2,  1,  ier)      
*
      call zongopr( +2,0 )
*
      call itf_phy_step (F_stepno)
*
      call zongopr( -2,0 )
*     
      if (Xst_nstat.gt.0) call sergout( F_stepno.eq.1 )
*
      return
      end