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