Skip to content

Commit

Permalink
Merge branch 'refactoring' into raw_restart_minor_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JanStreffing authored Mar 12, 2024
2 parents 5187931 + 49a74cf commit 7dc9c8a
Show file tree
Hide file tree
Showing 22 changed files with 426 additions and 173 deletions.
42 changes: 27 additions & 15 deletions config/namelist.config.toy_soufflet
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

! This is the namelist file for model general configuration

&modelname
Expand All @@ -6,26 +7,30 @@ runid='fesom'

&timestep
step_per_day=72 !96 !96 !72 !72 !45 !72 !96
run_length= 10 !62 !62 !62 !28
run_length_unit='y' ! y, m, d, s
run_length=10 !62 !62 !62 !28
run_length_unit='d' ! y, m, d, s
/

&clockinit ! the model starts at
timenew=0.0
daynew=1
yearnew=1948
yearnew=1958
/

&paths
MeshPath='/work/ollie/sjuricke/Soufflet_20/'
ClimateDataPath='/work/ollie/dsidoren/input/hydrography/phc3.0/'
ResultPath='/home/ollie/dsidoren/test_visc/'
MeshPath='/albedo/home/pscholz/fesom2/test/meshes/soufflet/'
ClimateDataPath='/albedo/work/projects/p_fesom/FROM-OLLIE/FESOM2/hydrography/phc3.0/'
ResultPath='../result_tmp/'
/

&restart_log
restart_length=1 !only required for d,h,s cases, y, m take 1
restart_length_unit='y' !output period: y, d, h, s
logfile_outfreq=960 !in logfile info. output frequency, # steps
restart_length=1 ! --> do netcdf restart ( only required for d,h,s cases, y, m take 1)
restart_length_unit='y' !output period: y, d, h, s, off
raw_restart_length=1 ! --> do core dump restart
raw_restart_length_unit='off' ! e.g. y, d, h, s, off
bin_restart_length=1 ! --> do derived type binary restart
bin_restart_length_unit='off' ! e.g. y, d, h, s, off
logfile_outfreq=72 !in logfile info. output frequency, # steps
/

&ale_def
Expand All @@ -34,10 +39,10 @@ use_partial_cell=.false.
/

&geometry
cartesian=.false.
cartesian=.true.
fplane=.false.
cyclic_length=4.5 ![degree]
rotated_grid=.false. !option only valid for coupled model case now
rotated_grid=.false. !option only valid for coupled model case now
force_rotation=.false.
alphaEuler=50. ![degree] Euler angles, convention:
betaEuler=15. ![degree] first around z, then around new x,
Expand All @@ -49,15 +54,22 @@ include_fleapyear=.false.
/

&run_config
use_ice=.false. ! ocean+ice
use_ice=.false. ! ocean+ice
use_cavity=.false. !
use_cavity_partial_cell=.false.
use_floatice = .false.
use_sw_pene=.false.
flag_debug=.false.
flag_warn_cflz=.false.
toy_ocean=.true.
which_toy="soufflet"
flag_debug=.true.
flag_debug=.false.

/

&machine
n_levels=2
n_part= 12, 36 ! 432 number of partitions on each hierarchy level
!PS n_levels=2
!PS n_part= 70, 128 ! 432 number of partitions on each hierarchy level
n_levels=1
n_part= 128 !6096 ! 432 number of partitions on each hierarchy level
/
2 changes: 2 additions & 0 deletions config/namelist.cvmix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ idemix_mu0 = 0.33333333 ! dissipation parameter (dimensionless)
idemix_sforcusage = 0.2
idemix_n_hor_iwe_prop_iter = 5 ! iterations for contribution from horiz. wave propagation
idemix_surforc_file = '/work/ollie/clidyn/forcing/IDEMIX/fourier_smooth_2005_cfsr_inert_rgrid.nc'
idemix_surforc_vname= 'var706'
idemix_botforc_file = '/work/ollie/clidyn/forcing/IDEMIX/tidal_energy_gx1v6_20090205_rgrid.nc'
idemix_botforc_vname= 'wave_dissipation'
/

