Skip to content

Commit

Permalink
Address issues with the Intel compiler and aerosol wavelength grid in…
Browse files Browse the repository at this point in the history
…dexing (#10)

* link to cpp std lib

* fix CMake flag, update TUV-x, and fix aerosol wavelength grid use
  • Loading branch information
mattldawson authored Apr 5, 2024
1 parent a3669a5 commit c12d1e4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ required = True
local_path = libraries/tuv-x
protocol = git
repo_url = https://github.com/NCAR/tuv-x.git
hash = b771af381777b7689d9da56995fb5b5fdd33be65
hash = d60e6c037ee0c481d629d5b9bf977f89a29d1b35
required = True

[hemco]
Expand Down
7 changes: 3 additions & 4 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,15 @@ def _build_tuvx(caseroot, libroot, bldroot):
cmake_args = "-DCMAKE_Fortran_COMPILER={} ".format(arg_dict["SFC"])
else:
cmake_args = "-DCMAKE_Fortran_COMPILER={} ".format(arg_dict["MPIFC"])
cmake_args += "-DENABLE_MPI:BOOL=TRUE "
cmake_args += "-DTUVX_ENABLE_MPI:BOOL=TRUE "
if case.get_value("DEBUG"):
cmake_args += "-DCMAKE_BUILD_TYPE=Debug "
else:
cmake_args += "-DCMAKE_BUILD_TYPE=Release "
cmake_args += "-DENABLE_UTIL_ONLY=ON "
cmake_args += "-DCMAKE_C_COMPILER_WORKS=1 "
cmake_args += "-DCMAKE_CXX_COMPILER_WORKS=1 "
cmake_args += "-DENABLE_TESTS=OFF "
cmake_args += "-DENABLE_COVERAGE=OFF "
cmake_args += "-DTUVX_ENABLE_TESTS=OFF "
cmake_args += "-DTUVX_ENABLE_COVERAGE=OFF "
cmake_args += "-DCMAKE_Fortran_FLAGS='{}' ".format(arg_dict["FFLAGS"])
cmake_args += "-DCMAKE_INSTALL_PREFIX='{}' ".format(libroot)
cmake_args += srcpath
Expand Down
2 changes: 1 addition & 1 deletion cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
<entry id="CAM_LINKED_LIBS">
<type>char</type>
<valid_values></valid_values>
<default_value>-ltuvx</default_value>
<default_value>-ltuvx -lstdc++</default_value>
<group>build_component_cam</group>
<file>env_build.xml</file>
<desc>
Expand Down
21 changes: 9 additions & 12 deletions src/chemistry/mozart/mo_tuvx.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1716,9 +1716,9 @@ subroutine get_aerosol_optical_properties( this, state, pbuf, optical_depth, &
! last bin should be moved to the just before the first bin (!?!)
! =========================================================================
call get_sw_spectral_boundaries( low_bound, high_bound, 'nm' )
wavelength_edges(1:nswbands-1) = high_bound(nswbands-1:1:-1)
wavelength_edges(nswbands ) = high_bound(nswbands )
wavelength_edges(nswbands+1 ) = low_bound( nswbands )
wavelength_edges(1:nswbands-1) = low_bound( nswbands-1:1:-1)
wavelength_edges(nswbands ) = low_bound( nswbands )
wavelength_edges(nswbands+1 ) = high_bound(nswbands )
call reorder_optics_array( aer_tau )
call reorder_optics_array( aer_tau_w )
call reorder_optics_array( aer_tau_w_g )
Expand All @@ -1729,17 +1729,14 @@ subroutine get_aerosol_optical_properties( this, state, pbuf, optical_depth, &
! TODO is this the correct regridding scheme to use?
n_tuvx_bins = this%n_wavelength_bins_
do i_col = 1, pcols
do i_level = 1, pver
do i_level = 1, pver + 1
call rebin(nswbands, n_tuvx_bins, wavelength_edges, this%wavelength_edges_, &
aer_tau(i_col,pver-i_level,:), optical_depth(i_col,i_level,:))
aer_tau(i_col,pver+1-i_level,:), optical_depth(i_col,i_level,:))
call rebin(nswbands, n_tuvx_bins, wavelength_edges, this%wavelength_edges_, &
aer_tau_w(i_col,pver-i_level,:), single_scattering_albedo(i_col,i_level,:))
aer_tau_w(i_col,pver+1-i_level,:), single_scattering_albedo(i_col,i_level,:))
call rebin(nswbands, n_tuvx_bins, wavelength_edges, this%wavelength_edges_, &
aer_tau_w_g(i_col,pver-i_level,:), asymmetry_factor(i_col,i_level,:))
aer_tau_w_g(i_col,pver+1-i_level,:), asymmetry_factor(i_col,i_level,:))
end do
optical_depth(i_col,pver+1,:) = optical_depth(i_col,pver,:)
single_scattering_albedo(i_col,pver+1,:) = single_scattering_albedo(i_col,pver,:)
asymmetry_factor(i_col,pver+1,:) = asymmetry_factor(i_col,pver,:)
end do

! ================================================================
Expand All @@ -1748,12 +1745,12 @@ subroutine get_aerosol_optical_properties( this, state, pbuf, optical_depth, &
associate( tau => optical_depth, &
omega => single_scattering_albedo, &
g => asymmetry_factor )
where(omega > 0.0_r8)
where(omega > 0.0_r8 .and. g > 0.0_r8)
g = g / omega
elsewhere
g = 0.0_r8
end where
where(tau > 0.0_r8)
where(tau > 0.0_r8 .and. omega > 0.0_r8)
omega = omega / tau
elsewhere
omega = 0.0_r8
Expand Down

0 comments on commit c12d1e4

Please sign in to comment.