4 SUBROUTINE med_initialdata_input_ptr ( grid , config_flags )
8 TYPE (domain) , POINTER :: grid
9 TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
11 SUBROUTINE med_initialdata_input ( grid , config_flags )
15 TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
16 END SUBROUTINE med_initialdata_input
18 CALL med_initialdata_input ( grid , config_flags )
19 END SUBROUTINE med_initialdata_input_ptr
21 SUBROUTINE med_initialdata_input ( grid , config_flags )
29 USE module_bc_time_utilities
36 SUBROUTINE start_domain ( grid , allowed_to_read ) ! comes from module_start in appropriate dyn_ directory
39 LOGICAL, INTENT(IN) :: allowed_to_read
40 END SUBROUTINE start_domain
45 TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
47 INTEGER :: fid , ierr , myproc
48 CHARACTER (LEN=256) :: inpname , rstname, timestr
49 CHARACTER (LEN=80) :: message
51 LOGICAL, EXTERNAL :: wrf_dm_on_monitor
53 INTEGER :: save_dyn_opt
56 CALL nl_get_restart( 1, restart )
57 IF ( .NOT. restart ) THEN
58 ! Initialize the mother domain.
59 grid%input_from_file = .true.
60 IF ( grid%input_from_file ) THEN
62 CALL wrf_debug ( 1 , 'wrf main: calling open_r_dataset for wrfinput' )
64 IF ( wrf_dm_on_monitor() ) CALL start_timing
66 ! typically <date> will not be part of input_inname but allow for it
67 CALL domain_clock_get( grid, current_timestr=timestr )
68 CALL construct_filename2a ( inpname , config_flags%input_inname , grid%id , 2 , timestr )
70 CALL open_r_dataset ( fid, TRIM(inpname) , grid , config_flags , "DATASET=INPUT", ierr )
71 IF ( ierr .NE. 0 ) THEN
72 WRITE( wrf_err_message , * ) 'program wrf: error opening ',TRIM(inpname),' for reading ierr=',ierr
73 CALL WRF_ERROR_FATAL ( wrf_err_message )
75 ! registry-generated code that reads the variable set defined on a given stream
76 #include "fine_stream_input.inc"
78 CALL close_dataset ( fid , config_flags , "DATASET=INPUT" )
79 IF ( wrf_dm_on_monitor() ) THEN
80 WRITE ( message , FMT = '("processing wrfinput file (stream 0) for domain ",I8)' ) grid%id
81 CALL end_timing ( TRIM(message) )
84 !gmm add input for noamp hydro model here
85 IF ( config_flags%opt_run.eq.5 ) THEN
87 CALL construct_filename2a ( inpname , config_flags%auxinput7_inname &
88 ,grid%id , 2 , timestr)
90 if( grid%auxinput7_oid .NE. 0 ) then
91 CALL close_dataset ( grid%auxinput7_oid , config_flags , "DATASET=AUXINPUT7" )
94 CALL open_r_dataset ( grid%auxinput7_oid, TRIM(inpname) , grid , config_flags , "DATASET=AUXINPUT7", ierr )
96 ! call set_first_operation(grid%auxinput6_oid)
99 IF ( ierr .NE. 0 ) THEN
100 WRITE( wrf_err_message , * ) 'program wrf: error opening ',TRIM(inpname),' for reading ierr=',ierr
101 CALL WRF_ERROR_FATAL ( wrf_err_message )
104 CALL wrf_debug ( 0 , 'med_initialdata_input: calling input_aux_model_input7' )
105 CALL input_auxinput7 ( grid%auxinput7_oid , grid , config_flags , ierr )
106 CALL wrf_debug ( 100 , 'med_initialdata_input: back from input_aux_model_input7' )
108 CALL close_dataset ( grid%auxinput7_oid , config_flags , "DATASET=AUXINPUT7" )
115 grid%nest_pos = grid%ht
116 where ( grid%nest_pos .gt. 0 ) grid%nest_pos = grid%nest_pos + 500. ! make a cliff
120 grid%imask_nostag = 1
123 grid%imask_xystag = 1
125 grid%press_adj = .FALSE.
128 ! if calling start_domain here, we always want it be called as NLM
129 save_dyn_opt = model_config_rec%dyn_opt
130 model_config_rec%dyn_opt = dyn_em
131 IF ( model_config_rec%dyn_opt .NE. dyn_em_check ) &
133 CALL start_domain ( grid , .TRUE. )
135 model_config_rec%dyn_opt = save_dyn_opt
139 IF ( wrf_dm_on_monitor() ) CALL start_timing
141 CALL domain_clock_get( grid, current_timestr=timestr )
142 CALL construct_filename2a ( rstname , config_flags%rst_inname , grid%id , 2 , timestr )
144 WRITE(message,*)'RESTART run: opening ',TRIM(rstname),' for reading'
145 CALL wrf_message ( message )
146 CALL open_r_dataset ( fid , TRIM(rstname) , grid , config_flags , "DATASET=RESTART", ierr )
147 IF ( ierr .NE. 0 ) THEN
148 WRITE( message , '("program wrf: error opening ",A32," for reading")') TRIM(rstname)
149 CALL WRF_ERROR_FATAL ( message )
151 CALL input_restart ( fid, grid , config_flags , ierr )
152 CALL close_dataset ( fid , config_flags , "DATASET=RESTART" )
154 IF ( wrf_dm_on_monitor() ) THEN
155 WRITE ( message , FMT = '("processing restart file for domain ",I8)' ) grid%id
156 CALL end_timing ( TRIM(message) )
159 grid%imask_nostag = 1
162 grid%imask_xystag = 1
164 grid%press_adj = .FALSE.
166 CALL start_domain ( grid , .TRUE. )
170 END SUBROUTINE med_initialdata_input
172 SUBROUTINE med_shutdown_io ( grid , config_flags )
178 USE module_dm, ONLY : domain_active_this_task
182 RECURSIVE SUBROUTINE med_shutdown_io_recurse ( grid , config_flags )
185 TYPE (domain) , POINTER :: grid
186 TYPE (grid_config_rec_type), INTENT(IN) :: config_flags
187 END SUBROUTINE med_shutdown_io_recurse
191 TYPE(domain), TARGET :: grid
192 TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
194 TYPE(domain),POINTER :: grid_ptr
195 CHARACTER (LEN=80) :: message
198 IF ( grid%lbc_fid > 0 ) CALL close_dataset ( grid%lbc_fid , config_flags , "DATASET=BOUNDARY" )
201 CALL med_shutdown_io_recurse ( grid_ptr , config_flags )
203 CALL wrf_ioexit( ierr ) ! shut down the quilt I/O
207 END SUBROUTINE med_shutdown_io
209 RECURSIVE SUBROUTINE med_shutdown_io_recurse ( grid , config_flags )
219 TYPE(domain), POINTER :: grid
220 TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
222 TYPE(domain), POINTER :: grid_ptr
223 CHARACTER (LEN=80) :: message
227 IF ( ASSOCIATED( grid ) ) THEN
228 CALL push_communicators_for_domain(grid%id)
229 IF ( grid%oid > 0 ) CALL close_dataset ( grid%oid , config_flags , "DATASET=HISTORY" )
230 ! registry generated closes for auxhist streams
231 # include "shutdown_closes.inc"
233 DO WHILE ( ASSOCIATED( grid_ptr ) )
234 DO kid = 1, max_nests
235 IF ( ASSOCIATED( grid_ptr%nests(kid)%ptr ) ) THEN
236 CALL med_shutdown_io_recurse ( grid_ptr%nests(kid)%ptr, config_flags )
239 grid_ptr => grid_ptr%sibling
241 CALL pop_communicators_for_domain
244 END SUBROUTINE med_shutdown_io_recurse
247 SUBROUTINE med_add_config_info_to_grid ( grid )
256 TYPE(domain) , TARGET :: grid
258 #define SOURCE_RECORD model_config_rec %
259 #define SOURCE_REC_DEX (grid%id)
260 #define DEST_RECORD grid %
261 #include "config_assigns.inc"
265 END SUBROUTINE med_add_config_info_to_grid