247a248,331
>   SUBROUTINE output_boundary_wrfspec ( fid , grid , config_flags , ierr )
>     USE module_io_wrf
>     USE module_io
>     USE module_domain
>     USE module_state_description
>     USE module_configure
>     USE module_date_time
>     USE esmf_mod
> 
>     IMPLICIT NONE
>     TYPE(domain) :: grid
>     TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
>     INTEGER, INTENT(IN) :: fid 
>     INTEGER, INTENT(INOUT) :: ierr
> 
>     INTEGER :: ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme
>     INTEGER :: ips, ipe, jps, jpe, kps, kpe, RC, Hndl, io_form
>     LOGICAL :: for_out
> 
>     TYPE(ESMF_TimeInterval) :: bdy_increment
>     TYPE(ESMF_Time)         :: next_time, current_time
>     CHARACTER*40            :: next_datestr,current_datestr
> 
> 	write(0,*) 'ENTER OUTPUT_BOUNDARY_WRFSPEC'
> 
> 	call get_handle ( Hndl, io_form , for_out, fid )
> 
> 	write(0,*) 'Hndl in output_boundary_wrfspec: ', Hndl
> 
> !   FIGURE OUT LOOP LIMITS
> 
>     CALL get_ijk_from_grid (  grid ,                        &
>                               ids, ide, jds, jde, kds, kde,    &
>                               ims, ime, jms, jme, kms, kme,    &
>                               ips, ipe, jps, jpe, kps, kpe    )
> 
> 
> 	write(0,*) 'ids, ide: ', ids, ide
> 	write(0,*) 'jds, jde: ', jds, jde
> 
> !	write(0,*) 'bdy_increment, config_flags%bdyfrq: ', bdy_increment, config_flags%bdyfrq
> 
>        CALL ESMF_ClockGetCurrTime( grid%domain_clock, current_time, rc=rc )
>        CALL ESMF_TimeGetString( current_time, current_datestr, rc=rc )
> 	
>        CALL ESMF_TimeIntervalSet( bdy_increment, S=NINT(config_flags%bdyfrq),rc=rc)
>        next_time = current_time + bdy_increment
>        CALL ESMF_TimeGetString( next_time, next_datestr, rc=rc )
> 
> 	write(0,*) 'grid%nmm_pd_b(1,1,1,1): ', grid%nmm_pd_b(1,1,1,1)
> 	write(0,*) 'grid%nmm_pd_bt(1,1,1,1): ', grid%nmm_pd_bt(1,1,1,1)
> 
> 	if (  (maxval(grid%nmm_pd_bt(:,1,1,1)) .eq. 0)  .and.  &
>               (minval(grid%nmm_pd_bt(:,1,1,1)) .eq. 0)       ) then
> 
> 	write(0,*) 'dont think should write this time out'
> 	write(0,*) 'current_datestr(1:19): ', current_datestr(1:19)
> 	
> 	else
> 
> 	write(0,*) 'writing out for current, next: ',  &
>             current_datestr(1:19), next_datestr(1:19)
> 
> 	write(Hndl) current_datestr(1:19), next_datestr(1:19)
> 	write(Hndl) grid%nmm_pd_b
> 	write(Hndl) grid%nmm_pd_bt
> 	write(Hndl) grid%nmm_t_b
> 	write(Hndl) grid%nmm_t_bt
> 	write(Hndl) grid%nmm_q_b
> 	write(Hndl) grid%nmm_q_bt
> 	write(Hndl) grid%nmm_u_b
> 	write(Hndl) grid%nmm_u_bt
> 	write(Hndl) grid%nmm_v_b
> 	write(Hndl) grid%nmm_v_bt
> 	write(Hndl) grid%nmm_q2_b
> 	write(Hndl) grid%nmm_q2_bt
> 	write(Hndl) grid%nmm_cwm_b
> 	write(Hndl) grid%nmm_cwm_bt
> 
> 	endif
> 
>     RETURN
>   END SUBROUTINE output_boundary_wrfspec
> 
276a361,364
> !mp
>     INTEGER start_year, start_month, start_day, start_hour, start_minute, &
>             start_second
> !mp
285d372
<     INTEGER :: start_year , start_month , start_day , start_hour , start_minute , start_second
334a422,426
> #if 0
>     IF ( switch .EQ. boundary_only ) THEN
>       CALL get_bdyfrq ( grid%id , bdyfrq )
>     ENDIF
> #endif
338a431,432
>     CALL wrf_debug ( 100 , wrf_err_message )
> 
346a441
> 
353,354c448,453
<    WRITE ( start_date , FMT = '(I4.4,"-",I2.2,"-",I2.2,"_",I2.2,":",I2.2,":",I2.2)' ) &
<            start_year,start_month,start_day,start_hour,start_minute,start_second
---
> 	
>    WRITE ( start_date , FMT = &
>          '(I4.4,"-",I2.2,"-",I2.2,"T",I2.2,":",I2.2,":",I2.2)' ) &
>          start_year,start_month,start_day,start_hour,start_minute,start_second
> 
> 	write(0,*) 'call wrf_put_dom_ti_char for start_date: ', start_date
355a455
> 	write(0,*) 'ierr from start_date put: ', ierr
383a484,487
> #if (EH_CORE == 1)
>         CASE ( dyn_eh )
>           CALL wrf_put_dom_ti_char ( fid , 'GRIDTYPE',  'C' , ierr )
> #endif
508a613,615
> #if 0
>         CALL wrf_put_dom_ti_real ( fid , 'BDYFRQ' ,  config_flags%bdyfrq , 1 , ierr )
> #else
511a619
> 	write(0,*) 'call wrf_put_dom_td_char, current_date(1:19): ', current_date(1:19)
512a621
> 	write(0,*) 'ierr from wrf_put_dom_td_char: ', ierr
513a623
> #endif
610a721
> 	write(0,*) 'call input_wrf, fid: ', fid
611a723
> 	write(0,*) 'return input_wrf, fid: ', fid
802a915,1064
>   SUBROUTINE input_boundary_wrfspec ( fid , grid , config_flags , ierr )
>     USE module_io_wrf
>     USE module_io
>     USE module_domain
>     USE module_state_description
>     USE module_configure
>     USE module_date_time
>     USE module_dm
>     USE esmf_mod
> 
>     IMPLICIT NONE
>     LOGICAL wrf_dm_on_monitor, for_out
>     EXTERNAL wrf_dm_on_monitor
>     TYPE(domain) :: grid
>     TYPE(grid_config_rec_type),  INTENT(IN   )    :: config_flags
>     INTEGER, INTENT(IN) :: fid 
>     INTEGER, INTENT(INOUT) :: ierr
>     INTEGER             :: Hndl, io_form
> 
>     INTEGER :: ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme
>     INTEGER :: ips, ipe, jps, jpe, kps, kpe, RC, dim,dim1,dim2,dim3,dim4
> 
>     TYPE(ESMF_TimeInterval) :: bdy_increment
>     TYPE(ESMF_Time)         :: next_time, current_time
>     CHARACTER*40            :: next_datestr,current_datestr
> 
> 	write(0,*) 'enter input_boundary_wrfspec'
> 
> 
> 	call get_handle ( Hndl, io_form , for_out, fid )
> 
> 	write(0,*) 'post get_handle Hndl ', Hndl
> 
> !   FIGURE OUT LOOP LIMITS
> 
> 
>     CALL get_ijk_from_grid (  grid ,                        &
>                               ids, ide, jds, jde, kds, kde,    &
>                               ims, ime, jms, jme, kms, kme,    &
>                               ips, ipe, jps, jpe, kps, kpe    )
> 
> 	write(0,*) 'return get_ijk_from_grid'
> 
> 	write(0,*) 'ids, ide: ', ids, ide
> 	write(0,*) 'jds, jde: ', jds, jde
> 
> 	write(0,*) 'bdy_increment, config_flags%bdyfrq: ', bdy_increment, config_flags%bdyfrq
> 
>        CALL ESMF_ClockGetCurrTime( grid%domain_clock, current_time, rc=rc )
>        CALL ESMF_TimeGetString( current_time, current_datestr, rc=rc )
> 	write(0,*) 'current_datestr: ', current_datestr(1:19)
> 	
>        CALL ESMF_TimeIntervalSet( bdy_increment, S=NINT(config_flags%bdyfrq),rc=rc)
>        next_time = current_time + bdy_increment
>        CALL ESMF_TimeGetString( next_time, next_datestr, rc=rc )
> 	write(0,*) 'next_datestr: ', next_datestr(1:19)
> 
>     IF ( wrf_dm_on_monitor() ) THEN
> 
> 	write(0,*) 'on monitor task....read LBCs'
> 
> 
> !!!! UNIT NUMBER SHOULD NOT BE HARDWIRED LIKE THIS!!!!!
> !!!! UNIT NUMBER SHOULD NOT BE HARDWIRED LIKE THIS!!!!!
> !!!! UNIT NUMBER SHOULD NOT BE HARDWIRED LIKE THIS!!!!!
> 
> 
> 	read(Hndl) current_datestr(1:19), next_datestr(1:19)
> 	write(0,*) 'read from wrfbdy current, next: ', &
>                      current_datestr(1:19), next_datestr(1:19)
> 
> !HERE
> 
> ! 2d array
> 	
> 	read(Hndl) grid%nmm_pd_b
> 	read(Hndl) grid%nmm_pd_bt
> 
> ! 3d array (all same size)
> 	read(Hndl) grid%nmm_t_b
> 	read(Hndl) grid%nmm_t_bt
> 
> 	read(Hndl) grid%nmm_q_b
> 	read(Hndl) grid%nmm_q_bt
> 
> 	read(Hndl) grid%nmm_u_b
> 	read(Hndl) grid%nmm_u_bt
> 
> 	read(Hndl) grid%nmm_v_b
> 	read(Hndl) grid%nmm_v_bt
> 
> 	read(Hndl) grid%nmm_q2_b
> 	read(Hndl) grid%nmm_q2_bt
> 
> 	read(Hndl) grid%nmm_cwm_b
> 	read(Hndl) grid%nmm_cwm_bt
> 
> !        CALL atotime( next_datestr(1:19), grid%next_bdy_time )
>       write(0,*) 'root task grid%nmm_pd_b(1,1,1,1): ', grid%nmm_pd_b(1,1,1,1)
>       write(0,*) 'root task grid%nmm_pd_bt(1,1,1,1): ', grid%nmm_pd_bt(1,1,1,1)
>       write(0,*) 'root task grid%nmm_u_b(25,35,1,1): ', grid%nmm_u_b(25,35,1,1)
> 
> 	ENDIF ! wrf_dm_on_monitor
> 
> 	dim1=size(grid%nmm_pd_b, dim=1)
> 	dim2=size(grid%nmm_pd_b, dim=2)
> 	dim3=size(grid%nmm_pd_b, dim=3)
> 	dim4=size(grid%nmm_pd_b, dim=4)
> 
> 	write(0,*) 'dim1,dim2,dim3,dim4: ', dim1,dim2,dim3,dim4
> 
> 	dim=dim1*dim2*dim3*dim4
> 	write(0,*) 'call wrf_dm_bcast_bytes for size: ', RWORDSIZE*dim
> 
>           CALL wrf_dm_bcast_string(next_datestr(1:19), 19)
> 	write(0,*) 'everybody next_datestr(1:19): ', next_datestr(1:19)
>         CALL atotime( next_datestr(1:19), grid%next_bdy_time )
> 
> 	write(0,*) 'call wrf_dm_bcast_bytes for size: ', RWORDSIZE*dim
>           CALL wrf_dm_bcast_bytes( grid%nmm_pd_b, RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_pd_bt, RWORDSIZE*dim )
> 
> 	write(0,*) 'everybody grid%nmm_pd_b(1,1,1,1): ', grid%nmm_pd_b(1,1,1,1)
> 	write(0,*) 'everybody grid%nmm_pd_bt(1,1,1,1): ', grid%nmm_pd_bt(1,1,1,1)
> 
> 	dim1=size(grid%nmm_t_b, dim=1)
> 	dim2=size(grid%nmm_t_b, dim=2)
> 	dim3=size(grid%nmm_t_b, dim=3)
> 	dim4=size(grid%nmm_t_b, dim=4)
> 
> 	write(0,*) 'for 3D dim1,dim2,dim3,dim4: ', dim1,dim2,dim3,dim4
> 	dim=dim1*dim2*dim3*dim4
> 	write(0,*) 'call wrf_dm_bcast_bytes for 3D vars of size: ', RWORDSIZE*dim
> 
>           CALL wrf_dm_bcast_bytes( grid%nmm_t_b,  RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_t_bt, RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_u_b,  RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_u_bt, RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_v_b,  RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_v_bt, RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_q2_b,  RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_q2_bt, RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_cwm_b,  RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_cwm_bt, RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_q_b,  RWORDSIZE*dim )
>           CALL wrf_dm_bcast_bytes( grid%nmm_q_bt, RWORDSIZE*dim )
> 
> 
>   END SUBROUTINE input_boundary_wrfspec
> 
860a1123,1124
> 	write(0,*) 'in input_wrf with switch,fid: ', switch,fid
> 	write(0,*) 'returned with dyn_opt from file: ', itmp
886c1150
< #if (EM_CORE == 1)
---
> #if (EM_CORE == 1) || (EH_CORE == 1)
924d1187
< 
937c1200
<     
---
> 
939c1202,1212
< 	write(0,*) 'call wrf_get_dom_td_char THISBDYTIME'
---
> #if 0
>         CALL wrf_get_dom_ti_real ( fid , 'BDYFRQ' ,  config_flags%bdyfrq , 1 , icnt , ierr )
>         WRITE(wrf_err_message,*)'input_wrf: wrf_get_dom_ti_real for BDYFRQ returns ',config_flags%bdyfrq,ierr
>         CALL wrf_debug ( 300 , wrf_err_message )
>         CALL set_bdyfrq ( grid%id , config_flags%bdyfrq )
>         CALL get_time_to_read_again ( oldtime )
>         CALL ESMF_TimeIntervalSet( timetonext, S=NINT(config_flags%bdyfrq) )
>         newtime = oldtime + timetonext
>         CALL set_time_to_read_again ( newtime )
> #else
> 	write(0,*) 'call wrf_get_dom_td_char for THISBDYTIME'
941c1214,1216
< 	write(0,*) 'return wrf_get_dom_td_char THISBDYTIME: ', this_datestr(1:19)
---
> 	write(0,*) 'return from wrf_get_dom_td_char, ierr: ', ierr
> 	write(0,*) 'return wrf_get_dom_td_char for THISBDYTIME, this_datestr: ', this_datestr(1:19)
> 	write(0,*) 'current_date: ', current_date(1:19)
943d1217
< 	write(0,*) 'call wrf_get_dom_td_char....NEXTBDYTIME'
945d1218
< 	write(0,*) 'return wrf_get_dom_td_char NEXTBDYTIME: ', next_datestr(1:19)
946a1220
> #endif