copyright (C) 2001  MSC-RPN COMM  %%%MC2%%%
***s/r e_dynfld
*

      subroutine e_dynfld ( topo_h ) 1,4
      implicit none
*
      real topo_h(*)
*
*AUTHOR  M. Desgagne    May 2001
*
*IMPLICIT
#include "cdate.cdk"
#include "lcldim.cdk"
#include "grd.cdk"
#include "nesting.cdk"
#include "nestpnt.cdk"
#include "halo.cdk"
#include "partopo.cdk"
*
**
      character*16 date1,date2
      logical topo_ok,data_ok
      integer ipas,err,RPN_COMM_split,gni_mc2,gnj_mc2,
     $        i,j,n,unf,unf_root,scrap1,scrap2,scrap3,donut
      real maxtopo
      real*8 dayfrac,sec_in_day
      parameter (sec_in_day=86400.0d0)
      data unf_root /61/
*
*---------------------------------------------------------------------
*
      write (6,610) Pil_runstrt_S,Pil_runend_S
*
      call hpalloc (pagcl2, 5*npex*npey, err,1)
      gni_mc2 = Grd_ni-1-2*hx
      gnj_mc2 = Grd_nj-1-2*hx
      unf = unf_root - 1
      do j = 0, npey-1
      do i = 0, npex-1
         unf = unf    + 1
         n   = j*npex + i
         err = RPN_COMM_split (i,npex,gni_mc2,scrap1,scrap2,
     $                         gc_ld2(2,n),scrap3,hx,gc_ld2(1,n),.true.)
         err = RPN_COMM_split (j,npey,gnj_mc2,scrap1,scrap2,
     $                         gc_ld2(4,n),scrap1,hx,gc_ld2(3,n),.true.)
         gc_ld2(5,n) = unf
      end do
      end do
*
      ipas    = 0
      date1   = Pil_runstrt_S
      dayfrac = dble(Pil_nesdt) / sec_in_day
      call incdatsd(date2,Pil_runstrt_S,dayfrac)
      topo_ok = sfc2d
*
      if (init3d) then
*
         ipas    = 1
         call getspc (topo_h,date1,-1,topo_ok,data_ok)
         if (.not.data_ok) stop
*
      endif
*
      if (bcs) then
*
         donut = -1
         if (gnpilver.le.0) donut = halo
*
 111     if (Pil_runend_S.gt.date1) then
            dayfrac = dble(ipas*Pil_nesdt) / sec_in_day
            call incdatsd(date1,Pil_runstrt_S,dayfrac)
*
            call getspc (topo_h,date1,donut,topo_ok,data_ok)
            if (.not.data_ok) return
            ipas = ipas + 1
*
            if (date1.eq.date2)
     $      call system ('if [ -s soumet_la_job ] ; then . soumet_la_job ; /bin/rm -f soumet_la_job ; fi')
            goto 111
         endif
*
      endif
*
 610  format (/ ' MC2NTR START TIME= ',a16,/
     $          ' MC2NTR END TIME=   ',a16)
*---------------------------------------------------------------------
      return
      end