Skip to content
Merged
1 change: 1 addition & 0 deletions Registry/Registry.EM_COMMON
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,7 @@ rconfig integer spec_bdy_final_mu namelist,bdy_control 1 1
rconfig integer real_data_init_type namelist,bdy_control 1 1 irh "real_data_init_type" "REAL DATA INITIALIZATION OPTIONS: 1=SI, 2=MM5, 3=GENERIC" "PRE-PROCESSOR TYPES"
rconfig logical have_bcs_moist namelist,bdy_control max_domains .false. rh "have_bcs_moist" "" ""
rconfig logical have_bcs_scalar namelist,bdy_control max_domains .false. rh "have_bcs_scalar" "" ""
rconfig logical multi_bdy_files namelist,bdy_control 1 .false. rh "multi_bdy_files" "" ""

rconfig integer background_proc_id namelist,grib2 1 255 rh "background_proc_id" "Background processing id for grib2" ""
rconfig integer forecast_proc_id namelist,grib2 1 255 rh "forecast_proc_id" "Analysis and forecast processing id for grib2" ""
Expand Down
1 change: 1 addition & 0 deletions Registry/Registry.NMM
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@ rconfig logical open_ye namelist,bdy_control max_domains .f
rconfig logical polar namelist,bdy_control max_domains .false. rh "polar" "" ""
rconfig logical nested namelist,bdy_control max_domains .false. rh "nested" "" ""
rconfig integer real_data_init_type namelist,bdy_control 1 1 irh "real_data_init_type" "REAL DATA INITIALIZATION OPTIONS: 1=SI, 2=MM5, 3=GENERIC" "PRE-PROCESSOR TYPES"
rconfig logical multi_bdy_files namelist,bdy_control 1 .false. rh "multi_bdy_files" "" ""

rconfig integer background_proc_id namelist,grib2 1 255 rh "background_proc_id" "Background processing id for grib2" ""
rconfig integer forecast_proc_id namelist,grib2 1 255 rh "forecast_proc_id" "Analysis and forecast processing id for grib2" ""
Expand Down
54 changes: 43 additions & 11 deletions main/real_em.F
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ END SUBROUTINE start_domain
CHARACTER (LEN=256) :: si_inpname
CHARACTER (LEN=80) :: message

CHARACTER(LEN=19) :: start_date_char , end_date_char , current_date_char , next_date_char
CHARACTER(LEN=19) :: start_date_char , end_date_char , current_date_char , next_date_char , &
prev_date_char

INTEGER :: time_loop_max , loop, rc
INTEGER :: julyr , julday
Expand Down Expand Up @@ -377,6 +378,7 @@ END SUBROUTINE start_domain
! Here we define the initial time to process, for later use by the code.

current_date_char = start_date_char
prev_date_char = start_date_char
start_date = start_date_char // '.0000'
current_date = start_date

Expand Down Expand Up @@ -576,7 +578,8 @@ END SUBROUTINE start_domain
#endif

CALL cpu_time ( t3 )
CALL assemble_output ( grid , config_flags , loop , time_loop_max )
CALL assemble_output ( grid , config_flags , loop , time_loop_max, current_date_char , prev_date_char )
prev_date_char = current_date_char
CALL cpu_time ( t4 )
WRITE ( wrf_err_message , FMT='(A,I10,A)' ) 'Timing for output ',NINT(t4-t3) ,' s.'
CALL wrf_debug( 0, wrf_err_message )
Expand Down Expand Up @@ -668,7 +671,7 @@ SUBROUTINE compute_si_start_and_end ( &
END DO loop_count
END SUBROUTINE compute_si_start_and_end

SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )
SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max , current_date_char , prev_date_char )

USE module_big_step_utilities_em
USE module_domain
Expand All @@ -693,6 +696,7 @@ SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )
CHARACTER (LEN=256) :: inpname , bdyname
CHARACTER(LEN= 4) :: loop_char
CHARACTER (LEN=256) :: message
CHARACTER (LEN=19) , INTENT(IN) :: current_date_char, prev_date_char
character *19 :: temp19
character *24 :: temp24 , temp24b

Expand All @@ -703,6 +707,10 @@ SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )
REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: qn1bdy3dtemp1, qn1bdy3dtemp2, qn2bdy3dtemp1, qn2bdy3dtemp2
real::t1,t2

