protomain.F

References to this file elsewhere.
1 !WRF:DRIVER_LAYER:MAIN
2 !
3 
4 PROGRAM wrf
5 
6    USE module_machine
7    USE module_domain
8    USE module_integrate
9    USE module_driver_constants
10    USE module_configure
11 
12    USE module_timing
13    USE module_wrf_error
14 #ifdef DM_PARALLEL
15    USE module_dm
16 #endif
17 
18    IMPLICIT NONE
19 
20    REAL    :: time
21 
22    INTEGER :: loop , &
23               levels_to_process
24 
25    TYPE (domain) , POINTER :: keep_grid, grid_ptr, null_domain
26    TYPE (domain)           :: dummy
27    TYPE (grid_config_rec_type)              :: config_flags
28    INTEGER                 :: number_at_same_level
29    INTEGER                 :: time_step_begin_restart
30 
31    INTEGER :: max_dom , domain_id , fid , oid , idum1 , idum2 , ierr
32    INTEGER :: debug_level
33    LOGICAL :: input_from_file
34 
35 #ifdef DM_PARALLEL
36    INTEGER                 :: nbytes
37    INTEGER, PARAMETER      :: configbuflen = 4* CONFIG_BUF_LEN
38    INTEGER                 :: configbuf( configbuflen )
39    LOGICAL , EXTERNAL      :: wrf_dm_on_monitor
40 #endif
41 
42    CHARACTER (LEN=80)      :: rstname
43    CHARACTER (LEN=80)      :: message
44 
45    !  Define the name of this program (program_name defined in module_domain)
46 
47    program_name = "WRF MODEL"
48 
49    !  Get the NAMELIST data for input.
50 
51    CALL init_modules
52 
53 #ifdef DM_PARALLEL
54    IF ( wrf_dm_on_monitor() ) THEN
55      CALL initial_config
56    ENDIF
57    CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
58    CALL wrf_dm_bcast_bytes( configbuf, nbytes )
59    CALL set_config_as_buffer( configbuf, configbuflen )
60    CALL wrf_dm_initialize
61 #else
62    CALL initial_config
63 #endif
64 
65    CALL nl_get_debug_level ( 1, debug_level )
66    CALL set_wrf_debug_level ( debug_level )
67 
68    ! allocated and configure the mother domain
69 
70    NULLIFY( null_domain )
71 
72    CALL wrf_debug ( 100 , 'wrf: calling alloc_and_configure_domain ' )
73    CALL alloc_and_configure_domain ( domain_id  = 1 ,                  &
74                                      grid       = head_grid ,          &
75                                      parent     = null_domain ,        &
76                                      kid        = -1                   )
77 
78    CALL wrf_debug ( 100 , 'wrf: calling model_to_grid_config_rec ' )
79    CALL model_to_grid_config_rec ( head_grid%id , model_config_rec , config_flags )
80    CALL wrf_debug ( 100 , 'wrf: calling set_scalar_indices_from_config ' )
81    CALL set_scalar_indices_from_config ( head_grid%id , idum1, idum2 )
82    CALL wrf_debug ( 100 , 'wrf: calling init_wrfio' )
83    CALL init_wrfio
84 
85 #ifdef DM_PARALLEL
86    CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
87    CALL wrf_dm_bcast_bytes( configbuf, nbytes )
88    CALL set_config_as_buffer( configbuf, configbuflen )
89 #endif
90 
91    CALL med_initialdata_input( head_grid , config_flags )
92 
93    !  The forecast integration for the most coarse grid is now started.  The
94    !  integration is from the first step (1) to the last step of the simulation.
95 
96    CALL wrf_debug ( 100 , 'wrf: calling integrate' )
97    CALL integrate ( head_grid , head_grid%total_time_steps+1 , head_grid%time_step_max ) 
98    CALL wrf_debug ( 100 , 'wrf: back from integrate' )
99 
100    CALL med_shutdown_io ( head_grid , config_flags )
101 
102    CALL wrf_shutdown
103 
104 END PROGRAM wrf
105