Skip to content

Commit

Permalink
Merge branch 'philipwjones/mpas-framework/fix-config-dup' into next (PR
Browse files Browse the repository at this point in the history
#4907)

Remove duplicate config variables in ocean

Removes the auto-generation of duplicate config scalars (varinp_name)
that were introduced in a previous commit for safety when adding the
get_config_scalar routine.

[BFB]
  • Loading branch information
jonbob committed May 19, 2022
2 parents 98fbc7c + 574082a commit 406142e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 93 deletions.
25 changes: 5 additions & 20 deletions components/mpas-framework/src/tools/registry/gen_inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,32 +614,20 @@ int parse_namelist_records_from_registry(ezxml_t registry)/*{{{*/

if(strncmp(nmlopttype, "real", 1024) == 0){
fortprintf(fd, " real (kind=RKIND) :: %s = %lf\n", nmloptname, (double)atof(nmloptval));
fortprintf(fcd, " real (kind=RKIND), pointer :: %s\n", nmloptname);
if (strstr(nmloptname, "config_") == nmloptname ) {
fortprintf(fcd, " real (kind=RKIND) :: varinp_%s\n", nmloptname+7);
}
fortprintf(fcd, " real (kind=RKIND) :: %s\n", nmloptname);
} else if(strncmp(nmlopttype, "integer", 1024) == 0){
fortprintf(fd, " integer :: %s = %d\n", nmloptname, atoi(nmloptval));
fortprintf(fcd, " integer, pointer :: %s\n", nmloptname);
if (strstr(nmloptname, "config_") == nmloptname ) {
fortprintf(fcd, " integer :: varinp_%s\n", nmloptname+7);
}
fortprintf(fcd, " integer :: %s\n", nmloptname);
} else if(strncmp(nmlopttype, "logical", 1024) == 0){
fortprintf(fcd, " logical, pointer :: %s\n", nmloptname);
if (strstr(nmloptname, "config_") == nmloptname ) {
fortprintf(fcd, " logical :: varinp_%s\n", nmloptname+7);
}
fortprintf(fcd, " logical :: %s\n", nmloptname);
if(strncmp(nmloptval, "true", 1024) == 0 || strncmp(nmloptval, ".true.", 1024) == 0){
fortprintf(fd, " logical :: %s = .true.\n", nmloptname);
} else {
fortprintf(fd, " logical :: %s = .false.\n", nmloptname);
}
} else if(strncmp(nmlopttype, "character", 1024) == 0){
fortprintf(fd, " character (len=StrKIND) :: %s = '%s'\n", nmloptname, nmloptval);
fortprintf(fcd, " character (len=StrKIND), pointer :: %s\n", nmloptname);
if (strstr(nmloptname, "config_") == nmloptname ) {
fortprintf(fcd, " character (len=StrKIND) :: varinp_%s\n", nmloptname+7);
}
fortprintf(fcd, " character (len=StrKIND) :: %s\n", nmloptname);
}
}
fortprintf(fd, "\n");
Expand Down Expand Up @@ -728,10 +716,7 @@ int parse_namelist_records_from_registry(ezxml_t registry)/*{{{*/
nmloptname = ezxml_attr(nmlopt_xml, "name");

