Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring tracers butzin second try #576

Merged
merged 17 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/namelist.config
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use_cavity_partial_cell=.false.
use_floatice = .false.
use_sw_pene=.true.
flag_debug=.false.
use_transit=.false.
/

&machine
Expand Down
17 changes: 17 additions & 0 deletions config/namelist.transit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
! The namelist file for transient tracers

&transit_param
anthro_transit=.false.
paleo_transit=.false.
length_transit=1 ! 166 for anthro_transit=.true.
ti_start_transit=1 ! 1 for D14C, 80 for CFC-12
ifile_transit='/work/ollie/mbutzin/fesom2/input/trace_gases/Table_CO2_isoC_CFC12_SF6.txt'
r14c_a = 1.0000 ! atm. 14C/C ratio, global mean
r39ar_a = 1.0000 ! atm. 39Ar/Ar ratio, global mean
xarg_a = 9.34e-3 ! atm. Argon concn. (mole fraction), global mean
xco2_a = 284.32e-6 ! atm. CO2 concn. (mole fraction), global mean
dic_0 = 2.00 ! mixed layer DIC concn. (mol / m**3), global mean
arg_0 = 0.01 ! mixed layer Argon concn. (mol / m**3), global mean
decay14 = 3.8561e-12 ! decay constant of 14C (1 / s), 1 a = 365.0 d
decay39 = 8.1708e-11 ! decay constant of 39Ar (1 / s), 1 a = 365.0 d
/
18 changes: 17 additions & 1 deletion src/gen_model_setup.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ subroutine setup_model(partit)
use diagnostics, only: ldiag_solver,lcurt_stress_surf,lcurt_stress_surf, ldiag_Ri, ldiag_TurbFlux, ldiag_trflx, &
ldiag_dMOC, ldiag_DVD, diag_list
use g_clock, only: timenew, daynew, yearnew
use g_ic3d
use g_ic3d
use mod_transit
implicit none
type(t_partit), intent(inout), target :: partit
character(len=MAX_PATH) :: nmlfile
Expand Down Expand Up @@ -80,6 +81,21 @@ subroutine setup_model(partit)
read (fileunit, NML=diag_list)
close (fileunit)

if (use_transit) then
! Transient tracer input, input file names have to be specified in
! namelist.config, nml=run_config
if(partit%mype==0) print *, "Transient tracers are ON. Tracer input file: ", ifile_transit
open (20,file=ifile_transit)
if (anthro_transit .or. paleo_transit) then
call read_transit_input
else
! Spinup / equilibrium runs with constant tracer input,
! read parameter values from namelist.oce
read (20,nml=transit_param)
end if
close (20)
end if

if(partit%mype==0) write(*,*) 'Namelist files are read in'

!_____________________________________________________________________________
Expand Down
4 changes: 4 additions & 0 deletions src/gen_modules_clock.F90
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ subroutine clock_init(partit)
USE MOD_PARTIT
USE MOD_PARSUP
use g_config
use mod_transit, only: ti_transit, ti_start_transit
implicit none
type(t_partit), intent(in), target :: partit
integer :: i, daystart, yearstart
Expand All @@ -95,6 +96,9 @@ subroutine clock_init(partit)
else
r_restart=.true.
end if
! For simulations with transient tracer input data
if (use_transit) ti_transit = yearnew - yearstart + ti_start_transit


! year as character string
write(cyearold,'(i4)') yearold
Expand Down
4 changes: 3 additions & 1 deletion src/gen_modules_config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ module g_config
character(100) :: which_toy="soufflet"
logical :: flag_debug=.false. ! prints name of actual subroutine he is in
logical :: flag_warn_cflz=.true. ! switches off cflz warning
logical :: use_transit=.false. ! switches off transient tracers
namelist /run_config/ use_ice,use_floatice, use_sw_pene, use_cavity, &
use_cavity_partial_cell, cavity_partial_cell_thresh, &
use_cavity_fw2press, toy_ocean, which_toy, flag_debug, flag_warn_cflz, lwiso !---wiso-code: add lwiso
use_cavity_fw2press, toy_ocean, which_toy, flag_debug, flag_warn_cflz, lwiso, &
use_transit

