Skip to content

Commit 922c5a1

Browse files
committed
Finished revising iout_sta=2; tested
1 parent fad771c commit 922c5a1

4 files changed

Lines changed: 33 additions & 19 deletions

File tree

src/Core/schism_glbl.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,8 @@ module schism_glbl
604604
real(rkind),save,allocatable :: xsta(:),ysta(:),zstal(:),zsta(:),arco_sta(:,:), &
605605
xsta_bmi(:),ysta_bmi(:),zsta_bmi(:), &
606606
&sta_out(:,:),sta_out_gb(:,:),sta_out3d(:,:,:), &
607-
&zta_out3d(:,:,:),sta_out3d_gb(:,:,:),zta_out3d_gb(:,:,:)
608-
integer,save,allocatable :: iep_sta(:),iep_flag(:),iof_sta(:),indx_out(:,:),indx_wwm_out(:)
607+
&zta_out3d(:,:),sta_out3d_gb(:,:,:),zta_out3d_gb(:,:)
608+
integer,save,allocatable :: idry_sta(:),iep_sta(:),iep_flag(:),iof_sta(:),indx_out(:,:),indx_wwm_out(:)
609609

610610
! Message passing arrays used in main
611611
integer,save,allocatable :: srqst(:),sstat(:,:),rrqst(:),rstat(:,:)

src/Hydro/schism_init.F90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4191,11 +4191,12 @@ subroutine schism_init(iorder,indir,iths,ntime)
41914191

41924192
! Allocate: zstal is vertical up; xsta, ysta, zsta are global coord. if ics=2
41934193
if(iorder==0) then
4194-
allocate(xsta(nout_sta),ysta(nout_sta),zstal(nout_sta),zsta(nout_sta),iep_sta(nout_sta),iep_flag(nout_sta), &
4194+
allocate(xsta(nout_sta),ysta(nout_sta),zstal(nout_sta),zsta(nout_sta), &
4195+
&idry_sta(nout_sta),iep_sta(nout_sta),iep_flag(nout_sta), &
41954196
&arco_sta(nout_sta,4),sta_out(nout_sta,nvar_sta),sta_out_gb(nout_sta,nvar_sta), &
41964197
&sta_out3d(nvrt,nout_sta,nvar_sta),sta_out3d_gb(nvrt,nout_sta,nvar_sta), &
41974198
&xsta_bmi(nout_sta),ysta_bmi(nout_sta),zsta_bmi(nout_sta), &
4198-
&zta_out3d(nvrt,nout_sta,nvar_sta),zta_out3d_gb(nvrt,nout_sta,nvar_sta),stat=istat)
4199+
&zta_out3d(nvrt,nout_sta),zta_out3d_gb(nvrt,nout_sta),stat=istat)
41994200
if(istat/=0) call parallel_abort('MAIN: sta. allocation failure')
42004201
iep_flag=0
42014202
sta_out=0.0_rkind

src/Hydro/schism_step.F90

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10330,15 +10330,17 @@ subroutine schism_step(it)
1033010330
do j=1,nvar_sta !excluding zcor
1033110331
if(iof_sta(j)==0.or.mod(it,nspool_sta)/=0) cycle
1033210332

