Commit d3df175d authored by kbk's avatar kbk
Browse files

support for non-climatological 3D boundaries (S,T)

parent 7609f710
!$Id: bdy_3d.F90,v 1.5 2003-05-05 15:47:59 kbk Exp $ !$Id: bdy_3d.F90,v 1.6 2005-05-04 11:50:57 kbk Exp $
#include "cppdefs.h" #include "cppdefs.h"
!----------------------------------------------------------------------- !-----------------------------------------------------------------------
!BOP !BOP
...@@ -32,7 +32,10 @@ ...@@ -32,7 +32,10 @@
! Original author(s): Karsten Bolding & Hans Burchard ! Original author(s): Karsten Bolding & Hans Burchard
! !
! $Log: bdy_3d.F90,v $ ! $Log: bdy_3d.F90,v $
! Revision 1.5 2003-05-05 15:47:59 kbk ! Revision 1.6 2005-05-04 11:50:57 kbk
! support for non-climatological 3D boundaries (S,T)
!
! Revision 1.5 2003/05/05 15:47:59 kbk
! T and S boundaries work in parallel runs ! T and S boundaries work in parallel runs
! !
! Revision 1.4 2003/04/23 12:16:34 kbk ! Revision 1.4 2003/04/23 12:16:34 kbk
...@@ -91,10 +94,10 @@ ...@@ -91,10 +94,10 @@
#endif #endif
LEVEL2 'init_bdy_3d()' LEVEL2 'init_bdy_3d()'
allocate(S_bdy(nsbv,0:kmax),stat=rc) allocate(S_bdy(0:kmax,nsbv),stat=rc)
if (rc /= 0) stop 'init_init_bdy_3d: Error allocating memory (S_bdy)' if (rc /= 0) stop 'init_init_bdy_3d: Error allocating memory (S_bdy)'
allocate(T_bdy(nsbv,0:kmax),stat=rc) allocate(T_bdy(0:kmax,nsbv),stat=rc)
if (rc /= 0) stop 'init_init_bdy_3d: Error allocating memory (T_bdy)' if (rc /= 0) stop 'init_init_bdy_3d: Error allocating memory (T_bdy)'
#ifdef DEBUG #ifdef DEBUG
...@@ -182,8 +185,8 @@ ...@@ -182,8 +185,8 @@
do j=wfj(n),wlj(n) do j=wfj(n),wlj(n)
do ii=1,4 do ii=1,4
if (az(i-1+ii,j).gt.0) then if (az(i-1+ii,j).gt.0) then
S(i-1+ii,j,:) = sp(ii)*S_bdy(k,:)+(1.-sp(ii))*S(i-1+ii,j,:) S(i-1+ii,j,:) = sp(ii)*S_bdy(:,k)+(1.-sp(ii))*S(i-1+ii,j,:)
T(i-1+ii,j,:) = sp(ii)*T_bdy(k,:)+(1.-sp(ii))*T(i-1+ii,j,:) T(i-1+ii,j,:) = sp(ii)*T_bdy(:,k)+(1.-sp(ii))*T(i-1+ii,j,:)
end if end if
end do end do
k = k+1 k = k+1
...@@ -197,8 +200,8 @@ ...@@ -197,8 +200,8 @@
do i = nfi(n),nli(n) do i = nfi(n),nli(n)
do jj=1,4 do jj=1,4
if (az(i,j+1-jj).gt.0) then if (az(i,j+1-jj).gt.0) then
S(i,j+1-jj,:) = sp(jj)*S_bdy(k,:)+(1.-sp(jj))*S(i,j+1-jj,:) S(i,j+1-jj,:) = sp(jj)*S_bdy(:,k)+(1.-sp(jj))*S(i,j+1-jj,:)
T(i,j+1-jj,:) = sp(jj)*T_bdy(k,:)+(1.-sp(jj))*T(i,j+1-jj,:) T(i,j+1-jj,:) = sp(jj)*T_bdy(:,k)+(1.-sp(jj))*T(i,j+1-jj,:)
end if end if
end do end do
k = k+1 k = k+1
...@@ -212,8 +215,8 @@ ...@@ -212,8 +215,8 @@
do j=efj(n),elj(n) do j=efj(n),elj(n)
do ii=1,4 do ii=1,4
if (az(i+1-ii,j).gt.0) then if (az(i+1-ii,j).gt.0) then
S(i+1-ii,j,:) = sp(ii)*S_bdy(k,:)+(1.-sp(ii))*S(i+1-ii,j,:) S(i+1-ii,j,:) = sp(ii)*S_bdy(:,k)+(1.-sp(ii))*S(i+1-ii,j,:)
T(i+1-ii,j,:) = sp(ii)*T_bdy(k,:)+(1.-sp(ii))*T(i+1-ii,j,:) T(i+1-ii,j,:) = sp(ii)*T_bdy(:,k)+(1.-sp(ii))*T(i+1-ii,j,:)
end if end if
end do end do
k = k+1 k = k+1
...@@ -227,8 +230,8 @@ ...@@ -227,8 +230,8 @@
do i = sfi(n),sli(n) do i = sfi(n),sli(n)
do jj=1,4 do jj=1,4
if (az(i,j-1+jj).gt.0) then if (az(i,j-1+jj).gt.0) then
S(i,j-1+jj,:) = sp(jj)*S_bdy(k,:)+(1.-sp(jj))*S(i,j-1+jj,:) S(i,j-1+jj,:) = sp(jj)*S_bdy(:,k)+(1.-sp(jj))*S(i,j-1+jj,:)
T(i,j-1+jj,:) = sp(jj)*T_bdy(k,:)+(1.-sp(jj))*T(i,j-1+jj,:) T(i,j-1+jj,:) = sp(jj)*T_bdy(:,k)+(1.-sp(jj))*T(i,j-1+jj,:)
end if end if
end do end do
k = k+1 k = k+1
......
!$Id: ncdf_3d_bdy.F90,v 1.9 2004-04-06 16:32:29 kbk Exp $ !$Id: ncdf_3d_bdy.F90,v 1.10 2005-05-04 11:50:57 kbk Exp $
#include "cppdefs.h" #include "cppdefs.h"
!----------------------------------------------------------------------- !-----------------------------------------------------------------------
!BOP !BOP
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
use variables_3d, only: hn use variables_3d, only: hn
use bdy_3d, only: T_bdy,S_bdy use bdy_3d, only: T_bdy,S_bdy
use time, only: string_to_julsecs,time_diff,julianday,secondsofday use time, only: string_to_julsecs,time_diff,julianday,secondsofday
use time, only: write_time_string,timestr
IMPLICIT NONE IMPLICIT NONE
! !
private private
...@@ -35,15 +36,21 @@ ...@@ -35,15 +36,21 @@
logical :: from_3d_fields=.false. logical :: from_3d_fields=.false.
REALTYPE :: offset REALTYPE :: offset
REAL_4B, allocatable :: bdy_times(:),wrk(:) REAL_4B, allocatable :: bdy_times(:),wrk(:)
REAL_4B, allocatable, dimension(:) :: zlev
REALTYPE, allocatable, dimension(:,:) :: T_old, T_new REALTYPE, allocatable, dimension(:,:) :: T_old, T_new
REAL_4B, allocatable, dimension(:,:) :: T_wrk
REALTYPE, allocatable, dimension(:,:) :: S_old, S_new REALTYPE, allocatable, dimension(:,:) :: S_old, S_new
REAL_4B, allocatable, dimension(:,:) :: S_wrk
REALTYPE, allocatable, dimension(:,:,:) :: T_bdy_clim,S_bdy_clim REALTYPE, allocatable, dimension(:,:,:) :: T_bdy_clim,S_bdy_clim
! !
! !REVISION HISTORY: ! !REVISION HISTORY:
! Original author(s): Karsten Bolding & Hans Burchard ! Original author(s): Karsten Bolding & Hans Burchard
! !
! $Log: ncdf_3d_bdy.F90,v $ ! $Log: ncdf_3d_bdy.F90,v $
! Revision 1.9 2004-04-06 16:32:29 kbk ! Revision 1.10 2005-05-04 11:50:57 kbk
! support for non-climatological 3D boundaries (S,T)
!
! Revision 1.9 2004/04/06 16:32:29 kbk
! TimeDiff --> time_diff ! TimeDiff --> time_diff
! !
! Revision 1.8 2003/12/16 16:50:41 kbk ! Revision 1.8 2003/12/16 16:50:41 kbk
...@@ -107,9 +114,6 @@ ...@@ -107,9 +114,6 @@
integer :: ndims integer :: ndims
integer, allocatable, dimension(:):: dim_ids,dim_len integer, allocatable, dimension(:):: dim_ids,dim_len
character(len=16), allocatable :: dim_name(:) character(len=16), allocatable :: dim_name(:)
REAL_4B, allocatable, dimension(:):: zlev
integer :: rc,err integer :: rc,err
integer :: i,j,k,l,m,n,id integer :: i,j,k,l,m,n,id
!EOP !EOP
...@@ -193,10 +197,11 @@ ...@@ -193,10 +197,11 @@
if (err .NE. NF_NOERR) go to 10 if (err .NE. NF_NOERR) go to 10
if (climatology) then if (climatology) then
allocate(T_bdy_clim(time_len,nsbv,0:kmax),stat=rc)
allocate(T_bdy_clim(time_len,0:kmax,nsbv),stat=rc)
if (rc /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_bdy_clim)' if (rc /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_bdy_clim)'
allocate(S_bdy_clim(time_len,nsbv,0:kmax),stat=rc) allocate(S_bdy_clim(time_len,0:kmax,nsbv),stat=rc)
if (rc /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_bdy_clim)' if (rc /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_bdy_clim)'
! we read each boundary column individually ! we read each boundary column individually
...@@ -206,7 +211,7 @@ ...@@ -206,7 +211,7 @@
! m counts the time ! m counts the time
! l counts the boundary number ! l counts the boundary number
! k counts the number of the specific point ! k counts the number of the specific point
! MUST cover the same area as in topo.nc ! MUST cover the same area as in topo.nc
if (from_3d_fields) then if (from_3d_fields) then
edges(1) = 1; edges(1) = 1;
edges(2) = 1; edges(2) = 1;
...@@ -220,7 +225,6 @@ ...@@ -220,7 +225,6 @@
do m=1,time_len do m=1,time_len
start(time_dim) = m start(time_dim) = m
l = 0 l = 0
do n=1,NWB do n=1,NWB
l = l+1 l = l+1
...@@ -234,12 +238,12 @@ ...@@ -234,12 +238,12 @@
end if end if
err = nf_get_vara_real(ncid,salt_id,start,edges,wrk) err = nf_get_vara_real(ncid,salt_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
S_bdy_clim(m,k,:)) S_bdy_clim(m,:,k))
err = nf_get_vara_real(ncid,temp_id,start,edges,wrk) err = nf_get_vara_real(ncid,temp_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
T_bdy_clim(m,k,:)) T_bdy_clim(m,:,k))
k = k+1 k = k+1
end do end do
end do end do
...@@ -256,12 +260,12 @@ ...@@ -256,12 +260,12 @@
end if end if
err = nf_get_vara_real(ncid,salt_id,start,edges,wrk) err = nf_get_vara_real(ncid,salt_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
S_bdy_clim(m,k,:)) S_bdy_clim(m,:,k))
err = nf_get_vara_real(ncid,temp_id,start,edges,wrk) err = nf_get_vara_real(ncid,temp_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
T_bdy_clim(m,k,:)) T_bdy_clim(m,:,k))
k = k+1 k = k+1
end do end do
end do end do
...@@ -278,12 +282,12 @@ ...@@ -278,12 +282,12 @@
end if end if
err = nf_get_vara_real(ncid,salt_id,start,edges,wrk) err = nf_get_vara_real(ncid,salt_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
S_bdy_clim(m,k,:)) S_bdy_clim(m,:,k))
err = nf_get_vara_real(ncid,temp_id,start,edges,wrk) err = nf_get_vara_real(ncid,temp_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
T_bdy_clim(m,k,:)) T_bdy_clim(m,:,k))
k = k+1 k = k+1
end do end do
end do end do
...@@ -300,12 +304,12 @@ ...@@ -300,12 +304,12 @@
end if end if
err = nf_get_vara_real(ncid,salt_id,start,edges,wrk) err = nf_get_vara_real(ncid,salt_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
S_bdy_clim(m,k,:)) S_bdy_clim(m,:,k))
err = nf_get_vara_real(ncid,temp_id,start,edges,wrk) err = nf_get_vara_real(ncid,temp_id,start,edges,wrk)
if (err .ne. NF_NOERR) go to 10 if (err .ne. NF_NOERR) go to 10
call interpol(zlev,wrk,H(i,j),kmax,hn(i,j,:), & call interpol(zax_len,zlev,wrk,H(i,j),kmax,hn(i,j,:), &
T_bdy_clim(m,k,:)) T_bdy_clim(m,:,k))
k = k+1 k = k+1
end do end do
end do end do
...@@ -316,16 +320,16 @@ ...@@ -316,16 +320,16 @@
err = nf_inq_varid(ncid,'time',time_id) err = nf_inq_varid(ncid,'time',time_id)
if (err .NE. NF_NOERR) go to 10 if (err .NE. NF_NOERR) go to 10
err = nf_get_att_text(ncid,time_id,'units',units) err = nf_get_att_text(ncid,time_id,'units',units)
if (err .NE. NF_NOERR) go to 10 if (err .NE. NF_NOERR) go to 10
allocate(bdy_times(time_len),stat=err) allocate(bdy_times(time_len),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (bdy_times)' if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (bdy_times)'
err = nf_get_var_real(ncid,time_id,bdy_times) err = nf_get_var_real(ncid,time_id,bdy_times)
if (err .NE. NF_NOERR) go to 10 if (err .NE. NF_NOERR) go to 10
call string_to_julsecs(units,j1,s1) call string_to_julsecs(units,j1,s1)
offset = time_diff(julianday,secondsofday,j1,s1) offset = time_diff(julianday,secondsofday,j1,s1)
if( offset .lt. _ZERO_ ) then if( offset .lt. _ZERO_ ) then
...@@ -335,18 +339,93 @@ ...@@ -335,18 +339,93 @@
LEVEL3 'Boundary offset time ',offset LEVEL3 'Boundary offset time ',offset
end if end if
allocate(T_old(nsbv,0:kmax),stat=err) allocate(T_old(0:kmax,nsbv),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_old)' if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_old)'
allocate(T_new(nsbv,0:kmax),stat=err) allocate(T_new(0:kmax,nsbv),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_new)' if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_new)'
allocate(T_wrk(zax_len,nsbv),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (T_wrk)'
allocate(S_old(nsbv,0:kmax),stat=err) allocate(S_old(0:kmax,nsbv),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_old)' if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_old)'
allocate(S_new(nsbv,0:kmax),stat=err) allocate(S_new(0:kmax,nsbv),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_new)' if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_new)'
allocate(S_wrk(zax_len,nsbv),stat=err)
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (S_wrk)'
n = size(bdy_times)
do i=1,n
if(bdy_times(i) .ge. real(offset)) then
EXIT
end if
end do
if(i .gt. 1 .and. bdy_times(i) .gt. real(offset)) then
i = i-1
end if
start(1) = 1; edges(1) = dim_len(zax_dim);
start(2) = 1; edges(2) = nsbv;
start(3) = i; edges(3) = 1
err = nf_get_vara_real(ncid,temp_id,start,edges,T_wrk)
if (err .ne. NF_NOERR) go to 10
err = nf_get_vara_real(ncid,salt_id,start,edges,S_wrk)
if (err .ne. NF_NOERR) go to 10
l = 0
do n=1,NWB
l = l+1
k = bdy_index(l)
i = wi(n)
do j=wfj(n),wlj(n)
call interpol(zax_len,zlev,T_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
T_new(:,k))
call interpol(zax_len,zlev,S_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
S_new(:,k))
k = k+1
end do
end do
do n = 1,NNB
l = l+1
k = bdy_index(l)
j = nj(n)
do i = nfi(n),nli(n)
call interpol(zax_len,zlev,S_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
S_new(:,k))
call interpol(zax_len,zlev,T_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
T_new(:,k))
k = k+1
end do
end do
allocate(wrk(nsbv*(kmax+1)),stat=err) do n=1,NEB
if (err /= 0) stop 'init_3d_bdy_ncdf: Error allocating memory (wrk)' l = l+1
k = bdy_index(l)
i = ei(n)
do j=efj(1),elj(1)
call interpol(zax_len,zlev,S_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
S_new(:,k))
call interpol(zax_len,zlev,T_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
T_new(:,k))
k = k+1
end do
end do
do n = 1,NSB
l = l+1
k = bdy_index(l)
j = sj(n)
do i = sfi(n),sli(n)
call interpol(zax_len,zlev,S_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
S_new(:,k))
call interpol(zax_len,zlev,T_wrk(:,k),H(i,j),kmax,hn(i,j,:), &
T_new(:,k))
k = k+1
end do
end do
end if end if
#ifdef DEBUG #ifdef DEBUG
...@@ -385,7 +464,10 @@ ...@@ -385,7 +464,10 @@
! Original author(s): Karsten Bolding & Hans Burchard ! Original author(s): Karsten Bolding & Hans Burchard
! !
! $Log: ncdf_3d_bdy.F90,v $ ! $Log: ncdf_3d_bdy.F90,v $
! Revision 1.9 2004-04-06 16:32:29 kbk ! Revision 1.10 2005-05-04 11:50:57 kbk
! support for non-climatological 3D boundaries (S,T)
!
! Revision 1.9 2004/04/06 16:32:29 kbk
! TimeDiff --> time_diff ! TimeDiff --> time_diff
! !
! Revision 1.8 2003/12/16 16:50:41 kbk ! Revision 1.8 2003/12/16 16:50:41 kbk
...@@ -416,9 +498,14 @@ ...@@ -416,9 +498,14 @@
! Introduced module ncdf_2d_bdy ! Introduced module ncdf_2d_bdy
! !
! !LOCAL VARIABLES: ! !LOCAL VARIABLES:
integer :: err integer :: err
REALTYPE :: rat REALTYPE :: rat
integer :: monthsecs,prev,this,next integer :: monthsecs,prev,this,next
logical, save :: first=.true.
integer, save :: loop0
REALTYPE :: t
REALTYPE, save :: t1=_ZERO_,t2=-_ONE_
integer :: i,j,k,l,n
!EOP !EOP
!------------------------------------------------------------------------- !-------------------------------------------------------------------------
!BOC !BOC
...@@ -446,109 +533,103 @@ ...@@ -446,109 +533,103 @@
T_bdy=(1.-rat)*0.5*(T_bdy_clim(prev,:,:)+T_bdy_clim(this,:,:)) & T_bdy=(1.-rat)*0.5*(T_bdy_clim(prev,:,:)+T_bdy_clim(this,:,:)) &
+ rat*0.5*(T_bdy_clim(next,:,:)+T_bdy_clim(this,:,:)) + rat*0.5*(T_bdy_clim(next,:,:)+T_bdy_clim(this,:,:))
else else
end if
#if 0
start(1) = 1 ; edges(1) = kmax+1
start(2) = 1 ; edges(2) = bdy_len
if (first) then if (first) then
loop0=loop-1 loop0=loop-1
endif endif
t = (loop-loop0)*dtm t = (loop-loop0)*dtm
if (first) then if(t .gt. t2 .or. first) then
first = .false.
n = size(bdy_times) if (first) then
do i=1,n first = .false.
if (bdy_times(i) .gt. real(t + offset)) then t2=t
EXIT else
call write_time_string()
LEVEL2 timestr,': reading 3D boundary data ...'
end if end if
end do
t1 = bdy_times(i-1) - offset
t2 = bdy_times(i) - offset
start(3) = i-1 ; edges(3) = 1
err = nf_get_vara_real(ncid,temp_id,start,edges,wrk)
if(err .NE. NF_NOERR) go to 10
indx = 0
do k=1,89
do j=0,kmax
indx = indx+1
T_old(k,j) = wrk(indx)
end do
end do
start(3) = i ; edges(3) = 1
err = nf_get_vara_real(ncid,temp_id,start,edges,wrk)
if(err .NE. NF_NOERR) go to 10
indx = 0
do k=1,89
do j=0,kmax
indx = indx+1
T_new(k,j) = wrk(indx)
end do
end do
start(3) = i-1 ; edges(3) = 1
err = nf_get_vara_real(ncid,salt_id,start,edges,wrk)
if(err .NE. NF_NOERR) go to 10
indx = 0
do k=1,89
do j=0,kmax
indx = indx+1
S_old(k,j) = wrk(indx)
end do
end do
start(3) = i ; edges(3) = 1
err = nf_get_vara_real(ncid,salt_id,start,edges,wrk)
if(err .NE. NF_NOERR) go to 10
indx = 0
do k=1,89
do j=0,kmax
indx = indx+1
S_new(k,j) = wrk(indx)
end do
end do
end if
if(t .gt. t2) then n = size(bdy_times)
STDERR 'New 3D boundary data' do i=1,n
do i=1,n if(bdy_times(i) .ge. real(t + offset)) then
if(bdy_times(i) .gt. real(t + offset)) then EXIT
EXIT end if
end if end do