! Copyright 2014 College of William and Mary ! ! Licensed under the Apache License, Version 2.0 (the "License"); ! you may not use this file except in compliance with the License. ! You may obtain a copy of the License at ! ! http://www.apache.org/licenses/LICENSE-2.0 ! ! Unless required by applicable law or agreed to in writing, software ! distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the License for the specific language governing permissions and ! limitations under the License. ! !**************************************************************************************** ! Read (combined or uncombined) nc outputs for multiple files at all nodes ! Works for mixed tri/quad outputs on NODE/ELEMENT based vars. ! Inputs: screen; combined or uncombined nc file; vgrid.in (in this dir or ../) ! Outputs: extract.out (ascii); optional: max/min/avg 2D output, with ! self-explanatory file names ! History: (1) added non-standard outputs (April 2012) - transparent to most scripts ! as format is same; (2) added ivcor=1 (Dec 2013); (3) ! added quads (Nov. 2014) (4) changed to nc outputs (Sept ! 2017); (5) added uncombined option (Feb 2019); (6) added special ! treatment on max_elev and other min/max/avg for other vars (Mar, ! 2020) !**************************************************************************************** ! ifort -O2 -assume byterecl -o read_output8_allnodes.exe ../UtilLib/extract_mod.f90 ../UtilLib/schism_geometry.f90 ../UtilLib/compute_zcor.f90 read_output8_allnodes.f90 -I$NETCDF/include -I$NETCDF_FORTRAN/include -L$NETCDF_FORTRAN/lib -L$NETCDF/lib -lnetcdf -lnetcdff ! ifort -g -assume byterecl -o read_output8_allnodes.exe ../UtilLib/extract_mod.f90 ../UtilLib/schism_geometry.f90 ../UtilLib/compute_zcor.f90 read_output8_allnodes.f90 -I$NETCDF/include -I$NETCDF_FORTRAN/include -L$NETCDF_FORTRAN/lib -L$NETCDF/lib -lnetcdf -lnetcdff program read_out use netcdf use extract_mod use schism_geometry_mod use compute_zcor ! parameter(nbyte=4) character(len=30) :: file63,varname,outname(3) character(len=12) :: it_char ! character*48 data_format ! integer,allocatable :: i34(:),elnode(:,:) integer :: nx(4,4,3) allocatable :: sigma(:),cs(:),ztot(:) allocatable :: outvar(:,:,:,:),out(:,:,:),icum(:,:,:),eta2(:,:),ztmp(:,:) allocatable :: xcj(:),ycj(:),dps(:),kbs(:),xctr(:),yctr(:),dpe(:),kbe(:) allocatable :: zs(:,:),ze(:,:),idry(:),outs(:,:,:),oute(:,:,:),rstat2d(:,:),rviolator(:) allocatable :: ic3(:,:),isdel(:,:),isidenode(:,:),kbp(:),sigma_lcl(:,:) integer, allocatable :: elside(:,:),idry_e(:),nne(:),indel(:,:),iviolator(:) real*8,allocatable :: timeout(:) integer :: icomp_stats(3) print*, 'Do you work on uncombined (0) or combined (1) nc?' read(*,*)icomb if(icomb==0) then print*,'<<<<k) nx(k,i,j)=nx(k,i,j)-k if(nx(k,i,j)<1.or.nx(k,i,j)>k) then write(*,*)'nx wrong',i,j,k,nx(k,i,j) stop endif enddo !j enddo !i enddo !k nne=0 do i=1,ne do j=1,i34(i) nd=elnode(j,i) nne(nd)=nne(nd)+1 enddo enddo mnei=maxval(nne) allocate(indel(mnei,np),stat=istat) if(istat/=0) stop 'Failed to alloc. indel' nne=0 do i=1,ne do j=1,i34(i) nd=elnode(j,i) nne(nd)=nne(nd)+1 if(nne(nd)>mnei) then write(*,*)'Too many neighbors',nd stop endif indel(nne(nd),nd)=i enddo enddo !i call compute_nside(np,ne,i34,elnode(1:4,1:ne),ns2) if(ns2/=ns) then write(*,*)'Mismatch in side:',ns2,ns stop endif allocate(ic3(4,ne),elside(4,ne),isdel(2,ns2),isidenode(2,ns2),xcj(ns2),ycj(ns2),stat=istat) if(istat/=0) stop 'Allocation error: side(0)' call schism_geometry_single(np,ne,ns2,real(x),real(y),i34,elnode(1:4,1:ne),ic3(1:4,1:ne), & &elside(1:4,1:ne),isdel,isidenode,xcj,ycj) !For dimensioning purpose if(np>ns.or.ne>ns) stop 'ns is not largest' if (inode_ele==0) then last_dim=np elseif (inode_ele==1) then last_dim=ne endif print*, '<<<<0) then idry_e(i)=0 else idry_e(i)=1 endif enddo !i do i=1,ne if(idry_e(i)==0) then !wet ifl=1 !isolated wet loop2: do j=1,i34(i) nd=elnode(j,i) do m=1,nne(nd) ie=indel(m,nd) if(i/=ne.and.idry_e(ie)==0) then ifl=0 exit loop2 endif enddo !m enddo loop2 !j if(ifl==0) then ! not isolated wet do j=1,i34(i) nd=elnode(j,i) tmp=outvar(1,1,nd,irec) if(tmp+dp(nd)>0) rstat2d(2,nd)=max(rstat2d(2,nd),tmp) enddo endif endif !idry_e enddo !i=1,ne else !other variables, or min_ele or avg_ele do i=1,last_dim if(ivs==2) then tmp=sqrt(outvar(1,1,i,irec)**2+outvar(2,1,i,irec)**2) else tmp=outvar(1,1,i,irec) endif if (icomp_stats(1)==1) then !min rstat2d(1,i)=min(rstat2d(1,i),tmp) endif if(icomp_stats(2)==1) then !max rstat2d(2,i)=max(rstat2d(2,i),tmp) endif if(icomp_stats(3)==1) then !min rstat2d(3,i)=tmp+rstat2d(3,i) endif enddo !i endif !is_elev endif ! icomp_stats else !if(i23d==3) then !3D !Compute z coordinates do i=1,last_dim if(ivcor==1) then !localized if(dp(i)+eta2(i,irec)<=h0) then idry(i)=1 else !wet idry(i)=0 do k=kbp(i),nvrt ztmp(k,i)=(eta2(i,irec)+dp(i))*sigma_lcl(k,i)+eta2(i,irec) enddo !k endif !wet/dry else if(ivcor==2) then !SZ call zcor_SZ_single(dp(i),eta2(i,irec),h0,h_s,h_c,theta_b,theta_f,kz,nvrt,ztot, & &sigma,ztmp(:,i),idry(i),kbpl) endif do k=max0(1,kbp00(i)),nvrt ! Output: time, node #, level #, z-coordinate, 3D variable if(idry(i)==1) then write(65,*)timeout(irec_real)/86400,i,k,-1.e6,(outvar(m,k,i,irec),m=1,ivs) else write(65,*)timeout(irec_real)/86400,i,k,ztmp(k,i),(outvar(m,k,i,irec),m=1,ivs) endif enddo !k !Debug !write(65,*)x(i),y(i),out(i,1,1:ivs) enddo !i endif !i23d enddo !irec if(irec2==nrec) exit loop1 irec1=irec1+nrec3 end do loop1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ enddo !iday nrec_total=nrec*(iday2-iday1+1) if(icomp_stats(3)==1) then rstat2d(3,:)=rstat2d(3,:)/real(nrec_total) endif print*, '<<<<