! namelist for PP
Expand Down
1 change: 1 addition & 0 deletions config/namelist.dyn
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ use_wsplit = .false. ! Switch for implicite/explicte splitting of vert. veloci
wsplit_maxcfl= 1.0 ! maximum allowed CFL criteria in vertical (0.5 < w_max_cfl < 1.)
! in older FESOM it used to be w_exp_max=1.e-3
ldiag_KE=.false. ! activates energy diagnostics
AB_order=2
/

2 changes: 2 additions & 0 deletions config/namelist.io
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ldiag_dMOC =.false.
ldiag_DVD =.false.
ldiag_forc =.false.
ldiag_extflds =.false.
ldiag_trflx =.false.
/

&nml_general
Expand All @@ -21,6 +22,7 @@ vec_autorotate =.false.
! for 'fer_C', 'bolus_u', 'bolus_v', 'bolus_w', 'fer_K' to work Fer_GM must be .true. otherwise no output
! 'otracers' - all other tracers if applicable
! for 'dMOC' to work ldiag_dMOC must be .true. otherwise no output
! for 'utemp', 'vtemp', 'usalt', 'vsalt' output, set ldiag_trflx=.true.
&nml_list
io_list = 'sst ',1, 'm', 4,
'sss ',1, 'm', 4,
Expand Down
72 changes: 8 additions & 64 deletions config/namelist.oce.toy_soufflet
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,25 @@
&oce_dyn
state_equation=0 ! 1 - full equation of state, 0 - linear equation of state
C_d=0.0025 ! Bottom drag, nondimensional
gamma0=0.00 ! [m/s], backgroung viscosity= gamma0*len, it should be as small as possible (keep it < 0.01 m/s).
gamma1=0.002 ! [nodim], for computation of the flow aware viscosity
gamma2=0.02 ! [s/m], is only used in easy backscatter option
Div_c=.5 ! the strength of the modified Leith viscosity, nondimensional, 0.3 -- 1.0
Leith_c=.5 ! the strength of the Leith viscosity
visc_option=5 ! 1=Harmonic Leith parameterization;
! 2=Laplacian+Leith+biharmonic background
! 3=Biharmonic Leith parameterization
! 4=Biharmonic flow aware
! 5=Easy Backscatter
! 6=Biharmonic flow aware (viscosity depends on velocity Laplacian)
! 7=Biharmonic flow aware (viscosity depends on velocity differences)
easy_bs_return= 1.5 ! coefficient for returned sub-gridscale energy, to be used with visc_option=5 (easy backscatter)
A_ver= 1.e-4 ! Vertical viscosity, m^2/s
scale_area=5.8e9 ! Visc. and diffus. are for an element with scale_area
mom_adv=2 ! 1=vector CV, p1 vel, 2=sca. CV, 3=vector inv.
free_slip=.false. ! Switch on free slip
i_vert_visc=.true.
w_split=.false.
w_exp_max=1.e-3
SPP=.false. ! Salt Plume Parameterization
Fer_GM=.false. ! to swith on/off GM after Ferrari et al. 2010
K_GM_max = 3000.0 ! max. GM thickness diffusivity (m2/s)
Fer_GM=.false. ! to swith on/off GM after Ferrari et al. 2010
K_GM_max = 2000.0 ! max. GM thickness diffusivity (m2/s)
K_GM_min = 2.0 ! max. GM thickness diffusivity (m2/s)
K_GM_bvref = 2 ! def of bvref in ferreira scaling 0=srf,1=bot mld,2=mean over mld,3=weighted mean over mld
K_GM_rampmax = 40.0 ! Resol >K_GM_rampmax[km] GM on
K_GM_rampmin = 30.0 ! Resol <K_GM_rampmin[km] GM off, in between linear scaled down
K_GM_rampmax = -1.0 ! Resol >K_GM_rampmax[km] GM on
K_GM_rampmin = -1.0 ! Resol <K_GM_rampmin[km] GM off, in between linear scaled down
K_GM_resscalorder = 1

