29 field_dimension_order, &
30 field_dimension_sizes, &
41 type(restart_file_type),
intent(inout) :: fileObj
42 character(len=*),
intent(in) :: filename
43 character(len=*),
intent(in) :: fieldname
44 integer(INT_KIND),
dimension(:),
intent(in) :: field_dimension_order
46 integer(INT_KIND),
dimension(NIDX),
intent(in) :: field_dimension_sizes
48 integer(INT_KIND),
intent(out) :: index_field
50 type(domainug),
intent(in),
target :: domain
51 logical(INT_KIND),
intent(in),
optional :: mandatory
53 real,
intent(in),
optional :: data_default
54 character(len=*),
intent(in),
optional :: longname
55 character(len=*),
intent(in),
optional :: units
56 logical(INT_KIND),
intent(in),
optional :: read_only
58 logical(INT_KIND),
intent(in),
optional :: owns_data
62 real(DOUBLE_KIND) :: default_data
64 character(len=256) :: filename2
65 integer(INT_KIND) :: length
66 character(len=256) :: append_string
68 character(len=256) :: fname
69 type(var_type),
pointer :: cur_var
70 integer(INT_KIND) :: i
71 character(len=256) :: error_msg
74 if (
size(field_dimension_order) .gt. 5)
then
75 call mpp_error(fatal, &
76 "fms_io_unstructured_setup_one_field:" &
77 //
" the inputted field cannot contain more than" &
78 //
" five dimensions.")
82 if (any(field_dimension_sizes .lt. 0))
then
83 call mpp_error(fatal, &
84 "fms_io_unstructured_setup_one_field:" &
85 //
" all dimensions must have a size that is a non-" &
86 //
" negative integer.")
90 if (
present(data_default))
then
91 default_data = data_default
93 default_data = mpp_fill_double
97 length = len_trim(filename)
98 if (filename(length-2:length) .eq.
".nc")
then
99 filename2 = filename(1:length-3)
101 filename2 = filename(1:length)
107 if (len_trim(filename_appendix) .gt. 0)
then
108 append_string = filename_appendix
110 if (len_trim(append_string) .gt. 0)
then
111 filename2 = trim(filename2)//
'.'//trim(append_string)
116 call get_mosaic_tile_file_ug(filename2, &
120 if (
associated(fileobj%var))
then
124 if (trim(fileobj%name) .ne. trim(fname))
then
125 call mpp_error(fatal, &
126 "fms_io_unstructured_setup_one_field:" &
127 //
" filename = "//trim(fname)//
" is not" &
128 //
" consistent with the filename of the" &
129 //
" restart object = "//trim(fileobj%name))
138 if (
allocated(fileobj%axes))
then
139 if (trim(fileobj%name) .ne. trim(fname))
then
140 call mpp_error(fatal, &
141 "fms_io_unstructured_setup_one_field:" &
142 //
" filename = "//trim(fname)//
" is not" &
143 //
" consistent with the filename of the" &
144 //
" restart object = "//trim(fileobj%name))
147 fileobj%name = trim(fname)
151 allocate(fileobj%var(max_fields))
152 allocate(fileobj%p0dr(max_time_level_register,max_fields))
153 allocate(fileobj%p1dr(max_time_level_register,max_fields))
154 allocate(fileobj%p2dr(max_time_level_register,max_fields))
155 allocate(fileobj%p3dr(max_time_level_register,max_fields))
156 allocate(fileobj%p4dr(max_time_level_register,max_fields))
157 allocate(fileobj%p2dr8(max_time_level_register,max_fields))
158 allocate(fileobj%p3dr8(max_time_level_register,max_fields))
159 allocate(fileobj%p0di(max_time_level_register,max_fields))
160 allocate(fileobj%p1di(max_time_level_register,max_fields))
161 allocate(fileobj%p2di(max_time_level_register,max_fields))
162 allocate(fileobj%p3di(max_time_level_register,max_fields))
167 do i = 1,num_registered_files
168 if (trim(fname) .eq. trim(registered_file(i)))
then
169 call mpp_error(fatal, &
170 "fms_io_unstructured_setup_one_field: " &
171 //trim(fname)//
" is already registered with" &
172 //
" another restart_file_type data.")
180 num_registered_files = num_registered_files + 1
181 if (num_registered_files .gt. max_files_w)
then
182 call mpp_error(fatal, &
183 "fms_io_unstructured_setup_one_field:" &
184 //
" the number of registered files is greater" &
185 //
" than max_files_w. Please increase" &
186 //
" max_files_w in the fms_io_nml namelist.")
188 registered_file(num_registered_files) = trim(fname)
192 fileobj%register_id = num_registered_files
193 fileobj%max_ntime = field_dimension_sizes(tidx)
194 fileobj%is_root_pe = mpp_domain_ug_is_tile_root_pe(domain)
197 fileobj%var(i)%name =
"none"
198 fileobj%var(i)%longname =
"";
199 fileobj%var(i)%units =
"none";
200 fileobj%var(i)%domain_present = .false.
201 fileobj%var(i)%domain_idx = -1
202 fileobj%var(i)%is_dimvar = .false.
203 fileobj%var(i)%read_only = .false.
204 fileobj%var(i)%owns_data = .false.
205 fileobj%var(i)%position = center
206 fileobj%var(i)%ndim = -1
207 fileobj%var(i)%siz(:) = -1
208 fileobj%var(i)%gsiz(:) = -1
209 fileobj%var(i)%id_axes(:) = -1
210 fileobj%var(i)%initialized = .false.
211 fileobj%var(i)%mandatory = .true.
212 fileobj%var(i)%is = -1
213 fileobj%var(i)%ie = -1
214 fileobj%var(i)%js = -1
215 fileobj%var(i)%je = -1
216 fileobj%var(i)%default_data = -1
217 fileobj%var(i)%compressed_axis =
""
218 fileobj%var(i)%ishift = -1
219 fileobj%var(i)%jshift = -1
220 fileobj%var(i)%x_halo = -1
221 fileobj%var(i)%y_halo = -1
222 fileobj%var(i)%field_dimension_order(:) = -1
223 fileobj%var(i)%field_dimension_sizes(:) = -1
230 do i = 1,fileobj%nvar
231 if (trim(fileobj%var(i)%name) .eq. trim(fieldname))
then
237 if (index_field > 0)
then
242 cur_var => fileobj%var(index_field)
247 do i = 1,
size(field_dimension_order)
248 if (field_dimension_order(i) .ne. cur_var%field_dimension_order(i))
then
249 call mpp_error(fatal, &
250 "fms_io_unstructured_setup_one_field:" &
251 //
" field dimension ordering mismatch for " &
252 //trim(fieldname)//
" of file "//trim(filename))
259 if (cur_var%field_dimension_sizes(xidx) .ne. field_dimension_sizes(xidx) .or. &
260 cur_var%field_dimension_sizes(yidx) .ne. field_dimension_sizes(yidx) .or. &
261 cur_var%field_dimension_sizes(cidx) .ne. field_dimension_sizes(cidx) .or. &
262 cur_var%field_dimension_sizes(zidx) .ne. field_dimension_sizes(zidx) .or. &
263 cur_var%field_dimension_sizes(hidx) .ne. field_dimension_sizes(hidx) .or. &
264 cur_var%field_dimension_sizes(uidx) .ne. field_dimension_sizes(uidx) .or. &
265 cur_var%field_dimension_sizes(ccidx) .ne. field_dimension_sizes(ccidx))
then
266 call mpp_error(fatal, &
267 "fms_io_unstructured_setup_one_field:" &
268 //
" field dimension size mismatch for field " &
269 //trim(fieldname)//
" of file "//trim(filename))
273 cur_var%siz(4) = cur_var%siz(4) + field_dimension_sizes(tidx)
274 if (fileobj%max_ntime .lt. cur_var%siz(4))
then
275 fileobj%max_ntime = cur_var%siz(4)
277 if (cur_var%siz(4) .gt. max_time_level_register)
then
278 call mpp_error(fatal, &
279 "fms_io_unstructured_setup_one_field:" &
280 //
" the time level of field "//trim(cur_var%name) &
281 //
" in file "//trim(fileobj%name)//
" is greater" &
282 //
" than MAX_TIME_LEVEL_REGISTER(=2), increase" &
283 //
" MAX_TIME_LEVEL_REGISTER or check your code.")
288 fileobj%nvar = fileobj%nvar + 1
289 if (fileobj%nvar .gt. max_fields)
then
290 write(error_msg,
'(I3,"/",I3)') fileobj%nvar,max_fields
291 call mpp_error(fatal, &
292 "fms_io_unstructured_setup_one_field:" &
293 //
" max_fields exceeded, needs increasing," &
294 //
" nvar/max_fields = "//trim(error_msg))
296 index_field = fileobj%nvar
298 cur_var => fileobj%var(index_field)
301 cur_var%domain_ug => domain
305 cur_var%field_dimension_sizes = field_dimension_sizes
306 do i = 1,
size(field_dimension_order)
307 cur_var%field_dimension_order(i) = field_dimension_order(i)
309 cur_var%siz(4) = field_dimension_sizes(tidx)
312 cur_var%name = fieldname
313 cur_var%default_data = real(default_data)
314 if (
present(mandatory))
then
315 cur_var%mandatory = mandatory
317 if (
present(read_only))
then
318 cur_var%read_only = read_only
320 if (
present(owns_data))
then
321 cur_var%owns_data = owns_data
323 if (
present(longname))
then
324 cur_var%longname = longname
326 cur_var%longname = fieldname
328 if (
present(units))
then
329 cur_var%units = units
subroutine fms_io_unstructured_setup_one_field(fileObj, filename, fieldname, field_dimension_order, field_dimension_sizes, index_field, domain, mandatory, data_default, longname, units, read_only, owns_data)
Add a field to a restart object (restart_file_type). Return the index of the inputted field in the fi...