Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / convertor / kma_netcdf / netcdf2kma.f90
blob3abe2d2e90b3c13368b4c225844659b6efcc06b9
1 !NETCDF2KMA:DRIVER_LAYER:MAIN
4 PROGRAM netcdf2kma
6 use da_control, only : debug_level
8 USE module_machine
9 USE module_domain
10 USE module_driver_constants
11 USE module_configure
13 USE module_timing
14 USE module_wrf_error
15 #ifdef DM_PARALLEL
16 USE module_dm
17 #endif
19 USE da_wrfvar_io
20 USE module_netcdf2kma_interface
21 USE module_wave2grid_kma
23 IMPLICIT NONE
25 REAL :: time
27 TYPE (domain) , POINTER :: keep_grid, grid_ptr, null_domain
28 TYPE (grid_config_rec_type) :: config_flags
30 INTEGER :: domain_id , fid , oid , idum1 , idum2
32 !--------------
33 INTERFACE
34 SUBROUTINE Setup_Timekeeping ( grid )
35 USE module_domain
36 TYPE(domain), POINTER :: grid
37 END SUBROUTINE Setup_Timekeeping
38 END INTERFACE
39 !--------------
41 #ifdef DM_PARALLEL
42 INTEGER :: nbytes
43 INTEGER, PARAMETER :: configbuflen = 4*8192
44 INTEGER :: configbuf( configbuflen )
45 LOGICAL , EXTERNAL :: wrf_dm_on_monitor
46 #endif
48 !--Define the name of this program (program_name defined in module_domain)
50 program_name = "NETCDF2KMA"
52 !--Get the NAMELIST data for input.
54 CALL init_modules(1)
55 !rizvi's add start
56 ! Initialize utilities (time manager, etc.)
57 call wrfu_initialize(defaultCalendar=WRFU_CAL_GREGORIAN)
58 !rizvi's add over
60 #ifdef DM_PARALLEL
61 IF ( wrf_dm_on_monitor() ) THEN
62 CALL start_timing
63 CALL initial_config
64 ENDIF
65 CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
66 CALL wrf_dm_bcast_bytes( configbuf, nbytes )
67 CALL set_config_as_buffer( configbuf, configbuflen )
68 CALL wrf_dm_initialize
69 #else
70 CALL start_timing
71 CALL initial_config
72 #endif
74 !shc-wei start
75 ! CALL get_debug_level ( debug_level )
76 CALL nl_get_debug_level ( 1,debug_level )
77 !shc-wei end
78 CALL set_wrf_debug_level ( debug_level )
80 !--allocated and configure the mother domain
82 NULLIFY( null_domain )
84 CALL wrf_debug ( 100 , 'wrf: calling alloc_and_configure_domain ' )
85 CALL alloc_and_configure_domain ( domain_id = 1 , &
86 ! local_time = 0 , & !shc-wei
87 grid = head_grid , &
88 parent = null_domain , &
89 kid = -1 )
91 CALL wrf_debug ( 100 , 'wrf: calling model_to_grid_config_rec ' )
92 CALL model_to_grid_config_rec ( head_grid%id , model_config_rec , config_flags )
93 CALL wrf_debug ( 100 , 'wrf: calling set_scalar_indices_from_config ' )
94 CALL set_scalar_indices_from_config ( head_grid%id , idum1, idum2 )
95 CALL wrf_debug ( 100 , 'wrf: calling init_wrfio' )
96 CALL Setup_Timekeeping ( head_grid )
97 if(config_flags%real_data_init_type == 1 .or. &
98 config_flags%real_data_init_type == 3) then
99 CALL init_wrfio
101 #ifdef DM_PARALLEL
102 CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
103 CALL wrf_dm_bcast_bytes( configbuf, nbytes )
104 CALL set_config_as_buffer( configbuf, configbuflen )
105 #endif
107 endif
108 call med_add_config_info_to_grid ( head_grid )
111 !-- read input in netcdf format
112 CALL da_med_initialdata_input( head_grid , config_flags, 'rizvi_to_choose' )
114 !--write in grid-array in kma-ascii format
116 CALL wrf_debug ( 100 , 'da_3dvar: calling netcdf2kma_interface ' )
117 CALL netcdf2kma_interface ( head_grid, config_flags )
118 CALL wrf_debug ( 100 , 'da_3dvar: back from netcdf2kma_interface' )
120 CALL med_shutdown_io ( head_grid , config_flags )
122 #ifdef DM_PARALLEL
123 IF ( wrf_dm_on_monitor() ) THEN
124 message(1) = 'Time elapsed in netcdf2kma'
125 CALL end_timing ( TRIM(message(1)) )
126 END IF
127 #else
128 message(1) = 'Time elapsed in netcdf2kma'
129 CALL end_timing ( TRIM(message(1)) )
130 #endif
132 CALL wrf_shutdown
134 STOP "Stopped normally. in netcdf2kma"
136 END PROGRAM netcdf2kma