Skip to content

Commit

Permalink
update and convert MOSAiC cases to DEPHY format; allow both surfacefo…
Browse files Browse the repository at this point in the history
…rcingT to be true and surfaceforcinglsm to be true - ingests LSM data and a forcing surface T
  • Loading branch information
grantfirl committed Aug 1, 2024
1 parent 48d180e commit 7eae638
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 81 deletions.
25 changes: 8 additions & 17 deletions scm/etc/case_config/MOSAiC-AMPS.nml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
$case_config
case_name = 'MOSAiC-AMPS',
runtime = 604800.0,
thermo_forcing_type = 2,
mom_forcing_type = 3,
relax_time = 3600.0,
sfc_flux_spec = .false.,
sfc_type = 2,
sfc_roughness_length_cm = 0.02,
reference_profile_choice = 1,
year = 2019,
month = 10,
day = 31,
hour = 0,
column_area = 2.0E9,
lsm_ics = .true.,
$end
&case_config
case_name = 'MOSAiC-AMPS'
column_area = 2000000000.0
input_type = 1
lsm_ics = .true.
reference_profile_choice = 1
sfc_roughness_length_cm = 0.02
/
25 changes: 8 additions & 17 deletions scm/etc/case_config/MOSAiC-SS.nml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
$case_config
case_name = 'MOSAiC-SS',
runtime = 604800.0,
thermo_forcing_type = 2,
mom_forcing_type = 3,
relax_time = 3600.0,
sfc_flux_spec = .false.,
sfc_type = 2,
sfc_roughness_length_cm = 0.02,
reference_profile_choice = 1,
year = 2020,
month = 3,
day = 2,
hour = 0,
column_area = 2.0E9,
lsm_ics = .true.,
$end
&case_config
case_name = 'MOSAiC-SS'
column_area = 2000000000.0
input_type = 1
lsm_ics = .true.
reference_profile_choice = 1
sfc_roughness_length_cm = 0.02
/
68 changes: 52 additions & 16 deletions scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
#height = ffc.get_height_from_pres(T_abs[:,0],levels,z_sfc)

#the following variables are not in this forcing file, but are included in other cases
soil_depth = np.zeros(4,dtype=float)
soil_depth[:] = [0.1, 0.4, 1.0, 2.0]

#rad_heating = nc_fid.variables['dT_dt_rad'][:] #K/s
#rad_heating = np.swapaxes(rad_heating, 0, 1) #swap the time and levels axis
rad_heating = np.zeros((levels.size,time.size),dtype=float)
Expand All @@ -163,29 +166,31 @@
smc = 0.33
slc = 0.33
hice = 0.3
slmsk = 2.0
slmsk = 2.0 #sea ice
tsfco = T_surf[start_t_index]
weasd = 200.0
weasd = 200.0 #mm water equivalent snow depth
fice = 1.0
tisfc = tsfco
snwdph = 2.e-4
tg3 = 271.35
zorl = 15.0
alvsf = 0.23
alnsf = 0.23
alvwf = 0.23
alnwf = 0.23
facsf = 0.5055632
facwf = 0.4944368
alvsf = 0.06
alnsf = 0.06
alvwf = 0.06
alnwf = 0.06
facsf = 0.0
facwf = 0.0
vegfrac = 0.0
canopy = 0.0
vegtyp = 10
soiltyp = 12
vegtyp = 0
soiltyp = 0
scolor = 1
uustar = 0.3828793
shdmin = 0.01
shdmax = 0.8
shdmin = 0.0
shdmax = 0.0
slopetyp = 1
snoalb = 0.7287961
snoalb = 0.0
sncovr = 1.0

# Open ozone file
#f = open('../../data/raw_case_input/twpice_CRM_ozone.txt', 'r')
Expand Down Expand Up @@ -237,6 +242,12 @@
writefile_levels_var.units = 'Pa'
writefile_levels_var.description = 'pressure levels'

writefile_soil_depth_dim = writefile_fid.createDimension('soil_depth', None)
writefile_soil_depth_var = writefile_fid.createVariable('soil_depth', 'f4', ('soil_depth',))
writefile_soil_depth_var[:] = soil_depth[:]
writefile_soil_depth_var.units = 'm'
writefile_soil_depth_var.description = 'soil depth'

writefile_ice_thickness_dim = writefile_fid.createDimension('ice_thickness', None)
writefile_ice_thickness_var = writefile_fid.createVariable('ice_thickness', 'f4', ('ice_thickness',))
writefile_ice_thickness_var[:] = ice_thickness
Expand Down Expand Up @@ -302,6 +313,21 @@
writefile_zorl_var.units = 'cm'
writefile_zorl_var.description = 'composite surface roughness length'

writefile_zorll_var = writefile_scalar_grp.createVariable('zorll', 'f4')
writefile_zorll_var[:] = zorl
writefile_zorll_var.units = 'cm'
writefile_zorll_var.description = 'surface roughness length over land'

writefile_zorlw_var = writefile_scalar_grp.createVariable('zorlw', 'f4')
writefile_zorlw_var[:] = zorl
writefile_zorlw_var.units = 'cm'
writefile_zorlw_var.description = 'surface roughness length over ocean'

