Skip to content

Commit

Permalink
revised extract scripts for forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
josephzhang8 committed Dec 11, 2024
1 parent 2bc82d2 commit c5b540f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
31 changes: 14 additions & 17 deletions src/Utility/Post-Processing-Fortran/read_output10_xyz.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
! const. extrapolation is used, except if z=1.e10, in which case
! depth averaged value will be calculated (for 3D vars).
! Output time series for 3D variables (surface values for 2D variables), DEFINED AT NODES OR
! ELEMENTS. Can handle (overlapping) forecast
! ELEMENTS. Can handle (overlapping) forecast (in this case, time origins of stacks are offset
! by a constant time)

! Inputs:
! (1) screen;
Expand Down Expand Up @@ -87,13 +88,11 @@ program read_out
print*, 'Is this a hindcast (0) or forecast(1):'
read(*,*)iforecast
if(iforecast/=0) then
print*, 'Input start and end record # within each forecast:'
print*, 'Input start and end record # to extract frm each stack:'
read(*,*)ifct_rec1,ifct_rec2
if(ifct_rec1>ifct_rec2) stop 'ifct_rec1>ifct_rec2'
print*, 'Input # of offset stacks between starts of consecutive forecasts:'
read(*,*)istagger
print*, 'Input time origin offset (days) to be added to output start time:'
read(*,*)t_offset
print*, 'Input offset in days between origins of consecutive stacks:'
read(*,*)offset_origin
endif