fortprintf(fd, " call mpas_pool_add_config(%s, '%s', %s)\n", pool_name, nmloptname, nmloptname);
fortprintf(fcg, " call mpas_pool_get_config(configPool, '%s', %s)\n", nmloptname, nmloptname);
if (strstr(nmloptname, "config_") == nmloptname ) {
fortprintf(fcg, " call mpas_pool_get_config_scalar(configPool, '%s', varinp_%s)\n", nmloptname, nmloptname+7);
}
fortprintf(fcg, " call mpas_pool_get_config_scalar(configPool, '%s', %s)\n", nmloptname, nmloptname);
}
fortprintf(fd, "\n");
fortprintf(fcg, "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ subroutine ocn_compute_high_frequency_output(domain, timeLevel, err)!{{{
call mpas_pool_get_array(highFrequencyOutputAMPool, 'vertVelSFC', vertVelSFC)

! split explicit specific arrays
call mpas_pool_get_config(ocnConfigs, 'config_time_integrator', config_time_integrator)
if ( config_time_integrator == trim('split_explicit') .or. config_time_integrator == trim('split_implicit') ) then
call mpas_pool_get_array(statePool, 'normalBaroclinicVelocity', normalBaroclinicVelocity, 1)
call mpas_pool_get_array(statePool, 'normalBarotropicVelocity', normalBarotropicVelocity, 1)
Expand Down
2 changes: 1 addition & 1 deletion components/mpas-ocean/src/driver/mpas_ocn_core.F
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ocn_core_init(domain, startTimeStamp) result(ierr)!{{{

ierr = 0

call mpas_pool_get_config(domain % configs, 'config_ocean_run_mode', config_ocean_run_mode)
call mpas_pool_get_config_scalar(domain % configs, 'config_ocean_run_mode', config_ocean_run_mode)

numThreads = mpas_threading_get_max_threads()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1910,16 +1910,12 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
'debugTracers' .and. &
config_reset_debugTracers_near_surface) then

! varinp_reset_debugTracers_top_nLayers = config_reset_debugTracers_top_nLayers
! note that varinp_... is the scalar analog to the config... input variables
! OpenACC complains about the pointer config... version

!$omp parallel
!$omp do schedule(runtime) private(k, lat)
do iCell = 1, nCellsAll

! Reset tracer1 to 2 in top n layers
do k = minLevelCell(iCell), minLevelCell(iCell)+varinp_reset_debugTracers_top_nLayers-1
do k = minLevelCell(iCell), minLevelCell(iCell)+config_reset_debugTracers_top_nLayers-1
tracersGroupNew(1,k,iCell) = 2.0_RKIND
end do

Expand All @@ -1931,11 +1927,11 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
.or.lat>- 2.5.and.lat< 2.5 &
.or.lat> 35.0.and.lat< 40.0 &
.or.lat> 55.0.and.lat< 60.0 ) then
do k = minLevelCell(iCell), minLevelCell(iCell)+varinp_reset_debugTracers_top_nLayers-1
do k = minLevelCell(iCell), minLevelCell(iCell)+config_reset_debugTracers_top_nLayers-1
tracersGroupNew(2,k,iCell) = 2.0_RKIND
end do
else
do k = minLevelCell(iCell), minLevelCell(iCell)+varinp_reset_debugTracers_top_nLayers-1
do k = minLevelCell(iCell), minLevelCell(iCell)+config_reset_debugTracers_top_nLayers-1
tracersGroupNew(2,k,iCell) = 1.0_RKIND
end do
end if
Expand All @@ -1949,11 +1945,11 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
.or.lat> 10.0.and.lat< 15.0 &
.or.lat> 30.0.and.lat< 35.0 &
.or.lat> 50.0.and.lat< 55.0 ) then
do k = minLevelCell(iCell), minLevelCell(iCell)+varinp_reset_debugTracers_top_nLayers-1
do k = minLevelCell(iCell), minLevelCell(iCell)+config_reset_debugTracers_top_nLayers-1
tracersGroupNew(3,k,iCell) = 2.0_RKIND
end do
else
do k = minLevelCell(iCell), minLevelCell(iCell)+varinp_reset_debugTracers_top_nLayers-1
do k = minLevelCell(iCell), minLevelCell(iCell)+config_reset_debugTracers_top_nLayers-1
tracersGroupNew(3,k,iCell) = 1.0_RKIND
end do
end if
Expand Down
28 changes: 14 additions & 14 deletions components/mpas-ocean/src/shared/mpas_ocn_diagnostics.F
Original file line number Diff line number Diff line change
Expand Up @@ -1453,8 +1453,8 @@ subroutine ocn_diagnostic_solve_surfaceLayer(layerThickness, activeTracers, &
!$omp do schedule(runtime)
#endif
do iCell = 1, nCells
surfaceFluxAttenuationCoefficient(iCell) = varinp_flux_attenuation_coefficient
surfaceFluxAttenuationCoefficientRunoff(iCell) = varinp_flux_attenuation_coefficient_runoff
surfaceFluxAttenuationCoefficient(iCell) = config_flux_attenuation_coefficient
surfaceFluxAttenuationCoefficientRunoff(iCell) = config_flux_attenuation_coefficient_runoff
end do
#ifndef MPAS_OPENACC
!$omp end do
Expand Down Expand Up @@ -2754,7 +2754,7 @@ subroutine ocn_compute_land_ice_flux_input_fields(layerThickness, normalVelocity
velocityMagnitude = sqrt(kineticEnergyCell(minLevelCell(cell1),cell1) + kineticEnergyCell(minLevelCell(cell2),cell2))
landIceEdgeFraction = 0.5_RKIND*(landIceFraction(cell1)+landIceFraction(cell2))

topDrag(iEdge) = - rho_sw * landIceEdgeFraction * varinp_land_ice_flux_topDragCoeff &
topDrag(iEdge) = - rho_sw * landIceEdgeFraction * config_land_ice_flux_topDragCoeff &
* velocityMagnitude * normalVelocity(minLevelEdgeBot(iEdge),iEdge)

end do
Expand All @@ -2772,13 +2772,13 @@ subroutine ocn_compute_land_ice_flux_input_fields(layerThickness, normalVelocity
do iCell = 1, nCellsAll
! the magnitude of the top drag is CD*u**2 = CD*(2*KE)
topDragMag(iCell) = rho_sw * landIceFraction(iCell) &
* 2.0_RKIND * varinp_land_ice_flux_topDragCoeff * kineticEnergyCell(minLevelCell(iCell),iCell)
* 2.0_RKIND * config_land_ice_flux_topDragCoeff * kineticEnergyCell(minLevelCell(iCell),iCell)

! the friction velocity is the square root of the top drag + variance of tidal velocity
! (computed regardless of land-ice coverage)
landIceFrictionVelocity(iCell) = sqrt(varinp_land_ice_flux_topDragCoeff * &
landIceFrictionVelocity(iCell) = sqrt(config_land_ice_flux_topDragCoeff * &
(2.0_RKIND * kineticEnergyCell(minLevelCell(iCell),iCell) &
+ varinp_land_ice_flux_rms_tidal_velocity**2))
+ config_land_ice_flux_rms_tidal_velocity**2))
end do
#ifndef MPAS_OPENACC
!$omp end do
Expand All @@ -2795,7 +2795,7 @@ subroutine ocn_compute_land_ice_flux_input_fields(layerThickness, normalVelocity
blTempScratch(iCell) = 0.0_RKIND
blSaltScratch(iCell) = 0.0_RKIND
do iLevel = minLevelCell(iCell), maxLevelCell(iCell)
dz = min(layerThickness(iLevel,iCell),varinp_land_ice_flux_boundaryLayerThickness-blThickness)
dz = min(layerThickness(iLevel,iCell),config_land_ice_flux_boundaryLayerThickness-blThickness)
if(dz <= 0.0_RKIND) exit
blTempScratch(iCell) = blTempScratch(iCell) + activeTracers(indexTval, iLevel, iCell)*dz
blSaltScratch(iCell) = blSaltScratch(iCell) + activeTracers(indexSval, iLevel, iCell)*dz
Expand All @@ -2819,16 +2819,16 @@ subroutine ocn_compute_land_ice_flux_input_fields(layerThickness, normalVelocity
do iCell = 1, nCellsAll
landIceBoundaryLayerTracers(indexBLTval, iCell) = blTempScratch(iCell)
landIceBoundaryLayerTracers(indexBLSval, iCell) = blSaltScratch(iCell)
if(varinp_land_ice_flux_boundaryLayerNeighborWeight > 0.0_RKIND) then
if(config_land_ice_flux_boundaryLayerNeighborWeight > 0.0_RKIND) then
weightSum = 1.0_RKIND
do i = 1, nEdgesOnCell(iCell)
cell2 = cellsOnCell(i,iCell)

landIceBoundaryLayerTracers(indexBLTval, iCell) = landIceBoundaryLayerTracers(indexBLTval, iCell) &
+ cellMask(minLevelCell(cell2),cell2)*varinp_land_ice_flux_boundaryLayerNeighborWeight*blTempScratch(cell2)
+ cellMask(minLevelCell(cell2),cell2)*config_land_ice_flux_boundaryLayerNeighborWeight*blTempScratch(cell2)
landIceBoundaryLayerTracers(indexBLSval, iCell) = landIceBoundaryLayerTracers(indexBLSval, iCell) &
+ cellMask(minLevelCell(cell2),cell2)*varinp_land_ice_flux_boundaryLayerNeighborWeight*blSaltScratch(cell2)
weightSum = weightSum + cellMask(minLevelCell(cell2),cell2)*varinp_land_ice_flux_boundaryLayerNeighborWeight
+ cellMask(minLevelCell(cell2),cell2)*config_land_ice_flux_boundaryLayerNeighborWeight*blSaltScratch(cell2)
weightSum = weightSum + cellMask(minLevelCell(cell2),cell2)*config_land_ice_flux_boundaryLayerNeighborWeight
end do
landIceBoundaryLayerTracers(:, iCell) = landIceBoundaryLayerTracers(:, iCell)/weightSum
end if
Expand All @@ -2848,9 +2848,9 @@ subroutine ocn_compute_land_ice_flux_input_fields(layerThickness, normalVelocity
do iCell = 1, nCellsAll
! transfer coefficients from namelist
landIceTracerTransferVelocities(indexHeatTransval, iCell) = landIceFrictionVelocity(iCell) &
* varinp_land_ice_flux_jenkins_heat_transfer_coefficient
* config_land_ice_flux_jenkins_heat_transfer_coefficient
landIceTracerTransferVelocities(indexSaltTransval, iCell) = landIceFrictionVelocity(iCell) &
* varinp_land_ice_flux_jenkins_salt_transfer_coefficient
* config_land_ice_flux_jenkins_salt_transfer_coefficient
end do
#ifndef MPAS_OPENACC
!$omp end do
Expand Down Expand Up @@ -2899,7 +2899,7 @@ subroutine ocn_compute_land_ice_flux_input_fields(layerThickness, normalVelocity
#endif
do iCell = 1, nCellsAll
if(landIceMask(iCell) == 1) then
sfcFlxAttCoeff(iCell) = varinp_land_ice_flux_attenuation_coefficient
sfcFlxAttCoeff(iCell) = config_land_ice_flux_attenuation_coefficient
end if
end do
#ifndef MPAS_OPENACC
Expand Down
28 changes: 14 additions & 14 deletions components/mpas-ocean/src/shared/mpas_ocn_equation_of_state.F
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,17 @@ real (kind=RKIND) function ocn_freezing_temperature(salinity, pressure, inLandIc
real (kind=RKIND) :: coeff_mushy

if(inLandIceCavity) then
coeff_0 = varinp_land_ice_cavity_freezing_temperature_coeff_0
coeff_S = varinp_land_ice_cavity_freezing_temperature_coeff_S
coeff_p = varinp_land_ice_cavity_freezing_temperature_coeff_p
coeff_pS = varinp_land_ice_cavity_freezing_temperature_coeff_pS
coeff_0 = config_land_ice_cavity_freezing_temperature_coeff_0
coeff_S = config_land_ice_cavity_freezing_temperature_coeff_S
coeff_p = config_land_ice_cavity_freezing_temperature_coeff_p
coeff_pS = config_land_ice_cavity_freezing_temperature_coeff_pS
coeff_mushy = 0.0_RKIND
else
coeff_0 = varinp_open_ocean_freezing_temperature_coeff_0
coeff_S = varinp_open_ocean_freezing_temperature_coeff_S
coeff_p = varinp_open_ocean_freezing_temperature_coeff_p
coeff_pS = varinp_open_ocean_freezing_temperature_coeff_pS
az1_liq = varinp_open_ocean_freezing_temperature_coeff_mushy_az1_liq
coeff_0 = config_open_ocean_freezing_temperature_coeff_0
coeff_S = config_open_ocean_freezing_temperature_coeff_S
coeff_p = config_open_ocean_freezing_temperature_coeff_p
coeff_pS = config_open_ocean_freezing_temperature_coeff_pS
az1_liq = config_open_ocean_freezing_temperature_coeff_mushy_az1_liq
coeff_mushy = 1.0_RKIND / az1_liq
end if

Expand Down Expand Up @@ -541,13 +541,13 @@ real (kind=RKIND) function ocn_freezing_temperature_salinity_deriv(salinity, pre


if(inLandIceCavity) then
coeff_S = varinp_land_ice_cavity_freezing_temperature_coeff_S
coeff_pS = varinp_land_ice_cavity_freezing_temperature_coeff_pS
coeff_S = config_land_ice_cavity_freezing_temperature_coeff_S
coeff_pS = config_land_ice_cavity_freezing_temperature_coeff_pS
coeff_mushy = 0.0_RKIND
else
coeff_S = varinp_open_ocean_freezing_temperature_coeff_S
coeff_pS = varinp_open_ocean_freezing_temperature_coeff_pS
az1_liq = varinp_open_ocean_freezing_temperature_coeff_mushy_az1_liq
coeff_S = config_open_ocean_freezing_temperature_coeff_S
coeff_pS = config_open_ocean_freezing_temperature_coeff_pS
az1_liq = config_open_ocean_freezing_temperature_coeff_mushy_az1_liq
coeff_mushy = 1.0_RKIND / az1_liq
end if

Expand Down
Loading

0 comments on commit 406142e

Please sign in to comment.