!WRF:MEDIATION_LAYER:
!
SUBROUTINE med_initialdata_input ( grid , config_flags ) 2,27
! Driver layer
USE module_domain
USE module_io_domain
! Model layer
USE module_configure
USE module_bc_time_utilities
IMPLICIT NONE
! Interface
INTERFACE
SUBROUTINE start_domain ( grid ) ! comes from module_start in appropriate dyn_ directory
USE module_domain
TYPE (domain) grid
END SUBROUTINE start_domain
END INTERFACE
! Arguments
TYPE(domain) :: grid
TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
! Local
INTEGER :: time_step_begin_restart
INTEGER :: fid , ierr , myproc
CHARACTER (LEN=80) :: inpname , rstname
CHARACTER (LEN=80) :: message
CALL get_time_step_begin_restart( time_step_begin_restart )
IF ( time_step_begin_restart .EQ. 0 ) THEN
! Initialize the mother domain.
CALL start_timing
grid%input_from_file = .true.
IF ( grid%input_from_file ) THEN
CALL wrf_debug ( 100 , 'wrf main: calling open_r_dataset for wrfinput' )
#if 1
CALL construct_filename1
( inpname , 'wrfinput' , grid%id , 2 )
CALL open_r_dataset
( fid, TRIM(inpname) , grid , config_flags , "DATASET=INPUT", ierr )
IF ( ierr .NE. 0 ) THEN
WRITE( wrf_err_message , * ) 'program wrf: error opening wrfinput for reading ierr=',ierr
CALL WRF_ERROR_FATAL
( wrf_err_message )
ENDIF
CALL wrf_debug ( 100 , 'wrf: calling input_model_input' )
CALL input_model_input
( fid , grid , config_flags , ierr )
CALL wrf_debug
( 100 , 'wrf: back from input_model_input' )
CALL close_dataset
( fid , config_flags , "DATASET=INPUT" )
#else
write(0,*)'initial read of data commented out in share/mediation_wrfmain.F'
#endif
#if 0
CALL open_w_dataset
( fid, 'xxxxxxxx', head_grid , config_flags , output_model_input , "DATASET=INPUT", ierr )
CALL output_model_input
( fid, head_grid , config_flags , ierr )
CALL close_dataset
( fid , config_flags , "DATASET=INPUT" )
#endif
CALL set_time_to_read_again
( -1. )
ENDIF
#if 1
CALL start_domain
( grid )
#else
write(0,*)'mediation_wrfmain: start_domain commented out'
#endif
ELSE
#if 0
CALL wrf_get_myproc
( myproc )
CALL construct_filename3
( rstname , 'wrfrst' , grid%id , 2 , time_step_begin_restart , 6 , myproc, 4 )
#else
CALL construct_filename
( rstname , 'wrfrst' , grid%id , 2 , time_step_begin_restart , 6 )
#endif
WRITE(message,*)'opening ',TRIM(rstname),' for reading'
CALL wrf_debug
( 0 , message )
CALL open_r_dataset
( fid , TRIM(rstname) , grid , config_flags , "DATASET=RESTART", ierr )
IF ( ierr .NE. 0 ) THEN
WRITE( message , '("program wrf: error opening ",A32," for reading")') TRIM(rstname)
CALL WRF_ERROR_FATAL
( message )
ENDIF
CALL input_restart
( fid, grid , config_flags , ierr )
CALL close_dataset
( fid , config_flags , "DATASET=RESTART" )
!initialize the lbc reading mechanism to read in the first set of lbcs
CALL set_time_to_read_again
( -1. )
#if 1
CALL start_domain
( grid )
#else
write(0,*)'mediation_wrfmain: start_domain commented out'
#endif
grid%total_time_steps = time_step_begin_restart
ENDIF
RETURN
END SUBROUTINE med_initialdata_input
SUBROUTINE med_shutdown_io ( grid , config_flags ) 2,6
! Driver layer
USE module_domain
USE module_io_domain
! Model layer
USE module_configure
IMPLICIT NONE
! Arguments
TYPE(domain) :: grid
TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
! Local
CHARACTER (LEN=80) :: message
INTEGER :: ierr
WRITE ( message , FMT = '("main: time step #",I8)' ) grid%time_step_max
IF ( grid%oid > 0 ) CALL close_dataset
( grid%oid , config_flags , "DATASET=HISTORY" )
#ifdef QUILT_NO
IF ( grid%auxhist1_oid > 0 ) CALL close_dataset
( grid%auxhist1_oid , config_flags , "DATASET=AUXHIST1" )
#endif
CALL wrf_ioexit
( ierr ) ! shut down the quilt I/O
RETURN
END SUBROUTINE med_shutdown_io
SUBROUTINE med_add_config_info_to_grid ( grid ) 1,2
USE module_domain
USE module_configure
IMPLICIT NONE
! Input data.
TYPE(domain) , TARGET :: grid
#define SOURCE_RECORD model_config_rec %
#define SOURCE_REC_DEX (grid%id)
#define DEST_RECORD grid %
#include <config_assigns.inc>
RETURN
END SUBROUTINE med_add_config_info_to_grid