scaling_Ferreira =.true. ! GM vertical scaling after Ferreira et al.(2005) (as also implemented by Qiang in FESOM 1.4)
scaling_Ferreira =.false. ! GM vertical scaling after Ferreira et al.(2005) (as also implemented by Qiang in FESOM 1.4)
scaling_Rossby =.false. ! GM is smoothly switched off according to Rossby radius (from 1. in coarse areas to 0. where resolution reaches 2 points/Rossby radius)
scaling_resolution =.true. ! GM is spatially scaled with resolution; A value of K_GM corresponds then to a resolution of 100km
scaling_FESOM14 =.true. ! special treatment of GM in the NH (as also implemented by Qiang in FESOM 1.4; it is zero within the boundary layer)
scaling_FESOM14 =.false. ! special treatment of GM in the NH (as also implemented by Qiang in FESOM 1.4; it is zero within the boundary layer)

Redi =.false.
visc_sh_limit=5.0e-3 ! for KPP, max visc due to shear instability
mix_scheme='PP' ! vertical mixing scheme: KPP, PP
mix_scheme='PP' ! vertical mixing scheme: KPP, PP
Ricr = 0.3 ! critical bulk Richardson Number
concv = 1.6 ! constant for pure convection (eqn. 23) (Large 1.5-1.6; MOM default 1.8)
/

&oce_tra
use_momix = .false. ! switch on/off !Monin-Obukhov -> TB04 mixing
momix_lat = -50.0 ! latitidinal treshhold for TB04, =90 --> global
momix_kv = 0.01 ! PP/KPP, mixing coefficient within MO length
use_instabmix = .true. ! enhance convection in case of instable stratification
instabmix_kv = 0.1
use_windmix = .false. ! enhance mixing trough wind only for PP mixing (for stability)
windmix_kv = 1.e-3
windmix_nl = 2

diff_sh_limit=5.0e-3 ! for KPP, max diff due to shear instability
Kv0_const=.false.
double_diffusion=.false. ! for KPP,dd switch
K_ver=1.0e-5
K_hor=10.
surf_relax_T=0.0
surf_relax_S=0.0 ! 50m/300days 6.43e-07! m/s 10./(180.*86400.)
balance_salt_water =.false. ! balance virtual-salt or freshwater flux or not
clim_relax=0.0 ! 1/s, geometrical information has to be supplied
ref_sss_local=.true.
ref_sss=34.
i_vert_diff=.true. ! true
tracer_adv =2 ! 1=MUSCL, 2=MUSCL+FCT
! Implemented trassers (3d restoring):
! 301 - Fram strait.
! 302 - Bering Strait
! 303 - BSO
num_tracers=2 !number of all tracers
tracer_ID =0,1 !their IDs (0 and 1 are reserved for temperature and salinity)
/

&oce_init3d ! initial conditions for tracers
n_ic3d = 2 ! number of tracers to initialize
idlist = 1, 0 ! their IDs (0 is temperature, 1 is salinity, etc.). The reading order is defined here!
filelist = 'phc3.0_winter.nc', 'phc3.0_winter.nc' ! list of files in ClimateDataPath to read (one file per tracer), same order as idlist
varlist = 'salt', 'temp' ! variables to read from specified files
t_insitu = .true. ! if T is insitu it will be converted to potential after reading it
/
1 change: 1 addition & 0 deletions config/namelist.tra
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ gamma0_tra = 0.0005 ! gammaX_tra are analogous to those in the dynamical
gamma1_tra = 0.0125
gamma2_tra = 0.
i_vert_diff =.true.
AB_order = 2
/

