subroutine stats_exit use modstat_nc, only : exitstat_nc implicit none if(.not.(lstatsdump .or. ltreedump)) return if(.not. lstatsprepared) return if (lstatsdump) then deallocate(uik,wik,vjk,wjk,uij,vij,uc,vc,wc,usgs,vsgs,wsgs) if (ltempeq) deallocate(tempnow,thli,thlj,thlk,thlsgs) if (lmoist) deallocate(qtk,qtsgs) if (lrh) deallocate(rhnow) end if if (ltavg3d .or. lytdump .or. lydump) then if (nsv>0) deallocate(svi,svj,svk,svsgs) end if if (lstatstavgdump) then deallocate(ut,vt,wt,pt) deallocate(utc,vtc,wtc,uutc,vvtc,wwtc) deallocate(utik,wtik,uwtik,vtjk,wtjk,vwtjk,utij,vtij,uvtij) deallocate(usgst,vsgst,wsgst) if (ltempeq) deallocate(tempt,thlt,thlti,thltj,thltk,uthlti,vthltj,wthltk,thlthlt,thlsgst) if (lmoist) deallocate(qtt,qlt,qttk,wqttk,qtqtt,qtsgst) if (lrh) deallocate(rht) end if if (ltdump .or. ltkslicedump) then deallocate(ws_localt,ws_10t,ws_now,ws_local_valid,ws_10_valid,wind_heights, & ws_local_klo,ws_local_khi,ws_local_weight,ws_local_available) end if if (ltavg3d .or. lytdump) then if (nsv>0) deallocate(svt,svti,svtj,svtk,usvti,vsvtj,wsvtk,svsvt,svsgst) end if if (ltavg3d) then if (nsv>0) deallocate(svtname,upsvptname,vpsvptname,wpsvptname,svpsvptname,svsgsname) if ((lchem) .and. (nsv>2)) deallocate(PSS,PSSt) end if if (ltdump) then if (myidy==0) call exitstat_nc(ncidt) end if if (ltislicedump .and. local_ntislice > 0 .and. myidy == 0) call exitstat_nc(ncidtis) if (ltjslicedump .and. local_ntjslice > 0 .and. myidx == 0) call exitstat_nc(ncidtjs) if (ltkslicedump .and. myidy == 0) call exitstat_nc(ncidtks) if (ltavg3d) deallocate(tVars) if (lxytdump) then deallocate(uxyt,vxyt,wxyt,pxyt,usgsxyt,vsgsxyt,wsgsxyt) deallocate(upwpxytik,vpwpxytjk,upvpxytij,upupxytc,vpvpxytc,wpwpxytc,tkexytc) deallocate(uwxytik,vwxytjk,uvxytij,uuxyti,vvxytj,wwxytk) if (ltempeq) deallocate(tempxyt,thlxyt,wpthlpxytk,wthlxytk,thlpthlpxyt,thlsgsxyt) if (lmoist) deallocate(qtxyt,qlxyt,wpqtpxytk,wqtxytk,qtpqtpxyt,qtsgsxyt) if (lrh) deallocate(rhxyt) if (myid==0) call exitstat_nc(ncidxyt) end if if (lxydump) then deallocate(uxy,vxy,wxy,pxy,usgsxy,vsgsxy,wsgsxy) deallocate(upwpxyik,vpwpxyjk,upvpxyij) deallocate(uwxyik,uxyik,wxyik,vwxyjk,vxyjk,wxyjk,uvxyij,uxyij,vxyij,uuxyi,vvxyj,wwxyk) if (ltempeq) deallocate(tempxy,thlxy,wpthlpxyk,wthlxyk,thlxyk,thlsgsxy) if (lmoist) deallocate(qtxy,qlxy,wpqtpxyk,wqtxyk,qtxyk,qtsgsxy) if (lrh) deallocate(rhxy) if (myid==0) call exitstat_nc(ncidxy) end if if (lytdump) then deallocate(uyt,vyt,wyt,pyt,usgsyt,wsgsyt) deallocate(upwpytik,uwytik,upupytc,vpvpytc,wpwpytc) if (ltempeq) deallocate(tempyt,thlyt,wpthlpytk,wthlytk,thlpthlpyt,thlsgsyt) if (lmoist) deallocate(qtyt,qlyt,wpqtpytk,wqtytk,qtpqtpyt,qtsgsyt) if (lrh) deallocate(rhyt) if (nsv>0) deallocate(svytname,wpsvpytname,wsvytname,svpsvpytname,svsgsytname,svyt,wpsvpytk,wsvytk,svpsvpyt,svsgsyt) if (myidy==0) call exitstat_nc(ncidyt) end if if (lydump) then deallocate(uy,vy,wy,py,usgsy,wsgsy) deallocate(upwpyik,uwyik,uyik,wyik) if (ltempeq) deallocate(tempy,thly,wpthlpyk,wthlyk,thlyk,thlsgsy) if (lmoist) deallocate(qty,qly,wpqtpyk,wqtyk,qtyk,qtsgsy) if (lrh) deallocate(rhy) if (nsv>0) deallocate(svyname,wpsvpyname,wsvyname,svsgsyname,svy,wpsvpyk,wsvyk,svyk,svsgsy) if (myidy==0) call exitstat_nc(ncidy) end if if (ltreedump) then deallocate(tr_ut,tr_vt,tr_wt,tr_now) if (ltempeq) deallocate(tr_thlt) if (lmoist) deallocate(tr_qtt,tr_qtRt,tr_qtAt,tr_omegat) if (nsv>0) deallocate(svtreename,tr_svt) if (myidy==0) call exitstat_nc(ncidtree) end if end subroutine stats_exit