!_____________________________________________________________________________
! *** others ***
Expand Down
16 changes: 11 additions & 5 deletions src/io_meandata.F90
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ subroutine ini_mean_io(ice, dynamics, tracers, partit, mesh)
use g_config, only: use_cavity
use g_forcing_param, only: use_virt_salt, use_landice_water, use_age_tracer !---fwf-code, age-code
use g_config, only : lwiso !---wiso-code
use mod_transit, only : index_transit
implicit none
integer :: i, j
integer, save :: nm_io_unit = 103 ! unit to open namelist file, skip 100-102 for cray
Expand Down Expand Up @@ -469,11 +470,16 @@ subroutine ini_mean_io(ice, dynamics, tracers, partit, mesh)
end if
!---wiso-code-end

CASE ('otracers ')
do j=3, tracers%num_tracers
write (id_string, "(I3.3)") tracers%data(j)%ID
call def_stream((/nl-1, nod2D/), (/nl-1, myDim_nod2D/), 'tra_'//id_string, 'pasive tracer ID='//id_string, 'n/a', tracers%data(j)%values(:,:), io_list(i)%freq, io_list(i)%unit, io_list(i)%precision, partit, mesh)
end do
! Transient tracers
CASE('SF6 ')
if (use_transit) call def_stream((/nl-1, nod2D/), (/nl-1, myDim_nod2D/), 'sf6', 'sulfur hexafluoride', 'mol / m**3', tracers%data(index_transit(1))%values(:,:), io_list(i)%freq, io_list(i)%unit, io_list(i)%precision, partit, mesh)
CASE('CFC-12 ')
if (use_transit) call def_stream((/nl-1, nod2D/), (/nl-1, myDim_nod2D/), 'cfc12', 'chlorofluorocarbon CFC-12', 'mol / m**3', tracers%data(index_transit(2))%values(:,:), io_list(i)%freq, io_list(i)%unit, io_list(i)%precision, partit, mesh)
CASE('R14C ')
if (use_transit) call def_stream((/nl-1, nod2D/), (/nl-1, myDim_nod2D/), 'r14c', '14C / C ratio of DIC', 'none', tracers%data(index_transit(3))%values(:,:), io_list(i)%freq, io_list(i)%unit, io_list(i)%precision, partit, mesh)
CASE('R39Ar ')
if (use_transit) call def_stream((/nl-1, nod2D/), (/nl-1, myDim_nod2D/), 'r39ar', '39Ar / Ar ratio', 'none', tracers%data(index_transit(4))%values(:,:), io_list(i)%freq, io_list(i)%unit, io_list(i)%precision, partit, mesh)
! Transient tracers end
CASE ('slope_x ')
call def_stream((/nl-1, nod2D/), (/nl-1, myDim_nod2D/), 'slope_x', 'neutral slope X', 'none', slope_tapered(1,:,:), io_list(i)%freq, io_list(i)%unit, io_list(i)%precision, partit, mesh)
CASE ('slope_y ')
Expand Down
17 changes: 17 additions & 0 deletions src/io_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,24 @@ subroutine ini_ocean_io(year, dynamics, tracers, partit, mesh)
trname='salt'
longname='salinity'
units='psu'
CASE(6)
trname='sf6'
longname='sulfur hexafluoride'
units='mol / m**3'
CASE(12)
trname='cfc12'
longname='chlorofluorocarbon CFC-12'
units='mol / m**3'
CASE(14)
trname='r14c'
longname='14C / C ratio of DIC'
units='none'
CASE(39)
trname='r39ar'
longname='39Ar / Ar ratio'
units='none'
CASE DEFAULT
! other passive tracers
write(trname,'(A3,i1)') 'tra_', j
write(longname,'(A15,i1)') 'passive tracer ', j
units='none'
Expand Down
Loading
Loading