25 is_in, ie_in, js_in, je_in, window_id)
27 integer,
intent(in) :: index
28 type(time_type),
intent(in) :: time
29 real(FMS_TI_KIND_),
dimension(:,:),
intent(inout) :: data_in
30 integer,
intent(in),
optional :: interp
31 logical,
intent(in),
optional :: verbose
32 type(horiz_interp_type),
intent(in),
optional :: horz_interp
33 logical,
dimension(:,:),
intent(out),
optional :: mask_out
34 integer,
intent(in),
optional :: is_in, ie_in, js_in, je_in
35 integer,
intent(in),
optional :: window_id
37 real(FMS_TI_KIND_),
dimension(size(data_in,1), size(data_in,2), 1) :: data_out
38 logical,
dimension(size(data_in,1), size(data_in,2), 1) :: mask3d
40 data_out(:,:,1) = data_in(:,:)
41 call time_interp_external(index, time, data_out, interp, verbose, horz_interp, mask3d, &
42 is_in=is_in,ie_in=ie_in,js_in=js_in,je_in=je_in,window_id=window_id)
43 data_in(:,:) = data_out(:,:,1)
44 if (
PRESENT(mask_out)) mask_out(:,:) = mask3d(:,:,1)
56 & js_in, je_in, window_id)
58 integer,
intent(in) :: index
60 type(time_type),
intent(in) :: time
61 real(FMS_TI_KIND_),
dimension(:,:,:),
intent(inout) :: time_data
62 integer,
intent(in),
optional :: interp
63 logical,
intent(in),
optional :: verbose
64 type(horiz_interp_type),
intent(in),
optional :: horz_interp
65 logical,
dimension(:,:,:),
intent(out),
optional :: mask_out
66 integer,
intent(in),
optional :: is_in, ie_in, js_in, je_in
67 integer,
intent(in),
optional :: window_id
69 integer :: nx, ny, nz, interp_method, t1, t2
70 integer :: i1, i2, isc, iec, jsc, jec, mod_time
71 integer :: yy, mm, dd, hh, min, ss
72 character(len=256) :: err_msg
73 character(len=FMS_PATH_LEN) :: filename
75 integer :: isw, iew, jsw, jew, nxw, nyw
81 real(FMS_TI_KIND_) :: w1,w2
83 character(len=16) :: message1, message2
84 integer,
parameter :: kindl = fms_ti_kind_
86 nx =
size(time_data,1)
87 ny =
size(time_data,2)
88 nz =
size(time_data,3)
90 interp_method = linear_time_interp
91 if (
PRESENT(interp)) interp_method = interp
93 if (
PRESENT(verbose)) verb=verbose
94 if (debug_this_module) verb = .true.
96 if (index < 1.or.index > num_fields) &
97 call mpp_error(fatal, &
98 &
'invalid index in call to time_interp_ext -- field was not initialized or failed to initialize')
100 isc=loaded_fields(index)%isc;iec=loaded_fields(index)%iec
101 jsc=loaded_fields(index)%jsc;jec=loaded_fields(index)%jec
103 if( loaded_fields(index)%numwindows == 1 )
then
107 if(.not.
present(is_in) .or. .not.
present(ie_in) .or. .not.
present(js_in) .or. .not.
present(je_in))
then
108 call mpp_error(fatal,
'time_interp_external: is_in, ie_in, js_in and je_in must be present ' // &
109 'when numwindows > 1, field='//trim(loaded_fields(index)%name))
111 nxw = ie_in - is_in + 1
112 nyw = je_in - js_in + 1
113 isc = isc + is_in - 1
114 iec = isc + ie_in - is_in
115 jsc = jsc + js_in - 1
116 jec = jsc + je_in - js_in
119 isw = (nx-nxw)/2+1; iew = isw+nxw-1
120 jsw = (ny-nyw)/2+1; jew = jsw+nyw-1
122 if (nx < nxw .or. ny < nyw .or. nz < loaded_fields(index)%siz(3))
then
123 write(message1,
'(i6,2i5)') nx,ny,nz
124 call mpp_error(fatal,
'field '//trim(loaded_fields(index)%name)// &
125 ' Array size mismatch in time_interp_external. Array "data" is too small. shape(data)=' &
128 if(
PRESENT(mask_out))
then
129 if (
size(mask_out,1) /= nx .or.
size(mask_out,2) /= ny .or.
size(mask_out,3) /= nz)
then
130 write(message1,
'(i6,2i5)') nx,ny,nz
131 write(message2,
'(i6,2i5)')
size(mask_out,1),
size(mask_out,2),
size(mask_out,3)
132 call mpp_error(fatal,
'field '//trim(loaded_fields(index)%name)// &
133 ' array size mismatch in time_interp_external.'// &
134 ' Shape of array "mask_out" does not match that of array "data".'// &
135 ' shape(data)='//message1//
' shape(mask_out)='//message2)
140 if (loaded_fields(index)%siz(4) == 1)
then
141 call load_record(loaded_fields(index),1,horz_interp, is_in, ie_in ,js_in, je_in,window_id)
142 i1 = find_buf_index(1,loaded_fields(index)%ibuf)
143 if( loaded_fields(index)%region_type == no_region )
then
144 where(loaded_fields(index)%mask(isc:iec,jsc:jec,:,i1))
145 time_data(isw:iew,jsw:jew,:) = real( loaded_fields(index)%domain_data(isc:iec,jsc:jec,:,i1),&
149 time_data(isw:iew,jsw:jew,:) = real(loaded_fields(index)%missing, fms_ti_kind_)
152 where(loaded_fields(index)%mask(isc:iec,jsc:jec,:,i1))
153 time_data(isw:iew,jsw:jew,:) = real(loaded_fields(index)%domain_data(isc:iec,jsc:jec,:,i1),&
157 if(
PRESENT(mask_out)) mask_out(isw:iew,jsw:jew,:) = loaded_fields(index)%mask(isc:iec,jsc:jec,:,i1)
161 if(loaded_fields(index)%have_modulo_times)
then
162 call time_interp(time,loaded_fields(index)%modulo_time_beg, loaded_fields(index)%modulo_time_end, &
163 loaded_fields(index)%time(:), w2, t1, t2, &
164 loaded_fields(index)%correct_leap_year_inconsistency, err_msg=err_msg)
165 if(err_msg .NE.
'')
then
166 filename = trim(loaded_fields(index)%fileobj%path)
167 call mpp_error(fatal,
"time_interp_external 1: "//trim(err_msg)//&
168 ",file="//trim(filename)//
",field="//trim(loaded_fields(index)%name) )
172 if(loaded_fields(index)%modulo_time)
then
177 call time_interp(time,loaded_fields(index)%time(:),w2,t1,t2,modtime=mod_time, err_msg=err_msg)
178 if(err_msg .NE.
'')
then
179 filename = trim(loaded_fields(index)%fileobj%path)
180 call mpp_error(fatal,
"time_interp_external 2: "//trim(err_msg)//&
181 ",file="//trim(filename)//
",field="//trim(loaded_fields(index)%name) )
186 call get_date(time,yy,mm,dd,hh,min,ss)
187 write(outunit,
'(a,i4,a,i2,a,i2,1x,i2,a,i2,a,i2)') &
188 'target time yyyy/mm/dd hh:mm:ss= ',yy,
'/',mm,
'/',dd,hh,
':',min,
':',ss
189 write(outunit,*)
't1, t2, w1, w2= ', t1, t2, w1, w2
192 call load_record(loaded_fields(index),t1,horz_interp, is_in, ie_in ,js_in, je_in, window_id)
193 call load_record(loaded_fields(index),t2,horz_interp, is_in, ie_in ,js_in, je_in, window_id)
194 i1 = find_buf_index(t1,loaded_fields(index)%ibuf)
195 i2 = find_buf_index(t2,loaded_fields(index)%ibuf)
197 call mpp_error(fatal,
'time_interp_external : records were not loaded correctly in memory')
200 write(outunit,*)
'ibuf= ',loaded_fields(index)%ibuf
201 write(outunit,*)
'i1,i2= ',i1, i2
204 if( loaded_fields(index)%region_type == no_region )
then
205 where(loaded_fields(index)%mask(isc:iec,jsc:jec,:,i1) .and. &
206 loaded_fields(index)%mask(isc:iec,jsc:jec,:,i2))
207 time_data(isw:iew,jsw:jew,:) = real(loaded_fields(index)%domain_data(isc:iec,jsc:jec,:,i1), kindl)&
208 * w1 + real(loaded_fields(index)%domain_data(isc:iec,jsc:jec,:,i2), kindl) * w2
211 time_data(isw:iew,jsw:jew,:) = real(loaded_fields(index)%missing, kindl)
214 where(loaded_fields(index)%mask(isc:iec,jsc:jec,:,i1) .and. &
215 loaded_fields(index)%mask(isc:iec,jsc:jec,:,i2))
216 time_data(isw:iew,jsw:jew,:) = real( loaded_fields(index)%domain_data(isc:iec,jsc:jec,:,i1), kindl)&
217 * w1 + real(loaded_fields(index)%domain_data(isc:iec,jsc:jec,:,i2), kindl) * w2
220 if(
PRESENT(mask_out)) &
221 mask_out(isw:iew,jsw:jew,:) = &
222 loaded_fields(index)%mask(isc:iec,jsc:jec,:,i1).and.&
223 loaded_fields(index)%mask(isc:iec,jsc:jec,:,i2)
232 integer,
intent(in) :: index
233 type(time_type),
intent(in) :: time
234 real(FMS_TI_KIND_),
intent(inout) :: time_data
235 logical,
intent(in),
optional :: verbose
238 integer :: i1, i2, mod_time
239 integer :: yy, mm, dd, hh, min, ss
240 character(len=256) :: err_msg
241 character(len=FMS_PATH_LEN) :: filename
243 real(FMS_TI_KIND_) :: w1,w2
245 integer,
parameter :: kindl = fms_ti_kind_
248 if (
PRESENT(verbose)) verb=verbose
249 if (debug_this_module) verb = .true.
251 if (index < 1.or.index > num_fields) &
252 call mpp_error(fatal, &
253 &
'invalid index in call to time_interp_ext -- field was not initialized or failed to initialize')
255 if (loaded_fields(index)%siz(4) == 1)
then
257 call load_record_0d(loaded_fields(index),1)
258 i1 = find_buf_index(1,loaded_fields(index)%ibuf)
259 time_data = real(loaded_fields(index)%domain_data(1,1,1,i1), fms_ti_kind_)
261 if(loaded_fields(index)%have_modulo_times)
then
262 call time_interp(time,loaded_fields(index)%modulo_time_beg, loaded_fields(index)%modulo_time_end, &
263 loaded_fields(index)%time(:), w2, t1, t2, &
264 loaded_fields(index)%correct_leap_year_inconsistency, err_msg=err_msg)
265 if(err_msg .NE.
'')
then
266 filename = trim(loaded_fields(index)%fileobj%path)
267 call mpp_error(fatal,
"time_interp_external 3:"//trim(err_msg)//&
268 ",file="//trim(filename)//
",field="//trim(loaded_fields(index)%name) )
271 if(loaded_fields(index)%modulo_time)
then
276 call time_interp(time,loaded_fields(index)%time(:),w2,t1,t2,modtime=mod_time, err_msg=err_msg)
277 if(err_msg .NE.
'')
then
278 filename = trim(loaded_fields(index)%fileobj%path)
279 call mpp_error(fatal,
"time_interp_external 4:"//trim(err_msg)// &
280 ",file="//trim(filename)//
",field="//trim(loaded_fields(index)%name) )
285 call get_date(time,yy,mm,dd,hh,min,ss)
286 write(outunit,
'(a,i4,a,i2,a,i2,1x,i2,a,i2,a,i2)') &
287 'target time yyyy/mm/dd hh:mm:ss= ',yy,
'/',mm,
'/',dd,hh,
':',min,
':',ss
288 write(outunit,*)
't1, t2, w1, w2= ', t1, t2, w1, w2
290 call load_record_0d(loaded_fields(index),t1)
291 call load_record_0d(loaded_fields(index),t2)
292 i1 = find_buf_index(t1,loaded_fields(index)%ibuf)
293 i2 = find_buf_index(t2,loaded_fields(index)%ibuf)
296 call mpp_error(fatal,
'time_interp_external : records were not loaded correctly in memory')
297 time_data = real(loaded_fields(index)%domain_data(1,1,1,i1), fms_ti_kind_)*w1 &
298 & + real(loaded_fields(index)%domain_data(1,1,1,i2), fms_ti_kind_)*w2
300 write(outunit,*)
'ibuf= ',loaded_fields(index)%ibuf
301 write(outunit,*)
'i1,i2= ',i1, i2
subroutine time_interp_external_2d_(index, time, data_in, interp, verbose, horz_interp, mask_out, is_in, ie_in, js_in, je_in, window_id)
2D interpolation for time_interp_external
subroutine time_interp_external_3d_(index, time, time_data, interp, verbose, horz_interp, mask_out, is_in, ie_in, js_in, je_in, window_id)
3D interpolation for time_interp_external Provide data from external file interpolated to current mod...
subroutine time_interp_external_0d_(index, time, time_data, verbose)
Scalar interpolation for time_interp_external.