if(ibp==1) then !.bp format
Expand Down Expand Up @@ -208,9 +207,9 @@ program read_out
!... Time iteration
!...
!Start time at the start of stack for forecast mode
start_time0=dtout*istagger*nrec*(iday1-1)
do iday=iday1,iday2
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
start_time0=offset_origin*86400*(iday-1) !start time of this stack (sec)
write(it_char,'(i12)')iday
it_char=adjustl(it_char)
leng=len_trim(it_char)
Expand Down Expand Up @@ -312,11 +311,11 @@ program read_out
endif
else if(irec>=ifct_rec1.and.irec<=ifct_rec2) then !forecast
tout=start_time0+dtout*irec
write(18,'(e16.8,20000(1x,e14.6))')tout/86400+t_offset,(out2(i,1,1),i=1,nxy)
write(18,'(e16.8,20000(1x,e14.6))')tout/86400,(out2(i,1,1),i=1,nxy)
if(ivs==2) then
write(19,'(e16.8,20000(1x,e14.6))')tout/86400+t_offset,(out2(i,1,2),i=1,nxy)
write(21,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(sqrt(out2(i,1,1)**2+out2(i,1,2)**2),i=1,nxy)
write(22,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(atan2(out2(i,1,2),out2(i,1,1))/pi*180,i=1,nxy)
write(19,'(e16.8,20000(1x,e14.6))')tout/86400,(out2(i,1,2),i=1,nxy)
write(21,'(e16.8,20000(1x,f14.6))')tout/86400,(sqrt(out2(i,1,1)**2+out2(i,1,2)**2),i=1,nxy)
write(22,'(e16.8,20000(1x,f14.6))')tout/86400,(atan2(out2(i,1,2),out2(i,1,1))/pi*180,i=1,nxy)
endif
endif
else !3D
Expand Down Expand Up @@ -432,11 +431,11 @@ program read_out
endif
else if(irec>=ifct_rec1.and.irec<=ifct_rec2) then !forecast
tout=start_time0+dtout*irec
write(18,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(out3(i,1),i=1,nxy)
write(18,'(e16.8,20000(1x,f14.6))')tout/86400,(out3(i,1),i=1,nxy)
if(ivs==2) then
write(19,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(out3(i,2),i=1,nxy)
write(21,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(sqrt(out3(i,1)**2+out3(i,2)**2),i=1,nxy)
write(22,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(atan2(out3(i,2),out3(i,1))/pi*180,i=1,nxy)
write(19,'(e16.8,20000(1x,f14.6))')tout/86400,(out3(i,2),i=1,nxy)
write(21,'(e16.8,20000(1x,f14.6))')tout/86400,(sqrt(out3(i,1)**2+out3(i,2)**2),i=1,nxy)
write(22,'(e16.8,20000(1x,f14.6))')tout/86400,(atan2(out3(i,2),out3(i,1))/pi*180,i=1,nxy)
endif
endif

Expand All @@ -445,8 +444,6 @@ program read_out
iret=nf90_close(ncid)
iret=nf90_close(ncid4)
if(ivs==2) iret=nf90_close(ncid2)

start_time0=start_time0+dtout*nrec
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
enddo !iday

Expand Down
21 changes: 10 additions & 11 deletions src/Utility/Post-Processing-Fortran/read_output9_xyz.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
! depth averaged value will be calculated (for 3D vars).
! Output time series for 3D variables (surface values for 2D variables), DEFINED AT NODES OR
! ELEMENTS.
! Works with combined or uncombined nc outputs. Can handle (overlapping) forecast
! Works with combined or uncombined nc outputs. Can handle (overlapping) forecast (in this case
! time origins of stacks are offset by a constant time)

! Inputs:
! (1) screen;
Expand Down Expand Up @@ -98,11 +99,11 @@ program read_out
print*, 'Is this a hindcast (0) or forecast(1):'
read(*,*)iforecast
if(iforecast/=0) then
print*, 'Input start and end record # from each forecast:'
print*, 'Input start and end record # to extract in each stack:'
read(*,*)ifct_rec1,ifct_rec2
if(ifct_rec1>ifct_rec2) stop 'ifct_rec1>ifct_rec2'
print*, 'Input time offset (days) for output start time:'
read(*,*)t_offset
print*, 'Input offset in days between origins of consecutive stacks:'
read(*,*)offset_origin
endif

if(ibp==1) then !.bp format
Expand Down Expand Up @@ -237,9 +238,9 @@ program read_out
!... Time iteration
!...
!Start time at the start of stack for forecast mode
start_time0=dtout*nrec*(iday1-1)
do iday=iday1,iday2
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
start_time0=offset_origin*86400*(iday-1) !start time of this stack (sec)
! write(it_char,'(i12)')iday
! it_char=adjustl(it_char)
! leng=len_trim(it_char)
Expand Down Expand Up @@ -352,8 +353,8 @@ program read_out
if(ivs==2) write(19,'(e16.8,20000(1x,e14.6))')timeout(irec_real)/86400,(out2(i,1,2),i=1,nxy)
else if(irec_real>=ifct_rec1.and.irec_real<=ifct_rec2) then !forecast
tout=start_time0+dtout*irec_real
write(18,'(e16.8,20000(1x,e14.6))')tout/86400+t_offset,(out2(i,1,1),i=1,nxy)
if(ivs==2) write(19,'(e16.8,20000(1x,e14.6))')tout/86400+t_offset,(out2(i,1,2),i=1,nxy)
write(18,'(e16.8,20000(1x,e14.6))')tout/86400,(out2(i,1,1),i=1,nxy)
if(ivs==2) write(19,'(e16.8,20000(1x,e14.6))')tout/86400,(out2(i,1,2),i=1,nxy)
endif
else !3D
if(i23d<=3) then !node
Expand Down Expand Up @@ -491,8 +492,8 @@ program read_out
if(ivs==2) write(19,'(e16.8,20000(1x,f14.6))')timeout(irec_real)/86400,(out3(i,2),i=1,nxy)
else if(irec_real>=ifct_rec1.and.irec_real<=ifct_rec2) then !forecast
tout=start_time0+dtout*irec_real
write(18,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(out3(i,1),i=1,nxy)
if(ivs==2) write(19,'(e16.8,20000(1x,f14.6))')tout/86400+t_offset,(out3(i,2),i=1,nxy)
write(18,'(e16.8,20000(1x,f14.6))')tout/86400,(out3(i,1),i=1,nxy)
if(ivs==2) write(19,'(e16.8,20000(1x,f14.6))')tout/86400,(out3(i,2),i=1,nxy)
endif

endif !i23d
Expand All @@ -504,8 +505,6 @@ program read_out
end do loop1
!enddo !irec=1,nrec
!iret=nf90_close(ncid)

start_time0=start_time0+dtout*nrec
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
enddo !iday

Expand Down

0 comments on commit c5b540f

Please sign in to comment.