10333+
idry_sta(:)=0 !init
1033310334
do i=1,nout_sta
1033410335
ie=iep_sta(i)
1033510336
if(ie==0) then !no parent in this rank
1033610337
iep_flag(i)=0 !for comm. later
1033710338
sta_out(i,j)=0.d0
1033810339
sta_out3d(:,i,j)=0.d0
10339-
zta_out3d(:,i,j)=0.d0
10340+
zta_out3d(:,i)=0.d0 !same for all j
1034010341
else !is parent
1034110342
iep_flag(i)=1
10343+
idry_sta(i)=idry_e(ie) !save for comm later
1034210344
sta_out(i,j)=0.d0 !initialize
1034310345
if(j==1) then !elev.
1034410346
swild2(1,1:i34(ie))=eta2(elnode(1:i34(ie),ie))
@@ -10371,7 +10373,7 @@ subroutine schism_step(it)
1037110373
if(idry_e(ie)==1) then !dry
1037210374
sta_out(i,j)=-1.d7 !-999.d0
1037310375
sta_out3d(:,i,j)=-1.d7 !-999.d0
10374-
zta_out3d(:,i,j)=-1.d7 !-999.d0
10376+
zta_out3d(:,i)=-1.d7 !same for all j
1037510377
else !wet
1037610378
do m=1,i34(ie) !wet nodes
1037710379
nd=elnode(m,ie)
@@ -10404,7 +10406,7 @@ subroutine schism_step(it)
1040410406
itmp=minval(kbp(elnode(1:i34(ie),ie)))
1040510407
do k=1,nvrt
1040610408
if(k<itmp) then
10407-
zta_out3d(k,i,j)=-1.d7
10409+
zta_out3d(k,i)=-1.d7
1040810410
sta_out3d(k,i,j)=-1.d7
1040910411
else !at least 1 node has valid value
1041010412
do m=1,i34(ie)
@@ -10419,7 +10421,7 @@ subroutine schism_step(it)
1041910421
! swild4(2,m)=swild2(k,m)
1042010422
! endif
1042110423
enddo !m
10422-
zta_out3d(k,i,j)=sum(arco_sta(i,1:i34(ie))*swild4(1,1:i34(ie)))
10424+
zta_out3d(k,i)=sum(arco_sta(i,1:i34(ie))*swild4(1,1:i34(ie)))
1042310425
sta_out3d(k,i,j)=sum(arco_sta(i,1:i34(ie))*swild4(2,1:i34(ie)))
1042410426
endif !k
1042510427
enddo !k
@@ -10432,10 +10434,14 @@ subroutine schism_step(it)
1043210434
enddo !j=1,nvar_sta
1043310435

1043410436
! Output by rank 0
10437+
call mpi_reduce(idry_sta,nwild2,nout_sta,itype,MPI_SUM,0,comm,ierr)
10438+
!Save back to idry_sta to free up nwild2; /=0 => dry
10439+
if(myrank==0) idry_sta=nwild2(1:nout_sta)
10440+
1043510441
call mpi_reduce(iep_flag,nwild2,nout_sta,itype,MPI_SUM,0,comm,ierr)
1043610442
call mpi_reduce(sta_out,sta_out_gb,nout_sta*nvar_sta,rtype,MPI_SUM,0,comm,ierr)
1043710443
call mpi_reduce(sta_out3d,sta_out3d_gb,nvrt*nout_sta*nvar_sta,rtype,MPI_SUM,0,comm,ierr)
10438-
call mpi_reduce(zta_out3d,zta_out3d_gb,nvrt*nout_sta*nvar_sta,rtype,MPI_SUM,0,comm,ierr)
10444+
call mpi_reduce(zta_out3d,zta_out3d_gb,nvrt*nout_sta,rtype,MPI_SUM,0,comm,ierr)
1043910445

1044010446
if(myrank==0) then
1044110447
! write(290,*)nwild2(1:nout_sta)
@@ -10448,30 +10454,30 @@ subroutine schism_step(it)
1044810454
sta_out_gb(j,i)=1.d7 !-9999.d0
1044910455
if(i>4) then !3D only
1045010456
sta_out3d_gb(:,j,i)=1.d7 !-9999.d0
10451-
zta_out3d_gb(:,j,i)=1.d7 !-9999.d0
10457+
zta_out3d_gb(:,j)=1.d7 !-9999.d0
1045210458
endif
1045310459
else
1045410460
sta_out_gb(j,i)=sta_out_gb(j,i)/dble(nwild2(j))
1045510461
if(i>4) then !3D only
1045610462
sta_out3d_gb(:,j,i)=sta_out3d_gb(:,j,i)/dble(nwild2(j))
10457-
zta_out3d_gb(:,j,i)=zta_out3d_gb(:,j,i)/dble(nwild2(j))
10463+
zta_out3d_gb(:,j)=zta_out3d_gb(:,j)/dble(nwild2(j))
1045810464
endif
1045910465
endif
1046010466
enddo !j
10461-
write(250+i,'(e24.16,6000(1x,e14.6))')time,sta_out_gb(:,i)
10467+
write(250+i,'(e24.16,6000(1x,e15.6e3))')time,sta_out_gb(:,i)
1046210468
if(iout_sta==2.and.i>4) then
10463-
write(250+i,'(e24.16,300000(1x,e14.6))')time,sta_out3d_gb(:,:,i) !,zta_out3d_gb(:,:,i)
10469+
write(250+i,'(e24.16,300000(1x,e15.6e3))')time,sta_out3d_gb(:,:,i) !,zta_out3d_gb(:,:,i)
1046410470
!Add zcor output: do it only once
1046510471
if(.not.ltmp) then
1046610472
ltmp=.true.
10467-
write(250+nvar_sta+1,*) !empty line to be in consistent form as other 3D
10468-
write(250+nvar_sta+1,'(e24.16,300000(1x,e14.6))')time,zta_out3d_gb(:,:,i)
10473+
write(250+nvar_sta+1,'(300000(1x,i5))')idry_sta(:)
10474+
write(250+nvar_sta+1,'(e24.16,300000(1x,e15.6e3))')time,zta_out3d_gb(:,:)
1046910475
endif !
1047010476
endif !iout_sta
1047110477
enddo !i=1,nvar_sta
1047210478

