forked from wrf-model/WRF
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvert_em.F
167 lines (128 loc) · 5.36 KB
/
convert_em.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
!This is a data converter program. Its actions are controlled by
!the registry and the namelist. It will read variables on the
!'i' stream output and output variables on the 'o' stream as
!indicated in the registry. The input and output forms are
!controlled by io_form_input and io_form_history in the namelist.input.
PROGRAM convert_data
USE module_machine
USE module_domain
USE module_io_domain
USE module_driver_constants
USE module_configure
USE module_timing
#if ( WRF_CHEM == 1 )
USE module_input_chem_data
USE module_input_chem_bioemiss
#endif
USE module_utility
#ifdef DM_PARALLEL
USE module_dm
#endif
IMPLICIT NONE
#if ( WRF_CHEM == 1 )
! interface
INTERFACE
! mediation-supplied
SUBROUTINE med_read_wrf_chem_bioemiss ( grid , config_flags)
USE module_domain
TYPE (domain) grid
TYPE (grid_config_rec_type) config_flags
END SUBROUTINE med_read_wrf_chem_bioemiss
END INTERFACE
#endif
REAL :: time , bdyfrq
INTEGER :: debug_level, fid, ierr
CHARACTER*256 :: timestr, inpname
TYPE(domain) , POINTER :: null_domain
TYPE(domain) , POINTER :: grid
TYPE (grid_config_rec_type) :: config_flags
INTEGER :: number_at_same_level
INTEGER :: max_dom, domain_id
INTEGER :: idum1, idum2
#ifdef DM_PARALLEL
INTEGER :: nbytes
INTEGER, PARAMETER :: configbuflen = 4* CONFIG_BUF_LEN
INTEGER :: configbuf( configbuflen )
LOGICAL , EXTERNAL :: wrf_dm_on_monitor
#endif
INTEGER :: ids , ide , jds , jde , kds , kde
INTEGER :: ims , ime , jms , jme , kms , kme
INTEGER :: ips , ipe , jps , jpe , kps , kpe
INTEGER :: ijds , ijde , spec_bdy_width
INTEGER :: i , j , k , idts, rc
CHARACTER (LEN=80) :: message
INTEGER :: start_year , start_month , start_day , start_hour , start_minute , start_second
INTEGER :: end_year , end_month , end_day , end_hour , end_minute , end_second
INTEGER :: interval_seconds , real_data_init_type
INTEGER :: time_loop_max , time_loop
real::t1,t2
INTERFACE
SUBROUTINE Setup_Timekeeping( grid )
USE module_domain
TYPE(domain), POINTER :: grid
END SUBROUTINE Setup_Timekeeping
END INTERFACE
! Define the name of this program (program_name defined in module_domain)
! NOTE: share/input_wrf.F tests first 7 chars of this name to decide
! whether to read P_TOP as metadata from the SI (yes, if .eq. REAL_EM)
program_name = "CONVERT V2.1 "
#ifdef DM_PARALLEL
CALL disable_quilting
#endif
! Initialize the modules used by the WRF system. Many of the CALLs made from the
! init_modules routine are NO-OPs. Typical initializations are: the size of a
! REAL, setting the file handles to a pre-use value, defining moisture and
! chemistry indices, etc.
CALL wrf_debug ( 100 , 'convert_em: calling init_modules ' )
CALL init_modules(1) ! Phase 1 returns after MPI_INIT() (if it is called)
#ifdef NO_LEAP_CALENDAR
CALL WRFU_Initialize( defaultCalKind=WRFU_CAL_NOLEAP, rc=rc )
#else
CALL WRFU_Initialize( defaultCalKind=WRFU_CAL_GREGORIAN, rc=rc )
#endif
CALL init_modules(2) ! Phase 2 resumes after MPI_INIT() (if it is called)
! The configuration switches mostly come from the NAMELIST input.
#ifdef DM_PARALLEL
IF ( wrf_dm_on_monitor() ) THEN
CALL initial_config
ENDIF
CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
CALL wrf_dm_bcast_bytes( configbuf, nbytes )
CALL set_config_as_buffer( configbuf, configbuflen )
CALL wrf_dm_initialize
#else
CALL initial_config
#endif
CALL nl_get_debug_level ( 1, debug_level )
CALL set_wrf_debug_level ( debug_level )
CALL wrf_message ( program_name )
! Allocate the space for the mother of all domains.
NULLIFY( null_domain )
CALL wrf_debug ( 100 , 'convert_em: calling alloc_and_configure_domain ' )
CALL alloc_and_configure_domain ( domain_id = 1 , &
grid = head_grid , &
parent = null_domain , &
kid = -1 )
grid => head_grid
CALL Setup_Timekeeping ( grid )
CALL wrf_debug ( 100 , 'convert_em: calling set_scalar_indices_from_config ' )
CALL set_scalar_indices_from_config ( grid%id , idum1, idum2 )
CALL wrf_debug ( 100 , 'convert_em: calling model_to_grid_config_rec ' )
CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
! Initialize the WRF IO: open files, init file handles, etc.
CALL wrf_debug ( 100 , 'convert_em: calling init_wrfio' )
CALL init_wrfio
#ifdef DM_PARALLEL
CALL wrf_debug ( 100 , 'convert_em: re-broadcast the configuration records' )
CALL get_config_as_buffer( configbuf, configbuflen, nbytes )
CALL wrf_dm_bcast_bytes( configbuf, nbytes )
CALL set_config_as_buffer( configbuf, configbuflen )
#endif
CALL domain_clock_get( grid, current_timestr=timestr )
CALL construct_filename2a ( inpname , config_flags%input_inname , grid%id , 2 , timestr )
CALL open_r_dataset ( fid, TRIM(inpname) , grid , config_flags , "DATASET=INPUT", ierr )
CALL input_model_input ( fid , grid , config_flags , ierr )
CALL med_hist_out ( head_grid , 0, config_flags )
CALL wrf_shutdown
CALL WRFU_Finalize( rc=rc )
END PROGRAM convert_data