&tracer_phys
Expand Down
57 changes: 57 additions & 0 deletions config/namelist.tra.toy_soufflet
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
&tracer_listsize
num_tracers=100 !number of tracers to allocate. shallbe large or equal to the number of streams in &nml_list
/

&tracer_list
nml_tracer_list =
1 , 'MFCT', 'QR4C', 'FCT ', 1., 1.,
2 , 'MFCT', 'QR4C', 'FCT ', 1., 1.,
!101, 'UPW1', 'UPW1', 'NON ', 0., 0.
/

&tracer_init3d ! initial conditions for tracers
n_ic3d = 2 ! number of tracers to initialize
idlist = 2, 1 ! their IDs (0 is temperature, 1 is salinity, etc.). The reading order is defined here!
filelist = 'phc3.0_winter.nc', 'phc3.0_winter.nc' ! list of files in ClimateDataPath to read (one file per tracer), same order as idlist
varlist = 'salt', 'temp' ! variables to read from specified files
t_insitu = .true. ! if T is insitu it will be converted to potential after reading it
/

&tracer_init2d ! initial conditions for 2D tracers (sea ice)
n_ic2d = 3 ! number of tracers to initialize
idlist = 1, 2, 3 ! their IDs (0 is a_ice, 1 is m_ice, 3 m_snow). The reading order is defined here!
filelist = 'a_ice.nc', 'm_ice.nc', 'm_snow.nc' ! list of files in ClimateDataPath to read (one file per tracer), same order as idlist
varlist = 'a_ice', 'm_ice', 'm_snow' ! variables to read from specified files
ini_ice_from_file=.false.
/

&tracer_general
! bharmonic diffusion for tracers. We recommend to use this option in very high resolution runs (Redi is generally off there).
smooth_bh_tra =.false. ! use biharmonic diffusion (filter implementation) for tracers
gamma0_tra = 0.0005 ! gammaX_tra are analogous to those in the dynamical part
gamma1_tra = 0.0125
gamma2_tra = 0.
i_vert_diff =.true.
/

&tracer_phys
use_momix = .false. ! switch on/off !Monin-Obukhov -> TB04 mixing
momix_lat = -50.0 ! latitidinal treshhold for TB04, =90 --> global
momix_kv = 0.01 ! PP/KPP, mixing coefficient within MO length
use_instabmix = .true. ! enhance convection in case of instable stratification
instabmix_kv = 0.1
use_windmix = .false. ! enhance mixing trough wind only for PP mixing (for stability)
windmix_kv = 1.e-3
windmix_nl = 2
diff_sh_limit=5.0e-3 ! for KPP, max diff due to shear instability
Kv0_const=.false.
double_diffusion=.false. ! for KPP,dd switch
K_ver=1.0e-5
K_hor=10.
surf_relax_T=0.0
surf_relax_S=1.929e-06 ! 50m/300days 6.43e-07! m/s 10./(180.*86400.)
balance_salt_water =.false. ! balance virtual-salt or freshwater flux or not
clim_relax=0.0 ! 1/s, geometrical information has to be supplied
ref_sss_local=.true.
ref_sss=34.
/
17 changes: 9 additions & 8 deletions src/MOD_DYN.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ MODULE MOD_DYN
TYPE T_DYN
!___________________________________________________________________________
! instant zonal merdional velocity & Adams-Bashfort rhs
real(kind=WP), allocatable, dimension(:,:,:):: uv, uv_rhs, uv_rhsAB, fer_uv

real(kind=WP), allocatable, dimension(:,:,:) :: uv, uv_rhs, fer_uv
real(kind=WP), allocatable, dimension(:,:,:,:) :: uv_rhsAB
integer :: AB_order=2
! horizontal velocities at nodes
real(kind=WP), allocatable, dimension(:,:,:):: uvnode

