616 int nbnd = k_dist.get_nband();
617 int ngpt = k_dist.get_ngpt();
618 int ngas = gas_concs.get_num_gases();
621 auto& flux_up = fluxes.flux_up;
622 auto& flux_dn = fluxes.flux_dn;
623 auto& flux_dn_dir = fluxes.flux_dn_dir;
624 auto& bnd_flux_up = fluxes.bnd_flux_up;
625 auto& bnd_flux_dn = fluxes.bnd_flux_dn;
626 auto& bnd_flux_dn_dir = fluxes.bnd_flux_dn_dir;
627 auto& clnclrsky_flux_up = clnclrsky_fluxes.flux_up;
628 auto& clnclrsky_flux_dn = clnclrsky_fluxes.flux_dn;
629 auto& clnclrsky_flux_dn_dir = clnclrsky_fluxes.flux_dn_dir;
630 auto& clrsky_flux_up = clrsky_fluxes.flux_up;
631 auto& clrsky_flux_dn = clrsky_fluxes.flux_dn;
632 auto& clrsky_flux_dn_dir = clrsky_fluxes.flux_dn_dir;
633 auto& clnsky_flux_up = clnsky_fluxes.flux_up;
634 auto& clnsky_flux_dn = clnsky_fluxes.flux_dn;
635 auto& clnsky_flux_dn_dir = clnsky_fluxes.flux_dn_dir;
638 parallel_for(SimpleBounds<2>(nlay+1,ncol), YAKL_LAMBDA(
int ilev,
int icol)
640 flux_up (icol,ilev) = 0;
641 flux_dn (icol,ilev) = 0;
642 flux_dn_dir(icol,ilev) = 0;
643 clnclrsky_flux_up (icol,ilev) = 0;
644 clnclrsky_flux_dn (icol,ilev) = 0;
645 clnclrsky_flux_dn_dir(icol,ilev) = 0;
646 clrsky_flux_up (icol,ilev) = 0;
647 clrsky_flux_dn (icol,ilev) = 0;
648 clrsky_flux_dn_dir(icol,ilev) = 0;
649 clnsky_flux_up (icol,ilev) = 0;
650 clnsky_flux_dn (icol,ilev) = 0;
651 clnsky_flux_dn_dir(icol,ilev) = 0;
653 parallel_for(SimpleBounds<3>(nbnd,nlay+1,ncol), YAKL_LAMBDA(
int ibnd,
int ilev,
int icol)
655 bnd_flux_up (icol,ilev,ibnd) = 0;
656 bnd_flux_dn (icol,ilev,ibnd) = 0;
657 bnd_flux_dn_dir(icol,ilev,ibnd) = 0;
661 auto dayIndices = int1d(
"dayIndices", ncol);
662 memset(dayIndices, -1);
665 auto dayIndices_h = dayIndices.createHostCopy();
666 auto mu0_h = mu0.createHostCopy();
668 for (
int icol = 1; icol <= ncol; icol++) {
669 if (mu0_h(icol) > 0) {
671 dayIndices_h(nday) = icol;
676 dayIndices_h.deep_copy_to(dayIndices);
683 auto mu0_day = real1d(
"mu0_day", nday);
684 parallel_for(SimpleBounds<1>(nday), YAKL_LAMBDA(
int iday)
686 mu0_day(iday) = mu0(dayIndices(iday));
690 auto p_lay_day = real2d(
"p_lay_day", nday, nlay);
691 auto t_lay_day = real2d(
"t_lay_day", nday, nlay);
692 parallel_for(SimpleBounds<2>(nlay,nday), YAKL_LAMBDA(
int ilay,
int iday)
694 p_lay_day(iday,ilay) = p_lay(dayIndices(iday),ilay);
695 t_lay_day(iday,ilay) = t_lay(dayIndices(iday),ilay);
697 auto p_lev_day = real2d(
"p_lev_day", nday, nlay+1);
698 auto t_lev_day = real2d(
"t_lev_day", nday, nlay+1);
699 parallel_for(SimpleBounds<2>(nlay+1,nday), YAKL_LAMBDA(
int ilev,
int iday)
701 p_lev_day(iday,ilev) = p_lev(dayIndices(iday),ilev);
702 t_lev_day(iday,ilev) = t_lev(dayIndices(iday),ilev);
706 auto gas_names = gas_concs.get_gas_names();
707 GasConcs gas_concs_day;
708 gas_concs_day.init(gas_names, nday, nlay);
709 for (
int igas = 0; igas < ngas; igas++) {
710 auto vmr_day = real2d(
"vmr_day", nday, nlay);
711 auto vmr = real2d(
"vmr" , ncol, nlay);
712 gas_concs.get_vmr(gas_names[igas], vmr);
713 parallel_for(SimpleBounds<2>(nlay,nday), YAKL_LAMBDA(
int ilay,
int iday)
715 vmr_day(iday,ilay) = vmr(dayIndices(iday),ilay);
717 gas_concs_day.set_vmr(gas_names[igas], vmr_day);
721 OpticalProps2str aerosol_day;
722 aerosol_day.init(k_dist.get_band_lims_wavenumber());
723 aerosol_day.alloc_2str(nday, nlay);
724 parallel_for(SimpleBounds<3>(nbnd,nlay,nday), YAKL_LAMBDA(
int ibnd,
int ilay,
int iday)
726 aerosol_day.tau(iday,ilay,ibnd) = aerosol.tau(dayIndices(iday),ilay,ibnd);
727 aerosol_day.ssa(iday,ilay,ibnd) = aerosol.ssa(dayIndices(iday),ilay,ibnd);
728 aerosol_day.g (iday,ilay,ibnd) = aerosol.g (dayIndices(iday),ilay,ibnd);
733 OpticalProps2str clouds_day;
734 clouds_day.init(k_dist.get_band_lims_wavenumber(), k_dist.get_band_lims_gpoint());
735 clouds_day.alloc_2str(nday, nlay);
736 parallel_for(SimpleBounds<3>(ngpt,nlay,nday), YAKL_LAMBDA(
int igpt,
int ilay,
int iday)
738 clouds_day.tau(iday,ilay,igpt) = clouds.tau(dayIndices(iday),ilay,igpt);
739 clouds_day.ssa(iday,ilay,igpt) = clouds.ssa(dayIndices(iday),ilay,igpt);
740 clouds_day.g (iday,ilay,igpt) = clouds.g (dayIndices(iday),ilay,igpt);
746 real2d sfc_alb_dir_T(
"sfc_alb_dir", nbnd, nday);
747 real2d sfc_alb_dif_T(
"sfc_alb_dif", nbnd, nday);
748 parallel_for(SimpleBounds<2>(nbnd,nday), YAKL_LAMBDA(
int ibnd,
int icol)
750 sfc_alb_dir_T(ibnd,icol) = sfc_alb_dir(dayIndices(icol),ibnd);
751 sfc_alb_dif_T(ibnd,icol) = sfc_alb_dif(dayIndices(icol),ibnd);
755 auto flux_up_day = real2d(
"flux_up_day", nday, nlay+1);
756 auto flux_dn_day = real2d(
"flux_dn_day", nday, nlay+1);
757 auto flux_dn_dir_day = real2d(
"flux_dn_dir_day", nday, nlay+1);
758 auto bnd_flux_up_day = real3d(
"bnd_flux_up_day", nday, nlay+1, nbnd);
759 auto bnd_flux_dn_day = real3d(
"bnd_flux_dn_day", nday, nlay+1, nbnd);
760 auto bnd_flux_dn_dir_day = real3d(
"bnd_flux_dn_dir_day", nday, nlay+1, nbnd);
761 FluxesByband fluxes_day;
762 fluxes_day.flux_up = flux_up_day;
763 fluxes_day.flux_dn = flux_dn_day;
764 fluxes_day.flux_dn_dir = flux_dn_dir_day;
765 fluxes_day.bnd_flux_up = bnd_flux_up_day;
766 fluxes_day.bnd_flux_dn = bnd_flux_dn_day;
767 fluxes_day.bnd_flux_dn_dir = bnd_flux_dn_dir_day;
770 OpticalProps2str optics;
771 optics.alloc_2str(nday, nlay, k_dist);
773 OpticalProps2str optics_no_aerosols;
774 if (extra_clnsky_diag) {
776 optics_no_aerosols.alloc_2str(nday, nlay, k_dist);
780 auto t_lay_limited = real2d(
"t_lay_limited", nday, nlay);
784 real2d toa_flux(
"toa_flux", nday, ngpt);
785 auto p_lay_host = p_lay.createHostCopy();
786 bool top_at_1 = p_lay_host(1, 1) < p_lay_host(1, nlay);
788 k_dist.gas_optics(nday, nlay, top_at_1, p_lay_day, p_lev_day,
789 t_lay_limited, gas_concs_day, optics, toa_flux);
790 if (extra_clnsky_diag) {
791 k_dist.gas_optics(nday, nlay, top_at_1, p_lay_day, p_lev_day,
792 t_lay_limited, gas_concs_day, optics_no_aerosols, toa_flux);
796 parallel_for(SimpleBounds<2>(ngpt,nday), YAKL_LAMBDA(
int igpt,
int iday)
798 toa_flux(iday,igpt) = tsi_scaling * toa_flux(iday,igpt);
801 if (extra_clnclrsky_diag) {
803 rte_sw(optics, top_at_1, mu0_day, toa_flux, sfc_alb_dir_T, sfc_alb_dif_T, fluxes_day);
805 parallel_for(SimpleBounds<2>(nlay+1,nday), YAKL_LAMBDA(
int ilev,
int iday)
807 int icol = dayIndices(iday);
808 clnclrsky_flux_up (icol,ilev) = flux_up_day (iday,ilev);
809 clnclrsky_flux_dn (icol,ilev) = flux_dn_day (iday,ilev);
810 clnclrsky_flux_dn_dir(icol,ilev) = flux_dn_dir_day(iday,ilev);
815 aerosol_day.delta_scale();
816 aerosol_day.increment(optics);
819 rte_sw(optics, top_at_1, mu0_day, toa_flux, sfc_alb_dir_T, sfc_alb_dif_T, fluxes_day);
822 parallel_for(SimpleBounds<2>(nlay+1,nday), YAKL_LAMBDA(
int ilev,
int iday)
824 int icol = dayIndices(iday);
825 clrsky_flux_up (icol,ilev) = flux_up_day (iday,ilev);
826 clrsky_flux_dn (icol,ilev) = flux_dn_day (iday,ilev);
827 clrsky_flux_dn_dir(icol,ilev) = flux_dn_dir_day(iday,ilev);
833 clouds_day.delta_scale();
834 clouds_day.increment(optics);
837 rte_sw(optics, top_at_1, mu0_day, toa_flux, sfc_alb_dir_T, sfc_alb_dif_T, fluxes_day);
840 parallel_for(SimpleBounds<2>(nlay+1,nday), YAKL_LAMBDA(
int ilev,
int iday)
842 int icol = dayIndices(iday);
843 flux_up (icol,ilev) = flux_up_day (iday,ilev);
844 flux_dn (icol,ilev) = flux_dn_day (iday,ilev);
845 flux_dn_dir(icol,ilev) = flux_dn_dir_day(iday,ilev);
847 parallel_for(SimpleBounds<3>(nbnd,nlay+1,nday), YAKL_LAMBDA(
int ibnd,
int ilev,
int iday)
849 int icol = dayIndices(iday);
850 bnd_flux_up (icol,ilev,ibnd) = bnd_flux_up_day (iday,ilev,ibnd);
851 bnd_flux_dn (icol,ilev,ibnd) = bnd_flux_dn_day (iday,ilev,ibnd);
852 bnd_flux_dn_dir(icol,ilev,ibnd) = bnd_flux_dn_dir_day(iday,ilev,ibnd);
855 if (extra_clnsky_diag) {
857 clouds_day.increment(optics_no_aerosols);
859 rte_sw(optics_no_aerosols, top_at_1, mu0_day, toa_flux, sfc_alb_dir_T, sfc_alb_dif_T, fluxes_day);
861 parallel_for(SimpleBounds<2>(nlay+1,nday), YAKL_LAMBDA(
int ilev,
int iday)
863 int icol = dayIndices(iday);
864 clnsky_flux_up (icol,ilev) = flux_up_day (iday,ilev);
865 clnsky_flux_dn (icol,ilev) = flux_dn_day (iday,ilev);
866 clnsky_flux_dn_dir(icol,ilev) = flux_dn_dir_day(iday,ilev);