1047310479
write(16,*)'done station outputs...'
10474-
endif !myrank
10480+
endif !myrank==0
1047510481
endif !iout_sta/=0
1047610482

1047710483
#ifdef USE_HA

src/Utility/Post-Processing-Fortran/read_staout.f90

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
character(len=30) :: fname
1010
integer :: time_dim,ndims(100),nwild(100)
1111
logical :: ltmp,lfirst
12+
integer, allocatable :: idry_sta(:)
1213
real, allocatable :: wild0(:),wild(:,:),zcor(:,:),xsta(:),ysta(:),zsta(:)
1314
real :: a1d(1)
1415
integer :: iempty(nfiles)
@@ -20,7 +21,7 @@
2021

2122
open(9,file='station.in',status='old')
2223
read(9,*); read(9,*)nsta
23-
allocate(wild0(nsta),wild(nvrt,nsta),zcor(nvrt,nsta),xsta(nsta),ysta(nsta),zsta(nsta))
24+
allocate(wild0(nsta),wild(nvrt,nsta),zcor(nvrt,nsta),xsta(nsta),ysta(nsta),zsta(nsta),idry_sta(nsta))
2425
do i=1,nsta
2526
read(9,*)j,xsta(i),ysta(i),zsta(i)
2627
enddo !i
@@ -78,6 +79,11 @@
7879
j=nf90_def_var(ncid,'station_location_z',NF90_FLOAT,ndims(1),nwild(19))
7980
j=nf90_put_att(ncid,nwild(19),'name','Z coorinates at each station in meters')
8081

82+
!Dry flags
83+
ndims(1)=nsta_dim; ndims(2)=time_dim
84+
j=nf90_def_var(ncid,'Station_dry_flags',NF90_INT,ndims(1:2),nwild(20))
85+
j=nf90_put_att(ncid,nwild(20),'name','Non-zero if dry at station')
86+
8187
do i=1,19 !nfiles+1+6
8288
j=nf90_def_var_deflate(ncid,nwild(i),0,1,4)
8389
enddo !i
@@ -130,11 +136,11 @@
130136
nt0=0
131137
do it=1,ntime
132138
nt0=nt0+1
133-
!odd lines are empty for zcor
139+
!odd lines are dry flags for zcor
134140
if(i<=nfiles) then
135141
read(10,*,end=99,err=99)time,wild0(:)
136142
else !empty line for zcor
137-
read(10,*,end=99,err=99)
143+
read(10,*,end=99,err=99)idry_sta(:)
138144
endif
139145
if(i>4) then !3D (incl zcor)
140146
read(10,*,end=99,err=99)time,wild(:,:) !,zcor(:,:)
@@ -155,6 +161,7 @@
155161
endif !i
156162
else !zcor
157163
j=nf90_put_var(ncid,nwild(16),wild(:,:),(/1,1,nt0/),(/nvrt,nsta,1/))
164+
j=nf90_put_var(ncid,nwild(20),idry_sta,(/1,nt0/),(/nsta,1/))
158165
endif !i<=nfiles
159166
enddo !it=1,ntime
160167

0 commit comments

Comments
 (0)