From f3fd2c3fc92787b9a7c5e209335b52c5956b7415 Mon Sep 17 00:00:00 2001 From: jmaerz <92309038+jmaerz@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:43:49 +0200 Subject: [PATCH] Add lon,lat info in iHAMOCC output to more comply to cdo commands (#355) * Write plon, plat info to BGC output to become more cdo compliant --- hamocc/mo_ncout_hamocc.F90 | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/hamocc/mo_ncout_hamocc.F90 b/hamocc/mo_ncout_hamocc.F90 index 98073b3c..4e794472 100644 --- a/hamocc/mo_ncout_hamocc.F90 +++ b/hamocc/mo_ncout_hamocc.F90 @@ -31,14 +31,14 @@ subroutine ncwrt_bgc(iogrp) ! ********************************************************************************************** use mod_time, only: date0,date,calendar,nstep,nstep_in_day,nday_of_year,time0,time - use mod_xc, only: kdm,mnproc,itdm,jtdm,lp - use mod_grid, only: depths + use mod_xc, only: kdm,mnproc,itdm,jtdm,lp,idm,jdm,nbdy + use mod_grid, only: depths,plat,plon use mod_dia, only: diafnm,sigmar1,iotype,ddm,depthslev,depthslev_bnds use mo_control_bgc, only: dtbgc,use_cisonew,use_AGG,use_CFC,use_natDIC,use_BROMO, & use_sedbypass,use_BOXATM,use_M4AGO,use_extNcycle use mo_vgrid, only: k0100,k0500,k1000,k2000,k4000 use mo_param1_bgc, only: ks - use mod_nctools, only: ncwrt1,ncdims,nctime,ncfcls,ncfopn,ncdimc,ncputr,ncputi + use mod_nctools, only: ncwrt1,ncdims,nctime,ncfcls,ncfopn,ncdimc,ncputr,ncputi,ncwrtr use mo_bgcmean, only: domassfluxes,flx_ndepnoy,flx_oalk, & flx_cal0100,flx_cal0500,flx_cal1000, & flx_cal2000,flx_cal4000,flx_cal_bot, & @@ -221,6 +221,7 @@ subroutine ncwrt_bgc(iogrp) character(len=20) :: startdate character(len=30) :: timeunits real :: datenum,rnacc + integer,dimension(2,2) :: dummy data append2file /nbgcmax*.false./ @@ -294,6 +295,14 @@ subroutine ncwrt_bgc(iogrp) call ncwrt1('sigma','sigma',sigmar1) call ncwrt1('depth','depth',depthslev) call ncwrt1('depth_bnds','bounds depth',depthslev_bnds) + dummy = 0 + if (cmpflg.ne.0) then + call ncwrtr('plon','pcomp',plon(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),dummy,0,1.,0.,8) + call ncwrtr('plat','pcomp',plat(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),dummy,0,1.,0.,8) + else + call ncwrtr('plon','x y',plon(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),dummy,0,1.,0.,8) + call ncwrtr('plat','x y',plat(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy),dummy,0,1.,0.,8) + endif ! --- finalize accumulation call finlyr(jphyto(iogrp),jdp(iogrp)) @@ -1346,6 +1355,22 @@ subroutine hamoccvardef(iogrp,timeunits,calendar,cmpflg) call ncattr('positive','down') call ncattr('bounds','depth_bnds') call ncdefvar('depth_bnds','bounds depth',ndouble,8) + + if (cmpflg == 1) then + call ncdefvar('plon','pcomp',ndouble,0) + else + call ncdefvar('plon','x y',ndouble,0) + endif + call ncattr('long_name','longitude') + call ncattr('units','degrees_east') + if (cmpflg == 1) then + call ncdefvar('plat','pcomp',ndouble,0) + else + call ncdefvar('plat','x y',ndouble,0) + endif + call ncattr('long_name','latitude') + call ncattr('units','degrees_north') + call ncdefvar3d(SRF_KWCO2(iogrp),cmpflg,'p', & & 'kwco2','CO2 piston velocity',' ','m s-1',0) call ncdefvar3d(SRF_KWCO2KHM(iogrp),cmpflg,'p', &