Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for reading sfc fluxes for DEPHYv1 format #428

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scm/src/run_scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,12 @@ def setup_rundir(self):
try:
input_type = case_nml['case_config']['input_type']
if input_type == 1:
surface_flux_spec = False
#open the case data file and read the surfaceForcing global attribute
case_data_dir = case_nml['case_config']['case_data_dir']
nc_fid = Dataset(os.path.join(SCM_ROOT, case_data_dir) + '/' + self._case + '_SCM_driver.nc' , 'r')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need these changes to lines 493-494? (Just the change to line 496)

Copy link
Collaborator Author

@hertneky hertneky Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dustinswales Thanks, I reverted the L493 change. I just tested and it is working fine (note I made that change awhile back due to some random issue reading the file). Thinking about it, I wonder if surface_forcing_moisture should also be considered here, since they can be set independently. I'm not sure how the SCM would react with them set differently without looking more at the code.

Copy link
Collaborator Author

@hertneky hertneky Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dustinswales Revisiting this reverted change. It looks like changes are needed here otherwise the fluxes are not read in correctly. case_nml['case_config']['case_data_dir'] is empty, so either it needs to be assigned the path somewhere above, OR remove L492 and modify L493 case_data_dir > self._case_data_dir. This only shows up when prescribing sfc_fluxes. While the case will appear to run normally without a fix, it will run the default suite and not the *_ps version since nothing is getting read correctly here.

surfaceForcing = nc_fid.getncattr('surfaceForcing')
nc_fid = Dataset(os.path.join(SCM_ROOT, self._case_data_dir) + '/' + self._case + '_SCM_driver.nc' , 'r')
surfaceForcing = nc_fid.getncattr('surface_forcing_temp')
nc_fid.close()
if (surfaceForcing.lower() == 'flux' or surfaceForcing.lower() == 'surfaceflux'):
if (surfaceForcing.lower() == 'flux' or surfaceForcing.lower() == 'surface_flux'):
surface_flux_spec = True
except KeyError:
# if not using DEPHY format, check to see if surface fluxes are specified in the case configuration file (default is False)
Expand Down
4 changes: 2 additions & 2 deletions scm/src/scm_input.F90
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
real(kind=sp) :: z_nudging_temp, z_nudging_theta, z_nudging_thetal, z_nudging_qv, z_nudging_qt, z_nudging_rv, z_nudging_rt, z_nudging_u, z_nudging_v
real(kind=sp) :: p_nudging_temp, p_nudging_theta, p_nudging_thetal, p_nudging_qv, p_nudging_qt, p_nudging_rv, p_nudging_rt, p_nudging_u, p_nudging_v
character(len=5) :: input_surfaceType
character(len=11) :: input_surfaceForcingWind='',input_surfaceForcingMoist='',input_surfaceForcingLSM='',input_surfaceForcingTemp=''
character(len=12) :: input_surfaceForcingWind='',input_surfaceForcingMoist='',input_surfaceForcingLSM='',input_surfaceForcingTemp=''

! initial variables (IC = Initial Condition)
real(kind=dp), allocatable :: input_lat(:) !< column latitude (deg)
Expand Down Expand Up @@ -1630,7 +1630,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
call NetCDF_read_var(ncid, "wprvp_s", .False., input_force_wprvp)
call NetCDF_read_var(ncid, "wprtp_s", .False., input_force_wprtp)
else if (trim(input_surfaceForcingMoist) == 'surface_flux') then
call NetCDF_read_var(ncid, "hfls", .False., input_force_sfc_sens_flx)
call NetCDF_read_var(ncid, "hfls", .False., input_force_sfc_lat_flx)
endif

!
Expand Down
Loading