23 use fms_mod,
only : write_version_number
31 #include<file_version.h> 33 integer,
public,
parameter ::
nelems=3
62 integer,
private,
parameter ::
ncomps=4
64 character(len=3) ,
parameter,
dimension(NCOMPS) ::
comp_names=(/
'ATM',
'LND',
'ICE',
'OCN'/)
67 character(len=5) ,
parameter,
dimension(NELEMS) ::
stock_names=(/
'water',
'heat ',
'salt '/)
68 character(len=12),
parameter,
dimension(NELEMS) ::
stock_units=(/
'[Kg] ',
'[Joules]',
'[Kg] '/)
77 character(len=80) :: formatstring,space
79 real,
dimension(NELEMS) :: val_atm, val_lnd, val_ice, val_ocn
82 call write_version_number(
'STOCK_CONSTANTS_MOD', version)
97 if(mpp_pe() == mpp_root_pe())
then 100 write(
stocks_file,*)
'================Stocks Report Guide=====================================' 102 write(
stocks_file,*)
'S(t) = Total amount of a tracer in the component model at time t.' 103 write(
stocks_file,*)
' Calculated via the component model itself.' 105 write(
stocks_file,*)
'F(t) = Cumulative input of a tracer to the component model at time t.' 106 write(
stocks_file,*)
' Calculated via interchange of fluxes with other component models.' 108 write(
stocks_file,*)
'S(t) - S(0) = Cumulative increase of the component stocks at time t' 109 write(
stocks_file,*)
' Calculated by the component itself.' 111 write(
stocks_file,*)
'In a conserving component F(t)=S(t)-S(0) to within numerical accuracy.' 113 write(
stocks_file,*)
'Component Model refers to one of OCN, ATM, LND or ICE' 115 write(
stocks_file,*)
'NOTE: When use_lag_fluxes=.true. is used in coupler, the ocean stocks ' 116 write(
stocks_file,*)
' calculations are in error by an order which scales as the inverse' 117 write(
stocks_file,*)
' of the number of time steps.' 119 write(
stocks_file,*)
'=======================================================================' 122 write(
stocks_file,*)
'======================Initial Stock S(0)===============================' 127 write(space,
'(i2)') s
128 formatstring= trim(formatstring)//
',a,a,'//trim(space)
129 formatstring= trim(formatstring)//trim(
'x')
131 formatstring= trim(formatstring)//
')' 138 write(space,
'(i2)') s
139 formatstring= trim(formatstring)//
',es22.15,3x' 141 formatstring= trim(formatstring)//
')' 149 write(
stocks_file,*)
'========================================================================' 164 real,
dimension(NCOMPS) :: f_value, f_ice_grid, f_ocn_grid, f_ocn_btf, q_start, q_now,c_value
165 character(len=80) :: formatstring
166 integer :: iday0, isec0, iday, isec, hours
168 integer :: diagid , comp,elem,i
169 integer,
parameter :: initid = -2
173 integer,
dimension(NCOMPS,NELEMS),
save :: f_valuediagid = initid
174 integer,
dimension(NCOMPS,NELEMS),
save :: c_valuediagid = initid
175 integer,
dimension(NCOMPS,NELEMS),
save :: fmc_valuediagid = initid
176 integer,
dimension(NCOMPS,NELEMS),
save :: f_lostdiagid = initid
180 character(len=30) :: field_name, units
182 if(mpp_pe()==mpp_root_pe())
then 186 hours = iday*24 + isec/3600 - iday0*24 - isec0/3600
188 write(
stocks_file,*)
'===============================================' 189 write(
stocks_file,
'(a,f12.3)')
't = TimeSinceStart[days]= ',days
190 write(
stocks_file,*)
'===============================================' 203 f_ice_grid(comp) = sum(stck%dq)
204 f_ocn_grid(comp) = sum(stck%dq_IN)
207 q_start(comp) = stck%q_start
208 q_now(comp) = stck%q_now
216 c_value(comp) = q_now(comp) - q_start(comp)
218 if(mpp_pe() == mpp_root_pe())
then 220 if(f_valuediagid(comp,elem) == initid)
then 222 field_name = trim(field_name) //
'StocksChange_Flux' 228 if(c_valuediagid(comp,elem) == initid)
then 230 field_name = trim(field_name) //
'StocksChange_Comp' 236 if(fmc_valuediagid(comp,elem) == initid)
then 238 field_name = trim(field_name) //
'StocksChange_Diff' 244 f_value(comp) = f_ice_grid(comp)
248 f_value(comp) = f_ocn_grid(comp)
250 if(f_lostdiagid(comp,elem) == initid)
then 252 field_name = trim(field_name) //
'StocksExchangeLost' 258 diagid=f_lostdiagid(comp,elem)
259 diagfield = f_ice_grid(comp) - f_ocn_grid(comp)
260 if (diagid > 0) used =
send_data(diagid, diagfield, time)
265 diagid=f_valuediagid(comp,elem)
266 diagfield = f_value(comp)
267 if (diagid > 0) used =
send_data(diagid, diagfield, time)
268 diagid=c_valuediagid(comp,elem)
269 diagfield = c_value(comp)
270 if (diagid > 0) used =
send_data(diagid, diagfield, time)
271 diagid=fmc_valuediagid(comp,elem)
272 diagfield = f_value(comp)-c_value(comp)
273 if (diagid > 0) used =
send_data(diagid, diagfield, time)
286 if(mpp_pe()==mpp_root_pe())
then 294 write(
stocks_file,
'(a,a,40x,a,20x,a,20x,a,20x,a)')
'Stocks of ',trim(
stock_names(elem)),
'ATM',
'LND',
'ICE',
'OCN' 295 formatstring =
'(a,a,2x,es22.15,2x,es22.15,2x,es22.15,2x,es22.15)' 300 ( q_now(i)-q_start(i), i=1,
ncomps)
304 ( f_value(i) - c_value(i), i=1,
ncomps)
305 write(
stocks_file,formatstring)
'Error =Diff/S(0) ',
'[NonDim] ', &
306 ((f_value(i) - c_value(i))/(1+q_start(i)), i=1,
ncomps)
309 formatstring =
'(a,a,a,6x,es22.15)'
integer, parameter nelems_report
character(len=3), dimension(ncomps), parameter comp_names
integer, parameter, public istock_salt
integer, parameter, public istock_heat
integer, parameter, public istock_bottom
integer, parameter, private istock_atm
character(len=12), dimension(nelems), parameter stock_units
integer, parameter, public istock_top
integer, parameter, public nelems
integer, parameter, public istock_side
integer, parameter nsides
integer, public stocks_file
type(stock_type), dimension(nelems), save ice_stock
integer, parameter, private istock_ocn
character(len=5), dimension(nelems), parameter stock_names
integer, parameter, private istock_lnd
integer, parameter, private istock_ice
integer, parameter, public istock_water
subroutine, public stocks_report_init(Time)
integer, parameter, private ncomps
type(stock_type), dimension(nelems), save ocn_stock
type(stock_type), dimension(nelems), save lnd_stock
subroutine, public stocks_report(Time)
type(stock_type), dimension(nelems), save atm_stock
subroutine, public get_time(Time, seconds, days, ticks, err_msg)
subroutine, public stocks_set_init_time(Time)
type(time_type), save init_time