SUBROUTINE wrt_his (ng) ! !svn $Id: wrt_his.F 407 2009-11-02 21:27:07Z arango $ !================================================== Hernan G. Arango === ! Copyright (c) 2002-2009 The ROMS/TOMS Group ! ! Licensed under a MIT/X style license ! ! See License_ROMS.txt ! !======================================================================= ! ! ! This routine writes requested model fields at requested levels ! ! into history NetCDF file. ! ! ! !======================================================================= ! USE mod_param USE mod_parallel USE mod_bbl USE mod_coupling USE mod_forces USE mod_grid USE mod_iounits USE mod_mixing USE mod_ncparam USE mod_netcdf USE mod_ocean USE mod_scalars USE mod_sediment USE mod_stepping ! USE nf_fwrite2d_mod, ONLY : nf_fwrite2d USE nf_fwrite3d_mod, ONLY : nf_fwrite3d USE omega_mod, ONLY : scale_omega ! implicit none ! ! Imported variable declarations. ! integer, intent(in) :: ng ! ! Local variable declarations. ! integer :: LBi, UBi, LBj, UBj integer :: gfactor, gtype, status integer :: i, itrc, j, k, tile real(r8) :: scale real(r8), allocatable :: wrk(:,:,:) ! SourceFile='wrt_his.F' ! LBi=LBOUND(GRID(ng)%h,DIM=1) UBi=UBOUND(GRID(ng)%h,DIM=1) LBj=LBOUND(GRID(ng)%h,DIM=2) UBj=UBOUND(GRID(ng)%h,DIM=2) ! !----------------------------------------------------------------------- ! Write out history fields. !----------------------------------------------------------------------- ! IF (exit_flag.ne.NoError) RETURN ! ! Set grid type factor to write full (gfactor=1) fields or water ! points (gfactor=-1) fields only. ! gfactor=1 ! ! Set time record index. ! tHISindx(ng)=tHISindx(ng)+1 NrecHIS(ng)=NrecHIS(ng)+1 ! ! Write out model time (s). ! CALL netcdf_put_fvar (ng, iNLM, HISname(ng), & & TRIM(Vname(idtime,ng)), time(ng:), & & (/tHISindx(ng)/), (/1/), & & ncid = ncHISid(ng), & & varid = hisVid(idtime,ng)) IF (exit_flag.ne.NoError) RETURN ! ! Write out wet/dry mask at RHO-points. ! scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idRwet,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & GRID(ng) % rmask_wet, & & SetFillVal = .FALSE.) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idRwet)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out wet/dry mask at U-points. ! scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUwet,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % umask, & & GRID(ng) % umask_wet, & & SetFillVal = .FALSE.) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUwet)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out wet/dry mask at V-points. ! scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVwet,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % vmask, & & GRID(ng) % vmask_wet, & & SetFillVal = .FALSE.) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVwet)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out free-surface (m) ! IF (Hout(idFsur,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idFsur,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask_full, & & OCEAN(ng) % zeta(:,:,kstp(ng)), & & SetFillVal = .FALSE.) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idFsur)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D U-momentum component (m/s). ! IF (Hout(idUbar,ng)) THEN scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbar,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % umask_full, & & OCEAN(ng) % ubar(:,:,kstp(ng))) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbar)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D V-momentum component (m/s). ! IF (Hout(idVbar,ng)) THEN scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbar,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % vmask_full, & & OCEAN(ng) % vbar(:,:,kstp(ng))) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbar)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D U-momentum component (m/s). ! IF (Hout(idUvel,ng)) THEN scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idUvel,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & & GRID(ng) % umask_full, & & OCEAN(ng) % u(:,:,:,nrhs(ng))) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUvel)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D V-momentum component (m/s). ! IF (Hout(idVvel,ng)) THEN scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idVvel,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & & GRID(ng) % vmask_full, & & OCEAN(ng) % v(:,:,:,nrhs(ng))) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVvel)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out S-coordinate omega vertical velocity (m/s). ! IF (Hout(idOvel,ng)) THEN IF (.not.allocated(wrk)) THEN allocate (wrk(LBi:UBi,LBj:UBj,0:N(ng))) wrk(LBi:UBi,LBj:UBj,0:N(ng))=0.0_r8 END IF scale=1.0_r8 gtype=gfactor*w3dvar DO tile=0,NtileX(ng)*NtileE(ng)-1 CALL scale_omega (ng, MyRank, LBi, UBi, LBj, UBj, 0, N(ng), & & GRID(ng) % pm, & & GRID(ng) % pn, & & OCEAN(ng) % W, & & wrk) END DO status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idOvel,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask_full, & & wrk) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idOvel)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF deallocate (wrk) END IF ! ! Write out vertical velocity (m/s). ! IF (Hout(idWvel,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idWvel,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask_full, & & OCEAN(ng) % wvel) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idWvel)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out tracer type variables. ! DO itrc=1,NT(ng) IF (Hout(idTvar(itrc),ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisTid(itrc,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & & GRID(ng) % rmask, & & OCEAN(ng) % t(:,:,:,nrhs(ng),itrc)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTvar(itrc))), & & tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO ! ! Write out density anomaly. ! IF (Hout(idDano,ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idDano,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & & GRID(ng) % rmask, & & OCEAN(ng) % rho) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idDano)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out vertical viscosity coefficient. ! IF (Hout(idVvis,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idVvis,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask_full, & & MIXING(ng) % Akv) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVvis)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out vertical diffusion coefficient for potential temperature. ! IF (Hout(idTdif,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idTdif,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask, & & MIXING(ng) % Akt(:,:,:,itemp)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTdif)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out vertical diffusion coefficient for salinity. ! IF (Hout(idSdif,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idSdif,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask, & & MIXING(ng) % Akt(:,:,:,isalt)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idSdif)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out turbulent kinetic energy. ! IF (Hout(idMtke,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idMtke,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask, & & MIXING(ng) % tke(:,:,:,nrhs(ng))) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idMtke)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out turbulent length scale field. ! IF (Hout(idMtls,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), hisVid(idMtls,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & & GRID(ng) % rmask, & & MIXING(ng) % gls(:,:,:,nrhs(ng))) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idMtls)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out surface active traces fluxes. ! DO itrc=1,NAT IF (Hout(idTsur(itrc),ng)) THEN IF (itrc.eq.itemp) THEN scale=rho0*Cp ! Celsius m/s to W/m2 ELSE IF (itrc.eq.isalt) THEN scale=1.0_r8 END IF gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), & & hisVid(idTsur(itrc),ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % stflx(:,:,itrc)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTsur(itrc))), & & tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO ! ! Write out latent heat flux. ! IF (Hout(idLhea,ng)) THEN scale=rho0*Cp gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idLhea,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % lhflx) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idLhea)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out sensible heat flux. ! IF (Hout(idShea,ng)) THEN scale=rho0*Cp gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idShea,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % shflx) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idShea)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out longwave radiation flux. ! IF (Hout(idLrad,ng)) THEN scale=rho0*Cp gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idLrad,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % lrflx) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idLrad)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out shortwave radiation flux. ! IF (Hout(idSrad,ng)) THEN scale=rho0*Cp gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idSrad,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % srflx) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idSrad)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out surface U-momentum stress. ! IF (Hout(idUsms,ng)) THEN scale=rho0 ! m2/s2 to Pa gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUsms,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % umask, & & FORCES(ng) % sustr) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUsms)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out surface V-momentum stress. ! IF (Hout(idVsms,ng)) THEN scale=rho0 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVsms,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % vmask, & & FORCES(ng) % svstr) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVsms)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bottom U-momentum stress. ! IF (Hout(idUbms,ng)) THEN scale=-rho0 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbms,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % umask, & & FORCES(ng) % bustr) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbms)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bottom V-momentum stress. ! IF (Hout(idVbms,ng)) THEN scale=-rho0 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbms,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % vmask, & & FORCES(ng) % bvstr) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbms)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out current-induced, bottom U-stress at RHO-points. ! IF (Hout(idUbrs,ng)) THEN scale=-rho0 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbrs,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % bustrc) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbrs)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out current-induced, bottom V-stress at RHO-points. ! IF (Hout(idVbrs,ng)) THEN scale=-rho0 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbrs,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % bvstrc) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbrs)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out wind-induced, bottom U-stress at RHO-points. ! IF (Hout(idUbws,ng)) THEN scale=rho0 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbws,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % bustrw) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbws)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out wind-induced, bottom V-stress at RHO-points. ! IF (Hout(idVbws,ng)) THEN scale=rho0 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbws,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % bvstrw) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbws)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out maximum wind and current, bottom U-stress at RHO-points. ! IF (Hout(idUbcs,ng)) THEN scale=rho0 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbcs,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % bustrcwmax) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbcs)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out maximum wind and current, bottom V-stress at RHO-points. ! IF (Hout(idVbcs,ng)) THEN scale=rho0 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbcs,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % bvstrcwmax) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbcs)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out wind-induced, bed wave orbital U-velocity at RHO-points. ! IF (Hout(idUbot,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbot,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % Ubot) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbot)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out wind-induced, bed wave orbital V-velocity at RHO-points ! IF (Hout(idVbot,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbot,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % Vbot) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbot)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bottom U-velocity above bed at RHO-points. ! IF (Hout(idUbur,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idUbur,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % Ur) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbur)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bottom V-velocity above bed at RHO-points. ! IF (Hout(idVbvr,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idVbvr,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & BBL(ng) % Vr) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbvr)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out sediment fraction of each size class in each bed layer. ! DO i=1,NST IF (Hout(idfrac(i),ng)) THEN scale=1.0_r8 gtype=gfactor*b3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), & & hisVid(idfrac(i),ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, Nbed, scale, & & GRID(ng) % rmask, & & OCEAN(ng) % bed_frac(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idfrac(i))), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO ! ! Write out sediment mass of each size class in each bed layer. ! DO i=1,NST IF (Hout(idBmas(i),ng)) THEN scale=1.0_r8 gtype=gfactor*b3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), & & hisVid(idBmas(i),ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, Nbed, scale, & & GRID(ng) % rmask, & & OCEAN(ng) % bed_mass(:,:,:,nrhs(ng),i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idBmas(i))), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO ! ! Write out sediment properties in each bed layer. ! DO i=1,MBEDP IF (Hout(idSbed(i),ng)) THEN scale=1.0_r8 gtype=gfactor*b3dvar status=nf_fwrite3d(ng, iNLM, ncHISid(ng), & & hisVid(idSbed(i),ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, Nbed, scale, & & GRID(ng) % rmask, & & OCEAN(ng) % bed(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idSbed(i))), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO ! ! Write out exposed sediment layer properties. ! DO i=1,MBOTP IF (Hout(idBott(i),ng)) THEN IF (i.eq.itauc) THEN scale=rho0 ELSE scale=1.0_r8 END IF gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), & & hisVid(idBott(i),ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & OCEAN(ng) % bottom(:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idBott(i))), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO ! ! Write out wind-induced wave height. ! IF (Hout(idWamp,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idWamp,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % Hwave) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idWamp)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out wind-induced wave length. ! IF (Hout(idWlen,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idWlen,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % Lwave) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idWlen)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out wind-induced wave direction. ! IF (Hout(idWdir,ng)) THEN scale=rad2deg gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncHISid(ng), hisVid(idWdir,ng), & & tHISindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & & GRID(ng) % rmask, & & FORCES(ng) % Dwave) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idWdir)), tHISindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! !----------------------------------------------------------------------- ! Synchronize history NetCDF file to disk to allow other processes ! to access data immediately after it is written. !----------------------------------------------------------------------- ! CALL netcdf_sync (ng, iNLM, HISname(ng), ncHISid(ng)) IF (exit_flag.ne.NoError) RETURN IF (Master) WRITE (stdout,20) kstp(ng), nrhs(ng), tHISindx(ng) ! 10 FORMAT (/,' WRT_HIS - error while writing variable: ',a,/,11x, & & 'into history NetCDF file for time record: ',i4) 20 FORMAT (6x,'WRT_HIS - wrote history fields (Index=', i1, & & ',',i1,') into time record = ',i7.7) RETURN END SUBROUTINE wrt_his