writefile_zorli_var = writefile_scalar_grp.createVariable('zorli', 'f4')
writefile_zorli_var[:] = zorl
writefile_zorli_var.units = 'cm'
writefile_zorli_var.description = 'surface roughness length over ice'

writefile_alvsf_var = writefile_scalar_grp.createVariable('alvsf', 'f4')
writefile_alvsf_var[:] = alvsf
writefile_alvsf_var.units = ''
Expand Down Expand Up @@ -352,6 +378,11 @@
writefile_soiltyp_var.units = ''
writefile_soiltyp_var.description = 'soil type 1-12'

writefile_scolor_var = writefile_scalar_grp.createVariable('scolor', 'f4')
writefile_scolor_var[:] = scolor
writefile_scolor_var.units = ''
writefile_scolor_var.description = 'soil color'

writefile_uustar_var = writefile_scalar_grp.createVariable('uustar', 'f4')
writefile_uustar_var[:] = uustar
writefile_uustar_var.units = 'm s-1'
Expand All @@ -377,6 +408,11 @@
writefile_snoalb_var.units = '1'
writefile_snoalb_var.description = 'maximum snow albedo'

writefile_sncovr_var = writefile_scalar_grp.createVariable('sncovr', 'f4')
writefile_sncovr_var[:] = sncovr
writefile_sncovr_var.units = '1'
writefile_sncovr_var.description = 'surface snow area fraction'

#initial group

writefile_height_var = writefile_initial_grp.createVariable('height', 'f4', ('levels',))
Expand All @@ -389,17 +425,17 @@
writefile_tiice_var.units = 'K'
writefile_tiice_var.description = 'initial profile of sea ice internal temperature'

writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4')
writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4', ('soil_depth',))
writefile_stc_var[:] = stc
writefile_stc_var.units = 'K'
writefile_stc_var.description = 'initial profile of sea ice internal temperature'

writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4')
writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4', ('soil_depth',))
writefile_smc_var[:] = smc
writefile_smc_var.units = 'm3 m-3'
writefile_smc_var.description = 'initial profile of soil moisture'

writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4')
writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4', ('soil_depth',))
writefile_slc_var[:] = slc
writefile_slc_var.units = 'm3 m-3'
writefile_slc_var.description = 'initial profile of soil liquid water'
Expand Down
68 changes: 52 additions & 16 deletions scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
#height = ffc.get_height_from_pres(T_abs[:,0],levels,z_sfc)

#the following variables are not in this forcing file, but are included in other cases
soil_depth = np.zeros(4,dtype=float)
soil_depth[:] = [0.1, 0.4, 1.0, 2.0]

#rad_heating = nc_fid.variables['dT_dt_rad'][:] #K/s
#rad_heating = np.swapaxes(rad_heating, 0, 1) #swap the time and levels axis
rad_heating = np.zeros((levels.size,time.size),dtype=float)
Expand All @@ -163,29 +166,31 @@
smc = 0.33
slc = 0.33
hice = 0.3
slmsk = 2.0
slmsk = 2.0 #sea ice
tsfco = T_surf[start_t_index]
weasd = 200.0
weasd = 200.0 #mm water equivalent snow depth
fice = 1.0
tisfc = tsfco
snwdph = 2.e-4
tg3 = 271.35
zorl = 15.0
alvsf = 0.23
alnsf = 0.23
alvwf = 0.23
alnwf = 0.23
facsf = 0.5055632
facwf = 0.4944368
alvsf = 0.06
alnsf = 0.06
alvwf = 0.06
alnwf = 0.06
facsf = 0.0
facwf = 0.0
vegfrac = 0.0
canopy = 0.0
vegtyp = 10
soiltyp = 12
vegtyp = 0
soiltyp = 0
scolor = 1
uustar = 0.3828793
shdmin = 0.01
shdmax = 0.8
shdmin = 0.0
shdmax = 0.0
slopetyp = 1
snoalb = 0.7287961
snoalb = 0.0
sncovr = 1.0

# Open ozone file
#f = open('../../data/raw_case_input/twpice_CRM_ozone.txt', 'r')
Expand Down Expand Up @@ -237,6 +242,12 @@
writefile_levels_var.units = 'Pa'
writefile_levels_var.description = 'pressure levels'

writefile_soil_depth_dim = writefile_fid.createDimension('soil_depth', None)
writefile_soil_depth_var = writefile_fid.createVariable('soil_depth', 'f4', ('soil_depth',))
writefile_soil_depth_var[:] = soil_depth[:]
writefile_soil_depth_var.units = 'm'
writefile_soil_depth_var.description = 'soil depth'

writefile_ice_thickness_dim = writefile_fid.createDimension('ice_thickness', None)
writefile_ice_thickness_var = writefile_fid.createVariable('ice_thickness', 'f4', ('ice_thickness',))
writefile_ice_thickness_var[:] = ice_thickness
Expand Down Expand Up @@ -302,6 +313,21 @@
writefile_zorl_var.units = 'cm'
writefile_zorl_var.description = 'composite surface roughness length'

