13 use oops_variables_mod
37 logical :: lalloc = .false.
38 character(len=field_clen) :: short_name =
"null"
39 character(len=field_clen) :: fv3jedi_name =
"null"
40 character(len=field_clen) :: long_name =
"null"
41 character(len=field_clen) :: units =
"null"
42 character(len=field_clen) :: io_file =
"null"
43 logical :: tracer = .false.
44 character(len=field_clen) :: space
45 character(len=field_clen) :: staggerloc
46 integer :: isc, iec, jsc, jec, npz
48 logical :: integerfield = .false.
57 logical function has_field(fields, field_name, field_index)
60 character(len=*),
intent(in) :: field_name
61 integer,
optional,
intent(out) :: field_index
66 do var = 1,
size(fields)
67 if ( trim(fields(var)%fv3jedi_name) == trim(field_name))
then
69 if (
present(field_index)) field_index = var
81 character(len=*),
intent(in) :: field_name
87 if(
associated(field))
nullify(field)
90 do var = 1,
size(fields)
91 if ( trim(fields(var)%fv3jedi_name) == trim(field_name))
then
98 if (.not.found)
call abor1_ftn(
"fv3jedi_field.get_field_return_type_pointer: field "&
99 //trim(field_name)//
" not found in fields")
108 character(len=*),
intent(in) :: field_name
109 real(kind=
kind_real),
pointer,
intent(out) :: field(:,:,:)
114 if(
associated(field))
nullify(field)
117 do var = 1,
size(fields)
118 if ( trim(fields(var)%fv3jedi_name) == trim(field_name))
then
119 field => fields(var)%array
125 if (.not.found)
call abor1_ftn(
"fv3jedi_field.get_field_return_array_pointer: field "&
126 //trim(field_name)//
" not found in fields")
135 character(len=*),
intent(in) :: field_name
136 real(kind=
kind_real),
allocatable,
intent(out) :: field(:,:,:)
139 logical :: found, boundsmatch
142 do var = 1,
size(fields)
143 if ( trim(fields(var)%fv3jedi_name) == trim(field_name))
then
145 if (.not.
allocated(field))
then
149 boundsmatch = lbound(field,1) == fields(var)%isc .and. ubound(field,1) == fields(var)%iec .and. &
150 lbound(field,2) == fields(var)%jsc .and. ubound(field,2) == fields(var)%jec .and. &
151 lbound(field,3) == 1 .and. ubound(field,3) == fields(var)%npz
152 if (.not.boundsmatch)
call abor1_ftn(
"get_field_return_array_allocatable: field "//&
153 trim(field_name)//
" bounds mismatch")
157 field = fields(var)%array
166 if (.not.found)
call abor1_ftn(
"get_field_return_array_allocatable: field "//trim(field_name)//&
167 " not found in fields")
177 character(len=*),
intent(in) :: field_name
178 real(kind=
kind_real),
allocatable,
intent(in) :: field(:,:,:)
181 logical :: found, boundsmatch
183 if (.not.
allocated(field))
call abor1_ftn(
"put_field: field "//trim(field_name)//
" not allocated")
186 do var = 1,
size(fields)
187 if ( trim(fields(var)%fv3jedi_name) == trim(field_name))
then
190 boundsmatch = lbound(field,1) == fields(var)%isc .and. ubound(field,1) == fields(var)%iec .and. &
191 lbound(field,2) == fields(var)%jsc .and. ubound(field,2) == fields(var)%jec .and. &
192 lbound(field,3) == 1 .and. ubound(field,3) == fields(var)%npz
193 if (.not.boundsmatch)
call abor1_ftn(
"put_field: field "//trim(field_name)//
" bounds mismatch")
196 fields(var)%array = field
205 if (.not.found)
call abor1_ftn(
"put_field: field "//trim(field_name)//
" not found in fields")
216 character(len=*),
intent(in) :: calling_method
220 if (
size(fields1) .ne.
size(fields2))
then
221 call abor1_ftn(trim(calling_method)//
"(checksame): Different number of fields")
224 do var = 1,
size(fields1)
225 if (fields1(var)%fv3jedi_name .ne. fields2(var)%fv3jedi_name)
then
226 call abor1_ftn(trim(calling_method)//
"(checksame): field "//trim(fields1(var)%fv3jedi_name)//&
227 " not in the equivalent position in the right hand side")
240 character(len=field_clen),
allocatable,
optional,
intent(out) :: not_copied(:)
243 character(len=field_clen) :: not_copied_(10000)
244 integer :: num_not_copied
248 do var = 1,
size(field_ou)
249 if (
has_field(field_in, field_ou(var)%fv3jedi_name ))
then
250 call get_field(field_in, field_ou(var)%fv3jedi_name, field_ou(var)%array)
252 num_not_copied = num_not_copied + 1
253 not_copied_(num_not_copied) = field_ou(var)%fv3jedi_name
258 if (
present(not_copied) .and. num_not_copied > 0)
then
259 allocate(not_copied(num_not_copied))
260 not_copied(1:num_not_copied) = not_copied_(1:num_not_copied)
270 character(len=*),
intent(in) :: long_name
271 character(len=*),
intent(out) :: fv3jedi_name
275 do n = 1,
size(fields)
276 if (trim(long_name) == trim(fields(n)%long_name))
then
277 fv3jedi_name = trim(fields(n)%fv3jedi_name)
283 do n = 1,
size(fields)
284 if (
"increment_of_"//trim(long_name) == trim(fields(n)%long_name))
then
285 fv3jedi_name = trim(fields(n)%fv3jedi_name)
290 call abor1_ftn(
"fv3jedi_field_mod.long_name_to_fv3jedi_name long_name "//trim(long_name)//&
291 " not found in fields.")