⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radcswmx.f90

📁 CCSM Research Tools: Community Atmosphere Model (CAM)
💻 F90
📖 第 1 页 / 共 5 页
字号:
! (4. wstr    : the fractional horizontal area of a grid box covered! by each stream! (5. kx1,2   : level indices for top/bottom of each region! ! The max-overlap calculation proceeds in 3 stages:! (1. compute layer radiative properties in raddedmx.! (2. combine these properties between layers ! (3. combine properties to compute fluxes at each interface.  ! ! Most of the indexing information calculated here is used in steps 2-3! after the call to raddedmx.! ! Initialize indices for layers to be max-overlapped! ! Loop to handle fix in totwgt=0. For original overlap config ! from npasses = 0.!          npasses = 0         do            do irgn = 0, nmxrgn(i)               kx2(irgn) = 0            end do            mrgn = 0! ! Outermost loop over regions (sets of adjacent layers) to be max overlapped!             do irgn = 1, nmxrgn(i)! ! Calculate min/max layer indices inside region.  !                region_found = .false.               if (kx2(irgn-1) < pver) then                  k1 = kx2(irgn-1)+1                  kx1(irgn) = k1                  kx2(irgn) = k1-1                  do k2 = pver, k1, -1                     if (pmid(i,k2) <= pmxrgn(i,irgn)) then                        kx2(irgn) = k2                        mrgn = mrgn+1                        region_found = .true.                        exit                     end if                  end do               else                  exit               endif               if (region_found) then! ! Sort cloud areas and corresponding level indices.  !                   nxs = 0                  if (cldeps > 0) then                      do k = k1,k2                        if (cld(i,k) >= cldmin .and. cld(i,k) >= cldeps) then                           nxs = nxs+1                           ksort(nxs) = k! ! We need indices for clouds in order of largest to smallest, so! sort 1-cld in ascending order!                            asort(nxs) = 1.0_r8-(floor(cld(i,k)/cldeps)*cldeps)                        end if                     end do                  else                     do k = k1,k2                        if (cld(i,k) >= cldmin) then                           nxs = nxs+1                           ksort(nxs) = k! ! We need indices for clouds in order of largest to smallest, so! sort 1-cld in ascending order!                            asort(nxs) = 1.0_r8-cld(i,k)                        end if                     end do                  endif! ! If nxs eq 1, no need to sort. ! If nxs eq 2, sort by swapping if necessary! If nxs ge 3, sort using local sort routine!                   if (nxs == 2) then                     if (asort(2) < asort(1)) then                        ktmp = ksort(1)                        ksort(1) = ksort(2)                        ksort(2) = ktmp                        atmp = asort(1)                        asort(1) = asort(2)                        asort(2) = atmp                     endif                  else if (nxs >= 3) then                     call sortarray(nxs,asort,ksort)                  endif! ! Construct wstr, cstr, nstr for this region!                   cstr(k1:k2,1:nxs+1) = 0                  mstr = 1                  cld0 = 0.0_r8                  do l = 1, nxs                     if (asort(l) /= cld0) then                        wstr(mstr,mrgn) = asort(l) - cld0                        cld0 = asort(l)                        mstr = mstr + 1                     endif                     cstr(ksort(l),mstr:nxs+1) = 1                  end do                  nstr(mrgn) = mstr                  wstr(mstr,mrgn) = 1.0_r8 - cld0! ! End test of region_found = true!                endif! ! End loop over regions irgn for max-overlap!             end do            nrgn = mrgn! ! Finish construction of cstr for additional top layer!             cstr(0,1:nstr(1)) = 0! ! INDEX COMPUTATIONS FOR STEP 2-3! This section of the code generates the following information:! (1. totwgt     step 3     total frac. area of configurations satisfying! areamin & nconfgmax criteria! (2. wgtv       step 3     frac. area of configurations ! (3. ccon       step 2     binary flag for clouds in each configuration! (4. nconfig    steps 2-3  number of configurations! (5. nuniqu/d   step 2     Number of unique cloud configurations for! up/downwelling rad. between surface/TOA! and level k! (6. istrtu/d   step 2     Indices into iconu/d! (7. iconu/d    step 2     Cloud configurations which are identical! for up/downwelling rad. between surface/TOA! and level k! ! Number of configurations (all permutations of streams in each region)!             nconfigm = product(nstr(1: nrgn))! ! Construction of totwgt, wgtv, ccon, nconfig!             istr(1: nrgn) = 1            nconfig = 0            totwgt = 0.0_r8            new_term = .true.            do iconfig = 1, nconfigm               xwgt = 1.0_r8               do mrgn = 1,  nrgn                  xwgt = xwgt * wstr(istr(mrgn),mrgn)               end do               if (xwgt >= areamin) then                  nconfig = nconfig + 1                  if (nconfig <= nconfgmax) then                     j = nconfig                     ptrc(nconfig) = nconfig                  else                     nconfig = nconfgmax                     if (new_term) then                        j = findvalue(1,nconfig,wgtv,ptrc)                     endif                     if (wgtv(j) < xwgt) then                        totwgt = totwgt - wgtv(j)                        new_term = .true.                     else                        new_term = .false.                     endif                  endif                  if (new_term) then                     wgtv(j) = xwgt                     totwgt = totwgt + xwgt                     do mrgn = 1, nrgn                        ccon(kx1(mrgn):kx2(mrgn),j) = cstr(kx1(mrgn):kx2(mrgn),istr(mrgn))                     end do                  endif               endif               mrgn =  nrgn               istr(mrgn) = istr(mrgn) + 1               do while (istr(mrgn) > nstr(mrgn) .and. mrgn > 1)                  istr(mrgn) = 1                  mrgn = mrgn - 1                  istr(mrgn) = istr(mrgn) + 1               end do! ! End do iconfig = 1, nconfigm!             end do! ! If totwgt = 0 implement maximum overlap and make another pass! if totwgt = 0 on this second pass then terminate.!             if (totwgt > 0.) then               exit            else               npasses = npasses + 1               if (npasses >= 2 ) then                  write(6,*)'RADCSWMX: Maximum overlap of column ','failed'                  call endrun               endif               nmxrgn(i)=1               pmxrgn(i,1)=1.0e30            end if!! End npasses = 0, do!         end do! ! ! Finish construction of ccon!          ccon(0,:) = 0         ccon(pverp,:) = 0! ! Construction of nuniqu/d, istrtu/d, iconu/d using binary tree !          nuniqd(0) = 1         nuniqu(pverp) = 1         istrtd(0,1) = 1         istrtu(pverp,1) = 1         do j = 1, nconfig            icond(0,j)=j            iconu(pverp,j)=j         end do         istrtd(0,2) = nconfig+1         istrtu(pverp,2) = nconfig+1         do k = 1, pverp            km1 = k-1            nuniq = 0            istrtd(k,1) = 1            do l0 = 1, nuniqd(km1)               is0 = istrtd(km1,l0)               is1 = istrtd(km1,l0+1)-1               n0 = 0               n1 = 0               do isn = is0, is1                  j = icond(km1,isn)                  if (ccon(k,j) == 0) then                     n0 = n0 + 1                     ptr0(n0) = j                  endif                  if (ccon(k,j) == 1) then                     n1 = n1 + 1                     ptr1(n1) = j                  endif               end do               if (n0 > 0) then                  nuniq = nuniq + 1                  istrtd(k,nuniq+1) = istrtd(k,nuniq)+n0                  icond(k,istrtd(k,nuniq):istrtd(k,nuniq+1)-1) =  ptr0(1:n0)               endif               if (n1 > 0) then                  nuniq = nuniq + 1                  istrtd(k,nuniq+1) = istrtd(k,nuniq)+n1                  icond(k,istrtd(k,nuniq):istrtd(k,nuniq+1)-1) =  ptr1(1:n1)               endif            end do            nuniqd(k) = nuniq         end do         do k = pver, 0, -1            kp1 = k+1            nuniq = 0            istrtu(k,1) = 1            do l0 = 1, nuniqu(kp1)               is0 = istrtu(kp1,l0)               is1 = istrtu(kp1,l0+1)-1               n0 = 0               n1 = 0               do isn = is0, is1                  j = iconu(kp1,isn)                  if (ccon(k,j) == 0) then                     n0 = n0 + 1                     ptr0(n0) = j                  endif                  if (ccon(k,j) == 1) then                     n1 = n1 + 1                     ptr1(n1) = j                  endif               end do               if (n0 > 0) then                  nuniq = nuniq + 1                  istrtu(k,nuniq+1) = istrtu(k,nuniq)+n0                  iconu(k,istrtu(k,nuniq):istrtu(k,nuniq+1)-1) =  ptr0(1:n0)               endif               if (n1 > 0) then                  nuniq = nuniq + 1                  istrtu(k,nuniq+1) = istrtu(k,nuniq)+n1                  iconu(k,istrtu(k,nuniq):istrtu(k,nuniq+1)-1) = ptr1(1:n1)               endif            end do            nuniqu(k) = nuniq         end do! !----------------------------------------------------------------------! End of index calculations!----------------------------------------------------------------------!----------------------------------------------------------------------! Start of flux calculations!----------------------------------------------------------------------! ! Initialize spectrally integrated totals:!          do k=0,pver            totfld(k) = 0.0_r8            fswup (k) = 0.0_r8            fswdn (k) = 0.0_r8         end do         sfltot        = 0.0_r8         fswup (pverp) = 0.0_r8         fswdn (pverp) = 0.0_r8! ! Start spectral interval!          do ns = 1,nspint            wgtint = nirwgt(ns)!----------------------------------------------------------------------! STEP 2! 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -