@@ -148,9 +148,6 @@ def _compute_initial_condition(self):
148148
149149 ds ['landIcePressure' ] = land_ice_pressure
150150
151- if self .time_varying_forcing :
152- self ._write_time_varying_forcing (ds_init = ds )
153-
154151 section = config ['isomip_plus' ]
155152
156153 # Deepen the bottom depth to maintain the minimum water-column
@@ -215,6 +212,15 @@ def _compute_initial_condition(self):
215212 ds ['normalVelocity' ] = normalVelocity .expand_dims (dim = 'Time' , axis = 0 )
216213
217214 write_netcdf (ds , 'initial_state.nc' )
215+
216+ if self .time_varying_forcing :
217+ self ._write_time_varying_forcing (ds_init = ds ,
218+ ice_density = ice_density )
219+ else :
220+ # We need to add the time dimension for plotting purposes
221+ ds ['landIcePressure' ] = \
222+ ds ['landIcePressure' ].expand_dims (dim = 'Time' , axis = 0 )
223+
218224 return ds , frac
219225
220226 def _plot (self , ds ):
@@ -243,8 +249,6 @@ def _plot(self, ds):
243249
244250 ds ['oceanFracObserved' ] = \
245251 ds ['oceanFracObserved' ].expand_dims (dim = 'Time' , axis = 0 )
246- ds ['landIcePressure' ] = \
247- ds ['landIcePressure' ].expand_dims (dim = 'Time' , axis = 0 )
248252 ds ['landIceThickness' ] = \
249253 ds ['landIceThickness' ].expand_dims (dim = 'Time' , axis = 0 )
250254 ds ['landIceGroundedFraction' ] = \
@@ -382,7 +386,7 @@ def _compute_restoring(self, ds, frac):
382386
383387 write_netcdf (ds_forcing , 'init_mode_forcing_data.nc' )
384388
385- def _write_time_varying_forcing (self , ds_init ):
389+ def _write_time_varying_forcing (self , ds_init , ice_density ):
386390 """
387391 Write time-varying land-ice forcing and update the initial condition
388392 """
@@ -402,10 +406,27 @@ def _write_time_varying_forcing(self, ds_init):
402406 landIceFraction = list ()
403407 landIceFloatingFraction = list ()
404408
409+ if self .thin_film_present :
410+ land_ice_thickness = ds_init .landIceThickness
411+ land_ice_pressure = compute_land_ice_pressure_from_thickness (
412+ land_ice_thickness = land_ice_thickness ,
413+ modify_mask = ds_init .landIceFraction > 0. ,
414+ land_ice_density = ice_density )
415+ land_ice_draft = compute_land_ice_draft_from_pressure (
416+ land_ice_pressure = land_ice_pressure ,
417+ modify_mask = ds_init .bottomDepth > 0. )
418+ land_ice_draft = np .maximum (land_ice_draft , - ds_init .bottomDepth )
419+ land_ice_draft = land_ice_draft .transpose ()
420+ else :
421+ land_ice_draft = ds_init .landIceDraft
422+ land_ice_pressure = ds_init .landIcePressure
423+
405424 for scale in scales :
406- landIceDraft .append (scale * ds_init . landIceDraft )
407- landIcePressure .append (scale * ds_init . landIcePressure )
425+ landIceDraft .append (scale * land_ice_draft )
426+ landIcePressure .append (scale * land_ice_pressure )
408427 landIceFraction .append (ds_init .landIceFraction )
428+ # Since floating fraction does not change, none of the thin film
429+ # cases allow for the area undergoing melting to change
409430 landIceFloatingFraction .append (ds_init .landIceFloatingFraction )
410431
411432 ds_out ['landIceDraftForcing' ] = xr .concat (landIceDraft , 'Time' )
@@ -427,6 +448,6 @@ def _write_time_varying_forcing(self, ds_init):
427448 'The fraction of each cell covered by floating land ice'
428449 write_netcdf (ds_out , 'land_ice_forcing.nc' )
429450
430- ds_init ['landIceDraft' ] = scales [0 ] * ds_init . landIceDraft
431- ds_init ['ssh' ] = ds_init . landIceDraft
432- ds_init ['landIcePressure' ] = scales [0 ] * ds_init . landIcePressure
451+ ds_init ['landIceDraft' ] = scales [0 ] * land_ice_draft
452+ ds_init ['ssh' ] = land_ice_draft
453+ ds_init ['landIcePressure' ] = scales [0 ] * land_ice_pressure
0 commit comments