@@ -20,6 +20,7 @@ module MOM_sum_output
20
20
use MOM_io, only : axis_info, set_axis_info, delete_axis_info, get_filename_appendix
21
21
use MOM_io, only : attribute_info, set_attribute_info, delete_attribute_info
22
22
use MOM_io, only : APPEND_FILE, SINGLE_FILE, WRITEONLY_FILE
23
+ use MOM_spatial_means, only : array_global_min_max
23
24
use MOM_time_manager, only : time_type, get_time, get_date, set_time, operator (>)
24
25
use MOM_time_manager, only : operator (+ ), operator (- ), operator (* ), operator (/ )
25
26
use MOM_time_manager, only : operator (/= ), operator (<= ), operator (>= ), operator (<)
@@ -124,6 +125,12 @@ module MOM_sum_output
124
125
! ! interval at which the run is stopped.
125
126
logical :: write_stocks ! < If true, write the integrated tracer amounts
126
127
! ! to stdout when the energy files are written.
128
+ logical :: write_min_max ! < If true, write the maximum and minimum values of temperature,
129
+ ! ! salinity and some tracer concentrations to stdout when the energy
130
+ ! ! files are written.
131
+ logical :: write_min_max_loc ! < If true, write the locations of the maximum and minimum values
132
+ ! ! of temperature, salinity and some tracer concentrations to stdout
133
+ ! ! when the energy files are written.
127
134
integer :: previous_calls = 0 ! < The number of times write_energy has been called.
128
135
integer :: prev_n = 0 ! < The value of n from the last call.
129
136
type (MOM_netcdf_file) :: fileenergy_nc ! < The file handle for the netCDF version of the energy file.
@@ -179,6 +186,15 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, &
179
186
call get_param(param_file, mdl, " ENABLE_THERMODYNAMICS" , CS% use_temperature, &
180
187
" If true, Temperature and salinity are used as state " // &
181
188
" variables." , default= .true. )
189
+ call get_param(param_file, mdl, " WRITE_TRACER_MIN_MAX" , CS% write_min_max, &
190
+ " If true, write the maximum and minimum values of temperature, salinity and " // &
191
+ " some tracer concentrations to stdout when the energy files are written." , &
192
+ default= .false. , do_not_log= .not. CS% write_stocks, debuggingParam= .true. )
193
+ call get_param(param_file, mdl, " WRITE_TRACER_MIN_MAX_LOC" , CS% write_min_max_loc, &
194
+ " If true, write the locations of the maximum and minimum values of " // &
195
+ " temperature, salinity and some tracer concentrations to stdout when the " // &
196
+ " energy files are written." , &
197
+ default= .false. , do_not_log= .not. CS% write_min_max, debuggingParam= .true. )
182
198
call get_param(param_file, mdl, " DT" , CS% dt_in_T, &
183
199
" The (baroclinic) dynamics time step." , &
184
200
units= " s" , scale= US% s_to_T, fail_if_missing= .true. )
@@ -404,6 +420,34 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
404
420
character (len= 32 ) :: mesg_intro, time_units, day_str, n_str, date_str
405
421
logical :: date_stamped
406
422
type (time_type) :: dt_force ! A time_type version of the forcing timestep.
423
+
424
+ real :: S_min ! The global minimum unmasked value of the salinity [ppt]
425
+ real :: S_max ! The global maximum unmasked value of the salinity [ppt]
426
+ real :: S_min_x ! The x-positions of the global salinity minima
427
+ ! in the units of G%geoLonT, often [degrees_E] or [km]
428
+ real :: S_min_y ! The y-positions of the global salinity minima
429
+ ! in the units of G%geoLatT, often [degrees_N] or [km]
430
+ real :: S_min_z ! The z-positions of the global salinity minima [layer]
431
+ real :: S_max_x ! The x-positions of the global salinity maxima
432
+ ! in the units of G%geoLonT, often [degrees_E] or [km]
433
+ real :: S_max_y ! The y-positions of the global salinity maxima
434
+ ! in the units of G%geoLatT, often [degrees_N] or [km]
435
+ real :: S_max_z ! The z-positions of the global salinity maxima [layer]
436
+
437
+ real :: T_min ! The global minimum unmasked value of the temperature [degC]
438
+ real :: T_max ! The global maximum unmasked value of the temperature [degC]
439
+ real :: T_min_x ! The x-positions of the global temperature minima
440
+ ! in the units of G%geoLonT, often [degreeT_E] or [km]
441
+ real :: T_min_y ! The y-positions of the global temperature minima
442
+ ! in the units of G%geoLatT, often [degreeT_N] or [km]
443
+ real :: T_min_z ! The z-positions of the global temperature minima [layer]
444
+ real :: T_max_x ! The x-positions of the global temperature maxima
445
+ ! in the units of G%geoLonT, often [degreeT_E] or [km]
446
+ real :: T_max_y ! The y-positions of the global temperature maxima
447
+ ! in the units of G%geoLatT, often [degreeT_N] or [km]
448
+ real :: T_max_z ! The z-positions of the global temperature maxima [layer]
449
+
450
+
407
451
! The units of the tracer stock vary between tracers, with [conc] given explicitly by Tr_units.
408
452
real :: Tr_stocks(MAX_FIELDS_) ! The total amounts of each of the registered tracers [kg conc]
409
453
real :: Tr_min(MAX_FIELDS_) ! The global minimum unmasked value of the tracers [conc]
@@ -527,11 +571,20 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
527
571
528
572
nTr_stocks = 0
529
573
Tr_minmax_avail(:) = .false.
530
- call call_tracer_stocks(h, Tr_stocks, G, GV, US, tracer_CSp, stock_names= Tr_names, &
531
- stock_units= Tr_units, num_stocks= nTr_stocks,&
532
- got_min_max= Tr_minmax_avail, global_min= Tr_min, global_max= Tr_max, &
533
- xgmin= Tr_min_x, ygmin= Tr_min_y, zgmin= Tr_min_z,&
534
- xgmax= Tr_max_x, ygmax= Tr_max_y, zgmax= Tr_max_z)
574
+ if (CS% write_min_max .and. CS% write_min_max_loc) then
575
+ call call_tracer_stocks(h, Tr_stocks, G, GV, US, tracer_CSp, stock_names= Tr_names, &
576
+ stock_units= Tr_units, num_stocks= nTr_stocks,&
577
+ got_min_max= Tr_minmax_avail, global_min= Tr_min, global_max= Tr_max, &
578
+ xgmin= Tr_min_x, ygmin= Tr_min_y, zgmin= Tr_min_z,&
579
+ xgmax= Tr_max_x, ygmax= Tr_max_y, zgmax= Tr_max_z)
580
+ elseif (CS% write_min_max) then
581
+ call call_tracer_stocks(h, Tr_stocks, G, GV, US, tracer_CSp, stock_names= Tr_names, &
582
+ stock_units= Tr_units, num_stocks= nTr_stocks,&
583
+ got_min_max= Tr_minmax_avail, global_min= Tr_min, global_max= Tr_max)
584
+ else
585
+ call call_tracer_stocks(h, Tr_stocks, G, GV, US, tracer_CSp, stock_names= Tr_names, &
586
+ stock_units= Tr_units, num_stocks= nTr_stocks)
587
+ endif
535
588
if (nTr_stocks > 0 ) then
536
589
do m= 1 ,nTr_stocks
537
590
vars(num_nc_fields+ m) = var_desc(Tr_names(m), units= Tr_units(m), &
@@ -540,6 +593,13 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
540
593
num_nc_fields = num_nc_fields + nTr_stocks
541
594
endif
542
595
596
+ if (CS% use_temperature .and. CS% write_stocks) then
597
+ call array_global_min_max(tv% T, G, nz, T_min, T_max, &
598
+ T_min_x, T_min_y, T_min_z, T_max_x, T_max_y, T_max_z, unscale= US% C_to_degC)
599
+ call array_global_min_max(tv% S, G, nz, S_min, S_max, &
600
+ S_min_x, S_min_y, S_min_z, S_max_x, S_max_y, S_max_z, unscale= US% S_to_ppt)
601
+ endif
602
+
543
603
if (CS% previous_calls == 0 ) then
544
604
545
605
CS% mass_prev_EFP = mass_EFP
@@ -847,24 +907,44 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
847
907
write (stdout,' (" Total Salt: ",ES24.16,", Change: ",ES24.16," Error: ",ES12.5," (",ES8.1,")")' ) &
848
908
Salt* 0.001 , Salt_chg* 0.001 , Salt_anom* 0.001 , Salt_anom/ Salt
849
909
endif
910
+ if (CS% write_min_max .and. CS% write_min_max_loc) then
911
+ write (stdout,' (16X,"Salinity Global Min:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
912
+ S_min, S_min_x, S_min_y, S_min_z
913
+ write (stdout,' (16X,"Salinity Global Max:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
914
+ S_max, S_max_x, S_max_y, S_max_z
915
+ elseif (CS% write_min_max) then
916
+ write (stdout,' (16X,"Salinity Global Min & Max:",ES24.16,1X,ES24.16)' ) S_min, S_max
917
+ endif
918
+
850
919
if (Heat == 0 .) then
851
920
write (stdout,' (" Total Heat: ",ES24.16,", Change: ",ES24.16," Error: ",ES12.5)' ) &
852
921
Heat, Heat_chg, Heat_anom
853
922
else
854
923
write (stdout,' (" Total Heat: ",ES24.16,", Change: ",ES24.16," Error: ",ES12.5," (",ES8.1,")")' ) &
855
924
Heat, Heat_chg, Heat_anom, Heat_anom/ Heat
856
925
endif
926
+ if (CS% write_min_max .and. CS% write_min_max_loc) then
927
+ write (stdout,' (16X,"Temperature Global Min:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
928
+ T_min, T_min_x, T_min_y, T_min_z
929
+ write (stdout,' (16X,"Temperature Global Max:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
930
+ T_max, T_max_x, T_max_y, T_max_z
931
+ elseif (CS% write_min_max) then
932
+ write (stdout,' (16X,"Temperature Global Min & Max:",ES24.16,1X,ES24.16)' ) T_min, T_max
933
+ endif
857
934
endif
858
935
do m= 1 ,nTr_stocks
859
936
860
- write (stdout,' (" Total ",a,": ",ES24.16,1X,a)' ) &
937
+ write (stdout,' (" Total ",a,": ",ES24.16,1X,a)' ) &
861
938
trim (Tr_names(m)), Tr_stocks(m), trim (Tr_units(m))
862
939
863
- if (Tr_minmax_avail(m)) then
864
- write (stdout,' (64X,"Global Min:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
865
- Tr_min(m),Tr_min_x(m),Tr_min_y(m),Tr_min_z(m)
866
- write (stdout,' (64X,"Global Max:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
867
- Tr_max(m),Tr_max_x(m),Tr_max_y(m),Tr_max_z(m)
940
+ if (CS% write_min_max .and. CS% write_min_max_loc .and. Tr_minmax_avail(m)) then
941
+ write (stdout,' (18X,a," Global Min:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
942
+ trim (Tr_names(m)), Tr_min(m), Tr_min_x(m), Tr_min_y(m), Tr_min_z(m)
943
+ write (stdout,' (18X,a," Global Max:",ES24.16,1X,"at: (",f7.2,",",f7.2,",",f8.2,")" )' ) &
944
+ trim (Tr_names(m)), Tr_max(m), Tr_max_x(m), Tr_max_y(m), Tr_max_z(m)
945
+ elseif (CS% write_min_max .and. Tr_minmax_avail(m)) then
946
+ write (stdout,' (18X,a," Global Min & Max:",ES24.16,1X,ES24.16)' ) &
947
+ trim (Tr_names(m)), Tr_min(m), Tr_max(m)
868
948
endif
869
949
870
950
enddo
@@ -1269,9 +1349,9 @@ subroutine write_depth_list(G, US, DL, filename)
1269
1349
1270
1350
call create_MOM_file(IO_handle, filename, vars, 3 , fields, SINGLE_FILE, &
1271
1351
extra_axes= extra_axes, global_atts= global_atts)
1272
- call MOM_write_field(IO_handle, fields(1 ), DL% depth, unscale = US% Z_to_m)
1273
- call MOM_write_field(IO_handle, fields(2 ), DL% area, unscale = US% L_to_m** 2 )
1274
- call MOM_write_field(IO_handle, fields(3 ), DL% vol_below, unscale = US% Z_to_m* US% L_to_m** 2 )
1352
+ call MOM_write_field(IO_handle, fields(1 ), DL% depth, scale = US% Z_to_m)
1353
+ call MOM_write_field(IO_handle, fields(2 ), DL% area, scale = US% L_to_m** 2 )
1354
+ call MOM_write_field(IO_handle, fields(3 ), DL% vol_below, scale = US% Z_to_m* US% L_to_m** 2 )
1275
1355
1276
1356
call delete_axis_info(extra_axes)
1277
1357
call delete_attribute_info(global_atts)
0 commit comments