#include "cppdefs.h" #ifdef AVERAGES SUBROUTINE wrt_avg (ng) ! !svn $Id: wrt_avg.F 331 2009-03-12 00:34:51Z arango $ !================================================== Hernan G. Arango === ! Copyright (c) 2002-2009 The ROMS/TOMS Group ! ! Licensed under a MIT/X style license ! ! See License_ROMS.txt ! !======================================================================= ! ! ! This subroutine writes model time-averaged fields into averages ! ! NetCDF file. ! ! ! !======================================================================= ! USE mod_param USE mod_parallel USE mod_average USE mod_forces USE mod_grid USE mod_iounits USE mod_ncparam USE mod_netcdf USE mod_scalars # if defined SEDIMENT || defined BBL_MODEL USE mod_sediment # endif # if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES) USE mod_tides # endif ! USE nf_fwrite2d_mod, ONLY : nf_fwrite2d # ifdef SOLVE3D USE nf_fwrite3d_mod, ONLY : nf_fwrite3d # endif ! implicit none ! ! Imported variable declarations. ! integer, intent(in) :: ng ! ! Local variable declarations. ! integer :: LBi, UBi, LBj, UBj integer :: gfactor, gtype, i, itrc, status real(r8) :: scale ! SourceFile='wrt_avg.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 time-averaged fields when appropriate. !----------------------------------------------------------------------- ! if (exit_flag.ne.NoError) RETURN ! ! Set grid type factor to write full (gfactor=1) fields or water ! points (gfactor=-1) fields only. ! # if defined WRITE_WATER && defined MASKING gfactor=-1 # else gfactor=1 # endif ! ! Set time record index. ! tAVGindx(ng)=tAVGindx(ng)+1 NrecAVG(ng)=NrecAVG(ng)+1 ! ! Write out averaged time. ! CALL netcdf_put_fvar (ng, iNLM, AVGname(ng), & & TRIM(Vname(idtime,ng)), AVGtime(ng:), & & (/tAVGindx(ng)/), (/1/), & & ncid = ncAVGid(ng), & & varid = avgVid(idtime,ng)) IF (exit_flag.ne.NoError) RETURN ! ! Write out free-surface (m). ! IF (Hout(idFsur,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idFsur,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif # ifdef WET_DRY & AVERAGE(ng) % avgzeta, & & SetFillVal = .FALSE.) # else & AVERAGE(ng) % avgzeta) # endif IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idFsur)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES) ! ! Write out detided free-surface (m). ! scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idFsuD,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & TIDES(ng) % zeta_detided) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idFsuD)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif ! ! Write out 2D momentum component (m/s) in the XI-direction. ! IF (Hout(idUbar,ng)) THEN scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idUbar,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgu2d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbar)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES) ! ! Write out detided 2D momentum component (m/s) in the XI-direction. ! scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idu2dD,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & TIDES(ng) % ubar_detided) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idu2dD)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif ! ! Write out 2D momentum component (m/s) in the ETA-direction. ! IF (Hout(idVbar,ng)) THEN scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idVbar,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgv2d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbar)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES) ! ! Write out detided 2D momentum component (m/s) in the ETA-direction. ! scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idv2dD,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & TIDES(ng) % vbar_detided) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idv2dD)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # if defined FORWARD_WRITE && defined SOLVE3D ! ! Write out time-averaged mass fluxes for 3D momentum coupling. ! scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idUfx1,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgDU_avg1) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUfx1)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idUfx2,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgDU_avg2) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUfx2)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idVfx1,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgDV_avg1) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVfx1)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idVfx2,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgDV_avg2) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVfx2)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # ifdef AVERAGES_NEARSHORE ! ! Write out 2D radiation stress, Sxx-component. ! IF (Hout(idW2xx,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idW2xx,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSxx2d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW2xx)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D radiation stress, Sxy-component. ! IF (Hout(idW2xy,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idW2xy,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSxy2d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW2xy)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D radiation stress, Syy-component. ! IF (Hout(idW2yy,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idW2yy,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSyy2d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW2yy)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D radiation stress in the XI-direction. ! IF (Hout(idU2rs,ng)) THEN scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idU2rs,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgu2RS) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idU2rs)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D radiation stress in the ETA-direction ! IF (Hout(idV2rs,ng)) THEN scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idV2rs,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgv2RS) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idV2rs)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D stokes momentum component (m/s) in the XI-direction. ! IF (Hout(idU2Sd,ng)) THEN scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idU2Sd,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgu2Sd) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idU2Sd)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 2D stokes momentum component (m/s) in the ETA-direction. ! IF (Hout(idV2Sd,ng)) THEN scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idV2Sd,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgv2Sd) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idV2Sd)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif # ifdef SOLVE3D ! ! Write out 3D momentum component (m/s) in the XI-direction. ! IF (Hout(idUvel,ng)) THEN scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idUvel,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgu3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUvel)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES) ! ! Write out detided 3D momentum component (m/s) in the XI-direction. ! scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idu3dD,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & TIDES(ng) % u_detided) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idu3dD)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif ! ! Write out 3D momentum component (m/s) in the ETA-direction. ! IF (Hout(idVvel,ng)) THEN scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idVvel,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgv3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVvel)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # if defined AVERAGES_DETIDE && (defined SSH_TIDES || defined UV_TIDES) ! ! Write out detided 3D momentum component (m/s) in the ETA-direction. ! scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idv3dD,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & TIDES(ng) % v_detided) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idv3dD)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # ifdef AVERAGES_NEARSHORE ! ! Write out 3D radiation stress, Sxx-component. ! IF (Hout(idW3xx,ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idW3xx,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSxx3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW3xx)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D radiation stress, Sxy-component. ! IF (Hout(idW3xy,ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idW3xy,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSxy3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW3xy)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D radiation stress, Syy-component. ! IF (Hout(idW3yy,ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idW3yy,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSyy3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW3yy)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D radiation stress, Szx-component. ! IF (Hout(idW3zx,ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idW3zx,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSzx3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW3zx)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D radiation stress, Szy-component. ! IF (Hout(idW3zy,ng)) THEN scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idW3zy,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgSzy3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idW3zy)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D radiation stress in the XI-direction, u_Rstress. ! IF (Hout(idU3rs,ng)) THEN scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idU3rs,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgu3RS) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idU3rs)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D radiation stress in the ETA-direction, v_Rstress. ! IF (Hout(idV3rs,ng)) THEN scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idV3rs,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgv3RS) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idV3rs)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D stokes momentum component (m/s) in the XI-direction. ! IF (Hout(idU3Sd,ng)) THEN scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idU3Sd,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgu3Sd) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idU3Sd)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out 3D stokes momentum component (m/s) in the ETA-direction. ! IF (Hout(idV3Sd,ng)) THEN scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idV3Sd,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgv3Sd) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idV3Sd)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif ! ! Write out S-coordinate omega vertical velocity (m/s). ! IF (Hout(idOvel,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idOvel,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgw3d) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idOvel)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out "true" vertical velocity (m/s). ! IF (Hout(idWvel,ng)) THEN scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idWvel,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgwvel) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idOvel)), tAVGindx(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, ncAVGid(ng), avgTid(itrc,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgt(:,:,:,itrc)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTvar(itrc))), & & tAVGindx(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, ncAVGid(ng), avgVid(idDano,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgrho) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idDano)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # ifdef LMD_SKPP ! ! Write out depth of surface boundary layer. ! IF (Hout(idHsbl,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idHsbl,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avghsbl) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idHsbl)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif # ifdef LMD_BKPP ! ! Write out depth of bottom boundary layer. ! IF (Hout(idHbbl,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idHbbl,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avghbbl) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idHbbl)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif # endif # ifdef AVERAGES_QUADRATIC ! ! Write out quadratic term. ! scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idZZav,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgZZ) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idZZav)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out quadratic term. ! scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idU2av,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgU2) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idU2av)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out quadratic term. ! scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idV2av,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgV2) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idV2av)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # ifdef SOLVE3D # ifdef AVERAGES_QUADRATIC ! ! Write u-volume flux. ! scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idHUav,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgHuon) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idHUav)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write v-volume flux. ! scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idHVav,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgHvom) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idHVav)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out quadratic term. ! scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idUUav,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgUU) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUUav)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out quadratic term. ! scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idUVav,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgUV) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUVav)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out quadratic term. ! scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idVVav,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgVV) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVVav)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! ! Write out quadratic term. ! DO i=1,NAT scale=1.0_r8 gtype=gfactor*r3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idTTav(i),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgTT(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTTav(i))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END DO ! ! Write out active tracer volume fluxes. ! DO i=1,NAT scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(iHUTav(i),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgHuonT(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,iHUTav(i))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(iHVTav(i),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgHvomT(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,iHVTav(i))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END DO ! ! Write out quadratic and terms. ! DO i=1,NAT scale=1.0_r8 gtype=gfactor*u3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idUTav(i),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgUT(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUTav(i))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF ! scale=1.0_r8 gtype=gfactor*v3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idVTav(i),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 1, N(ng), scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgVT(:,:,:,i)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVTav(i))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END DO # endif # ifdef AVERAGES_AKV ! ! Write out vertical viscosity coefficient. ! scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idVvis,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgAKv) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVvis)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # ifdef AVERAGES_AKT ! ! Write out vertical diffusion coefficient for potential temperature. ! scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idTdif,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgAKt) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTdif)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # ifdef AVERAGES_AKS ! ! Write out vertical diffusion coefficient for salinity. ! scale=1.0_r8 gtype=gfactor*w3dvar status=nf_fwrite3d(ng, iNLM, ncAVGid(ng), avgVid(idSdif,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, 0, N(ng), scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgAKs) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idSdif)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF # endif # ifdef AVERAGES_FLUXES ! ! Write out surface net heat flux. ! IF (Hout(idTsur(itemp),ng)) THEN # ifdef ADJOINT # if defined AD_SENSITIVITY || defined OBS_SENSITIVITY || \ defined OPT_OBSERVATIONS scale=1.0_r8/(rho0*Cp) # else scale=1.0_r8 # endif # else scale=rho0*Cp # endif gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), & & avgVid(idTsur(itemp),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgstf) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTsur(itemp))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out surface salt flux (PSU m/s = kg salt/m2/s). ! IF (Hout(idTsur(isalt),ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), & & avgVid(idTsur(isalt),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgswf) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idTsur(isalt))), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # ifdef BULK_FLUXES ! ! Write out latent heat flux. ! IF (Hout(idLhea,ng)) THEN # ifdef ADJOINT scale=1.0_r8 # else scale=rho0*Cp # endif gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idLhea,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avglhf) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idLhea)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out sensible heat flux. ! IF (Hout(idShea,ng)) THEN # ifdef ADJOINT scale=1.0_r8 # else scale=rho0*Cp # endif gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idShea,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgshf) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idShea)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out longwave radiation flux. ! IF (Hout(idLrad,ng)) THEN # ifdef ADJOINT scale=1.0_r8 # else scale=rho0*Cp # endif gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idLrad,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avglrf) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idLrad)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # ifdef EMINUSP ! ! Write out evaportaion rate (kg/m2/s). ! IF (Hout(idevap,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idevap,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgevap) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idevap)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out precipitation rate (kg/m2/s). ! IF (Hout(idrain,ng)) THEN scale=1.0_r8 gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idrain,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgrain) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idrain)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif # endif # ifdef SHORTWAVE ! ! Write out shortwave radiation flux. ! IF (Hout(idSrad,ng)) THEN # ifdef ADJOINT scale=1.0_r8 # else scale=rho0*Cp # endif gtype=gfactor*r2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idSrad,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % rmask, & # endif & AVERAGE(ng) % avgsrf) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idSrad)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif # endif # endif # ifdef AVERAGES_FLUXES ! ! Write out surface u-momentun stress. ! IF (Hout(idUsms,ng)) THEN # ifdef ADJOINT # if defined AD_SENSITIVITY || defined OBS_SENSITIVITY || \ defined OPT_OBSERVATIONS scale=1.0_r8/rho0 # else scale=1.0_r8 # endif # else scale=rho0 # endif gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idUsms,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgsus) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUsms)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out surface v-momentun stress. ! IF (Hout(idVsms,ng)) THEN # ifdef ADJOINT # if defined AD_SENSITIVITY || defined OBS_SENSITIVITY || \ defined OPT_OBSERVATIONS scale=1.0_r8/rho0 # else scale=1.0_r8 # endif # else scale=rho0 # endif gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idVsms,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgsvs) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVsms)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bottom u-momentun stress. ! IF (Hout(idUbms,ng)) THEN # ifdef ADJOINT # if defined AD_SENSITIVITY || defined OBS_SENSITIVITY || \ defined OPT_OBSERVATIONS scale=1.0_r8/rho0 # else scale=1.0_r8 # endif # else scale=rho0 # endif gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idUbms,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgbus) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbms)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bottom v-momentun stress. ! IF (Hout(idVbms,ng)) THEN # ifdef ADJOINT # if defined AD_SENSITIVITY || defined OBS_SENSITIVITY || \ defined OPT_OBSERVATIONS scale=1.0_r8/rho0 # else scale=1.0_r8 # endif # else scale=rho0 # endif gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), avgVid(idVbms,ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgbvs) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbms)), tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF # endif # if defined SEDIMENT && defined BEDLOAD ! ! Write out bed load transport in U-direction. ! DO itrc=1,NST IF (Hout(idUbld(itrc),ng)) THEN scale=1.0_r8 gtype=gfactor*u2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), & & avgVid(idUbld(itrc),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % umask, & # endif & AVERAGE(ng) % avgbedldu(:,:,itrc)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idUbld(itrc))), & & tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF ! ! Write out bed load transport in V-direction. ! IF (Hout(idVbld(itrc),ng)) THEN scale=1.0_r8 gtype=gfactor*v2dvar status=nf_fwrite2d(ng, iNLM, ncAVGid(ng), & & avgVid(idVbld(itrc),ng), & & tAVGindx(ng), gtype, & & LBi, UBi, LBj, UBj, scale, & # ifdef MASKING & GRID(ng) % vmask, & # endif & AVERAGE(ng) % avgbedldv(:,:,itrc)) IF (status.ne.nf90_noerr) THEN IF (Master) THEN WRITE (stdout,10) TRIM(Vname(1,idVbld(itrc))), & & tAVGindx(ng) END IF exit_flag=3 ioerror=status RETURN END IF END IF END DO # endif ! !----------------------------------------------------------------------- ! Synchronize time-average NetCDF file to disk to allow other processes ! to access data immediately after it is written. !----------------------------------------------------------------------- ! CALL netcdf_sync (ng, iNLM, AVGname(ng), ncAVGid(ng)) IF (exit_flag.ne.NoError) RETURN IF (Master) WRITE (stdout,20) tAVGindx(ng) ! 10 FORMAT (/,' WRT_AVG - error while writing variable: ',a,/,11x, & & 'into averages NetCDF file for time record: ',i4) 20 FORMAT (6x,'WRT_AVG - wrote averaged fields into time ', & & 'record =',t72,i7.7) #else SUBROUTINE wrt_avg #endif RETURN END SUBROUTINE wrt_avg