INTEGER :: open_status

#include "wrf_io_flags.h"

! Various sizes that we need to be concerned about.

ids = grid%sd31
Expand Down Expand Up @@ -807,7 +815,7 @@ SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )
CALL construct_filename1( inpname , 'wrfinput' , grid%id , 2 )
CALL open_w_dataset ( id1, TRIM(inpname) , grid , config_flags , output_input , "DATASET=INPUT", ierr )
IF ( ierr .NE. 0 ) THEN
CALL wrf_error_fatal( 'real: error opening wrfinput for writing' )
CALL wrf_error_fatal( 'REAL: error opening wrfinput for writing' )
END IF
CALL output_input ( id1, grid , config_flags , ierr )
CALL close_dataset ( id1 , config_flags , "DATASET=INPUT" )
Expand All @@ -817,7 +825,7 @@ SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )
CALL construct_filename1( inpname , 'wrflowinp' , grid%id , 2 )
CALL open_w_dataset ( id4, TRIM(inpname) , grid , config_flags , output_auxinput4 , "DATASET=AUXINPUT4", ierr )
IF ( ierr .NE. 0 ) THEN
CALL wrf_error_fatal( 'real: error opening wrflowinp for writing' )
CALL wrf_error_fatal( 'REAL: error opening wrflowinp for writing' )
END IF
CALL output_auxinput4 ( id4, grid , config_flags , ierr )
END IF
Expand Down Expand Up @@ -957,27 +965,51 @@ SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )

IF ( loop .eq. 2 ) THEN
IF ( (grid%id .eq. 1) .and. ( .NOT. config_flags%polar ) ) THEN
CALL construct_filename1( bdyname , 'wrfbdy' , grid%id , 2 )
CALL open_w_dataset ( id, TRIM(bdyname) , grid , config_flags , output_boundary , "DATASET=BOUNDARY", ierr )
IF ( ierr .NE. 0 ) THEN
CALL wrf_error_fatal( 'real: error opening wrfbdy for writing' )
IF ( .NOT. config_flags%multi_bdy_files ) THEN
CALL construct_filename2a( bdyname , TRIM(config_flags%bdy_inname) , grid%id , 2 , " " )
CALL open_w_dataset ( id, TRIM(bdyname) , grid , config_flags , output_boundary , "DATASET=BOUNDARY", ierr )
IF ( ierr .NE. 0 ) THEN
CALL wrf_error_fatal( 'REAL: error opening ' // TRIM(bdyname) // ' for writing' )
END IF
END IF
END IF
IF(grid_fdda .GE. 1)THEN
CALL construct_filename1( inpname , 'wrffdda' , grid%id , 2 )
CALL open_w_dataset ( id2, TRIM(inpname) , grid , config_flags , output_auxinput10 , "DATASET=AUXINPUT10", ierr )
IF ( ierr .NE. 0 ) THEN
CALL wrf_error_fatal( 'real: error opening wrffdda for writing' )
CALL wrf_error_fatal( 'REAL: error opening wrffdda for writing' )
END IF
END IF
ELSE

! Advance the clock to the next time period.

IF ( .NOT. domain_clockisstoptime(grid) ) THEN
CALL domain_clockadvance( grid )
CALL domain_clockprint ( 150, grid, &
'DEBUG assemble_output: clock after ClockAdvance,' )
END IF
END IF

! If the lateral boundary conditions are split, then open the file with a
! date string. Only single time periods are allowed in a lateral BC file
! when the files are split into multiple pieces. Also, we choose to
! CLOSE the file just before we need it OPENed.

IF ( config_flags%multi_bdy_files ) THEN
CALL construct_filename2a( bdyname , TRIM(config_flags%bdy_inname) , grid%id , 2 , prev_date_char )

CALL wrf_inquire_opened(id , TRIM(bdyname) , open_status , ierr )
IF ( open_status .EQ. WRF_FILE_OPENED_FOR_WRITE ) THEN
CALL close_dataset ( id , config_flags , "DATASET=BOUNDARY" )
END IF

CALL open_w_dataset ( id, TRIM(bdyname) , grid , config_flags , output_boundary , "DATASET=BOUNDARY", ierr )
IF ( ierr .NE. 0 ) THEN
CALL wrf_error_fatal( 'REAL: error opening ' // TRIM(bdyname) // ' for writing' )
END IF
END IF

IF ( config_flags%polar ) THEN

! No need to couple fields, since no lateral BCs are required.
Expand Down Expand Up @@ -1160,7 +1192,7 @@ SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max )
! Output boundary file.

IF(grid%id .EQ. 1)THEN
print *,'LBC valid between these times ',current_date, ' ',start_date
print *,'LBC valid between these times ',prev_date_char, ' and ',current_date_char
CALL output_boundary ( id, grid , config_flags , ierr )
END IF

Expand Down
4 changes: 4 additions & 0 deletions run/README.namelist
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,10 @@ The following are for observation nudging:
= .true. , ! use microphysics variables in bdy file
have_bcs_scalar (max_dom) = .false., ! model run after ndown only: do not use scalar variables in bdy file
= .true. , ! use scalar variables in bdy file
multi_bdy_files = .false., ! F=default; T=model will run with split and individually named LBC files
requires usage of bdy_inname = "wrfbdy_d<domain>_<date>"
the real program can generate all LBC files in a single run
only a single time period is in each separate LBC file

euler_adv = .false., ! conservative Eulerian passive advection (NMM only)
idtadt = 1, ! fundamental timesteps between calls to Euler advection, dynamics (NMM only)
Expand Down
34 changes: 17 additions & 17 deletions share/mediation_integrate.F
Original file line number Diff line number Diff line change
Expand Up @@ -2104,9 +2104,7 @@ SUBROUTINE med_latbound_in ( grid , config_flags )
Type (WRFU_Time ) :: startTime, stopTime, currentTime
Type (WRFU_TimeInterval ) :: stepTime
integer myproc,i,j,k
#ifdef _MULTI_BDY_FILES_
CHARACTER(LEN=80) :: timestr
#endif

#include "wrf_io_flags.h"

Expand Down Expand Up @@ -2142,14 +2140,16 @@ SUBROUTINE med_latbound_in ( grid , config_flags )
CALL WRFU_AlarmRingerOff( grid%alarms( BOUNDARY_ALARM ), rc=rc )
IF ( wrf_dm_on_monitor() ) CALL start_timing

#ifdef _MULTI_BDY_FILES_
! Possibility to have a <date> as part of the bdy_inname.
CALL domain_clock_get( grid, current_timestr=timestr )
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , timestr )
#else
! typically a <date> wouldn't be part of the bdy_inname, so just pass a dummy
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , " " )
#endif
IF ( config_flags%multi_bdy_files ) THEN
CALL domain_clock_get( grid, current_timestr=timestr )
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , timestr )

