da_wrfvar_init1.inc

References to this file elsewhere.
1 subroutine da_wrfvar_init1(no_init1)
2 
3    !-----------------------------------------------------------------------
4    ! Purpose: WRFVAR initialization routine, part 1
5    !-----------------------------------------------------------------------
6 
7    implicit none
8 
9    logical, optional, intent(in) :: no_init1
10 
11    !<DESCRIPTION>
12    ! Program_name, a global variable defined in frame/module_domain.F, is
13    ! set, then a routine <a href=init_modules.html>init_modules</a> is
14    ! called. This calls all the init programs that are provided by the
15    ! modules that are linked into WRF.  These include initialization of
16    ! external I/O packages.   Also, some key initializations for
17    ! distributed-memory parallelism occur here if DM_PARALLEL is specified
18    ! in the compile: setting up I/O quilt processes to act as I/O servers
19    ! and dividing up MPI communicators among those as well as initializing
20    ! external communication packages such as RSL or RSL_LITE.
21    !
22    !</DESCRIPTION>
23 
24    program_name = wrfvar_version//" (COMPATIBLE WITH "//wrf_version//") MODEL"
25 
26    ! Initialize WRF modules:  
27    ! Phase 1 returns after mpi_init() (if it is called)
28    if (.NOT. present(no_init1)) then
29       call init_modules(1)
30       ! Initialize utilities (time manager, etc.)
31       call wrfu_initialize(defaultCalendar=WRFU_CAL_GREGORIAN)
32    end if
33    ! Phase 2 resumes after mpi_init() (if it is called)
34    call init_modules(2)
35 
36    !<DESCRIPTION>
37    ! The wrf namelist.input file is read and stored in the use associated
38    ! structure model_config_rec, defined in frame/module_configure.F, by the
39    ! call to <a href=initial_config.html>initial_config</a>.  On distributed
40    ! memory parallel runs this is done only on one processor, and then
41    ! broadcast as a buffer.  For distributed-memory, the broadcast of the
42    ! configuration information is accomplished by first putting the
43    ! configuration information into a buffer (<a
44    ! href=get_config_as_buffer.html>get_config_as_buffer</a>), broadcasting
45    ! the buffer, then setting the configuration information (<a
46    ! href=set_config_as_buffer.html>set_config_as_buffer</a>).
47    !
48    !</DESCRIPTION>
49 
50    ! Don't use stdout here, too early
51    write(unit=6,fmt='(A)') "***  VARIATIONAL ANALYSIS ***"
52 
53 #ifdef DM_PARALLEL
54    call wrf_get_dm_communicator (comm)
55    call mpi_comm_size(comm, num_procs, ierr)
56    call mpi_comm_rank(comm, myproc, ierr)
57 #else
58    num_procs = 1
59    myproc = 0
60    comm = 0
61 #endif
62 
63    if (myproc==0) then
64       rootproc=.true.
65    else
66       rootproc=.false.
67    end if
68 
69 #ifdef DM_PARALLEL
70    if (rootproc) then
71       call initial_config
72    end if
73    call get_config_as_buffer(configbuf, configbuflen, nbytes)
74    call wrf_dm_bcast_bytes(configbuf, nbytes)
75    call set_config_as_buffer(configbuf, configbuflen)
76    call wrf_dm_initialize
77 #else
78    call initial_config
79 #endif
80 
81    ! Copy namelist variables to da_control
82 
83 #define SOURCE_RECORD model_config_rec%
84 #define DEST_RECORD
85 
86 #include "config_assigns.inc"
87 
88    if (.NOT. rootproc) check_max_iv_print=.false.
89 
90 end subroutine da_wrfvar_init1
91 
92