diff --git a/src/marbl_ciso_diagnostics_mod.F90 b/src/marbl_ciso_diagnostics_mod.F90 index 5cb01a71..9c322bb5 100644 --- a/src/marbl_ciso_diagnostics_mod.F90 +++ b/src/marbl_ciso_diagnostics_mod.F90 @@ -1158,7 +1158,7 @@ subroutine marbl_ciso_diagnostics_interior_tendency_compute(& full_depth_integral=diags(ind%CISO_Ca14CO3_form_zint(n))%field_2d(1)) end do - do k = 1,km + do k = 1,kmt !! do n = 1, autotroph_cnt diags(ind%CISO_d13C(n))%field_3d(k, 1) = autotroph_d13C(n,k) diags(ind%CISO_d14C(n))%field_3d(k, 1) = autotroph_d14C(n,k) @@ -1182,7 +1182,7 @@ subroutine marbl_ciso_diagnostics_interior_tendency_compute(& end do ! end loop over autotroph_cnt end do ! end loop over km - do k = 1,km + do k = 1,kmt !! diags(ind%CISO_DIC_d13C)%field_3d(k, 1) = DIC_d13C(k) diags(ind%CISO_DIC_d14C)%field_3d(k, 1) = DIC_d14C(k) diff --git a/src/marbl_ciso_interior_tendency_mod.F90 b/src/marbl_ciso_interior_tendency_mod.F90 index 103bb23e..783b5a86 100644 --- a/src/marbl_ciso_interior_tendency_mod.F90 +++ b/src/marbl_ciso_interior_tendency_mod.F90 @@ -173,8 +173,8 @@ subroutine marbl_ciso_interior_tendency_compute( & if (.not. ciso_on) return associate( & - column_km => marbl_domain%km, & - column_kmt => marbl_domain%kmt, & + km => marbl_domain%km, & + kmt => marbl_domain%kmt, & CO3 => interior_tendency_share%CO3_fields, & ! INPUT carbonate ion HCO3 => interior_tendency_share%HCO3_fields, & ! INPUT bicarbonate ion @@ -230,10 +230,10 @@ subroutine marbl_ciso_interior_tendency_compute( & !----------------------------------------------------------------------- ! Allocate memory for column_sinking_particle data types !----------------------------------------------------------------------- - call PO13C%construct(num_levels=column_km) - call PO14C%construct(num_levels=column_km) - call P_Ca13CO3%construct(num_levels=column_km) - call P_Ca14CO3%construct(num_levels=column_km) + call PO13C%construct(num_levels=km) + call PO14C%construct(num_levels=km) + call P_Ca13CO3%construct(num_levels=km) + call P_Ca14CO3%construct(num_levels=km) !---------------------------------------------------------------------------------------- ! Set cell attributes @@ -259,7 +259,7 @@ subroutine marbl_ciso_interior_tendency_compute( & ! Set ratios !----------------------------------------------------------------------- - do k = 1, column_km + do k = 1, kmt !----------------------------------------------------------------------- ! set local 13C/12C ratios, assuming ecosystem carries 12C (C=C12+C13+C14) @@ -658,7 +658,7 @@ subroutine marbl_ciso_interior_tendency_compute( & ! Update particulate terms from prior level for next level !----------------------------------------------------------------------- - if (k < column_km) then + if (k < km) then !!20230926 - DS - redundant conditional now loop is to kmt? call update_particulate_terms_from_prior_level(k+1, PO13C, P_Ca13CO3) call update_particulate_terms_from_prior_level(k+1, PO14C, P_Ca14CO3) @@ -724,33 +724,33 @@ end subroutine marbl_ciso_interior_tendency_compute !*********************************************************************** - subroutine marbl_ciso_interior_tendency_autotroph_zero_consistency_enforce(auto_ind, column_kmt, zero_mask, & + subroutine marbl_ciso_interior_tendency_autotroph_zero_consistency_enforce(auto_ind, kmt, zero_mask, & autotroph_tracer_indices, autotroph_local) use marbl_interface_private_types, only : marbl_living_tracer_index_type integer, intent(in) :: auto_ind - integer, intent(in) :: column_kmt - logical, intent(in) :: zero_mask(column_kmt) + integer, intent(in) :: kmt + logical, intent(in) :: zero_mask(kmt) type(marbl_living_tracer_index_type), intent(in) :: autotroph_tracer_indices type(autotroph_local_type), intent(inout) :: autotroph_local if (.not. ciso_on) return where (zero_mask) - autotroph_local%C13(auto_ind,1:column_kmt) = c0 - autotroph_local%C14(auto_ind,1:column_kmt) = c0 + autotroph_local%C13(auto_ind,1:kmt) = c0 + autotroph_local%C14(auto_ind,1:kmt) = c0 end where if (autotroph_tracer_indices%Ca13CO3_ind > 0) then where (zero_mask) - autotroph_local%Ca13CO3(auto_ind,1:column_kmt) = c0 + autotroph_local%Ca13CO3(auto_ind,1:kmt) = c0 end where end if if (autotroph_tracer_indices%Ca14CO3_ind > 0) then where (zero_mask) - autotroph_local%Ca14CO3(auto_ind,1:column_kmt) = c0 + autotroph_local%Ca14CO3(auto_ind,1:kmt) = c0 end where end if @@ -1070,7 +1070,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, tracer_local, use marbl_settings_mod , only : caco3_bury_thres_iopt_fixed_depth use marbl_settings_mod , only : caco3_bury_thres_depth use marbl_settings_mod , only : caco3_bury_thres_omega_calc - use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_set_used_particle_terms_to_zero + use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_subfloor_particle_terms_to_zero integer (int_kind), intent(in) :: k ! vertical model level type(marbl_domain_type), intent(in) :: domain @@ -1099,8 +1099,8 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, tracer_local, !----------------------------------------------------------------------- associate( & - column_km => domain%km , & ! IN - column_kmt => domain%kmt , & ! IN + km => domain%km , & ! IN + kmt => domain%kmt , & ! IN column_delta_z => domain%delta_z(k) , & ! IN column_zw => domain%zw(k) , & ! IN O2_loc => tracer_local(marbl_tracer_indices%O2_ind,k) , & ! IN @@ -1142,7 +1142,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, tracer_local, dz_loc = column_delta_z - if (k <= column_kmt) then + if (k <= kmt) then dzr_loc = c1 / dz_loc @@ -1209,9 +1209,9 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, tracer_local, ((POC_ciso%sflux_in(k) - POC_ciso%sflux_out(k)) + & (POC_ciso%hflux_in(k) - POC_ciso%hflux_out(k))) * dzr_loc - else ! k > column_kmt - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, POC_ciso) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, P_CaCO3_ciso) + else ! k > kmt + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, POC_ciso) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, P_CaCO3_ciso) dzr_loc = c0 endif @@ -1234,7 +1234,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, tracer_local, ! Here a constant depth is used for lysocline. !----------------------------------------------------------------------- - if (k == column_kmt) then + if (k == kmt) then POC_ciso%to_floor = POC_ciso%sflux_out(k) + POC_ciso%hflux_out(k) @@ -1287,7 +1287,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, tracer_local, POC_ciso%remin(1:k) = POC_ciso%remin(1:k) & + ((POC_ciso%to_floor - POC_ciso%sed_loss(k)) * bot_flux_to_tend(1:k)) endif - endif ! k == column_kmt + endif ! k == kmt end associate diff --git a/src/marbl_diagnostics_mod.F90 b/src/marbl_diagnostics_mod.F90 index 8433544f..a4db92d7 100644 --- a/src/marbl_diagnostics_mod.F90 +++ b/src/marbl_diagnostics_mod.F90 @@ -3909,7 +3909,7 @@ subroutine store_diagnostics_particulates(marbl_domain, & diags(ind%calcToFloor)%field_2d(1) = P_CaCO3%to_floor diags(ind%calcToSed)%field_2d(1) = sum(P_CaCO3%sed_loss) diags(ind%calcToSed_ALT_CO2)%field_2d(1) = sum(P_CaCO3_ALT_CO2%sed_loss) - diags(ind%bsiToSed)%field_2d(1) = sum(P_SiO2%sed_loss) + diags(ind%bsiToSed)%field_2d(1) = sum(P_SiO2%sed_loss(1:kmt)) !!20230926 diags(ind%pocToFloor)%field_2d(1) = POC%to_floor diags(ind%pocToSed)%field_2d(1) = sum(POC%sed_loss) diags(ind%SedDenitrif)%field_2d(1) = sum(sed_denitrif * delta_z) @@ -3924,7 +3924,7 @@ subroutine store_diagnostics_particulates(marbl_domain, & end subroutine store_diagnostics_particulates !*********************************************************************** - + ! changed loop limit from km to kmt subroutine store_diagnostics_oxygen(marbl_domain, & interior_tendency_forcing_ind, interior_tendency_forcings, potemp, salinity, & column_o2, o2_production, o2_consumption, marbl_interior_diags) @@ -3979,7 +3979,7 @@ subroutine store_diagnostics_oxygen(marbl_domain, & end subroutine store_diagnostics_oxygen !*********************************************************************** - + ! changed loop limit from km to kmt subroutine store_diagnostics_PAR( marbl_domain, PAR_col_frac, PAR_avg, marbl_interior_diags) type(marbl_domain_type) , intent(in) :: marbl_domain @@ -3994,12 +3994,12 @@ subroutine store_diagnostics_PAR( marbl_domain, PAR_col_frac, PAR_avg, marbl_int !----------------------------------------------------------------------- associate( & - km => marbl_domain%km, & + kmt => marbl_domain%kmt, & diags => marbl_interior_diags%diags, & ind => marbl_interior_tendency_diag_ind & ) - do k=1,km + do k=1,kmt diags(ind%PAR_avg)%field_3d(k, 1) = sum(PAR_col_frac(:)*PAR_avg(k,:)) end do diff --git a/src/marbl_interior_tendency_mod.F90 b/src/marbl_interior_tendency_mod.F90 index 8f2f5be2..dfea72af 100644 --- a/src/marbl_interior_tendency_mod.F90 +++ b/src/marbl_interior_tendency_mod.F90 @@ -93,8 +93,10 @@ module marbl_interior_tendency_mod contains !*********************************************************************** - - subroutine marbl_interior_tendency_compute( & + ! Changed calls with "km" as an argument to call with "kmt". + ! Added call to marbl_interior_tendency_share_subfloor_particle_terms_to_zero to make sure no mem re-use issues + ! Changed main do loop from 1,km to 1,kmt + subroutine marbl_interior_tendency_compute( & !! complete domain, & bot_flux_to_tend, & interior_tendency_forcings, & @@ -136,6 +138,7 @@ subroutine marbl_interior_tendency_compute( & use marbl_interface_public_types, only : marbl_diagnostics_type use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_export_variables use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_export_zooplankton + use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_subfloor_particle_terms_to_zero !! use marbl_restore_mod, only : marbl_restore_compute_interior_restore use marbl_settings_mod, only : lo2_consumption_scalef use marbl_settings_mod, only : lp_remin_scalef @@ -372,8 +375,8 @@ subroutine marbl_interior_tendency_compute( & call compute_PAR(domain, interior_tendency_forcings, interior_tendency_forcing_indices, & autotroph_local, unit_system, PAR) - call compute_autotroph_elemental_ratios(km, autotroph_local, marbl_tracer_indices, tracer_local, & - autotroph_derived_terms) + call compute_autotroph_elemental_ratios(kmt, autotroph_local, marbl_tracer_indices, tracer_local, & + autotroph_derived_terms) !!! tested call compute_temperature_functional_form(temperature(:), autotroph_settings(:)%Tref, & autotroph_settings(:)%temp_func_form_iopt, autotroph_settings(:)%Ea, Tfunc_auto(:,:)) @@ -381,36 +384,56 @@ subroutine marbl_interior_tendency_compute( & call compute_temperature_functional_form(temperature(:), zooplankton_settings(:)%Tref, & zooplankton_settings(:)%temp_func_form_iopt, zooplankton_settings(:)%Ea, Tfunc_zoo(:,:)) - call compute_Pprime(km, domain%zt, autotroph_local, temperature, autotroph_derived_terms%Pprime) +!!!20231101 + autotroph_derived_terms%Pprime(:,:) = c0 +!!!/20231101 + + call compute_Pprime(kmt, domain%zt, autotroph_local, temperature, autotroph_derived_terms%Pprime) !! tested call compute_autotroph_uptake(km, marbl_tracer_indices, tracer_local(:, :), carbonate, autotroph_derived_terms) - call compute_autotroph_photosynthesis(km, num_PAR_subcols, autotroph_local, temperature(:), & - Tfunc_auto(:,:), PAR%col_frac(:), PAR%avg(:,:), autotroph_derived_terms) + call compute_autotroph_photosynthesis(kmt, num_PAR_subcols, autotroph_local, temperature(1:kmt), & + Tfunc_auto(:,1:kmt), PAR%col_frac(:), PAR%avg(1:kmt,:), autotroph_derived_terms) !!! tested - passed!! call compute_autotroph_nutrient_uptake(marbl_tracer_indices, autotroph_derived_terms) - call compute_autotroph_calcification(km, autotroph_local, temperature, carbonate, autotroph_derived_terms) + call compute_autotroph_calcification(kmt, autotroph_local, temperature, carbonate, autotroph_derived_terms) !! tested - call compute_autotroph_nfixation(km, autotroph_derived_terms) + call compute_autotroph_nfixation(kmt, autotroph_derived_terms) !! tested - call compute_autotroph_loss(km, Tfunc_auto(:,:), autotroph_derived_terms) + call compute_autotroph_loss(kmt, Tfunc_auto(:,:), autotroph_derived_terms) !! tested call compute_Zprime(km, domain%zt, zooplankton_local%C, Tfunc_zoo(:,:), zooplankton_derived_terms) - call compute_grazing(km, Tfunc_zoo(:,:), zooplankton_local, zooplankton_derived_terms, autotroph_derived_terms) + call compute_grazing(kmt, Tfunc_zoo(:,:), zooplankton_local, zooplankton_derived_terms, autotroph_derived_terms) !! tested call compute_routing(km, zooplankton_derived_terms, autotroph_derived_terms) - call compute_dissolved_organic_matter (km, marbl_tracer_indices, num_PAR_subcols, & + call compute_dissolved_organic_matter (kmt, marbl_tracer_indices, num_PAR_subcols, & PAR, zooplankton_derived_terms, autotroph_derived_terms, & - delta_z1, tracer_local(:, :), unit_system, dissolved_organic_matter) - - do k = 1, km - - call compute_scavenging(k, km, marbl_tracer_indices, tracer_local(:,:), & - POC, P_CaCO3, P_SiO2, dust, Fefree(:), Fe_scavenge_rate(:), & - Fe_scavenge(:), Lig_scavenge(:), marbl_status_log) + delta_z1, tracer_local(:, :), unit_system, dissolved_organic_matter) !! + + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, P_CaCO3) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, P_CaCO3_ALT_CO2) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, P_SiO2) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, dust) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, POC) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, P_iron) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, POP) + PON_remin(kmt+1:km) = c0 + + !20231102 + denitrif(:) = c0 + sed_denitrif(:) = c0 + other_remin( :) = c0 + PON_sed_loss(:) = c0 + Fe_scavenge_rate(:) = c0 + !/20231102 + + do k = 1, kmt !! tested + call compute_scavenging(k, kmt, marbl_tracer_indices, tracer_local(:,1:kmt), & + POC, P_CaCO3, P_SiO2, dust, Fefree(1:kmt), Fe_scavenge_rate(1:kmt), & + Fe_scavenge(1:kmt), Lig_scavenge(1:kmt), marbl_status_log) if (marbl_status_log%labort_marbl) then call marbl_status_log%log_error_trace('compute_scavenging()', subname) @@ -431,30 +454,28 @@ subroutine marbl_interior_tendency_compute( & marbl_particulate_share, glo_avg_fields_interior_tendency, PON_sed_loss(k), & marbl_status_log) - if (marbl_status_log%labort_marbl) then + if (marbl_status_log%labort_marbl) then call marbl_status_log%log_error_trace('compute_particulate_terms()', subname) return - end if + end if - if (k < km) then - call update_particulate_terms_from_prior_level(k+1, POC, POP, P_CaCO3, & - P_CaCO3_ALT_CO2, P_SiO2, dust, P_iron, QA_dust_def(:)) - endif + call update_particulate_terms_from_prior_level(k+1, POC, POP, P_CaCO3, & + P_CaCO3_ALT_CO2, P_SiO2, dust, P_iron, QA_dust_def(:)) end do ! k - call compute_Lig_terms(km, num_PAR_subcols, marbl_tracer_indices, & + call compute_Lig_terms(kmt, num_PAR_subcols, marbl_tracer_indices, & !! tested POC%remin(:), dissolved_organic_matter%DOC_prod(:), PAR, delta_z1, tracer_local, Lig_scavenge(:), & autotroph_derived_terms%photoFe(:,:), unit_system, Lig_prod(:), Lig_photochem(:), Lig_deg(:), Lig_loss(:)) call compute_nitrif(kmt, km, num_PAR_subcols, marbl_tracer_indices, PAR, tracer_local(:,:), nitrif(:)) - call compute_denitrif(km, marbl_tracer_indices, tracer_local(:, :), & + call compute_denitrif(kmt, marbl_tracer_indices, tracer_local(:, :), & !! tested dissolved_organic_matter%DOC_remin(:), & dissolved_organic_matter%DOCr_remin(:), & POC%remin(:), other_remin(:), sed_denitrif(:), denitrif(:)) - call compute_local_tendencies(km, marbl_tracer_indices, autotroph_derived_terms, & + call compute_local_tendencies(kmt, marbl_tracer_indices, autotroph_derived_terms, & !! tested zooplankton_derived_terms, & dissolved_organic_matter, & nitrif(:), denitrif(:), sed_denitrif(:), & @@ -505,7 +526,7 @@ subroutine marbl_interior_tendency_compute( & ! Store any variables needed in other tracer modules ! FIXME #28: need to pull particulate share out ! of compute_particulate_terms! - call marbl_interior_tendency_share_export_variables(km, marbl_tracer_indices, & + call marbl_interior_tendency_share_export_variables(kmt, marbl_tracer_indices, & !! tested tracer_local(:,:), carbonate, dissolved_organic_matter, & QA_dust_def(:), interior_tendency_share) @@ -543,7 +564,8 @@ subroutine marbl_interior_tendency_compute( & end subroutine marbl_interior_tendency_compute !*********************************************************************** - + ! changed "column_kmt" to "kmt" + ! changed "dkm" to "km" subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_forcing_ind, & autotroph_local, unit_system, PAR) @@ -578,8 +600,8 @@ subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_for !----------------------------------------------------------------------- associate( & - dkm => domain%km, & - column_kmt => domain%kmt, & + km => domain%km, & + kmt => domain%kmt, & delta_z => domain%delta_z, & PAR_nsubcols => domain%num_PAR_subcols & ) @@ -624,9 +646,9 @@ subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_for ! compute attenuation coefficient over column !----------------------------------------------------------------------- - totalChl_local(:) = sum(autotroph_local%Chl(:,1:column_kmt), dim=1) + totalChl_local(:) = sum(autotroph_local%Chl(:,1:kmt), dim=1) WORK1(:) = max(totalChl_local(:), 0.02_r8) - do k = 1, column_kmt + do k = 1, kmt if (WORK1(k) < 0.13224_r8) then PAR%KPARdz(k) = (0.0919_r8*unit_system%len2m)*(WORK1(k)**0.3536_r8) else @@ -634,35 +656,35 @@ subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_for end if PAR%KPARdz(k) = PAR%KPARdz(k) * delta_z(k) end do - PAR%KPARdz(column_kmt+1:dkm) = c0 + PAR%KPARdz(kmt+1:km) = c0 !----------------------------------------------------------------------- ! propagate PAR values through column, only on subcolumns with PAR>0 ! note that if col_frac is 0, then so is PAR !----------------------------------------------------------------------- - WORK1(:) = exp(-PAR%KPARdz(1:column_kmt)) + WORK1(:) = exp(-PAR%KPARdz(1:kmt)) do subcol_ind = 1, PAR_nsubcols if (PAR%interface(0,subcol_ind) > c0) then ! this loop will probably not vectorize - do k = 1, column_kmt + do k = 1, kmt PAR%interface(k,subcol_ind) = PAR%interface(k-1,subcol_ind) * WORK1(k) if (PAR%interface(k,subcol_ind) < PAR_threshold) then - PAR%interface(k:column_kmt,subcol_ind) = c0 + PAR%interface(k:kmt,subcol_ind) = c0 exit end if end do - PAR%interface(column_kmt+1:dkm,subcol_ind) = c0 + PAR%interface(kmt+1:km,subcol_ind) = c0 - do k = 1, column_kmt + do k = 1, kmt PAR%avg(k,subcol_ind) = PAR%interface(k-1,subcol_ind) * (c1 - WORK1(k)) / PAR%KPARdz(k) end do - PAR%avg(column_kmt+1:dkm,subcol_ind) = c0 + PAR%avg(kmt+1:km,subcol_ind) = c0 else - PAR%interface(1:dkm,subcol_ind) = c0 - PAR%avg(1:dkm,subcol_ind) = c0 + PAR%interface(1:km,subcol_ind) = c0 + PAR%avg(1:km,subcol_ind) = c0 end if end do end associate @@ -752,15 +774,14 @@ end subroutine marbl_interior_tendency_adjust_bury_coeff !*********************************************************************** - subroutine setup_local_tracers(column_kmt, marbl_tracer_indices, tracers, & + subroutine setup_local_tracers(kmt, marbl_tracer_indices, tracers, & autotroph_local, tracer_local, zooplankton_local) - !----------------------------------------------------------------------- ! create local copies of model tracers ! treat negative values as zero, apply mask to local copies !----------------------------------------------------------------------- - integer(int_kind) , intent(in) :: column_kmt + integer(int_kind) , intent(in) :: kmt type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices real (r8) , intent(in) :: tracers(:,:) type(autotroph_local_type) , intent(inout) :: autotroph_local @@ -774,11 +795,11 @@ subroutine setup_local_tracers(column_kmt, marbl_tracer_indices, tracers, & integer (int_kind) :: zoo_ind, auto_ind, n ! tracer indices !----------------------------------------------------------------------- - do k = 1, column_kmt + do k = 1, kmt tracer_local(:,k) = max(c0, tracers(1:size(tracer_local,1),k)) end do - do k = column_kmt+1, size(tracer_local,2) + do k = kmt+1, size(tracer_local,2) tracer_local(:,k) = c0 end do @@ -844,7 +865,7 @@ subroutine setup_local_tracers(column_kmt, marbl_tracer_indices, tracers, & end do ! autotroph consistency check - call autotroph_zero_consistency_enforce(column_kmt, marbl_tracer_indices, autotroph_local) + call autotroph_zero_consistency_enforce(kmt, marbl_tracer_indices, autotroph_local) end subroutine setup_local_tracers @@ -975,7 +996,8 @@ subroutine set_surface_particulate_terms(surface_flux_forcing_indices, unit_syst end subroutine set_surface_particulate_terms !*********************************************************************** - + ! renamed dkm to km + ! changed loop limits to kmt subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & salinity, tracer_local, marbl_tracer_indices, unit_system, & co2calc_coeffs, co2calc_state, carbonate, ph_prev_col, & @@ -1023,8 +1045,8 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & sio3_loc = tracer_local(marbl_tracer_indices%sio3_ind,:) associate( & - dkm => domain%km, & - column_kmt => domain%kmt, & + km => domain%km, & + kmt => domain%kmt, & co3 => carbonate%CO3(:), & hco3 => carbonate%HCO3(:), & h2co3 => carbonate%H2CO3(:), & @@ -1037,7 +1059,7 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & ph_alt_co2 => carbonate%pH_ALT_CO2(:) & ) - do k=1,dkm + do k=1,kmt !! if (ph_prev_col(k) /= c0) then ph_lower_bound(k) = ph_prev_col(k) - del_ph ph_upper_bound(k) = ph_prev_col(k) + del_ph @@ -1048,7 +1070,7 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & end do call marbl_co2calc_interior(& - dkm, column_kmt, .true., unit_system, co2calc_coeffs, co2calc_state, & + km, kmt, .true., unit_system, co2calc_coeffs, co2calc_state, & temperature, salinity, press_bar, dic_loc, alk_loc, po4_loc, sio3_loc, & ph_lower_bound, ph_upper_bound, ph, h2co3, hco3, co3, marbl_status_log) @@ -1061,7 +1083,7 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & call marbl_status_log%log_warning_trace('marbl_co2calc_interior() with dic', subname) end if - do k=1,dkm + do k=1,kmt !! ph_prev_col(k) = pH(k) if (ph_prev_alt_co2_col(k) /= c0) then ph_lower_bound(k) = ph_prev_alt_co2_col(k) - del_ph @@ -1073,7 +1095,7 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & end do call marbl_co2calc_interior(& - dkm, column_kmt, .false., unit_system, co2calc_coeffs, co2calc_state, & + km, kmt, .false., unit_system, co2calc_coeffs, co2calc_state, & temperature, salinity, press_bar, dic_alt_co2_loc, alk_alt_co2_loc, po4_loc, & sio3_loc, ph_lower_bound, ph_upper_bound, ph_alt_co2, h2co3_alt_co2, & hco3_alt_co2, co3_alt_co2, marbl_status_log) @@ -1090,7 +1112,7 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & ph_prev_alt_co2_col = ph_alt_co2 call marbl_co2calc_co3_sat_vals(& - dkm, column_kmt, temperature, salinity, & + km, kmt, temperature, salinity, & press_bar, unit_system, co3_sat_calcite, & co3_sat_aragonite) @@ -1099,8 +1121,8 @@ subroutine compute_carbonate_chemistry(domain, temperature, press_bar, & end subroutine compute_carbonate_chemistry !*********************************************************************** - - subroutine autotroph_zero_consistency_enforce(column_kmt, marbl_tracer_indices, autotroph_local) + ! changed "column_kmt" to "kmt" + subroutine autotroph_zero_consistency_enforce(kmt, marbl_tracer_indices, autotroph_local) use marbl_ciso_interior_tendency_mod, only : marbl_ciso_interior_tendency_autotroph_zero_consistency_enforce @@ -1108,7 +1130,7 @@ subroutine autotroph_zero_consistency_enforce(column_kmt, marbl_tracer_indices, ! If any phyto box are zero, set others to zeros. !----------------------------------------------------------------------- - integer(int_kind), intent(in) :: column_kmt ! number of active model layers + integer(int_kind), intent(in) :: kmt ! number of active model layers type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices type(autotroph_local_type), intent(inout) :: autotroph_local @@ -1116,11 +1138,11 @@ subroutine autotroph_zero_consistency_enforce(column_kmt, marbl_tracer_indices, ! local variables !----------------------------------------------------------------------- integer (int_kind) :: auto_ind, k - logical (log_kind) :: zero_mask(column_kmt) + logical (log_kind) :: zero_mask(kmt) !----------------------------------------------------------------------- do auto_ind = 1, autotroph_cnt - do k = 1, column_kmt + do k = 1, kmt zero_mask(k) = (autotroph_local%Chl(auto_ind,k) == c0 & .or. autotroph_local%C(auto_ind,k) == c0 & @@ -1132,33 +1154,33 @@ subroutine autotroph_zero_consistency_enforce(column_kmt, marbl_tracer_indices, end if end do where (zero_mask) - autotroph_local%Chl(auto_ind,1:column_kmt) = c0 - autotroph_local%C(auto_ind,1:column_kmt) = c0 - autotroph_local%P(auto_ind,1:column_kmt) = c0 - autotroph_local%Fe(auto_ind,1:column_kmt) = c0 + autotroph_local%Chl(auto_ind,1:kmt) = c0 + autotroph_local%C(auto_ind,1:kmt) = c0 + autotroph_local%P(auto_ind,1:kmt) = c0 + autotroph_local%Fe(auto_ind,1:kmt) = c0 end where if (marbl_tracer_indices%auto_inds(auto_ind)%Si_ind > 0) then where (zero_mask) - autotroph_local%Si(auto_ind,1:column_kmt) = c0 + autotroph_local%Si(auto_ind,1:kmt) = c0 end where end if if (marbl_tracer_indices%auto_inds(auto_ind)%CaCO3_ind > 0) then where (zero_mask) - autotroph_local%CaCO3(auto_ind,1:column_kmt) = c0 + autotroph_local%CaCO3(auto_ind,1:kmt) = c0 end where end if ! carbon isotope components of autotroph_local_type ! FIXME #278: this interface will change when logical checks are not index-based - call marbl_ciso_interior_tendency_autotroph_zero_consistency_enforce(auto_ind, column_kmt, zero_mask, & + call marbl_ciso_interior_tendency_autotroph_zero_consistency_enforce(auto_ind, kmt, zero_mask, & marbl_tracer_indices%auto_inds(auto_ind), autotroph_local) end do end subroutine autotroph_zero_consistency_enforce !*********************************************************************** - - subroutine compute_autotroph_elemental_ratios(km, autotroph_local, marbl_tracer_indices, tracer_local, & + ! renamed km to kmt in argument list + subroutine compute_autotroph_elemental_ratios(kmt, autotroph_local, marbl_tracer_indices, tracer_local, & autotroph_derived_terms) use marbl_constants_mod, only : epsC @@ -1171,10 +1193,10 @@ subroutine compute_autotroph_elemental_ratios(km, autotroph_local, marbl_tracer_ use marbl_settings_mod, only : PquotaSlope, PquotaIntercept, PquotaMinNP use marbl_settings_mod, only : QCaCO3_max - integer, intent(in) :: km + integer, intent(in) :: kmt type(autotroph_local_type), intent(in) :: autotroph_local type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices - real (r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,km) + real (r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,kmt) type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms !----------------------------------------------------------------------- @@ -1321,24 +1343,24 @@ subroutine compute_temperature_functional_form(temperature, Tref, temp_func_form end subroutine compute_temperature_functional_form !*********************************************************************** - - subroutine compute_Pprime(km, zt, autotroph_local, temperature, Pprime) + ! renamed km to kmt in argument list + subroutine compute_Pprime(kmt, zt, autotroph_local, temperature, Pprime) use marbl_settings_mod, only : thres_z1_auto use marbl_settings_mod, only : thres_z2_auto - integer, intent(in) :: km - real(r8), intent(in) :: zt(km) + integer, intent(in) :: kmt + real(r8), intent(in) :: zt(kmt) type(autotroph_local_type), intent(in) :: autotroph_local - real(r8), intent(in) :: temperature(km) - real(r8), intent(out) :: Pprime(autotroph_cnt, km) + real(r8), intent(in) :: temperature(kmt) + real(r8), intent(out) :: Pprime(autotroph_cnt, kmt) !----------------------------------------------------------------------- ! local variables !----------------------------------------------------------------------- integer :: auto_ind - real(r8) :: f_loss_thres(km) - real(r8) :: C_loss_thres(km) + real(r8) :: f_loss_thres(kmt) + real(r8) :: C_loss_thres(kmt) !----------------------------------------------------------------------- ! calculate the loss threshold interpolation factor @@ -1357,8 +1379,8 @@ subroutine compute_Pprime(km, zt, autotroph_local, temperature, Pprime) end subroutine compute_Pprime !*********************************************************************** - - subroutine compute_autotroph_photosynthesis(km, PAR_nsubcols, & + ! renamed km to kmt in argument list + subroutine compute_autotroph_photosynthesis(kmt, PAR_nsubcols, & autotroph_local, temperature, Tfunc_auto, PAR_col_frac, PAR_avg, & autotroph_derived_terms) @@ -1368,13 +1390,13 @@ subroutine compute_autotroph_photosynthesis(km, PAR_nsubcols, & use marbl_constants_mod, only : epsTinv - integer(int_kind), intent(in) :: km + integer(int_kind), intent(in) :: kmt integer(int_kind), intent(in) :: PAR_nsubcols type(autotroph_local_type), intent(in) :: autotroph_local - real(r8), intent(in) :: temperature(km) - real(r8), intent(in) :: Tfunc_auto(autotroph_cnt,km) + real(r8), intent(in) :: temperature(kmt) + real(r8), intent(in) :: Tfunc_auto(autotroph_cnt,kmt) real(r8), intent(in) :: PAR_col_frac(PAR_nsubcols) - real(r8), intent(in) :: PAR_avg(km,PAR_nsubcols) + real(r8), intent(in) :: PAR_avg(kmt,PAR_nsubcols) type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms !----------------------------------------------------------------------- @@ -1399,8 +1421,16 @@ subroutine compute_autotroph_photosynthesis(km, PAR_nsubcols, & photoacc => autotroph_derived_terms%photoacc(:,:) & ) + ! 20231101 - ML - initialise with constant value + light_lim(:,:) = c0 + PCphoto( :,:) = c0 + photoacc( :,:) = c0 + photoC( :,:) = c0 + !/20231101 + do auto_ind = 1, autotroph_cnt - do k=1,km + + do k=1,kmt if (temperature(k) < autotroph_settings(auto_ind)%temp_thres) then PCmax = c0 @@ -1409,10 +1439,12 @@ subroutine compute_autotroph_photosynthesis(km, PAR_nsubcols, & end if if (thetaC(auto_ind,k) > c0) then - light_lim(auto_ind,k) = c0 - PCphoto(auto_ind,k) = c0 - photoacc(auto_ind,k) = c0 - + !20231101 + !light_lim(auto_ind,k) = c0 + !PCphoto(auto_ind,k) = c0 + !photoacc(auto_ind,k) = c0 + !/20231101 + do subcol_ind = 1, PAR_nsubcols work = autotroph_settings(auto_ind)%alphaPI * thetaC(auto_ind,k) * PAR_avg(k,subcol_ind) if (work > c0) then @@ -1445,8 +1477,8 @@ subroutine compute_autotroph_photosynthesis(km, PAR_nsubcols, & end subroutine compute_autotroph_photosynthesis !*********************************************************************** - - subroutine compute_autotroph_calcification(km, autotroph_local, temperature, carbonate, autotroph_derived_terms) + ! renamed km to kmt in argument list + subroutine compute_autotroph_calcification(kmt, autotroph_local, temperature, carbonate, autotroph_derived_terms) !----------------------------------------------------------------------- ! CaCO3 Production, parameterized as function of small phyto production @@ -1461,9 +1493,9 @@ subroutine compute_autotroph_calcification(km, autotroph_local, temperature, car use marbl_settings_mod, only : CaCO3_temp_thres2 use marbl_settings_mod, only : f_photosp_CaCO3 - integer, intent(in) :: km + integer, intent(in) :: kmt type(autotroph_local_type), intent(in) :: autotroph_local - real(r8), intent(in) :: temperature(km) + real(r8), intent(in) :: temperature(kmt) type(carbonate_type), intent(in) :: carbonate type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms @@ -1471,7 +1503,7 @@ subroutine compute_autotroph_calcification(km, autotroph_local, temperature, car ! local variables !----------------------------------------------------------------------- integer :: auto_ind - real(r8) :: picpoc(km) + real(r8) :: picpoc(kmt) !----------------------------------------------------------------------- associate( & @@ -1522,12 +1554,12 @@ subroutine compute_autotroph_calcification(km, autotroph_local, temperature, car end subroutine compute_autotroph_calcification !*********************************************************************** + ! renamed km to kmt in argument list + subroutine compute_autotroph_uptake(kmt, marbl_tracer_indices, tracer_local, carbonate, autotroph_derived_terms) - subroutine compute_autotroph_uptake(km, marbl_tracer_indices, tracer_local, carbonate, autotroph_derived_terms) - - integer, intent(in) :: km + integer, intent(in) :: kmt type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices - real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,km) + real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,kmt) type(carbonate_type), intent(in) :: carbonate type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms @@ -1607,8 +1639,8 @@ subroutine compute_autotroph_uptake(km, marbl_tracer_indices, tracer_local, carb end subroutine compute_autotroph_uptake !*********************************************************************** - - subroutine compute_autotroph_nfixation(km, autotroph_derived_terms) + ! renamed km to kmt in argument list + subroutine compute_autotroph_nfixation(kmt, autotroph_derived_terms) !----------------------------------------------------------------------- ! Get N fixation by diazotrophs based on C fixation, @@ -1618,14 +1650,14 @@ subroutine compute_autotroph_nfixation(km, autotroph_derived_terms) use marbl_settings_mod, only : Q use marbl_settings_mod, only : r_Nfix_photo - integer, intent(in) :: km + integer, intent(in) :: kmt type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms !----------------------------------------------------------------------- ! local variables !----------------------------------------------------------------------- integer :: auto_ind - real(r8) :: work1(km) + real(r8) :: work1(kmt) !----------------------------------------------------------------------- associate( & @@ -1708,7 +1740,7 @@ subroutine compute_autotroph_nutrient_uptake(marbl_tracer_indices, autotroph_der ! Get nutrient uptake by diatoms based on C fixation !----------------------------------------------------------------------- - photoFe(auto_ind,:) = photoC(auto_ind,:) * gQfe(auto_ind,:) + photoFe(auto_ind,:) = photoC(auto_ind,:) * gQfe(auto_ind,:) ! Here's the first error if (marbl_tracer_indices%auto_inds(auto_ind)%Si_ind > 0) then photoSi(auto_ind,:) = photoC(auto_ind,:) * gQsi(auto_ind,:) @@ -1720,8 +1752,8 @@ subroutine compute_autotroph_nutrient_uptake(marbl_tracer_indices, autotroph_der end subroutine compute_autotroph_nutrient_uptake !*********************************************************************** - - subroutine compute_autotroph_loss(km, Tfunc_auto, autotroph_derived_terms) + ! renamed km to kmt in argument list + subroutine compute_autotroph_loss(kmt, Tfunc_auto, autotroph_derived_terms) !----------------------------------------------------------------------- ! Compute autotroph-loss, autotroph aggregation loss and routine of @@ -1730,8 +1762,8 @@ subroutine compute_autotroph_loss(km, Tfunc_auto, autotroph_derived_terms) use marbl_settings_mod, only : auto_mort2_exp - integer, intent(in) :: km - real(r8), intent(in) :: Tfunc_auto(autotroph_cnt,km) + integer, intent(in) :: kmt + real(r8), intent(in) :: Tfunc_auto(autotroph_cnt,kmt) type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms !----------------------------------------------------------------------- @@ -1783,25 +1815,25 @@ subroutine compute_autotroph_loss(km, Tfunc_auto, autotroph_derived_terms) end subroutine compute_autotroph_loss !*********************************************************************** - - subroutine compute_Zprime(km, zt, zooC, Tfunc_zoo, zooplankton_derived_terms) + ! renamed km to kmt in argument list + subroutine compute_Zprime(kmt, zt, zooC, Tfunc_zoo, zooplankton_derived_terms) use marbl_settings_mod, only : thres_z1_zoo use marbl_settings_mod, only : thres_z2_zoo use marbl_settings_mod, only : zoo_mort2_exp - integer(int_kind), intent(in) :: km - real(r8), intent(in) :: zt(km) - real(r8), intent(in) :: zooC(zooplankton_cnt,km) - real(r8), intent(in) :: Tfunc_zoo(zooplankton_cnt,km) + integer(int_kind), intent(in) :: kmt + real(r8), intent(in) :: zt(kmt) + real(r8), intent(in) :: zooC(zooplankton_cnt,kmt) + real(r8), intent(in) :: Tfunc_zoo(zooplankton_cnt,kmt) type(zooplankton_derived_terms_type), intent(inout) :: zooplankton_derived_terms !----------------------------------------------------------------------- ! local variables !----------------------------------------------------------------------- integer :: zoo_ind - real(r8) :: f_loss_thres(km) - real(r8) :: C_loss_thres(km) + real(r8) :: f_loss_thres(kmt) + real(r8) :: C_loss_thres(kmt) !----------------------------------------------------------------------- associate( & @@ -1811,6 +1843,8 @@ subroutine compute_Zprime(km, zt, zooC, Tfunc_zoo, zooplankton_derived_terms) zoo_loss_basal => zooplankton_derived_terms%zoo_loss_basal(:,:) & !(zooplankton_cnt) output ) + zoo_loss_bulk(:,:) = c0 !20231101 + ! calculate the loss threshold interpolation factor f_loss_thres(:) = min(max((thres_z2_zoo - zt(:))/(thres_z2_zoo - thres_z1_zoo), c0), c1) @@ -1832,8 +1866,8 @@ subroutine compute_Zprime(km, zt, zooC, Tfunc_zoo, zooplankton_derived_terms) end subroutine compute_Zprime !*********************************************************************** - - subroutine compute_grazing(km, Tfunc_zoo, zooplankton_local, zooplankton_derived_terms, autotroph_derived_terms) + ! renamed km to kmt in argument list + subroutine compute_grazing(kmt, Tfunc_zoo, zooplankton_local, zooplankton_derived_terms, autotroph_derived_terms) !----------------------------------------------------------------------- ! CALCULATE GRAZING @@ -1852,8 +1886,8 @@ subroutine compute_grazing(km, Tfunc_zoo, zooplankton_local, zooplankton_derived use marbl_pft_mod, only : grz_fnc_michaelis_menten use marbl_pft_mod, only : grz_fnc_sigmoidal - integer, intent(in) :: km - real(r8), intent(in) :: Tfunc_zoo(zooplankton_cnt,km) + integer, intent(in) :: kmt + real(r8), intent(in) :: Tfunc_zoo(zooplankton_cnt,kmt) type(zooplankton_local_type), intent(in) :: zooplankton_local type(zooplankton_derived_terms_type), intent(inout) :: zooplankton_derived_terms type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms @@ -1890,22 +1924,23 @@ subroutine compute_grazing(km, Tfunc_zoo, zooplankton_local, zooplankton_derived ) auto_graze(:,:) = c0 ! total grazing losses from autotroph pool at auto_ind - auto_graze_zoo(:,:,:) = c0 ! autotroph grazing losses routed to zooplankton at auto_ind - auto_graze_zootot(:,:) = c0 ! autotroph grazing losses routed to total zooplankton at auto_ind auto_graze_poc(:,:) = c0 ! autotroph grazing losses routed to poc - auto_graze_doc(:,:) = c0 ! autotroph grazing losses routed to doc auto_graze_dic(:,:) = c0 ! autotroph grazing losses routed to dic (computed by residual) + auto_graze_doc(:,:) = c0 ! autotroph grazing losses routed to doc + auto_graze_zoo(:,:,:) = c0 ! autotroph grazing losses routed to zooplankton at auto_ind + auto_graze_zootot(:,:) = c0 ! autotroph grazing losses routed to total zooplankton at auto_ind - zoo_graze(:,:) = c0 ! total grazing losses from zooplankton pool at zoo_ind - zoo_graze_zoo(:,:,:) = c0 ! zooplankton grazing losses routed to zooplankton at zoo_ind - zoo_graze_zootot(:,:) = c0 ! zooplankton grazing losses routed to total zooplankton at zoo_ind - zoo_graze_poc(:,:) = c0 ! zooplankton grazing losses routed to poc - zoo_graze_doc(:,:) = c0 ! zooplankton grazing losses routed to doc - zoo_graze_dic(:,:) = c0 ! zooplankton grazing losses routed to dic (computed by residual) - x_graze_zoo(:,:) = c0 ! grazing gains by zooplankton at zoo_ind + zoo_graze( :,:) = c0 ! total grazing losses from zooplankton pool at zoo_ind + zoo_graze_poc( :,:) = c0 ! zooplankton grazing losses routed to poc + zoo_graze_dic( :,:) = c0 ! zooplankton grazing losses routed to dic (computed by residual) + zoo_graze_doc( :,:) = c0 ! zooplankton grazing losses routed to doc + zoo_graze_zoo( :,:,:) = c0 ! zooplankton grazing losses routed to zooplankton at zoo_ind + zoo_graze_zootot(:,:) = c0 ! zooplankton grazing losses routed to total zooplankton at zoo_ind + x_graze_zoo( :,:) = c0 ! grazing gains by zooplankton at zoo_ind + f_zoo_detr( :,:) = c0 !20231101 - do k=1, km + do k=1, kmt do pred_ind = 1, zooplankton_cnt work3 = c0 @@ -2037,13 +2072,13 @@ subroutine compute_grazing(km, Tfunc_zoo, zooplankton_local, zooplankton_derived end subroutine compute_grazing !*********************************************************************** - - subroutine compute_routing(km, zooplankton_derived_terms, autotroph_derived_terms) + ! renamed km to kmt in argument list + subroutine compute_routing(kmt, zooplankton_derived_terms, autotroph_derived_terms) use marbl_settings_mod, only : parm_labile_ratio use marbl_settings_mod, only : f_toDOP - integer, intent(in) :: km + integer, intent(in) :: kmt type(zooplankton_derived_terms_type), intent(inout) :: zooplankton_derived_terms type(autotroph_derived_terms_type), intent(inout) :: autotroph_derived_terms @@ -2083,7 +2118,19 @@ subroutine compute_routing(km, zooplankton_derived_terms, autotroph_derived_term zoo_loss_dic => zooplankton_derived_terms%zoo_loss_dic(:,:) & ! output ) - do k=1,km + !20231101 + auto_graze_dic( :,:) = c0 + remaining_P_dop(:,:) = c0 + remaining_P_pop(:,:) = c0 + remaining_P_dip(:,:) = c0 + zoo_graze_dic( :,:) = c0 + + zoo_loss_poc(:,:) = c0 + zoo_loss_doc(:,:) = c0 + zoo_loss_dic(:,:) = c0 + !/20231101 + + do k=1,kmt !----------------------------------------------------------------------- ! compute routing to dic of grazed material !----------------------------------------------------------------------- @@ -2102,12 +2149,12 @@ subroutine compute_routing(km, zooplankton_derived_terms, autotroph_derived_term ! - zooplankton linear and quadratic losses get routed to DOC, DIC, and POC ! - basal respiration losses only contribute to DIC !----------------------------------------------------------------------- - + do zoo_ind = 1, zooplankton_cnt - zoo_loss_poc(zoo_ind,k) = f_zoo_detr(zoo_ind,k) * zoo_loss_bulk(zoo_ind,k) - zoo_loss_doc(zoo_ind,k) = (c1 - parm_labile_ratio) * (c1 - f_zoo_detr(zoo_ind,k)) * zoo_loss_bulk(zoo_ind,k) - zoo_loss_dic(zoo_ind,k) = (parm_labile_ratio * (c1 - f_zoo_detr(zoo_ind,k)) * zoo_loss_bulk(zoo_ind,k)) + & - zoo_loss_basal(zoo_ind,k) + zoo_loss_poc(zoo_ind,k) = f_zoo_detr(zoo_ind,k) * zoo_loss_bulk(zoo_ind,k) ! line that throws the error + zoo_loss_doc(zoo_ind,k) = (c1 - parm_labile_ratio) * (c1 - f_zoo_detr(zoo_ind,k)) * zoo_loss_bulk(zoo_ind,k) + zoo_loss_dic(zoo_ind,k) = (parm_labile_ratio * (c1 - f_zoo_detr(zoo_ind,k)) * zoo_loss_bulk(zoo_ind,k)) + & + zoo_loss_basal(zoo_ind,k) end do @@ -2148,8 +2195,8 @@ subroutine compute_routing(km, zooplankton_derived_terms, autotroph_derived_term end subroutine compute_routing !*********************************************************************** - - subroutine compute_dissolved_organic_matter (km, marbl_tracer_indices, & + ! renamed km to kmt in argument list + subroutine compute_dissolved_organic_matter (kmt, marbl_tracer_indices, & PAR_nsubcols, PAR, & zooplankton_derived_terms, autotroph_derived_terms, & dz1, tracer_local, unit_system, dissolved_organic_matter) @@ -2166,14 +2213,14 @@ subroutine compute_dissolved_organic_matter (km, marbl_tracer_indices, & use marbl_settings_mod, only : DOPr_reminR0 use marbl_settings_mod, only : DOMr_reminR_photo - integer(int_kind), intent(in) :: km + integer(int_kind), intent(in) :: kmt type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices integer(int_kind), intent(in) :: PAR_nsubcols type(marbl_PAR_type), intent(in) :: PAR type(zooplankton_derived_terms_type), intent(in) :: zooplankton_derived_terms type(autotroph_derived_terms_type), intent(in) :: autotroph_derived_terms real(r8), intent(in) :: dz1 - real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,km) + real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,kmt) type(unit_system_type), intent(in) :: unit_system type(dissolved_organic_matter_type), intent(inout) :: dissolved_organic_matter @@ -2230,7 +2277,7 @@ subroutine compute_dissolved_organic_matter (km, marbl_tracer_indices, & DOP_prod(:) = Qp_zoo * (sum(zoo_loss_doc(:,:), dim=1) + sum(zoo_graze_doc(:,:), dim=1)) & + sum(remaining_P_dop(:,:), dim=1) - do k=1, km + do k=1, kmt !----------------------------------------------------------------------- ! Different remin rates in light and dark for semi-labile pools !----------------------------------------------------------------------- @@ -2286,11 +2333,11 @@ subroutine compute_dissolved_organic_matter (km, marbl_tracer_indices, & end subroutine compute_dissolved_organic_matter !*********************************************************************** - - subroutine compute_scavenging(k, km, marbl_tracer_indices, & + ! renamed km to kmt in argument list + subroutine compute_scavenging(k, kmt, marbl_tracer_indices, & tracer_local, POC, P_CaCO3, P_SiO2, dust, & Fefree, Fe_scavenge_rate, Fe_scavenge, Lig_scavenge, & - marbl_status_log) + marbl_status_log) !! use marbl_constants_mod, only : c3, c4 use marbl_settings_mod , only : Lig_cnt @@ -2300,17 +2347,17 @@ subroutine compute_scavenging(k, km, marbl_tracer_indices, & use marbl_settings_mod , only : dust_Fe_scavenge_scale integer, intent(in) :: k - integer, intent(in) :: km + integer, intent(in) :: kmt !! type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices - real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,km) + real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt,kmt)!! type(column_sinking_particle_type), intent(in) :: POC type(column_sinking_particle_type), intent(in) :: P_CaCO3 type(column_sinking_particle_type), intent(in) :: P_SiO2 type(column_sinking_particle_type), intent(in) :: dust - real(r8), intent(out) :: Fefree(km) - real(r8), intent(out) :: Fe_scavenge_rate(km) ! scavenging rate of iron (1/s) - real(r8), intent(out) :: Fe_scavenge(km) - real(r8), intent(out) :: Lig_scavenge(km) + real(r8), intent(out) :: Fefree(kmt)!! + real(r8), intent(out) :: Fe_scavenge_rate(kmt)!! ! scavenging rate of iron (1/s) + real(r8), intent(out) :: Fe_scavenge(kmt)!! + real(r8), intent(out) :: Lig_scavenge(kmt)!! type(marbl_log_type), intent(inout) :: marbl_status_log !----------------------------------------------------------------------- @@ -2704,7 +2751,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef use marbl_glo_avg_mod, only : glo_avg_field_ind_interior_tendency_d_POP_bury_d_bury_coeff use marbl_glo_avg_mod, only : glo_avg_field_ind_interior_tendency_d_bSi_bury_d_bury_coeff use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_export_particulate - use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_set_used_particle_terms_to_zero + use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_subfloor_particle_terms_to_zero integer (int_kind) , intent(in) :: k ! vertical model level type(marbl_domain_type) , intent(in) :: domain @@ -2768,7 +2815,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef !----------------------------------------------------------------------- associate( & - column_kmt => domain%kmt, & + kmt => domain%kmt, & delta_z => domain%delta_z, & zw => domain%zw, & O2_loc => tracer_local(marbl_tracer_indices%o2_ind,k), & @@ -2813,7 +2860,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef poc_error = .false. dz_loc = delta_z(k) - if (k <= column_kmt) then + if (k <= kmt) then dzr_loc = c1 / dz_loc poc_diss = POC%diss @@ -3018,9 +3065,9 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef P_iron%hflux_out(k) = P_iron%hflux_in(k) - !------------------------------------------------------------------------ - ! compute POP remin and flux out, following code for iron - !------------------------------------------------------------------------ + !------------------------------------------------------------------------ + ! compute POP remin and flux out, following code for iron + !------------------------------------------------------------------------ POP%remin(k) = c0 if (POC%sflux_in(k) + POC%hflux_in(k) > c0) then @@ -3042,15 +3089,15 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef POP%hflux_out(k) = POP%hflux_in(k) - else ! k > column_kmt + else ! k > kmt - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, P_CaCO3) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, P_CaCO3_ALT_CO2) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, P_SiO2) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, dust) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, POC) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, P_iron) - call marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, POP) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, P_CaCO3) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, P_CaCO3_ALT_CO2) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, P_SiO2) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, dust) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, POC) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, P_iron) + call marbl_interior_tendency_share_subfloor_particle_terms_to_zero(k, POP) PON_remin(k) = c0 dzr_loc = c0 @@ -3068,7 +3115,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef ztop = c0 end if if (ztop .le. particulate_flux_ref_depth .and. particulate_flux_ref_depth .lt. zw(k)) then - if (k <= column_kmt) then + if (k <= kmt) then if (particulate_flux_ref_depth .eq. ztop) then ! expressions are simplified if particulate_flux_ref_depth is exactly the top of the layer POC%flux_at_ref_depth = POC%sflux_in(k) + POC%hflux_in(k) @@ -3137,7 +3184,7 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef PON_sed_loss = c0 - if (k == column_kmt) then + if (k == kmt) then POC%to_floor = POC%sflux_out(k) + POC%hflux_out(k) @@ -3308,29 +3355,29 @@ subroutine compute_particulate_terms(k, domain, bot_flux_to_tend, p_remin_scalef end subroutine compute_particulate_terms !*********************************************************************** - - subroutine compute_Lig_terms(km, PAR_nsubcols, marbl_tracer_indices, & + ! renamed km to kmt in argument list + subroutine compute_Lig_terms(kmt, PAR_nsubcols, marbl_tracer_indices, & POC_remin, DOC_prod, PAR, dz1, tracer_local, Lig_scavenge, & photoFe, unit_system, Lig_prod, Lig_photochem, Lig_deg, Lig_loss) use marbl_settings_mod, only : remin_to_Lig use marbl_settings_mod, only : parm_Lig_degrade_rate0 - integer(int_kind), intent(in) :: km + integer(int_kind), intent(in) :: kmt integer(int_kind), intent(in) :: PAR_nsubcols type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices - real(r8), intent(in) :: POC_remin(km) - real(r8), intent(in) :: DOC_prod(km) + real(r8), intent(in) :: POC_remin(kmt) + real(r8), intent(in) :: DOC_prod(kmt) type(marbl_PAR_type), intent(in) :: PAR real(r8), intent(in) :: dz1 - real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt, km) - real(r8), intent(in) :: Lig_scavenge(km) - real(r8), intent(in) :: photoFe(autotroph_cnt,km) + real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt, kmt) + real(r8), intent(in) :: Lig_scavenge(kmt) + real(r8), intent(in) :: photoFe(autotroph_cnt,kmt) type(unit_system_type), intent(in) :: unit_system - real(r8), intent(out) :: Lig_prod(km) - real(r8), intent(out) :: Lig_photochem(km) - real(r8), intent(out) :: Lig_deg(km) - real(r8), intent(out) :: Lig_loss(km) + real(r8), intent(out) :: Lig_prod(kmt) + real(r8), intent(out) :: Lig_photochem(kmt) + real(r8), intent(out) :: Lig_deg(kmt) + real(r8), intent(out) :: Lig_loss(kmt) !----------------------------------------------------------------------- ! local variables @@ -3444,23 +3491,23 @@ subroutine compute_nitrif(kmt, km, PAR_nsubcols, marbl_tracer_indices, PAR, trac end subroutine compute_nitrif !*********************************************************************** - - subroutine compute_denitrif(km, marbl_tracer_indices, tracer_local, DOC_remin, DOCr_remin, & - POC_remin, other_remin, sed_denitrif, denitrif) + ! renamed km to kmt in argument list + subroutine compute_denitrif(kmt, marbl_tracer_indices, tracer_local, DOC_remin, DOCr_remin, & + POC_remin, other_remin, sed_denitrif, denitrif) !! changed km > kmt throughout, tested !----------------------------------------------------------------------- ! Compute denitrification under low O2 conditions !----------------------------------------------------------------------- - integer, intent(in) :: km + integer, intent(in) :: kmt type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices - real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt, km) - real(r8), intent(in) :: DOC_remin(km) - real(r8), intent(in) :: DOCr_remin(km) - real(r8), intent(in) :: POC_remin(km) - real(r8), intent(in) :: other_remin(km) - real(r8), intent(inout) :: sed_denitrif(km) - real(r8), intent(out) :: denitrif(km) + real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt, kmt) + real(r8), intent(in) :: DOC_remin(kmt) + real(r8), intent(in) :: DOCr_remin(kmt) + real(r8), intent(in) :: POC_remin(kmt) + real(r8), intent(in) :: other_remin(kmt) + real(r8), intent(inout) :: sed_denitrif(kmt) + real(r8), intent(out) :: denitrif(kmt) !----------------------------------------------------------------------- ! local variables @@ -3473,7 +3520,7 @@ subroutine compute_denitrif(km, marbl_tracer_indices, tracer_local, DOC_remin, D O2_loc => tracer_local(marbl_tracer_indices%o2_ind,:), & NO3_loc => tracer_local(marbl_tracer_indices%no3_ind,:) & ) - do k=1,km + do k=1,kmt work = ((parm_o2_min + parm_o2_min_delta) - O2_loc(k)) / parm_o2_min_delta work = min(max(work, c0), c1) denitrif(k) = work * ((DOC_remin(k) + DOCr_remin(k) + POC_remin(k) * (c1 - POCremin_refract) & @@ -3492,37 +3539,37 @@ subroutine compute_denitrif(km, marbl_tracer_indices, tracer_local, DOC_remin, D end subroutine compute_denitrif !*********************************************************************** - - subroutine compute_local_tendencies(km, marbl_tracer_indices, autotroph_derived_terms, & + ! renamed km to kmt in argument list + subroutine compute_local_tendencies(kmt, marbl_tracer_indices, autotroph_derived_terms, & zooplankton_derived_terms, dissolved_organic_matter, nitrif, denitrif, sed_denitrif, & Fe_scavenge, Lig_prod, Lig_loss, P_iron_remin, POC_remin, POP_remin, P_SiO2_remin, & P_CaCO3_remin, P_CaCO3_ALT_CO2_remin, other_remin, PON_remin, tracer_local, & o2_consumption_scalef, o2_production, o2_consumption, interior_tendencies) - integer, intent(in) :: km + integer, intent(in) :: kmt type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices type(autotroph_derived_terms_type), intent(in) :: autotroph_derived_terms type(zooplankton_derived_terms_type), intent(in) :: zooplankton_derived_terms type(dissolved_organic_matter_type), intent(in) :: dissolved_organic_matter - real(r8), intent(in) :: nitrif(km) - real(r8), intent(in) :: denitrif(km) - real(r8), intent(in) :: sed_denitrif(km) - real(r8), intent(in) :: Fe_scavenge(km) - real(r8), intent(in) :: Lig_prod(km) - real(r8), intent(in) :: Lig_loss(km) - real(r8), intent(in) :: P_iron_remin(km) - real(r8), intent(in) :: POC_remin(km) - real(r8), intent(in) :: POP_remin(km) - real(r8), intent(in) :: P_SiO2_remin(km) - real(r8), intent(in) :: P_CaCO3_remin(km) - real(r8), intent(in) :: P_CaCO3_ALT_CO2_remin(km) - real(r8), intent(in) :: other_remin(km) - real(r8), intent(in) :: PON_remin(km) - real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt, km) - real(r8), intent(in) :: o2_consumption_scalef(km) - real(r8), intent(out) :: o2_production(km) - real(r8), intent(out) :: o2_consumption(km) - real(r8), intent(inout) :: interior_tendencies(marbl_tracer_indices%total_cnt, km) + real(r8), intent(in) :: nitrif(kmt) + real(r8), intent(in) :: denitrif(kmt) + real(r8), intent(in) :: sed_denitrif(kmt) + real(r8), intent(in) :: Fe_scavenge(kmt) + real(r8), intent(in) :: Lig_prod(kmt) + real(r8), intent(in) :: Lig_loss(kmt) + real(r8), intent(in) :: P_iron_remin(kmt) + real(r8), intent(in) :: POC_remin(kmt) + real(r8), intent(in) :: POP_remin(kmt) + real(r8), intent(in) :: P_SiO2_remin(kmt) + real(r8), intent(in) :: P_CaCO3_remin(kmt) + real(r8), intent(in) :: P_CaCO3_ALT_CO2_remin(kmt) + real(r8), intent(in) :: other_remin(kmt) + real(r8), intent(in) :: PON_remin(kmt) + real(r8), intent(in) :: tracer_local(marbl_tracer_indices%total_cnt, kmt) + real(r8), intent(in) :: o2_consumption_scalef(kmt) + real(r8), intent(out) :: o2_production(kmt) + real(r8), intent(out) :: o2_consumption(kmt) + real(r8), intent(inout) :: interior_tendencies(marbl_tracer_indices%total_cnt, kmt) !----------------------------------------------------------------------- ! local variables @@ -3599,7 +3646,7 @@ subroutine compute_local_tendencies(km, marbl_tracer_indices, autotroph_derived_ docr_ind => marbl_tracer_indices%docr_ind & ) - do k=1, km + do k=1, kmt !----------------------------------------------------------------------- ! nitrate & ammonium !----------------------------------------------------------------------- @@ -3818,6 +3865,7 @@ subroutine update_particulate_terms_from_prior_level(k, POC, POP, P_CaCO3, & type(column_sinking_particle_type) , intent(inout) :: POC, POP, P_CaCO3, P_CaCO3_ALT_CO2, P_SiO2, dust, P_iron real(r8) , intent(inout) :: QA_dust_def(:) !(km) + ! NOTE(bja, 2015-04) assume that k == ksurf condition was handled by ! call to marbl_set_surface_particulate_terms() if (k > 1) then diff --git a/src/marbl_interior_tendency_share_mod.F90 b/src/marbl_interior_tendency_share_mod.F90 index b818cd2b..4579f4d6 100644 --- a/src/marbl_interior_tendency_share_mod.F90 +++ b/src/marbl_interior_tendency_share_mod.F90 @@ -9,7 +9,7 @@ module marbl_interior_tendency_share_mod private public :: marbl_interior_tendency_share_update_particle_flux_from_above - public :: marbl_interior_tendency_share_set_used_particle_terms_to_zero + public :: marbl_interior_tendency_share_subfloor_particle_terms_to_zero public :: marbl_interior_tendency_share_export_variables public :: marbl_interior_tendency_share_export_zooplankton public :: marbl_interior_tendency_share_export_particulate @@ -33,18 +33,23 @@ end subroutine marbl_interior_tendency_share_update_particle_flux_from_above !*********************************************************************** - subroutine marbl_interior_tendency_share_set_used_particle_terms_to_zero(k, sinking_particle) + subroutine marbl_interior_tendency_share_subfloor_particle_terms_to_zero(kmt, sinking_particle) use marbl_interface_private_types, only : column_sinking_particle_type - integer (int_kind), intent(in) :: k + integer (int_kind), intent(in) :: kmt type(column_sinking_particle_type), intent(inout) :: sinking_particle - sinking_particle%sflux_out(k) = c0 - sinking_particle%hflux_out(k) = c0 - sinking_particle%remin(k) = c0 + !! 20231102 + sinking_particle%hflux_in(kmt+1:) = c0 + sinking_particle%sflux_in(kmt+1:) = c0 + !! /20231102 + sinking_particle%sflux_out(kmt+1:) = c0 + sinking_particle%hflux_out(kmt+1:) = c0 + sinking_particle%remin(kmt+1:) = c0 + sinking_particle%sed_loss(kmt+1:) = c0 !! 20230926 - end subroutine marbl_interior_tendency_share_set_used_particle_terms_to_zero + end subroutine marbl_interior_tendency_share_subfloor_particle_terms_to_zero !***********************************************************************