writefile_zorll_var = writefile_scalar_grp.createVariable('zorll', 'f4')
writefile_zorll_var[:] = zorl
writefile_zorll_var.units = 'cm'
writefile_zorll_var.description = 'surface roughness length over land'

writefile_zorlw_var = writefile_scalar_grp.createVariable('zorlw', 'f4')
writefile_zorlw_var[:] = zorl
writefile_zorlw_var.units = 'cm'
writefile_zorlw_var.description = 'surface roughness length over ocean'

writefile_zorli_var = writefile_scalar_grp.createVariable('zorli', 'f4')
writefile_zorli_var[:] = zorl
writefile_zorli_var.units = 'cm'
writefile_zorli_var.description = 'surface roughness length over ice'

writefile_alvsf_var = writefile_scalar_grp.createVariable('alvsf', 'f4')
writefile_alvsf_var[:] = alvsf
writefile_alvsf_var.units = ''
Expand Down Expand Up @@ -352,6 +378,11 @@
writefile_soiltyp_var.units = ''
writefile_soiltyp_var.description = 'soil type 1-12'

writefile_scolor_var = writefile_scalar_grp.createVariable('scolor', 'f4')
writefile_scolor_var[:] = scolor
writefile_scolor_var.units = ''
writefile_scolor_var.description = 'soil color'

writefile_uustar_var = writefile_scalar_grp.createVariable('uustar', 'f4')
writefile_uustar_var[:] = uustar
writefile_uustar_var.units = 'm s-1'
Expand All @@ -377,6 +408,11 @@
writefile_snoalb_var.units = '1'
writefile_snoalb_var.description = 'maximum snow albedo'

writefile_sncovr_var = writefile_scalar_grp.createVariable('sncovr', 'f4')
writefile_sncovr_var[:] = sncovr
writefile_sncovr_var.units = '1'
writefile_sncovr_var.description = 'surface snow area fraction'

#initial group

writefile_height_var = writefile_initial_grp.createVariable('height', 'f4', ('levels',))
Expand All @@ -389,17 +425,17 @@
writefile_tiice_var.units = 'K'
writefile_tiice_var.description = 'initial profile of sea ice internal temperature'

writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4')
writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4', ('soil_depth',))
writefile_stc_var[:] = stc
writefile_stc_var.units = 'K'
writefile_stc_var.description = 'initial profile of sea ice internal temperature'

writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4')
writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4', ('soil_depth',))
writefile_smc_var[:] = smc
writefile_smc_var.units = 'm3 m-3'
writefile_smc_var.description = 'initial profile of soil moisture'

writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4')
writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4', ('soil_depth',))
writefile_slc_var[:] = slc
writefile_slc_var.units = 'm3 m-3'
writefile_slc_var.description = 'initial profile of soil liquid water'
Expand Down
27 changes: 13 additions & 14 deletions scm/etc/scripts/dephy_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ def write_SCM_case_file(case_nml, case_data, use_area):
nslsnw_dim = nc_file.createDimension('nsoil_plus_nsnow',case_data._snicexy.shape[0] + case_data._soil_depth.shape[0])

if (case_data._tiice[0] != case_data._missing_value):
ice_dim = nc_file.createDimension('nice', case_data._tiice[0])
ice_dim = nc_file.createDimension('nice', case_data._tiice.shape[0])

#
timei_var = nc_file.createVariable('t0', wp, ('t0'))
Expand Down Expand Up @@ -2466,20 +2466,19 @@ def write_SCM_case_file(case_nml, case_data, use_area):
else:
ts_var[:] = case_data._missing_value
else:
if (nc_file.surface_forcing_lsm != 'lsm'):

nc_file.surface_forcing_temp = 'ts'
nc_file.surface_forcing_wind = 'z0'

z0_var = nc_file.createVariable('z0', wp, ('time'))
z0_var.units = 'm'
z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air'
z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2
nc_file.surface_forcing_temp = 'ts'
nc_file.surface_forcing_wind = 'z0'

ts_var = nc_file.createVariable('ts_forc', wp, ('time'))
ts_var.units = 'K'
ts_var.standard_name = 'forcing_surface_temperature'
ts_var[:] = case_data._T_surf[:]
z0_var = nc_file.createVariable('z0', wp, ('time'))
z0_var.units = 'm'
z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air'
z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2

ts_var = nc_file.createVariable('ts_forc', wp, ('time'))
ts_var.units = 'K'
ts_var.standard_name = 'forcing_surface_temperature'
ts_var[:] = case_data._T_surf[:]


nc_file.close()

Expand Down
4 changes: 3 additions & 1 deletion scm/src/scm_input.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,9 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
else
scm_input%input_lh_flux_sfc = input_force_sfc_lat_flx(:)
end if
else if (trim(input_surfaceForcingLSM) == 'lsm') then
end if

if (trim(input_surfaceForcingLSM) == 'lsm') then
!these were considered required variables above, so they should not need to be checked for missing
scm_input%input_stc = input_stc(:,active_init_time)
scm_input%input_smc = input_smc(:,active_init_time)
Expand Down

0 comments on commit 7eae638

Please sign in to comment.