Expand Down Expand Up @@ -108,12 +109,12 @@ MODULE MOD_DYN
real(kind=WP), allocatable, dimension(:,:,:) :: ke_adv, ke_cor, ke_pre, ke_hvis, ke_vvis, ke_du2, ke_umean, ke_u2mean
real(kind=WP), allocatable, dimension(:,:) :: ke_wind, ke_drag
! same as above but multiplied by velocity. we need both for later computation of turbulent fluxes
real(kind=WP), allocatable, dimension(:,:,:) :: ke_adv_xVEL, ke_cor_xVEL, ke_pre_xVEL, ke_hvis_xVEL, ke_vvis_xVEL
real(kind=WP), allocatable, dimension(:,:) :: ke_wind_xVEL, ke_drag_xVEL
real(kind=WP), allocatable, dimension(:,:) :: ke_wrho !we use pressure to compute (W*dens) as it appeares much easier to compute (P*dW) instead of (dP*w)
real(kind=WP), allocatable, dimension(:,:) :: ke_dW, ke_Pfull !for later computation of turbulent fluxes from the term above
real(kind=WP), allocatable, dimension(:,:,:) :: ke_adv_AB, ke_cor_AB
real(kind=WP), allocatable, dimension(:,:,:) :: ke_rhs_bak
real(kind=WP), allocatable, dimension(:,:,:) :: ke_adv_xVEL, ke_cor_xVEL, ke_pre_xVEL, ke_hvis_xVEL, ke_vvis_xVEL
real(kind=WP), allocatable, dimension(:,:) :: ke_wind_xVEL, ke_drag_xVEL
real(kind=WP), allocatable, dimension(:,:) :: ke_wrho !we use pressure to compute (W*dens) as it appeares much easier to compute (P*dW) instead of (dP*w)
real(kind=WP), allocatable, dimension(:,:) :: ke_dW, ke_Pfull !for later computation of turbulent fluxes from the term above
real(kind=WP), allocatable, dimension(:,:,:,:) :: ke_adv_AB, ke_cor_AB
real(kind=WP), allocatable, dimension(:,:,:) :: ke_rhs_bak
! surface fields to compute APE generation
real(kind=WP), allocatable, dimension(:) :: ke_J, ke_D, ke_G, ke_D2, ke_n0, ke_JD, ke_GD, ke_swA, ke_swB

Expand Down
28 changes: 27 additions & 1 deletion src/MOD_READ_BINARY_ARRAYS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MODULE MOD_READ_BINARY_ARRAYS
private
public :: read_bin_array, read1d_int_static
INTERFACE read_bin_array
MODULE PROCEDURE read1d_real, read1d_int, read1d_char, read2d_real, read2d_int, read3d_real, read3d_int
MODULE PROCEDURE read1d_real, read1d_int, read1d_char, read2d_real, read2d_int, read3d_real, read3d_int, read4d_real, read4d_int
END INTERFACE
contains
subroutine read1d_real(arr, unit, iostat, iomsg)
Expand Down Expand Up @@ -113,5 +113,31 @@ subroutine read3d_int(arr, unit, iostat, iomsg)
if (.not. allocated(arr)) allocate(arr(s1,s2,s3))
read(unit, iostat=iostat, iomsg=iomsg) arr(1:s1, 1:s2, 1:s3)
end subroutine read3d_int

subroutine read4d_real(arr, unit, iostat, iomsg)
real(kind=WP), intent(inout), allocatable :: arr(:,:,:,:)
integer, intent(in) :: unit
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
integer :: s1, s2, s3, s4

read(unit, iostat=iostat, iomsg=iomsg) s1, s2, s3, s4
if ((s1==0) .or. (s2==0) .or. (s3==0) .or. (s4==0)) return
if (.not. allocated(arr)) allocate(arr(s1,s2,s3,s4))
read(unit, iostat=iostat, iomsg=iomsg) arr(1:s1, 1:s2, 1:s3, 1:s4)
end subroutine read4d_real

subroutine read4d_int(arr, unit, iostat, iomsg)
integer, intent(inout), allocatable :: arr(:,:,:,:)
integer, intent(in) :: unit
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
integer :: s1, s2, s3, s4

