@@ -102,7 +102,8 @@ subroutine glissade_init_therm (temp_init, is_restart, &
102
102
artm , &
103
103
acab , &
104
104
bheatflx , &
105
- pmp_offset , temp )
105
+ pmp_offset , &
106
+ temp , tempunstag )
106
107
107
108
! initialization subroutine for higher-order dycores, where temperature is defined at
108
109
! the midpoint of each layer plus the upper and lower surfaces
@@ -137,6 +138,12 @@ subroutine glissade_init_therm (temp_init, is_restart, &
137
138
temp ! ice temperature
138
139
! intent(inout) because it might have been read already from an input file,
139
140
! but otherwise is set in this subroutine
141
+
142
+ real (dp), dimension (:,:,:), intent (inout ) :: &
143
+ tempunstag ! ice temperature on unstaggered grid
144
+ ! may be used to initialize from an unstaggered glide temperature field
145
+ ! intent(inout) because it might have been read from an input file,
146
+ ! but otherwise it is set (diagnostically) in this subroutine
140
147
141
148
! Local variables
142
149
@@ -146,12 +153,6 @@ subroutine glissade_init_therm (temp_init, is_restart, &
146
153
147
154
logical :: verbose_column ! if true, then write diagnostic info for the column
148
155
149
- ! WHL - option to overwrite initial temperature in input file
150
- ! Can be useful is working with an input file that includes initial temperatures,
151
- ! but we want to set a linear temperature profile instead
152
- ! TODO - Make this a config option?
153
- logical , parameter :: overwrite_input_temps = .false.
154
-
155
156
! Precompute some grid quantities used in the vertical temperature solve
156
157
157
158
allocate (dups(upn+1 ,2 )) ! TODO - upn-1 instead?
@@ -171,61 +172,93 @@ subroutine glissade_init_therm (temp_init, is_restart, &
171
172
up = upn-1
172
173
dups(up,2 ) = 1.d0 / ((sigma(up+1 ) - sigma(up)) * (sigma(up+1 ) - stagsigma(up)) )
173
174
174
- ! Check for a possible input error. If the user supplies a file with the 'temp' field, which has
175
- ! vertical dimension (1:upn), then the temperature in layers 1:upn may appear correct (though
176
- ! staggered incorrectly), but the temperature in layer 0 will remain at an unphysical value.
177
- ! Let the user know if this has happened.
178
- ! WHL - Nov. 2014 - I verified that the code aborts here if temp (rather than tempstag) is in the restart file.
179
-
180
- if (minval (temp(0 ,:,:)) < (- 1.d0 * trpt) .and. minval (temp(1 :upn,:,:)) > (- 1.d0 * trpt)) then
181
- call write_log(' Error, temperature field has been read incorrectly. Note that the ' &
182
- // ' Glissade dycore must be initialized with tempstag, not temp.' , GM_FATAL)
183
- endif
184
175
185
176
! ==== Initialize ice temperature.============
186
- ! Six possibilities:
187
- ! (1 ) Set ice temperature to 0 C everywhere in column (TEMP_INIT_ZERO).
188
- ! (2 ) Set ice temperature to surface air temperature everywhere in column (TEMP_INIT_ARTM).
189
- ! (3 ) Set up a linear temperature profile, with T = artm at the surface and T <= Tpmp
177
+ ! Following possibilities:
178
+ ! (0 ) Set ice temperature to 0 C everywhere in column (TEMP_INIT_ZERO).
179
+ ! (1 ) Set ice temperature to surface air temperature everywhere in column (TEMP_INIT_ARTM).
180
+ ! (2 ) Set up a linear temperature profile, with T = artm at the surface and T <= Tpmp
190
181
! at the bed (TEMP_INIT_LINEAR).
191
182
! A parameter (pmpt_offset) controls how far below Tpmp the initial bed temp is set.
192
- ! (4 ) Set up a temperature profile based on advective-diffusive balance, with T = artm
183
+ ! (3 ) Set up a temperature profile based on advective-diffusive balance, with T = artm
193
184
! at the surface and dT/dz = -F_geo/k at the bed (TEMP_INIT_ADVECTIVE_DIFFUSIVE).
194
185
! The temperature at each level is capped at the value computed by method (3).
195
- ! (5) Read ice temperature from an initial input file.
196
- ! (6) Read ice temperature from a restart file.
186
+ ! (4) Read ice temperature from external file (TEMP_INIT_EXTERNAL).
187
+ ! (4a) If variable tempstag is present: Set ice temperature to tempstag from input file.
188
+ ! (4b) If variable tempunstag is present (and tempstag is not): interpolate tempunstag
189
+ ! to the staggered ice temperature needed by the Glissade dycore.
197
190
!
198
- ! The default is (2).
199
- ! Method (4) may be optimal for reducing spinup time in the interior of large ice sheets.
200
- ! If not restarting and the temperature field is present in the input file, we do (5).
201
- ! If restarting, we always do (6).
202
- ! If (5) or (6), then the temperature field should already have been read from a file,
203
- ! and the rest of this subroutine will do nothing.
204
- ! Otherwise, the initial temperature is controlled by model%options%temp_init,
205
- ! which can be read from the config file.
191
+ ! The default is (1).
192
+ ! Methods (0-3) overwrite any temperature given in input files.
193
+ ! Method (3) may be optimal for reducing spinup time in the interior of large ice sheets.
194
+ ! Option (4) requires that temperature is present in the input file.
195
+
196
+ if (temp_init == TEMP_INIT_EXTERNAL) then
197
+
198
+ ! Temperature from external file
199
+
200
+ ! Check for a possible input error. If the user supplies a file with the 'temp' field, which has
201
+ ! vertical dimension (1:upn), then the temperature in layers 1:upn may appear correct (though
202
+ ! staggered incorrectly), but the temperature in layer 0 will remain at an unphysical value.
203
+ ! Let the user know if this has happened.
204
+ ! WHL - Nov. 2014 - I verified that the code aborts here if temp (rather than tempstag) is in the restart file.
205
+
206
+ if (minval (temp(0 ,:,:)) < (- 1.d0 * trpt) .and. minval (temp(1 :upn,:,:)) > (- 1.d0 * trpt)) then
207
+ call write_log(' Error, temperature field has been read incorrectly. Note that the ' &
208
+ // ' Glissade dycore must be initialized with tempstag, not temp.' &
209
+ // ' You can rename temp to tempunstag if you want it to be interpolated ' &
210
+ // ' to the vertically staggered tempstag (loss of detail).' , GM_FATAL)
211
+ endif
206
212
207
- if (is_restart == RESTART_TRUE) then
208
213
209
- ! Temperature has already been initialized from a restart file.
210
- ! (Temperature is always a restart variable.)
214
+ if ( minval (temp) > ( - 1.0d0 * trpt)) then ! temperature has been read from an input file
215
+ ! Note: trpt = 273.15 K
211
216
212
- call write_log(' Initializing ice temperature from the restart file' )
217
+ ! Temperature has already been initialized from a restart or input file.
218
+ ! We know this because the default initial temps of unphys_val
219
+ ! (a large negative number) have been overwritten.
213
220
214
- ! WHL - debug - option to overwrite input file
215
- ! ! elseif ( minval(temp) > (-1.0d0 * trpt) ) then ! temperature has been read from an input file
216
- elseif ( minval (temp) > (- 1.0d0 * trpt) .and. .not. overwrite_input_temps) then ! temperature has been read from an input file
217
- ! Note: trpt = 273.15 K
221
+ ! Initialise tempunstag, the temperature on unstaggered vertical grid
222
+ ! (not used for calculations)
223
+ ! Use sigma weighted interpolation from temp to layer interfaces
224
+ do up = 2 , upn-1
225
+ tempunstag(up,:,:) = temp(up-1 ,:,:) + (temp(up,:,:) - temp(up-1 ,:,:)) * &
226
+ (sigma(up) - stagsigma(up-1 )) / (stagsigma(up) - stagsigma(up-1 ))
227
+ end do
228
+ ! boundary conditions are identical on both grids, but temp starts at index 0
229
+ tempunstag(1 ,:,:) = temp(0 ,:,:)
230
+ tempunstag(upn,:,:) = temp(upn,:,:)
218
231
219
- ! Temperature has already been initialized from an input file.
220
- ! We know this because the default initial temps of unphys_val (a large negative number) have been overwritten.
232
+ call write_log(' Initializing ice temperature from a restart/input file' )
233
+
234
+
235
+ elseif ( maxval (tempunstag(:,:,:)) > (- 1.0d0 * trpt)) then
236
+
237
+ ! Test if any temperature in physical range
238
+ ! If yes, we have data from restart or input for unstaggered tempunstag that we use to initialise temp
239
+
240
+ call write_log(' Initializing ice temperature by interpolating tempunstag from restart/input file' )
241
+
242
+ ! Set temp to linear interpolation from tempunstag at layer interfaces
243
+ do up = 1 , upn-1
244
+ temp(up,:,:) = (tempunstag(up,:,:) + tempunstag(up+1 ,:,:)) * 0.5d0
245
+ end do
246
+ ! boundary conditions are identical on both grids, but temp starts at index 0
247
+ temp(0 ,:,:) = tempunstag(1 ,:,:)
248
+ temp(upn,:,:) = tempunstag(upn,:,:)
249
+
250
+ else
251
+ ! fatal error, neither tempstag nor tempunstag are present in the input files
252
+ call write_log(' Error, temp_init = 4 requires temperature variable tempstag or ' &
253
+ // ' tempunstag specified in the restart or input files. ' , GM_FATAL)
254
+ endif
221
255
222
- call write_log(' Initializing ice temperature from an input file' )
223
256
224
257
else ! not reading temperature from restart or input file
225
- ! initialize it here based on temp_init
258
+ ! initialize it here based on temp_init = (0-3)
226
259
227
260
! initialize T = 0 C everywhere
228
- temp(:,:,:) = 0.0d0
261
+ temp(:,:,:) = 0.0d0
229
262
230
263
! set temperature in each column based on the value of temp_init
231
264
0 commit comments