CFMIP / COSPv2.0

COSP - The CFMIP (Cloud Feedbacks Model Intercomparison Project) Observation Simulator Package
42 stars 38 forks source link

Error in COSP_CHANGE_VERTICAL_GRID #1

Closed Marston closed 7 years ago

Marston commented 7 years ago

I'm getting a empty/R_UNDEF COSPOUT%calipso_cldlayer(npoints,ncat) being returned from COSP_STATS.F90. I traced the problem to this:

r = R_UNDEF
dz = zu - zl

do i=1,Npoints
   ! Vertical grid at that point
   xl = zhalf(i,:)
   xu(1) = zfull(i,1)+zfull(i,1)-zhalf(i,1)
   xu(2:Nlevels) = xl(1:nlevels-1) ! this puts a 0 at xu(2) Why??????

Because zhalf(:,1) is all 0s in my model (TOA), this causes XU(2,:) to be 0 and therefore introduces a very large negative number (roughly -72 000) in the weights at 1 or 2 positions and in many other places the weight is 0. Effectively XU(1) is a doubling of zfull(i,1) which makes it about 160 000 m. I don't get why this is doubled here.

This results in the sum(w(:k)) always being less than 0 and therefore the output is never filled and returns with all R_UNDEF.

   ! Do the weighted mean
   do j=1,Ncolumns
      do k=1,M
         ws = sum(w(:,k))
         if (ws > 0.0) r(i,j,k) = sum(w(:,k)*yp(j,:))/ws
      enddo
   enddo

I'm not sure if this vertical grid was designed specifically for only 1 model type, but clearly it doesn't work in my case. I'm curious as to why the half levels are used here? My model has 91 levels that go up to about 80 km and we are trying to put this onto a 18 km grid. Would appreciate some help with this problem.

Best, /M

RobertPincus commented 7 years ago

As per offline email conversations, this was user confusion. zhalf(:,1) is the height of the domain in m and should never be 0.