read(unit, iostat=iostat, iomsg=iomsg) s1, s2, s3, s4
if ((s1==0) .or. (s2==0) .or. (s3==0) .or. (s4==0)) return
if (.not. allocated(arr)) allocate(arr(s1,s2,s3,s4))
read(unit, iostat=iostat, iomsg=iomsg) arr(1:s1, 1:s2, 1:s3, 1:s4)
end subroutine read4d_int
end module MOD_READ_BINARY_ARRAYS
!==========================================================
26 changes: 16 additions & 10 deletions src/MOD_TRACER.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ MODULE MOD_TRACER
SAVE

TYPE T_TRACER_DATA
real(kind=WP), allocatable, dimension(:,:) :: values, valuesAB ! instant values & Adams-Bashfort interpolation
logical :: smooth_bh_tra=.false.
real(kind=WP) :: gamma0_tra, gamma1_tra, gamma2_tra
logical :: i_vert_diff =.false.
character(20) :: tra_adv_hor, tra_adv_ver, tra_adv_lim ! type of the advection scheme for this tracer
real(kind=WP) :: tra_adv_ph = 1. ! a parameter to be used in horizontal advection (for MUSCL it is the fraction of fourth-order contribution in the solution)
real(kind=WP) :: tra_adv_pv = 1. ! a parameter to be used in horizontal advection (for QR4C it is the fraction of fourth-order contribution in the solution)
integer :: ID
real(kind=WP), allocatable, dimension(:,:) :: values ! instant values
real(kind=WP), allocatable, dimension(:,:) :: valuesAB ! Adams-Bashfort interpolation
real(kind=WP), allocatable, dimension(:,:,:) :: valuesold ! previous timesteps

logical :: smooth_bh_tra=.false.
real(kind=WP) :: gamma0_tra, gamma1_tra, gamma2_tra
logical :: i_vert_diff =.false.
character(20) :: tra_adv_hor, tra_adv_ver, tra_adv_lim ! type of the advection scheme for this tracer
real(kind=WP) :: tra_adv_ph = 1. ! a parameter to be used in horizontal advection (for MUSCL it is the fraction of fourth-order contribution in the solution)
real(kind=WP) :: tra_adv_pv = 1. ! a parameter to be used in horizontal advection (for QR4C it is the fraction of fourth-order contribution in the solution)
integer :: AB_order=2
integer :: ID

contains
procedure WRITE_T_TRACER_DATA
Expand Down Expand Up @@ -95,6 +99,7 @@ subroutine WRITE_T_TRACER_DATA(tdata, unit)
character(len=1024) :: iomsg

call write_bin_array(tdata%values, unit, iostat, iomsg)
call write_bin_array(tdata%valuesold,unit, iostat, iomsg)
call write_bin_array(tdata%valuesAB, unit, iostat, iomsg)
write(unit, iostat=iostat, iomsg=iomsg) tdata%smooth_bh_tra
write(unit, iostat=iostat, iomsg=iomsg) tdata%gamma0_tra
Expand All @@ -117,8 +122,9 @@ subroutine READ_T_TRACER_DATA(tdata, unit)
integer :: iostat
character(len=1024) :: iomsg

call read_bin_array(tdata%values, unit, iostat, iomsg)
call read_bin_array(tdata%valuesAB, unit, iostat, iomsg)
call read_bin_array(tdata%values, unit, iostat, iomsg)
call read_bin_array(tdata%valuesold,unit, iostat, iomsg)
call read_bin_array(tdata%valuesAB, unit, iostat, iomsg)
read(unit, iostat=iostat, iomsg=iomsg) tdata%smooth_bh_tra
read(unit, iostat=iostat, iomsg=iomsg) tdata%gamma0_tra
read(unit, iostat=iostat, iomsg=iomsg) tdata%gamma1_tra
Expand Down
Loading

0 comments on commit 7dc9c8a

Please sign in to comment.