From 5593b08813e3870c016b241a04bbc0c1598df966 Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Tue, 10 Sep 2024 16:06:48 -0700 Subject: [PATCH] move update_firstdayofmonth! to Interfacer --- experiments/ClimaEarth/run_amip.jl | 2 +- experiments/ClimaEarth/run_cloudless_aquaplanet.jl | 2 +- experiments/ClimaEarth/run_cloudy_aquaplanet.jl | 2 +- experiments/ClimaEarth/run_cloudy_slabplanet.jl | 2 +- experiments/ClimaEarth/run_dry_held_suarez.jl | 2 +- experiments/ClimaEarth/run_moist_held_suarez.jl | 2 +- src/Interfacer.jl | 10 ++++++++++ 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/experiments/ClimaEarth/run_amip.jl b/experiments/ClimaEarth/run_amip.jl index 44df091767..7f8d57d303 100644 --- a/experiments/ClimaEarth/run_amip.jl +++ b/experiments/ClimaEarth/run_amip.jl @@ -532,7 +532,7 @@ checkpoint_cb = CallbackManager.HourlyCallback( ) # 20 days update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback( dt = FT(1), - func = CallbackManager.update_firstdayofmonth!, + func = Interfacer.update_firstdayofmonth!, ref_date = [dates.first_day_of_month[1]], active = true, ) diff --git a/experiments/ClimaEarth/run_cloudless_aquaplanet.jl b/experiments/ClimaEarth/run_cloudless_aquaplanet.jl index 87c4d11657..15ea762c3d 100644 --- a/experiments/ClimaEarth/run_cloudless_aquaplanet.jl +++ b/experiments/ClimaEarth/run_cloudless_aquaplanet.jl @@ -225,7 +225,7 @@ checkpoint_cb = CallbackManager.HourlyCallback( ) # 20 days update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback( dt = FT(1), - func = CallbackManager.update_firstdayofmonth!, + func = Interfacer.update_firstdayofmonth!, ref_date = [dates.first_day_of_month[1]], active = true, ) diff --git a/experiments/ClimaEarth/run_cloudy_aquaplanet.jl b/experiments/ClimaEarth/run_cloudy_aquaplanet.jl index dede5363c8..3c3997d9b2 100644 --- a/experiments/ClimaEarth/run_cloudy_aquaplanet.jl +++ b/experiments/ClimaEarth/run_cloudy_aquaplanet.jl @@ -246,7 +246,7 @@ checkpoint_cb = CallbackManager.HourlyCallback( ) # 20 days update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback( dt = FT(1), - func = CallbackManager.update_firstdayofmonth!, + func = Interfacer.update_firstdayofmonth!, ref_date = [dates.first_day_of_month[1]], active = true, ) diff --git a/experiments/ClimaEarth/run_cloudy_slabplanet.jl b/experiments/ClimaEarth/run_cloudy_slabplanet.jl index 7b909b6ae6..4eb11a506e 100644 --- a/experiments/ClimaEarth/run_cloudy_slabplanet.jl +++ b/experiments/ClimaEarth/run_cloudy_slabplanet.jl @@ -292,7 +292,7 @@ checkpoint_cb = CallbackManager.HourlyCallback( ) # 20 days update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback( dt = FT(1), - func = CallbackManager.update_firstdayofmonth!, + func = Interfacer.update_firstdayofmonth!, ref_date = [dates.first_day_of_month[1]], active = true, ) diff --git a/experiments/ClimaEarth/run_dry_held_suarez.jl b/experiments/ClimaEarth/run_dry_held_suarez.jl index 1477bc27dc..c2860fc153 100644 --- a/experiments/ClimaEarth/run_dry_held_suarez.jl +++ b/experiments/ClimaEarth/run_dry_held_suarez.jl @@ -187,7 +187,7 @@ checkpoint_cb = CallbackManager.HourlyCallback( ) # 20 days TODO: not GPU friendly update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback( dt = FT(1), - func = CallbackManager.update_firstdayofmonth!, + func = Interfacer.update_firstdayofmonth!, ref_date = [dates.first_day_of_month[1]], active = true, ) diff --git a/experiments/ClimaEarth/run_moist_held_suarez.jl b/experiments/ClimaEarth/run_moist_held_suarez.jl index e2f1bdf8c2..9eb735937e 100644 --- a/experiments/ClimaEarth/run_moist_held_suarez.jl +++ b/experiments/ClimaEarth/run_moist_held_suarez.jl @@ -232,7 +232,7 @@ checkpoint_cb = CallbackManager.HourlyCallback( ) update_firstdayofmonth!_cb = CallbackManager.MonthlyCallback( dt = FT(1), - func = CallbackManager.update_firstdayofmonth!, + func = Interfacer.update_firstdayofmonth!, ref_date = [dates.first_day_of_month[1]], active = true, ) diff --git a/src/Interfacer.jl b/src/Interfacer.jl index 0d995a38a4..ae10268839 100644 --- a/src/Interfacer.jl +++ b/src/Interfacer.jl @@ -96,6 +96,16 @@ Return the model date at the current timestep. """ current_date(cs::CoupledSimulation, t) = cs.dates.date0[1] + Dates.Second(t) +""" + update_firstdayofmonth!(cs::Interfacer.CoupledSimulation, _) + +This function updates the first of the month reference date. +""" +function update_firstdayofmonth!(cs, _) + cs.dates.first_day_of_month[1] = cs.dates.first_day_of_month[1] + Dates.Month(1) + @info("update_firstdayofmonth! at $(cs.dates.date)") +end + """ ComponentModelSimulation