Commit ffbe2240 authored by Sabine's avatar Sabine
Browse files

first version for fluxoutput in netcdf

parent 95a8cb6c
......@@ -205,13 +205,16 @@ subroutine init_domainfill
if (ztra1(numpart+jj).gt.height(nz)-0.5) &
! Interpolate PV to the particle position
if ( then
write (*,*) 'init_domainfill, over: ',jyp,jym,ytra1(numpart+jj),jy,ran1(idummy),ny
......@@ -32,10 +32,10 @@ module netcdf_output_mod
use outg_mod, only: outheight,oroout,densityoutgrid,factor3d,volume,&
area,arean,volumen, orooutn
area,arean,volumen, orooutn, areaeast
use par_mod, only: dep_prec, sp, dp, maxspec, maxreceptor, nclassunc,&
unitoutrecept,unitoutreceptppt, nxmax,unittmp
use com_mod, only: path,length,ldirect,ibdate,ibtime,iedate,ietime, &
use com_mod, only: path,length,ldirect,bdate,ibdate,ibtime,iedate,ietime, &
numxgrid,numygrid,dxout,dyout,numzgrid, height, &
outlon0n,outlat0n,dxoutn,dyoutn,numxgridn,numygridn, &
......@@ -62,7 +62,7 @@ module netcdf_output_mod
public :: writeheader_netcdf,concoutput_surf_nest_netcdf,concoutput_netcdf,&
! include ''
......@@ -1423,6 +1423,159 @@ subroutine concoutput_surf_nest_netcdf(itime,outnum)
end subroutine concoutput_surf_nest_netcdf
subroutine fluxoutput_netcdf(itime)
! i
! *
! Output of the gridded fluxes. *
! Eastward, westward, northward, southward, upward and downward gross *
! fluxes are written to output file in either sparse matrix or grid dump *
! format, whichever is more efficient. *
! *
! Author: A. Stohl *
! *
! 04 April 2000 *
! netcdfoutput S. Eckhardt, 2020 *
! *
use flux_mod
implicit none
real(kind=dp) :: jul
integer :: itime,ix,jy,kz,ks,nage,jjjjmmdd,ihmmss,kp,i
character(len=255) :: ncfname
character :: adate*8,atime*6,timeunit*32,anspec*3
integer :: ncid
integer :: timeDimID, latDimID, lonDimID, levDimID
integer :: nspecDimID, npointDimID, nageclassDimID, ncharDimID, pointspecDimID
integer :: tID, lonID, latID, levID, lageID, fluxID
integer, dimension(6) :: dIDs
integer :: cache_size
real, allocatable, dimension(:) :: coord
! Determine current calendar date, needed for the file name
call caldate(jul,jjjjmmdd,ihmmss)
write(adate,'(i8.8)') jjjjmmdd
write(atime,'(i6.6)') ihmmss
ncfname=path(2)(1:length(2))//'grid_flux_'//adate// &
! setting cache size in bytes. It is set to 4 times the largest data block that is written
! size_type x nx x ny x nz
! create file
cache_size = 16 * numxgrid * numygrid * numzgrid
call nf90_err(nf90_create(trim(ncfname), cmode = nf90_hdf5, ncid = ncid, &
cache_size = cache_size))
! create dimensions:
! time
call nf90_err(nf90_def_dim(ncid, 'time', nf90_unlimited, timeDimID))
timeunit = 'seconds since '//adate(1:4)//'-'//adate(5:6)// &
'-'//adate(7:8)//' '//atime(1:2)//':'//atime(3:4)
call nf90_err(nf90_def_dim(ncid, 'longitude', numxgrid, lonDimID))
call nf90_err(nf90_def_dim(ncid, 'latitude', numygrid, latDimID))
call nf90_err(nf90_def_dim(ncid, 'height', numzgrid, levDimID))
call nf90_err(nf90_def_dim(ncid, 'numspec', nspec, nspecDimID))
call nf90_err(nf90_def_dim(ncid, 'pointspec', maxpointspec_act, pointspecDimID))
call nf90_err(nf90_def_dim(ncid, 'nageclass', nageclass, nageclassDimID))
call nf90_err(nf90_def_dim(ncid, 'nchar', 45, ncharDimID))
call nf90_err(nf90_def_dim(ncid, 'numpoint', numpoint, npointDimID))
! create variables
! time
call nf90_err(nf90_def_var(ncid, 'time', nf90_int, (/ timeDimID /), tID))
call nf90_err(nf90_put_att(ncid, tID, 'units', timeunit))
call nf90_err(nf90_put_att(ncid, tID, 'calendar', 'proleptic_gregorian'))
timeID = tID
! lon
call nf90_err(nf90_def_var(ncid, 'longitude', nf90_float, (/ lonDimID /), lonID))
call nf90_err(nf90_put_att(ncid, lonID, 'long_name', 'longitude in degree east'))
call nf90_err(nf90_put_att(ncid, lonID, 'axis', 'Lon'))
call nf90_err(nf90_put_att(ncid, lonID, 'units', 'degrees_east'))
call nf90_err(nf90_put_att(ncid, lonID, 'standard_name', 'grid_longitude'))
call nf90_err(nf90_put_att(ncid, lonID, 'description', 'grid cell centers'))
! lat
call nf90_err(nf90_def_var(ncid, 'latitude', nf90_float, (/ latDimID /), latID))
call nf90_err(nf90_put_att(ncid, latID, 'long_name', 'latitude in degree north'))
call nf90_err(nf90_put_att(ncid, latID, 'axis', 'Lat'))
call nf90_err(nf90_put_att(ncid, latID, 'units', 'degrees_north'))
call nf90_err(nf90_put_att(ncid, latID, 'standard_name', 'grid_latitude'))
call nf90_err(nf90_put_att(ncid, latID, 'description', 'grid cell centers'))
! height
call nf90_err(nf90_def_var(ncid, 'height', nf90_float, (/ levDimID /), levID))
call nf90_err(nf90_put_att(ncid, levID, 'units', 'meters'))
call nf90_err(nf90_put_att(ncid, levID, 'positive', 'up'))
call nf90_err(nf90_put_att(ncid, levID, 'standard_name', 'height'))
if (.not.allocated(coord)) allocate(coord(numxgrid))
do i = 1,numxgrid
coord(i) = outlon0 + (i-0.5)*dxout
call nf90_err(nf90_put_var(ncid, lonID, coord(1:numxgrid)))
if (.not.allocated(coord)) allocate(coord(numygrid))
do i = 1,numygrid
coord(i) = outlat0 + (i-0.5)*dyout
call nf90_err(nf90_put_var(ncid, latID, coord(1:numygrid)))
call nf90_err(nf90_put_var(ncid, levID, outheight(1:numzgrid)))
! write time, one field per time - different to the others!
call nf90_err(nf90_put_var( ncid, timeID, itime, (/ 1 /)))
dIDs = (/ londimid, latdimid, levdimid, timedimid, pointspecdimid, nageclassdimid /)
do ks=1,nspec
do kp=1,maxpointspec_act
do nage=1,nageclass
write(anspec,'(i3.3)') ks
! East Flux
call nf90_err(nf90_def_var(ncid,'flux_east_'//anspec, nf90_float, dIDs, &
do jy=0,numygrid-1
do ix=0,numxgrid-1
do kz=1, numzgrid
end do
end do
end do
call nf90_err(nf90_put_var(ncid,fluxid,1.e12*grid(0:numxgrid-1,0:numygrid-1,1:numzgrid)&
(/ 1,1,1,tpointer,kp,nage /), (/ numxgrid,numygrid,numzgrid,1,1,1 /) ))
end do
end do
end do
! Close netCDF file
call nf90_err(nf90_close(ncid))
end subroutine fluxoutput_netcdf
end module netcdf_output_mod
......@@ -81,7 +81,7 @@ subroutine timemanager(metdata_format)
use com_mod
#ifdef USE_NCF
use netcdf_output_mod, only: concoutput_netcdf,concoutput_nest_netcdf,&
implicit none
......@@ -428,7 +428,8 @@ subroutine timemanager(metdata_format)
if ((iout.eq.4).or.(iout.eq.5)) call plumetraj(itime)
if (iflux.eq.1) call fluxoutput(itime)
if ((iflux.eq.1).and.(lnetcdfout.eq.0)) call fluxoutput(itime)
if ((iflux.eq.1).and.(lnetcdfout.eq.1)) call fluxoutput_netcdf(itime)
write(*,45) itime,numpart,gridtotalunc,wetgridtotalunc,drygridtotalunc
!CGZ-lifetime: output species lifetime
......@@ -535,7 +535,8 @@ subroutine timemanager(metdata_format)
if ((iout.eq.4).or.(iout.eq.5)) call plumetraj(itime)
if (iflux.eq.1) call fluxoutput(itime)
if ((iflux.eq.1).and.(lnetcdfout.eq.0)) call fluxoutput(itime)
if ((iflux.eq.1).and.(lnetcdfout.eq.1)) call fluxoutput_netcdf(itime)
if (mp_measure_time) call mpif_mtime('iotime',1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment