@@ -312,40 +312,42 @@ for FT in (Float32, Float64)
312312 end
313313 end
314314end
315- # test dataset truncation
315+
316+ # test dataset truncation
316317@testset " test dataset truncation" begin
317- # Get the original dataset set up
318+ # Get the original dataset set up
318319 include (joinpath (pkgdir (ClimaCoupler), " artifacts" , " artifact_funcs.jl" ))
319320 sst_data_all = joinpath (sst_dataset_path (), " sst.nc" )
320321 ds = NCDatasets. NCDataset (sst_data_all, " r" )
321322 dates = ds[" time" ][:]
322323 first_date = dates[1 ]
323324 last_date = last (dates)
324325
325- # set up comms_ctx
326+ # set up comms_ctx
326327 device = ClimaComms. device ()
327- comms_ctx = ClimaComms. context (device)
328- ClimaComms. init (comms_ctx )
328+ comms_ctx_device = ClimaComms. context (device)
329+ ClimaComms. init (comms_ctx_device )
329330
330- # make path for truncated datasets
331+ # make path for truncated datasets
331332 COUPLER_OUTPUT_DIR = joinpath (" experiments" , " AMIP" , " output" , " tests" )
332333 mkpath (COUPLER_OUTPUT_DIR)
333334
334335 REGRID_DIR = joinpath (COUPLER_OUTPUT_DIR, " regrid_tmp" , " " )
335336 mkpath (REGRID_DIR)
336337
337- # values for the truncations
338- time_start = 0.0
339- time_end = 1.728e6
338+ # values for the truncations
339+ t_start = 0.0
340+ t_end = 1.728e6
340341 date0test = [" 18690101" , " 18700101" , " 19790228" , " 20220301" , " 20230101" ]
341342 for date in date0test
342343 date0 = Dates. DateTime (date, Dates. dateformat " yyyymmdd" )
343- sst_data = Regridder. truncate_dataset (sst_data_all, " test" , REGRID_DIR, date0, time_start, time_end, comms_ctx)
344+ sst_data =
345+ Regridder. truncate_dataset (sst_data_all, " sst" , " SST" , REGRID_DIR, date0, t_start, t_end, comms_ctx_device)
344346 ds_truncated = NCDatasets. NCDataset (sst_data, " r" )
345347 new_dates = ds_truncated[" time" ][:]
346348
347- date_start = date0 + Dates. Second (time_start )
348- date_end = date0 + Dates. Second (time_start + time_end )
349+ date_start = date0 + Dates. Second (t_start )
350+ date_end = date0 + Dates. Second (t_start + t_end )
349351
350352 # start date is before the first date of datafile
351353 if date_start < first_date
@@ -359,10 +361,10 @@ end
359361 @test new_dates[2 ] >= date_start
360362 end
361363
362- # end date is before the first date of datafile
364+ # end date is before the first date of datafile
363365 if date_end < first_date
364366 @test last (new_dates) == first_date
365- # end date is after the last date of datafile
367+ # end date is after the last date of datafile
366368 elseif date_end > last_date
367369 @test last (new_dates) == last_date
368370 # end date is within the bounds of datafile
371373 @test new_dates[length (new_dates) - 1 ] <= date_end
372374 end
373375
374- # check that truncation is indexing correctly
376+ # check that truncation is indexing correctly
375377 all_data = ds[" SST" ][:, :, :]
376378 new_data = ds_truncated[" SST" ][:, :, :]
377379 (start_id, end_id) = Regridder. find_idx_bounding_dates (dates, date_start, date_end)
0 commit comments