Description:
This is a driver-level routine that controls the integration of a domain and subdomains rooted at the domain.
The integrate routine takes a domain pointed to by the argument grid and advances the domain and its associated nests from the grids current time, stored as grid%current_time, to a given time forward in the simulation, stored as grid%stop_subtime. The stop_subtime value is arbitrary and does not have to be the same as time that the domain finished integrating. The simulation stop time for the grid is known to the grids clock (grid%domain_clock) and that is checked with a call to WRF_UTIL_ClockIsStopTime prior to beginning the loop over time period that is specified by the current_time/stop_subtime interval.
The clock, the simulation stop time for the domain, and other timing aspects for the grid are set up in the routine (setup_timekeeping) at the time that the domain is initialized. The lower-level time library and the type declarations for the times and time intervals used are defined either in external/esmf_time_f90/module_utility.F90 or in external/io_esmf/module_utility.F90 depending on a build-time decision to incorporate either the embedded ESMF subset implementation contained in external/esmf_time_f90 or to use a site-specific installation of the ESMF library. This decision is made during the configuration step of the WRF build process. Note that arithmetic and comparison is performed on these data types using F90 operator overloading, also defined in that library.
This routine is the lowest level of the WRF Driver Layer and for the most part the WRF routines that are called from here are in the topmost level of the Mediation Layer. Mediation layer routines typically are not defined in modules. Therefore, the routines that this routine calls have explicit interfaces specified in an interface block in this routine.
As part of the Driver Layer, this routine is intended to be non model-specific and so a minimum of WRF-specific logic is coded at this level. Rather, there are a number of calls to mediation layer routines that contain this logic, some of which are merely stubs in WRF Mediation Layer that sits below this routine in the call tree. The routines that integrate calls in WRF are defined in share/mediation_integrate.F.
Flow of control
1. Check to see that the domain is not finished by testing the value returned by WRF_UTIL_ClockIsStopTime for the domain.
2. Model_to_grid_config_rec is called to load the local config_flags structure with the configuration information for the grid stored in model_config_rec and indexed by the grids unique integer id. These structures are defined in frame/module_configure.F.
3. The current time of the domain is retrieved from the domains clock using WRF_UTIL_ClockGet. There is another call to WRF_UTIL_ClockGet inside the WHILE loop that follows.
4. Iterate forward while the current time is less than the stop subtime.
4.a. Start timing for this iteration (only on node zero in distributed-memory runs)
4.b. Call med_setup_step to allow the mediation layer to do anything thats needed to call the solver for this domain. In WRF this means setting the indices into the 4D tracer arrays for the domain.
4.c. Check for any nests that need to be started up at this time. This is done calling the logical function nests_to_open (defined in frame/module_nesting.F) which returns true and the index into the current domains list of children to use for the nest when one needs to be started.
4.c.1 Call alloc_and_configure_domain to allocate the new nest and link it as a child of this grid.
4.c.2 Call setup_Timekeeping for the nest.
4.c.3 Initialize the nests arrays by calling med_nest_initial. This will either interpolate data from this grid onto the nest, read it in from a file, or both. In a restart run, this is also where the nest reads in its restart file.
4.d If a nest was opened above, check for and resolve overlaps (this is not implemented in WRF 2.0, which supports multiple nests on the same level but does not support overlapping).
4.e Give the mediation layer an opportunity to do something before the solver is called by calling med_before_solve_io. In WRF this is the point at which history and restart data is output.
4.f Call solve_interface which calls the solver that advance the domain one time step, then advance the domains clock by calling WRF_UTIL_ClockAdvance. Upon advancing the clock, the current time for the grid is updated by calling WRF_UTIL_ClockGet. The enclosing WHILE loop around this section is for handling other domains with which this domain may overlap. It is not active in WRF 2.0 and only executes one trip.
4.g Call med_calc_model_time and med_after_solve_io, which are stubs in WRF.
4.h Iterate over the children of this domain (DO kid = 1, max_nests) and check each child pointer to see if it is associated (and therefore, active).
4.h.1 Force the nested domain boundaries from this domain by calling med_nest_force.
4.h.2 Setup the time period over which the nest is to run. Sine the current grid has been advanced one time step and the nest has not, the start for the nest is this grids current time minus one time step. The nests stop_subtime is the current time, bringing the nest up the same time level as this grid, its parent.
4.h.3 Recursively call this routine, integrate, to advance the nests time. Since it is recursive, this will also advance all the domains who are nests of this nest and so on. In other words, when this call returns, all the domains rooted at the nest will be at the current time.
4.h.4 Feedback data from the nested domain back onto this domain by calling med_nest_feedback.
4.i Write the time to compute this grid and its subtree. This marks the end of the loop begun at step 4, above.
5. Give the mediation layer an opportunity to do I/O at the end of the sequence of steps that brought the grid up to stop_subtime with a call to med_last_solve_io. In WRF, this is used to generate the final history and/or restart output when the domain reaches the end of its integration. There is logic here to make sure this occurs correctly on a nest, since the nest may finish before its parent.
Called by :
wrf_run (share/module_wrf_top.F)Uses:
MODULE_DOMAIN (frame/module_domain.F) MODULE_DRIVER_CONSTANTS (frame/module_driver_constants.F) MODULE_NESTING (frame/module_nesting.F) MODULE_CONFIGURE (frame/module_configure.F) MODULE_TIMING (frame/module_timing.F) MODULE_UTILITYArguments:
1. grid :: TYPE(DOMAIN), INTENT( INOUT )INTEGRATE calls :