@@ -253,6 +253,7 @@ subroutine IAU_initialize (IPD_Control, IAU_Data,Init_parm)
253
253
allocate (iau_state% inc1% tracer_inc(is:ie, js:je, km,ntracers))
254
254
iau_state% hr1= IPD_Control% iaufhrs(1 )
255
255
iau_state% wt = 1.0 ! IAU increment filter weights (default 1.0)
256
+ iau_state% wt_normfact = 1.0
256
257
if (IPD_Control% iau_filter_increments) then
257
258
! compute increment filter weights, sum to obtain normalization factor
258
259
dtp= IPD_control% dtp
@@ -298,26 +299,31 @@ subroutine getiauforcing(IPD_Control,IAU_Data)
298
299
type (IPD_control_type), intent (in ) :: IPD_Control
299
300
type (IAU_external_data_type), intent (inout ) :: IAU_Data
300
301
real (kind= kind_phys) t1,t2,sx,wx,wt,dtp
301
- integer n,i,j,k,sphum,kstep,nstep
302
+ integer n,i,j,k,sphum,kstep,nstep,itnext
302
303
303
304
IAU_Data% in_interval= .false.
304
305
if (nfiles.LE. 0 ) then
305
306
return
306
307
endif
307
308
308
- t1= iau_state% hr1 - IPD_Control% iau_delthrs* 0.5
309
- t2= iau_state% hr1 + IPD_Control% iau_delthrs* 0.5
309
+ if (nfiles .eq. 1 ) then
310
+ t1 = IPD_Control% iaufhrs(1 )- 0.5 * IPD_Control% iau_delthrs
311
+ t2 = IPD_Control% iaufhrs(1 )+ 0.5 * IPD_Control% iau_delthrs
312
+ else
313
+ t1 = IPD_Control% iaufhrs(1 )
314
+ t2 = IPD_Control% iaufhrs(nfiles)
315
+ endif
310
316
if (IPD_Control% iau_filter_increments) then
311
317
! compute increment filter weight
312
- ! t1 beginning of window, t2 end of window
318
+ ! t1 is beginning of window, t2 end of window
313
319
! IPD_Control%fhour current time
314
320
! in window kstep=-nstep,nstep (2*nstep+1 total)
315
321
! time step IPD_control%dtp
316
322
dtp= IPD_control% dtp
317
323
nstep = 0.5 * IPD_Control% iau_delthrs* 3600 / dtp
318
324
! compute normalized filter weight
319
- kstep = (IPD_Control% fhour- (t1 + IPD_Control % iau_delthrs * 0.5 ) )* 3600 ./ dtp
320
- if (kstep .ge. - nstep .and. kstep .le. nstep ) then
325
+ kstep = (( IPD_Control% fhour- t1) - 0.5 * IPD_Control % iau_delthrs )* 3600 ./ dtp
326
+ if (IPD_Control % fhour > = t1 .and. IPD_Control % fhour < t2 ) then
321
327
sx = acos (- 1 .)* kstep/ nstep
322
328
wx = acos (- 1 .)* kstep/ (nstep+1 )
323
329
if (kstep .ne. 0 ) then
@@ -326,7 +332,7 @@ subroutine getiauforcing(IPD_Control,IAU_Data)
326
332
wt = 1 .
327
333
endif
328
334
iau_state% wt = iau_state% wt_normfact* wt
329
- if (is_master()) print * ,' filter wt' ,kstep,IPD_Control% fhour,iau_state% wt
335
+ ! if (is_master()) print *,'kstep,t1,t,t2, filter wt= ',kstep,t1, IPD_Control%fhour,t2, iau_state%wt/iau_state%wt_normfact
330
336
else
331
337
iau_state% wt = 0 .
332
338
endif
@@ -340,31 +346,32 @@ subroutine getiauforcing(IPD_Control,IAU_Data)
340
346
IAU_Data% in_interval= .false.
341
347
else
342
348
if (IPD_Control% iau_filter_increments) call setiauforcing(IPD_Control,IAU_Data,iau_state% wt)
343
- if (is_master()) print * ,' apply iau forcing' ,t1,IPD_Control% fhour,t2
349
+ if (is_master()) print * ,' apply iau forcing t1,t,t2,filter wt= ' ,t1,IPD_Control% fhour,t2,iau_state % wt / iau_state % wt_normfact
344
350
IAU_Data% in_interval= .true.
345
351
endif
346
352
return
347
353
endif
348
354
349
355
if (nfiles > 1 ) then
350
- t2 = 2
351
- if (IPD_Control% fhour < IPD_Control % iaufhrs( 1 ) .or. IPD_Control% fhour >= IPD_Control % iaufhrs(nfiles) ) then
356
+ itnext = 2
357
+ if (IPD_Control% fhour < t1 .or. IPD_Control% fhour >= t2 ) then
352
358
! if (is_master()) print *,'no iau forcing',IPD_Control%iaufhrs(1),IPD_Control%fhour,IPD_Control%iaufhrs(nfiles)
353
359
IAU_Data% in_interval= .false.
354
360
else
361
+ if (is_master()) print * ,' apply iau forcing t1,t,t2,filter wt=' ,t1,IPD_Control% fhour,t2,iau_state% wt/ iau_state% wt_normfact
355
362
IAU_Data% in_interval= .true.
356
363
do k= nfiles,1 ,- 1
357
364
if (IPD_Control% iaufhrs(k) > IPD_Control% fhour) then
358
- t2 = k
365
+ itnext = k
359
366
endif
360
367
enddo
361
- ! if (is_master()) print *,'t2 =',t2
368
+ ! if (is_master()) print *,'itnext =',itnext
362
369
if (IPD_Control% fhour >= iau_state% hr2) then ! need to read in next increment file
363
370
iau_state% hr1= iau_state% hr2
364
- iau_state% hr2= IPD_Control% iaufhrs(int (t2) )
371
+ iau_state% hr2= IPD_Control% iaufhrs(itnext )
365
372
iau_state% inc1= iau_state% inc2
366
- if (is_master()) print * ,' reading next increment file' ,trim (IPD_Control% iau_inc_files(int (t2) ))
367
- call read_iau_forcing(IPD_Control,iau_state% inc2,' INPUT/' // trim (IPD_Control% iau_inc_files(int (t2) )))
373
+ if (is_master()) print * ,' reading next increment file' ,trim (IPD_Control% iau_inc_files(itnext ))
374
+ call read_iau_forcing(IPD_Control,iau_state% inc2,' INPUT/' // trim (IPD_Control% iau_inc_files(itnext )))
368
375
endif
369
376
call updateiauforcing(IPD_Control,IAU_Data,iau_state% wt)
370
377
endif
0 commit comments