From 386e09782e5d8ece38c460767d30eda4cf250461 Mon Sep 17 00:00:00 2001 From: sanAkel Date: Wed, 23 Apr 2025 18:23:59 -0400 Subject: [PATCH 1/6] Write out ISO formatted date in fileenergy_ascii --- src/diagnostics/MOM_sum_output.F90 | 86 ++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 17 deletions(-) diff --git a/src/diagnostics/MOM_sum_output.F90 b/src/diagnostics/MOM_sum_output.F90 index a0f1d5157e..e47f1414c1 100644 --- a/src/diagnostics/MOM_sum_output.F90 +++ b/src/diagnostics/MOM_sum_output.F90 @@ -417,7 +417,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci real :: reday ! Time in units given by CS%Timeunit, but often [days] character(len=240) :: energypath_nc character(len=200) :: mesg - character(len=32) :: mesg_intro, time_units, day_str, n_str, date_str + character(len=32) :: mesg_intro, time_units, day_str, n_str, date_str, date_str_ISO logical :: date_stamped type(time_type) :: dt_force ! A time_type version of the forcing timestep. @@ -473,6 +473,8 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci ! A description for output of each of the fields. type(vardesc) :: vars(NUM_FIELDS+MAX_FIELDS_) + date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) + ! write_energy_time is the next integral multiple of energysavedays. dt_force = set_time(seconds=2) ; if (present(dt_forcing)) dt_force = dt_forcing if (CS%previous_calls == 0) then @@ -616,16 +618,31 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci call open_ASCII_file(CS%fileenergy_ascii, trim(CS%energyfile), action=WRITEONLY_FILE) if (abs(CS%timeunit - 86400.0) < 1.0) then if (CS%use_temperature) then - write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & - &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & - &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') - write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& - &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') + if (date_stamped) then + write(CS%fileenergy_ascii,'(" Step,",5x,"Date, Truncs, & + &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & + &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') + write(CS%fileenergy_ascii,'(10x,"[ISO]",17x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& + &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') + else + write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & + &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & + &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') + write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& + &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') + endif else - write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & + if (date_stamped) then + write(CS%fileenergy_ascii,'(" Step,",5x,"Date, Truncs, & + &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') + write(CS%fileenergy_ascii,'(10x,"[ISO]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& + &"[kg]",11x,"[Nondim]")') + else + write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') - write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& + write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& &"[kg]",11x,"[Nondim]")') + endif endif else if ((CS%timeunit >= 0.99) .and. (CS%timeunit < 1.01)) then @@ -641,17 +658,33 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci endif if (CS%use_temperature) then - write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & - &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & - &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') - write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& - &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",6x,& - &"[degC]")') time_units + if (date_stamped) then + write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & + &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & + &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') + write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& + &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",6x,& + &"[degC]")') " " + else + write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & + &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & + &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') + write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& + &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",6x,& + &"[degC]")') time_units + endif else + if (date_stamped) then + write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & + &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') + write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& + &"[kg]",11x,"[Nondim]")') " " + else write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& &"[kg]",11x,"[Nondim]")') time_units + endif endif endif endif @@ -836,7 +869,6 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci En_mass = toten / mass_tot call get_time(day, start_of_day, num_days) - date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) if (date_stamped) & call get_date(day, iyear, imonth, iday, ihour, iminute, isecond, itick) if (abs(CS%timeunit - 86400.0) < 1.0) then @@ -859,6 +891,8 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci if (date_stamped) then write(date_str,'("MOM Date",i7,2("/",i2.2)," ",i2.2,2(":",i2.2))') & iyear, imonth, iday, ihour, iminute, isecond + write(date_str_ISO,'(i7.4,2(i2.2),"T",i2.2,2(i2.2))') & + iyear, imonth, iday, ihour, iminute, isecond else date_str = trim(mesg_intro)//trim(day_str) endif @@ -875,19 +909,37 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci endif if (CS%use_temperature) then - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & + if (date_stamped) then + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & + &", CFL ", F8.5, ", SL ",& + &es11.4,", M ",ES11.5,", S",f8.4,", T",f8.4,& + &", Me ",ES9.2,", Se ",ES9.2,", Te ",ES9.2)') & + trim(n_str), trim(date_str_ISO), CS%ntrunc, En_mass, max_CFL(1), & + -H_0APE(1), mass_tot, salin, temp, mass_anom/mass_tot, salin_anom, & + temp_anom + else + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &es11.4,", M ",ES11.5,", S",f8.4,", T",f8.4,& &", Me ",ES9.2,", Se ",ES9.2,", Te ",ES9.2)') & trim(n_str), trim(day_str), CS%ntrunc, En_mass, max_CFL(1), & -H_0APE(1), mass_tot, salin, temp, mass_anom/mass_tot, salin_anom, & temp_anom + endif else - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & + if (date_stamped) then + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & + &", CFL ", F8.5, ", SL ",& + &ES11.4,", Mass ",ES11.5,", Me ",ES9.2)') & + trim(n_str), trim(date_str_ISO), CS%ntrunc, En_mass, max_CFL(1), & + -H_0APE(1), mass_tot, mass_anom/mass_tot + else + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &ES11.4,", Mass ",ES11.5,", Me ",ES9.2)') & trim(n_str), trim(day_str), CS%ntrunc, En_mass, max_CFL(1), & -H_0APE(1), mass_tot, mass_anom/mass_tot + endif endif if (CS%ntrunc > 0) then From af7cb9dc0f202dc1b732285bd4a9acfa38c73de5 Mon Sep 17 00:00:00 2001 From: sanAkel Date: Thu, 24 Apr 2025 09:33:00 -0400 Subject: [PATCH 2/6] Add a new user input (default: False) to write out date in ISO format --- src/diagnostics/MOM_sum_output.F90 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/diagnostics/MOM_sum_output.F90 b/src/diagnostics/MOM_sum_output.F90 index e47f1414c1..daaff4ef04 100644 --- a/src/diagnostics/MOM_sum_output.F90 +++ b/src/diagnostics/MOM_sum_output.F90 @@ -114,7 +114,8 @@ module MOM_sum_output real :: timeunit !< The length of the units for the time axis and certain input parameters !! including ENERGYSAVEDAYS [s]. - logical :: date_stamped_output !< If true, use dates (not times) in messages to stdout. + logical :: date_ISO_stamped_output !< If true, use ISO formatted dates in messages to stdout. + logical :: date_stamped_output !< If true, use dates (not times) in messages to stdout. type(time_type) :: Start_time !< The start time of the simulation. ! Start_time is set in MOM_initialization.F90 integer, pointer :: ntrunc => NULL() !< The number of times the velocity has been @@ -235,6 +236,9 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, & CS%energyfile = trim(CS%energyfile)//"."//trim(adjustl(STATSLABEL)) #endif + call get_param(param_file, mdl, "DATE_ISO_STAMPED_STDOUT", CS%date_ISO_stamped_output, & + "If true, use ISO formatted dates in messages to stdout", & + default=.false.) call get_param(param_file, mdl, "DATE_STAMPED_STDOUT", CS%date_stamped_output, & "If true, use dates (not times) in messages to stdout", & default=.true.) @@ -869,6 +873,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci En_mass = toten / mass_tot call get_time(day, start_of_day, num_days) + date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) if (date_stamped) & call get_date(day, iyear, imonth, iday, ihour, iminute, isecond, itick) if (abs(CS%timeunit - 86400.0) < 1.0) then From 332492381cec59e8355bf47133a7ed39fcfc30e2 Mon Sep 17 00:00:00 2001 From: sanAkel Date: Thu, 24 Apr 2025 10:07:26 -0400 Subject: [PATCH 3/6] preserve answers by using the new logical for date_ISO_stamped --- src/diagnostics/MOM_sum_output.F90 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/diagnostics/MOM_sum_output.F90 b/src/diagnostics/MOM_sum_output.F90 index daaff4ef04..611d95ffa8 100644 --- a/src/diagnostics/MOM_sum_output.F90 +++ b/src/diagnostics/MOM_sum_output.F90 @@ -422,7 +422,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci character(len=240) :: energypath_nc character(len=200) :: mesg character(len=32) :: mesg_intro, time_units, day_str, n_str, date_str, date_str_ISO - logical :: date_stamped + logical :: date_stamped, date_ISO_stamped type(time_type) :: dt_force ! A time_type version of the forcing timestep. real :: S_min ! The global minimum unmasked value of the salinity [ppt] @@ -478,6 +478,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci type(vardesc) :: vars(NUM_FIELDS+MAX_FIELDS_) date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) + date_ISO_stamped = (CS%date_ISO_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) ! write_energy_time is the next integral multiple of energysavedays. dt_force = set_time(seconds=2) ; if (present(dt_forcing)) dt_force = dt_forcing @@ -622,7 +623,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci call open_ASCII_file(CS%fileenergy_ascii, trim(CS%energyfile), action=WRITEONLY_FILE) if (abs(CS%timeunit - 86400.0) < 1.0) then if (CS%use_temperature) then - if (date_stamped) then + if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(" Step,",5x,"Date, Truncs, & &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') @@ -636,7 +637,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') endif else - if (date_stamped) then + if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(" Step,",5x,"Date, Truncs, & &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') write(CS%fileenergy_ascii,'(10x,"[ISO]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& @@ -662,7 +663,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci endif if (CS%use_temperature) then - if (date_stamped) then + if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') @@ -678,7 +679,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci &"[degC]")') time_units endif else - if (date_stamped) then + if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& @@ -873,8 +874,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci En_mass = toten / mass_tot call get_time(day, start_of_day, num_days) - date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) - if (date_stamped) & + if (date_stamped .or. date_ISO_stamped) & call get_date(day, iyear, imonth, iday, ihour, iminute, isecond, itick) if (abs(CS%timeunit - 86400.0) < 1.0) then reday = REAL(num_days)+ (REAL(start_of_day)/86400.0) @@ -893,7 +893,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci elseif (n < 100000000) then ; write(n_str, '(I8)') n else ; write(n_str, '(I10)') n ; endif - if (date_stamped) then + if (date_stamped .or. date_ISO_stamped) then write(date_str,'("MOM Date",i7,2("/",i2.2)," ",i2.2,2(":",i2.2))') & iyear, imonth, iday, ihour, iminute, isecond write(date_str_ISO,'(i7.4,2(i2.2),"T",i2.2,2(i2.2))') & @@ -914,7 +914,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci endif if (CS%use_temperature) then - if (date_stamped) then + if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &es11.4,", M ",ES11.5,", S",f8.4,", T",f8.4,& @@ -932,7 +932,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci temp_anom endif else - if (date_stamped) then + if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &ES11.4,", Mass ",ES11.5,", Me ",ES9.2)') & From daded5bcb78dd579e2a410252b824ebd250a05f1 Mon Sep 17 00:00:00 2001 From: jiandewang Date: Wed, 7 May 2025 16:47:38 -0400 Subject: [PATCH 4/6] * revert ISO feature in MOM_sum_output.F90 * in order to do clean test for GFDL-20250423 PR --- src/diagnostics/MOM_sum_output.F90 | 99 +++++++----------------------- 1 file changed, 21 insertions(+), 78 deletions(-) diff --git a/src/diagnostics/MOM_sum_output.F90 b/src/diagnostics/MOM_sum_output.F90 index 611d95ffa8..a0f1d5157e 100644 --- a/src/diagnostics/MOM_sum_output.F90 +++ b/src/diagnostics/MOM_sum_output.F90 @@ -114,8 +114,7 @@ module MOM_sum_output real :: timeunit !< The length of the units for the time axis and certain input parameters !! including ENERGYSAVEDAYS [s]. - logical :: date_ISO_stamped_output !< If true, use ISO formatted dates in messages to stdout. - logical :: date_stamped_output !< If true, use dates (not times) in messages to stdout. + logical :: date_stamped_output !< If true, use dates (not times) in messages to stdout. type(time_type) :: Start_time !< The start time of the simulation. ! Start_time is set in MOM_initialization.F90 integer, pointer :: ntrunc => NULL() !< The number of times the velocity has been @@ -236,9 +235,6 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, & CS%energyfile = trim(CS%energyfile)//"."//trim(adjustl(STATSLABEL)) #endif - call get_param(param_file, mdl, "DATE_ISO_STAMPED_STDOUT", CS%date_ISO_stamped_output, & - "If true, use ISO formatted dates in messages to stdout", & - default=.false.) call get_param(param_file, mdl, "DATE_STAMPED_STDOUT", CS%date_stamped_output, & "If true, use dates (not times) in messages to stdout", & default=.true.) @@ -421,8 +417,8 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci real :: reday ! Time in units given by CS%Timeunit, but often [days] character(len=240) :: energypath_nc character(len=200) :: mesg - character(len=32) :: mesg_intro, time_units, day_str, n_str, date_str, date_str_ISO - logical :: date_stamped, date_ISO_stamped + character(len=32) :: mesg_intro, time_units, day_str, n_str, date_str + logical :: date_stamped type(time_type) :: dt_force ! A time_type version of the forcing timestep. real :: S_min ! The global minimum unmasked value of the salinity [ppt] @@ -477,9 +473,6 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci ! A description for output of each of the fields. type(vardesc) :: vars(NUM_FIELDS+MAX_FIELDS_) - date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) - date_ISO_stamped = (CS%date_ISO_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) - ! write_energy_time is the next integral multiple of energysavedays. dt_force = set_time(seconds=2) ; if (present(dt_forcing)) dt_force = dt_forcing if (CS%previous_calls == 0) then @@ -623,31 +616,16 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci call open_ASCII_file(CS%fileenergy_ascii, trim(CS%energyfile), action=WRITEONLY_FILE) if (abs(CS%timeunit - 86400.0) < 1.0) then if (CS%use_temperature) then - if (date_ISO_stamped) then - write(CS%fileenergy_ascii,'(" Step,",5x,"Date, Truncs, & - &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & - &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') - write(CS%fileenergy_ascii,'(10x,"[ISO]",17x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& - &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') - else - write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & - &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & - &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') - write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& - &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') - endif + write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & + &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & + &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') + write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& + &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",8x,"[degC]")') else - if (date_ISO_stamped) then - write(CS%fileenergy_ascii,'(" Step,",5x,"Date, Truncs, & + write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') - write(CS%fileenergy_ascii,'(10x,"[ISO]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& + write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& &"[kg]",11x,"[Nondim]")') - else - write(CS%fileenergy_ascii,'(" Step,",7x,"Day, Truncs, & - &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') - write(CS%fileenergy_ascii,'(12x,"[days]",17x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& - &"[kg]",11x,"[Nondim]")') - endif endif else if ((CS%timeunit >= 0.99) .and. (CS%timeunit < 1.01)) then @@ -663,33 +641,17 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci endif if (CS%use_temperature) then - if (date_ISO_stamped) then - write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & - &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & - &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') - write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& - &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",6x,& - &"[degC]")') " " - else - write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & - &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & - &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') - write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& - &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",6x,& - &"[degC]")') time_units - endif - else - if (date_ISO_stamped) then write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & - &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') - write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& - &"[kg]",11x,"[Nondim]")') " " - else + &Energy/Mass, Maximum CFL, Mean Sea Level, Total Mass, Mean Salin, & + &Mean Temp, Frac Mass Err, Salin Err, Temp Err")') + write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",7x,"[m]",13x,& + &"[kg]",9x,"[PSU]",6x,"[degC]",7x,"[Nondim]",8x,"[PSU]",6x,& + &"[degC]")') time_units + else write(CS%fileenergy_ascii,'(" Step,",7x,"Time, Truncs, & &Energy/Mass, Maximum CFL, Mean sea level, Total Mass, Frac Mass Err")') write(CS%fileenergy_ascii,'(A25,10x,"[m2 s-2]",11x,"[Nondim]",8x,"[m]",13x,& &"[kg]",11x,"[Nondim]")') time_units - endif endif endif endif @@ -874,7 +836,8 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci En_mass = toten / mass_tot call get_time(day, start_of_day, num_days) - if (date_stamped .or. date_ISO_stamped) & + date_stamped = (CS%date_stamped_output .and. (get_calendar_type() /= NO_CALENDAR)) + if (date_stamped) & call get_date(day, iyear, imonth, iday, ihour, iminute, isecond, itick) if (abs(CS%timeunit - 86400.0) < 1.0) then reday = REAL(num_days)+ (REAL(start_of_day)/86400.0) @@ -893,11 +856,9 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci elseif (n < 100000000) then ; write(n_str, '(I8)') n else ; write(n_str, '(I10)') n ; endif - if (date_stamped .or. date_ISO_stamped) then + if (date_stamped) then write(date_str,'("MOM Date",i7,2("/",i2.2)," ",i2.2,2(":",i2.2))') & iyear, imonth, iday, ihour, iminute, isecond - write(date_str_ISO,'(i7.4,2(i2.2),"T",i2.2,2(i2.2))') & - iyear, imonth, iday, ihour, iminute, isecond else date_str = trim(mesg_intro)//trim(day_str) endif @@ -914,37 +875,19 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci endif if (CS%use_temperature) then - if (date_ISO_stamped) then - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & - &", CFL ", F8.5, ", SL ",& - &es11.4,", M ",ES11.5,", S",f8.4,", T",f8.4,& - &", Me ",ES9.2,", Se ",ES9.2,", Te ",ES9.2)') & - trim(n_str), trim(date_str_ISO), CS%ntrunc, En_mass, max_CFL(1), & - -H_0APE(1), mass_tot, salin, temp, mass_anom/mass_tot, salin_anom, & - temp_anom - else - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &es11.4,", M ",ES11.5,", S",f8.4,", T",f8.4,& &", Me ",ES9.2,", Se ",ES9.2,", Te ",ES9.2)') & trim(n_str), trim(day_str), CS%ntrunc, En_mass, max_CFL(1), & -H_0APE(1), mass_tot, salin, temp, mass_anom/mass_tot, salin_anom, & temp_anom - endif else - if (date_ISO_stamped) then - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & - &", CFL ", F8.5, ", SL ",& - &ES11.4,", Mass ",ES11.5,", Me ",ES9.2)') & - trim(n_str), trim(date_str_ISO), CS%ntrunc, En_mass, max_CFL(1), & - -H_0APE(1), mass_tot, mass_anom/mass_tot - else - write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & + write(CS%fileenergy_ascii,'(A,",",A,",", I6,", En ",ES22.16, & &", CFL ", F8.5, ", SL ",& &ES11.4,", Mass ",ES11.5,", Me ",ES9.2)') & trim(n_str), trim(day_str), CS%ntrunc, En_mass, max_CFL(1), & -H_0APE(1), mass_tot, mass_anom/mass_tot - endif endif if (CS%ntrunc > 0) then From 3970dbded4e2cc361ee8b973c204fa99f280d66e Mon Sep 17 00:00:00 2001 From: BinLi-NOAA Date: Mon, 11 Aug 2025 09:57:12 -0400 Subject: [PATCH 5/6] modify MOM6 nuopc cap to convert a missing value to zero for the imported Stokes drift components * The mom_cap_methods.F90 file is revised to convert imported Stokes drift components from a missing value (9.99e20) to zero. This update doesn't have any impacts on global applications.These updates are only needed when the ocean model domain is greater than the wave model domain and the wave model cannot provide Stokes drift components for the entire ocean model domain. --- config_src/drivers/nuopc_cap/mom_cap.F90 | 12 +++++- .../drivers/nuopc_cap/mom_cap_methods.F90 | 38 ++++++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/config_src/drivers/nuopc_cap/mom_cap.F90 b/config_src/drivers/nuopc_cap/mom_cap.F90 index e0e618c76e..bd95dadddf 100644 --- a/config_src/drivers/nuopc_cap/mom_cap.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap.F90 @@ -140,6 +140,7 @@ module MOM_cap_mod logical :: grid_attach_area = .false. logical :: use_coldstart = .true. logical :: use_mommesh = .true. +logical :: set_missing_stks_to_zero = .false. logical :: restart_eor = .false. character(len=128) :: scalar_field_name = '' integer :: scalar_field_count = 0 @@ -367,6 +368,14 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc) write(logmsg,*) use_coldstart call ESMF_LogWrite('MOM_cap:use_coldstart = '//trim(logmsg), ESMF_LOGMSG_INFO) + set_missing_stks_to_zero = .false. + call NUOPC_CompAttributeGet(gcomp, name="set_missing_stks_to_zero", value=value, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) set_missing_stks_to_zero=(trim(value)=="true") + write(logmsg,*) set_missing_stks_to_zero + call ESMF_LogWrite('MOM_cap:set_missing_stks_to_zero = '//trim(logmsg), ESMF_LOGMSG_INFO) + use_mommesh = .true. call NUOPC_CompAttributeGet(gcomp, name="use_mommesh", value=value, & isPresent=isPresent, isSet=isSet, rc=rc) @@ -1844,7 +1853,8 @@ subroutine ModelAdvance(gcomp, rc) ! Import data !--------------- - call mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, rc=rc) + call mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, & + set_missing_stks_to_zero, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return !--------------- diff --git a/config_src/drivers/nuopc_cap/mom_cap_methods.F90 b/config_src/drivers/nuopc_cap/mom_cap_methods.F90 index 809a507e5e..118e2e7341 100644 --- a/config_src/drivers/nuopc_cap/mom_cap_methods.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap_methods.F90 @@ -72,12 +72,16 @@ end subroutine mom_set_geomtype !> This function has a few purposes: !! (1) it imports surface fluxes using data from the mediator; and !! (2) it can apply restoring in SST and SSS. -subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, rc) - type(ocean_public_type) , intent(in) :: ocean_public !< Ocean surface state - type(ocean_grid_type) , intent(in) :: ocean_grid !< Ocean model grid - type(ESMF_State) , intent(inout) :: importState !< incoming data from mediator - type(ice_ocean_boundary_type) , intent(inout) :: ice_ocean_boundary !< Ocean boundary forcing - integer , intent(inout) :: rc !< Return code +!! (3) it can convert imported stokes drift components to zero if they are missing. +subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, & + set_missing_stks_to_zero, rc) + type(ocean_public_type) , intent(in) :: ocean_public !< Ocean surface state + type(ocean_grid_type) , intent(in) :: ocean_grid !< Ocean model grid + logical , intent(in) :: set_missing_stks_to_zero !< If true, set + !! missing stokes drift to zero + type(ESMF_State) , intent(inout) :: importState !< incoming data from mediator + type(ice_ocean_boundary_type) , intent(inout) :: ice_ocean_boundary !< Ocean boundary forcing + integer , intent(inout) :: rc !< Return code ! Local Variables integer :: i, j, ib, ig, jg, n @@ -537,12 +541,26 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, do i = isc, iec ig = i + ocean_grid%isc - isc !rotate - do ib = 1, nsc - ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) & + if( set_missing_stks_to_zero ) then + do ib = 1, nsc + if( (abs(stkx(i,j,ib)-9.99E20_ESMF_KIND_R8) <= 0.01_ESMF_KIND_R8) ) then + ice_ocean_boundary%ustkb(i,j,ib) = 0.0 + ice_ocean_boundary%vstkb(i,j,ib) = 0.0 + else + ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) & + - ocean_grid%sin_rot(ig,jg)*stky(i,j,ib) + ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) & + + ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib) + end if + end do + else + do ib = 1, nsc + ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) & - ocean_grid%sin_rot(ig,jg)*stky(i,j,ib) - ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) & + ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) & + ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib) - enddo + enddo + end if ! apply masks ice_ocean_boundary%ustkb(i,j,:) = ice_ocean_boundary%ustkb(i,j,:) * ocean_grid%mask2dT(ig,jg) ice_ocean_boundary%vstkb(i,j,:) = ice_ocean_boundary%vstkb(i,j,:) * ocean_grid%mask2dT(ig,jg) From d6d211f3dcdac143df47be9b93a2e801d3f67518 Mon Sep 17 00:00:00 2001 From: jiandewang Date: Mon, 18 Aug 2025 21:14:30 +0000 Subject: [PATCH 6/6] minor modification in mom_cap_methods.F90 to fit for coding style requirment --- .../drivers/nuopc_cap/mom_cap_methods.F90 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config_src/drivers/nuopc_cap/mom_cap_methods.F90 b/config_src/drivers/nuopc_cap/mom_cap_methods.F90 index 118e2e7341..8a7a1b3942 100644 --- a/config_src/drivers/nuopc_cap/mom_cap_methods.F90 +++ b/config_src/drivers/nuopc_cap/mom_cap_methods.F90 @@ -541,26 +541,26 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, do i = isc, iec ig = i + ocean_grid%isc - isc !rotate - if( set_missing_stks_to_zero ) then + if(set_missing_stks_to_zero) then do ib = 1, nsc - if( (abs(stkx(i,j,ib)-9.99E20_ESMF_KIND_R8) <= 0.01_ESMF_KIND_R8) ) then + if((abs(stkx(i,j,ib)-9.99E20_ESMF_KIND_R8) <= 0.01_ESMF_KIND_R8)) then ice_ocean_boundary%ustkb(i,j,ib) = 0.0 ice_ocean_boundary%vstkb(i,j,ib) = 0.0 else ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) & - - ocean_grid%sin_rot(ig,jg)*stky(i,j,ib) + - ocean_grid%sin_rot(ig,jg)*stky(i,j,ib) ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) & - + ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib) - end if - end do + + ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib) + endif + enddo else do ib = 1, nsc ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) & - - ocean_grid%sin_rot(ig,jg)*stky(i,j,ib) + - ocean_grid%sin_rot(ig,jg)*stky(i,j,ib) ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) & - + ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib) + + ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib) enddo - end if + endif ! apply masks ice_ocean_boundary%ustkb(i,j,:) = ice_ocean_boundary%ustkb(i,j,:) * ocean_grid%mask2dT(ig,jg) ice_ocean_boundary%vstkb(i,j,:) = ice_ocean_boundary%vstkb(i,j,:) * ocean_grid%mask2dT(ig,jg)