! typically a <date> wouldn't be part of the bdy_inname, so just pass a dummy
ELSE
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , " " )

END IF

CALL wrf_inquire_opened(grid%lbc_fid , TRIM(bdyname) , open_status , ierr )
IF ( open_status .EQ. WRF_FILE_OPENED_FOR_READ ) THEN
Expand All @@ -2159,11 +2159,11 @@ SUBROUTINE med_latbound_in ( grid , config_flags )
ENDIF
CALL wrf_dm_bcast_bytes ( lbc_opened , LWORDSIZE )
IF ( .NOT. lbc_opened ) THEN
#ifdef _MULTI_BDY_FILES_
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , timestr )
#else
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , " " )
#endif
IF ( config_flags%multi_bdy_files ) THEN
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , timestr )
ELSE
CALL construct_filename2a ( bdyname , config_flags%bdy_inname , grid%id , 2 , " " )
END IF
WRITE(message,*)'Opening: ',TRIM(bdyname)
CALL wrf_debug(100,TRIM(message))
CALL open_r_dataset ( grid%lbc_fid, TRIM(bdyname) , grid , config_flags , "DATASET=BOUNDARY", ierr )
Expand Down Expand Up @@ -2203,10 +2203,10 @@ SUBROUTINE med_latbound_in ( grid , config_flags )
CALL input_boundary ( grid%lbc_fid, grid , config_flags , ierr )
ENDDO
#endif
#ifdef _MULTI_BDY_FILES_
! Close the bdy file so that next time around, we'll open it again.
CALL close_dataset ( grid%lbc_fid , config_flags , "DATASET=BOUNDARY" )
#endif
IF ( config_flags%multi_bdy_files ) THEN
CALL close_dataset ( grid%lbc_fid , config_flags , "DATASET=BOUNDARY" )
END IF
#if ( WRFPLUS == 1 )
IF ( config_flags%dyn_opt .NE. dyn_em_ad ) THEN
CALL WRFU_AlarmSet( grid%alarms( BOUNDARY_ALARM ), RingTime=grid%next_bdy_time, rc=rc )
Expand Down
44 changes: 44 additions & 0 deletions share/module_check_a_mundo.F
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ SUBROUTINE check_nml_consistency
!END FASDAS
!
INTEGER :: count_fatal_error
INTEGER :: len1, len2, len_loop

