merge standard release WRF/WPS V3.0.1.1 into wrffire
[wrffire.git] / wrfv2_fire / share / init_modules.F
blob3f561627622b7585734d580574b32024c2a5b546
1 !WRF:MEDIATION_LAYER
3 SUBROUTINE init_modules( phase )
4  USE module_bc
5  USE module_configure
6  USE module_driver_constants
7  USE module_model_constants
8  USE module_domain
9  USE module_machine
10  USE module_nesting
11  USE module_timing
12  USE module_tiles
13  USE module_io_wrf
14  USE module_io
15 #ifdef DM_PARALLEL
16  USE module_wrf_quilt
17  USE module_dm
18 #endif
19 #ifdef INTIO
20  USE module_ext_internal
21 #endif
23 ! <DESCRIPTION>
24 ! This routine USES the modules in WRF and then calls the init routines
25 ! they provide to perform module specific initializations at the
26 ! beginning of a run.  Note, this is only once per run, not once per
27 ! domain; domain specific initializations should be handled elsewhere,
28 ! such as in <a href=start_domain.html>start_domain</a>.
29
30 ! Certain framework specific module initializations in this file are
31 ! dependent on order they are called. For example, since the quilt module
32 ! relies on internal I/O, the init routine for internal I/O must be
33 ! called first.  In the case of DM_PARALLEL compiles, the quilt module
34 ! calls MPI_INIT as part of setting up and dividing communicators between
35 ! compute and I/O server tasks.  Therefore, it must be called prior to
36 ! module_dm, which will <em>also</em> try to call MPI_INIT if it sees
37 ! that MPI has not be initialized yet (implementations of module_dm
38 ! should in fact behave this way by first calling MPI_INITIALIZED before
39 ! they try to call MPI_INIT).  If MPI is already initialized before the
40 ! the quilting module is called, quilting will not work.
41
42 ! The phase argument is used to allow other superstructures like ESMF to 
43 ! place their initialization calls following the WRF initialization call 
44 ! that calls MPI_INIT().  When used with ESMF, ESMF will call wrf_init() 
45 ! which in turn will call phase 2 of this routine.  Phase 1 will be called 
46 ! earlier.  
48 ! </DESCRIPTION>
50  INTEGER, INTENT(IN) :: phase    ! phase==1 means return after MPI_INIT()
51                                  ! phase==2 means resume after MPI_INIT()
53 IF ( phase == 1 ) THEN
54  CALL init_module_bc
55  CALL init_module_configure
56  CALL init_module_driver_constants
57  CALL init_module_model_constants
58  CALL init_module_domain
59  CALL init_module_machine
61 #ifdef INTIO
62  CALL init_module_ext_internal  !! must be called before quilt
63 #endif
64 #ifdef DM_PARALLEL
65  CALL split_communicator
66  CALL init_module_wrf_quilt    !! this *must* be called before init_module_dm
67  CALL init_module_dm
68 #endif
69 ELSE
70  CALL init_module_nesting
71  CALL init_module_timing
72  CALL init_module_tiles
73  CALL init_module_io_wrf
74  CALL init_module_io
76 ! core specific initializations -- add new cores here
77 #if (EM_CORE == 1)
78 #  if ( DA_CORE != 1)
79  CALL init_modules_em
80 #  endif
81 #endif
82 #if (NMM_CORE == 1)
83  CALL init_modules_nmm
84 #endif
85 #if (COAMPS_CORE == 1)
86  CALL init_modules_coamps
87 #endif
88 ENDIF
90 END SUBROUTINE init_modules