updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / convertor / kma_netcdf / kma2netcdf.f90
blobfb8cda4a8fc72e7889bd4cf4644aacba71e3ffcb
1 !KMA2NETCDF:DRIVER_LAYER:MAIN
4 PROGRAM kma2netcdf
6 use module_configure, only : grid_config_rec_type
7 use module_domain, only : domain
8 use da_control, only : debug_level
10 USE module_machine
11 USE module_driver_constants
12 USE module_configure
14 USE module_timing
15 USE module_wrf_error
16 #ifdef DM_PARALLEL
17 USE module_dm
18 #endif
20 USE da_wrfvar_io
21 USE module_kma2netcdf_interface
22 USE module_kma_wave2grid
24 IMPLICIT NONE
26 REAL :: time
28 TYPE (domain) , POINTER :: keep_grid, grid_ptr, null_domain
29 TYPE (grid_config_rec_type) :: config_flags
31 INTEGER :: domain_id , fid , oid , idum1 , idum2
33 #ifdef DM_PARALLEL
34 INTEGER :: nbytes
35 INTEGER, PARAMETER :: configbuflen = 4*8192
36 INTEGER :: configbuf( configbuflen )
37 LOGICAL , EXTERNAL :: wrf_dm_on_monitor
38 #endif
40 !--------------
41 INTERFACE
42 SUBROUTINE Setup_Timekeeping ( grid )
43 USE module_domain
44 TYPE(domain), POINTER :: grid
45 END SUBROUTINE Setup_Timekeeping
46 END INTERFACE
47 !--------------
49 ! Definitions of dummy arguments to solve
51 !--Define the name of this program (program_name defined in module_domain)
53 program_name = "KMA2NETCDF"
55 !--Get the NAMELIST data for input.
57 CALL init_modules(1)
58 !rizvi's add start
59 ! Initialize utilities (time manager, etc.)
60 call wrfu_initialize(defaultCalendar=WRFU_CAL_GREGORIAN)
61 !rizvi's add over
63 #ifdef DM_PARALLEL IF ( wrf_dm_on_monitor() ) THEN
64 IF ( wrf_dm_on_monitor() ) THEN
65 CALL start_timing
66 CALL initial_config
67 ENDIF
68 CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
69 CALL wrf_dm_bcast_bytes( configbuf, nbytes )
70 CALL set_config_as_buffer( configbuf, configbuflen )
71 CALL wrf_dm_initialize
72 #else
73 CALL start_timing
74 CALL initial_config
75 #endif
77 !shc-wei start
78 ! CALL get_debug_level ( debug_level )
79 CALL nl_get_debug_level ( 1,debug_level )
80 !shc-wei end
81 CALL set_wrf_debug_level ( debug_level )
83 !--allocated and configure the mother domain
85 NULLIFY( null_domain )
87 CALL wrf_debug ( 100 , 'wrf: calling alloc_and_configure_domain ' )
88 CALL alloc_and_configure_domain ( domain_id = 1 , &
89 ! local_time = 0 , & !shc-wei
90 grid = head_grid , &
91 parent = null_domain , &
92 kid = -1 )
94 CALL wrf_debug ( 100 , 'wrf: calling model_to_grid_config_rec ' )
95 CALL model_to_grid_config_rec ( head_grid%id , model_config_rec , config_flags )
96 CALL wrf_debug ( 100 , 'wrf: calling set_scalar_indices_from_config ' )
97 CALL set_scalar_indices_from_config ( head_grid%id , idum1, idum2 )
98 CALL wrf_debug ( 100 , 'wrf: calling init_wrfio' )
99 CALL Setup_Timekeeping ( head_grid )
100 if(config_flags%real_data_init_type == 1 .or. &
101 config_flags%real_data_init_type == 3) then
102 CALL init_wrfio
104 #ifdef DM_PARALLEL
105 CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
106 CALL wrf_dm_bcast_bytes( configbuf, nbytes )
107 CALL set_config_as_buffer( configbuf, configbuflen )
108 #endif
109 endif
110 call med_add_config_info_to_grid ( head_grid )
112 !--read kma-ascii grid data and pack in grid-array
114 CALL wrf_debug ( 100 , 'kma2netcdf: calling kma2netcdf_interface ' )
116 CALL kma2netcdf_interface ( head_grid, config_flags)
118 CALL wrf_debug ( 100 , 'kma2netcdf: back from kma2netcdf_interface ' )
120 !--output 3dvar analysis
121 CALL da_med_initialdata_output( head_grid , config_flags )
123 CALL wrf_debug ( 100 , 'kma2netcdf: back from med_initialdata_output' )
125 CALL med_shutdown_io ( head_grid , config_flags )
127 #ifdef DM_PARALLEL
128 IF ( wrf_dm_on_monitor() ) THEN
129 message(1) = 'Time elapsed in kma2netcdf'
130 CALL end_timing ( TRIM(message(1)) )
131 END IF
132 #else
133 message(1) = 'Time elapsed in kma2netcdf'
134 CALL end_timing ( TRIM(message(1)) )
135 #endif
137 CALL wrf_shutdown
139 STOP "Stopped normally. in kma2netcdf"
141 END PROGRAM kma2netcdf