! These functions are located with in the Urban Physics files, but
! not within the confines of the modules. Since we are in the share
Expand Down Expand Up @@ -936,6 +937,49 @@ END FUNCTION bep_bem_nbui_max
model_config_rec%num_traj = 0
END IF

!-----------------------------------------------------------------------
! Catch old method for using multi-file LBCs. Let folks know the
! new way to get the same functionality with run-time options.
!-----------------------------------------------------------------------
#if _MULTI_BDY_FILES_
wrf_err_message = '--- ERROR: Do not use the compile-time -D_MULTI_BDY_FILES_ option for multi-file LBCs.'
CALL wrf_debug ( 0, TRIM(wrf_err_message) )
wrf_err_message = '--- ERROR: Use the run-time namelist option multi_bdy_files in nml record bdy_control.'
CALL wrf_debug ( 0, TRIM( wrf_err_message ) )
count_fatal_error = count_fatal_error + 1
#endif

!----------------------------------------------------------------------------
! If using multi_bdy_files option or not, make the lateral bdy file root name
! correct. For example, we want "wrfbdy_d01" for NON multi_bdy_files and we
! want "wrfbdy_d01_SOME_DATE" when using the multi_bdy_files option.
!----------------------------------------------------------------------------
IF ( model_config_rec%multi_bdy_files ) THEN
IF ( INDEX ( TRIM(model_config_rec%bdy_inname) , "_<date>" ) .GT. 0 ) THEN
! No op, all OK
ELSE
wrf_err_message = '--- ERROR: Need bdy_inname = "wrfbdy_d<domain>_<date>"'
CALL wrf_debug ( 0, TRIM(wrf_err_message) )
count_fatal_error = count_fatal_error + 1
! len1 = LEN_TRIM(model_config_rec%bdy_inname)
! len2 = "_<date>"
! model_config_rec%bdy_inname(1:len1+len2) = TRIM(model_config_rec%bdy_inname) // "_<date>"
END IF
ELSE IF ( .NOT. model_config_rec%multi_bdy_files ) THEN
IF ( INDEX ( TRIM(model_config_rec%bdy_inname) , "_<date>" ) .EQ. 0 ) THEN
! No op, all OK
ELSE
wrf_err_message = '--- ERROR: Remove bdy_inname = "wrfbdy_d<domain>_<date>"'
CALL wrf_debug ( 0, TRIM(wrf_err_message) )
count_fatal_error = count_fatal_error + 1
! len1 = LEN_TRIM(model_config_rec%bdy_inname)
! len2 = "_<date>"
! DO len_loop len1-len2+1 , len1
! model_config_rec%bdy_inname(len_loop:len_loop) = " "
! END DO
END IF
END IF

#elif( NMM_CORE == 1 )
!----------------------------------------------------------------------------
! If NMM core and trajectories are on then halt.
Expand Down
12 changes: 12 additions & 0 deletions test/em_real/examples.namelist
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ Switching off latent heating from a microphysics scheme (must also set cu_physic
spec_zone is ALWAYS = 1
relax_zone is ALWAYS = spec_bdy_width - spec_zone

&bdy_control
spec_bdy_width = 10,
specified = .true.,
spec_exp = 0.33
Expand All @@ -331,6 +332,17 @@ For a tropical channel configuration, set the following:
specified = .true.,
periodic_x = .true.,

** Using split lateral boundary files
The run-time flag multi_bdy_files must be set to TRUE (default is false), and the
lateral boundary files must have a date associated. When using the split LBC option,
there is ALWAYS and ONLY a single time LBC time in each file.

multi_bdy_files = .true.

Also requires
&time_control
bdy_inname = "wrfbdy_d<domain>_<date>"

** using io quilting option to improve output efficiency for large domain runs
(note that this is a separate namelist record):

Expand Down