
! This uses P-dependent rheology, hence total_pressure is needed
! Also the new option, P-dependent Vact, with H(p) based on Ammann et al.
!  and deta_p_correct_jumps

! This has updated parameters for the eclogite transition

! This has 7 phase systems (ol,pxgt,melt-ol,melt-pxgt,prim,ccrust,metal)

&switches
	verbose=.false.
	try_continue=.true.
	compressible=.true.
	dens_strat=.true.
	dens_actual=.false.
	tracers=.true.
	cont_tracers=.false.
	composition=.false.
	phase_changes=.true.
	melting=.true.
	multig_solve=.false. !.true.
	total_pressure=.true.
	dimensional_units=.true.
	plates_analyse=.false. !.true.
	quiet=.false. !.false.	!.true. ! limits stag's outputs to avoid reaching disk quota in home folder
	atmosphere=.false.
  &end

 &postprocessing
    ! if this flag is true, StagYY performs post-processing
    ! instead of running normally
        perform_postprocessing=.false. !.false.

	keep_freq=1 !1 ! will keep only frames every keep_frequency
	keep_freq_tra=1 !10 ! will keep only frames every keep_frequency
	read_only=.true. !.false. ! will not create the +hdf5_PostPro folder, just reads
	whilerunning=.false. !.false. ! will not create the +hdf5_PostPro folder, just reads

	! which fields should be treated
        PostPro_t=.true.     ! temperature
	PostPro_c=.false.     ! composition
	PostPro_cont=.false. ! continents
	PostPro_rheo=.false. ! rheology (diffusion vs dislocation)
	PostPro_ph= .false. ! phase field
	PostPro_bs=.true.	   ! basalt fraction
	PostPro_hz=.true.	   ! harzburgite fraction
	PostPro_primordial=.false. ! primordial fraction
	PostPro_f=.true.     ! melt fraction
	PostPro_rho = .false. ! density
	PostPro_svel = .false. ! seismic velocities
	PostPro_pvel = .false.
	PostPro_bvel = .false.
	PostPro_vp=.false.    ! velocity & pressure
	PostPro_vd=.false.    ! viscous dissipation
	PostPro_eta=.true.   ! viscosity
	PostPro_edot=.true.  ! strain rate (!! used in some averaging!!)
	PostPro_age=.false.   ! age (since last melted)
	PostPro_stress = .true. !CCC
	PostPro_topo=.false.  ! topography (CMB & surface)
	PostPro_crust=.false. !CCC ! crustal thickness
	PostPro_g=.false.     ! geoid and topography corrected for self-gravitation
	PostPro_hpe=.false.
	PostPro_tra=.false.   ! tracers
	PostPro_water = .false.
	PostPro_GrainSize=.true.
	PostPro_trapercell=.false.
	PostPro_air=.false.
	PostPro_carbon=.false.
	PostPro_nitrogen=.false.
	PostPro_TTG=.false.
	PostPro_cc=.false.
	PostPro_K_Ar=.false.
	PostPro_metal=.false.
	PostPro_nmelt=.false.
	PostPro_torpol=.false.
	PostPro_vm=.false.
	PostPro_w=.false.
  &end

 &geometry	
	shape='spherical' !'yinyang'
	D_dimensional=2890.e3   r_cmb=3480.e3
	D_dim_top=0.
	nxtot=1	!32 !64
	nytot=512 !512 !768 !512 !32 !96
	nztot=128 !64 !128 !96 !32 !96
	aspect_ratio(1)=6.3 !6.3 !3.15 !6.30
	aspect_ratio(2)=1.57 !6.3 !0.6 !6.4 !6.30
	zspacing_mode='function_exp'
	dresl_topbot=1.5
	dresl_surf=5.0
	wresl_surf=0.07  ! these are still normalized to D
	dresl_cmb=5.0 !2.0
	wresl_cmb=0.05
	dresl_400=1.0
	wresl_400=0.1
	dresl_660=3.0	!2.0	!5.0	!10.0
	wresl_660=0.1
!	dresl_air=1.0
!	wresl_air=0.1
	align_grid_with_TTGwindows = .true.
  &end	

&phase

	effective_cp_alpha=.true.
	scale_PCdepths=.false.
	g0_dimensional_PCdepths=9.81  
 
	nphase_systems=7
	sys_ol       =1       ! phase system meanings (also apply to viscosity parameters)
	sys_pxgt     =2
	sys_melt_ol  =3
	sys_melt_pxgt=4
	sys_prim     =5
	sys_ccrust   =6
	sys_metal    =7
	nphase(:)=3,4,0,0,4,1,0

	Tp0(:,1)=2300, 1900., 1600.			! in K
	Tp0(:,2)=2300, 1900., 1600., 1000.
	Tp0(:,3)=0.
	Tp0(:,4)=0.
	Tp0(:,5)=2300, 1900., 1600., 1000.
	Tp0(:,6)=1713.14
	Tp0(:,7)=0.
	phase_mode(:,1)='function', 'discont   ','discont   '  
	phase_mode(:,2)='function', 'eff_alpha ','eff_alpha ','function'
	phase_mode(:,3)='none'
	phase_mode(:,4)='none'
	phase_mode(:,5)='function', 'eff_alpha ','eff_alpha ','function'
	phase_mode(:,6)='discont'
	phase_mode(:,7)='none'
	dp0(:,1)=2740.e3, 660.e3, 410.e3			! in km
	!dp0(:,2)=2740.e3, 720.e3, 400.e3, 40.e3
	dp0(:,2)=2740.e3, 720.e3 , 300.e3, 40.e3
	dp0(:,5)=2740.e3, 720.e3, 300.e3, 40.e3
	dp0(:,6)=290.59e3
	drho_p(:,1)=61.6, 400., 180.			! in kg/m3
	drho_p(:,2)=61.6, 400., 150., 350.
	drho_p(:,5)=61.6, 400., 150., 350.
	drho_p(:,6)=167.751
	clap(:,1)=10.e6, -2.5e6, 2.5e6			! in Pa/K
	clap(:,2)=10.e6,  1.0e6, 1.0e6, 0.0
	clap(:,5)=10.e6,  1.0e6, 1.0e6, 0.0
	clap(:,6)=2.26e6
	w_p(:,1)=25.e3, 25.e3, 25.e3			! in m
	w_p(:,2)=25.e3, 75.e3, 75.e3, 25.e3
	w_p(:,5)=25.e3, 75.e3, 75.e3, 25.e3
	w_p(:,6)=25.e3

	Ol_frac_ref      = 0.6 !0.6
	basalt_frac_ref  = 0.2 !0.2

  &end

 &refstate
	perplex_properties=.false.
	!perplex_bs_file='/cluster/scratch/arozel/Stag/+PERPLEX/MORB-Hirose_CFMASN_z1km-T5K_stx11_hr_08Mar2012.bse'
	!perplex_hz_file='/cluster/scratch/arozel/Stag/+PERPLEX/Harzburgite-Hirose_CFMAS_z1km-T5K_stx11_08Mar2012.bse'
	!perplex_pr_file='/cluster/scratch/arozel/Stag/+PERPLEX/MORB-Hirose_CFMASN_z1km-T5K_stx11_hr_08Mar2012.bse'
	perplex_bs_file='../../../V27_ReferenceModel_iGEO/+PERPLEX/MORB-Hirose_CFMASN_z1km-T5K_stx11_hr_08Mar2012.bse'
	perplex_hz_file='../../../V27_ReferenceModel_iGEO/+PERPLEX/Harzburgite-Hirose_CFMAS_z1km-T5K_stx11_08Mar2012.bse'
	perplex_pr_file='../../../V27_ReferenceModel_iGEO/+PERPLEX/MORB-Hirose_CFMASN_z1km-T5K_stx11_hr_08Mar2012.bse'

	Birch_Murnaghan=.true.
	! in Parameters for 3rd-order BM eq of state (dimensional)
	! & exponent for kappa dependence on compression
	K0(1,1)=210.e9	Kp(1,1)=3.9  gr_s(1,1)=1.3  ex_tkappa(1,1)=1.0 ! ppv
	K0(1,2)=210.e9	Kp(1,2)=3.9  gr_s(1,2)=1.3  ex_tkappa(1,2)=1.0 ! 
	K0(1,5)=210.e9	Kp(1,5)=3.9  gr_s(1,5)=1.3  ex_tkappa(1,5)=1.0 ! 
	K0(1,6)=210.e9	Kp(1,6)=3.9  gr_s(1,6)=1.3  ex_tkappa(1,6)=1.0 ! 
	K0(2,1)=210.e9	Kp(2,1)=3.9  gr_s(2,1)=1.3  ex_tkappa(2,1)=1.0 ! pv
	K0(2,2)=210.e9	Kp(2,2)=3.9  gr_s(2,2)=1.3  ex_tkappa(2,2)=1.0 ! 
	K0(2,5)=210.e9	Kp(2,5)=3.9  gr_s(2,5)=1.3  ex_tkappa(2,5)=1.0 ! 
	K0(2,6)=210.e9	Kp(2,6)=3.9  gr_s(2,6)=1.3  ex_tkappa(2,6)=1.0 ! 
	K0(3,1)= 85.e9	Kp(3,1)=4.0  gr_s(3,1)=0.85 ex_tkappa(3,1)=1.0 ! tz
	K0(3,2)= 85.e9	Kp(3,2)=4.0  gr_s(3,2)=0.85 ex_tkappa(3,2)=1.0 ! 
	K0(3,5)= 85.e9	Kp(3,5)=4.0  gr_s(3,5)=0.85 ex_tkappa(3,5)=1.0 ! 
	K0(3,6)= 85.e9	Kp(3,6)=4.0  gr_s(3,6)=0.85 ex_tkappa(3,6)=1.0 ! 
	K0(4,1)=163.e9	Kp(4,1)=4.0  gr_s(4,1)=1.3  ex_tkappa(4,1)=1.0 ! um
	K0(4,2)=163.e9	Kp(4,2)=4.0  gr_s(4,2)=1.3  ex_tkappa(4,2)=1.0 ! 
	K0(4,5)=163.e9	Kp(4,5)=4.0  gr_s(4,5)=1.3  ex_tkappa(4,5)=1.0 ! 
	K0(4,6)=163.e9	Kp(4,6)=4.0  gr_s(4,6)=1.3  ex_tkappa(4,6)=1.0 ! 
	K0(5,1)=163.e9	Kp(5,1)=4.0  gr_s(5,1)=1.3  ex_tkappa(5,1)=1.0 ! garnet(basalt)
	K0(5,2)=163.e9	Kp(5,2)=4.0  gr_s(5,2)=1.3  ex_tkappa(5,2)=1.0 ! 
	K0(5,5)=163.e9	Kp(5,5)=4.0  gr_s(5,5)=1.3  ex_tkappa(5,5)=1.0 ! 
	K0(5,6)=163.e9	Kp(5,6)=4.0  gr_s(5,6)=1.3  ex_tkappa(5,6)=1.0 ! 

	K0(1,3)=30.e9	Kp(1,3)=6.0  gr_s(1,3)=0.6  ex_tkappa(2,3)=1.0 ! melt-ol
	K0(1,4)=30.e9	Kp(1,4)=6.0  gr_s(1,4)=0.6  ex_tkappa(2,4)=1.0 ! melt-pxgt

	K0(1,7)=210.e9	Kp(1,7)=3.9  gr_s(1,7)=1.3  ex_tkappa(1,7)=1.0 ! metal ???

	rhoref_surf=3240. 3080. 2900. 2900. 3080. 2700. 7000.    ! in kg/m3

	q_gamma=1.            ! dependence of gruneisen parameter on compression
	q_gamma(1,3)=-1.3     ! for melt
	q_gamma(1,4)=-1.3     ! for melt

	! ------ intermediate value
	!Rh=1e-11 !!18.77e-12         ! INITIAL. In W/kg  for EVOLUTION cases
	Rh=18.77e-12         ! INITIAL. In W/kg  for EVOLUTION cases
	Rh_halflife=2.43e9   ! in years
	core_cooling=.true.

	!Rh=5.2e-12           ! in W/kg  for modern-day cases
	!Rh_halflife=1.e30    ! in years
	!core_cooling=.false.

	Tref_surf=1600.      ! in K

	drho_cmb=4337.             ! in kg/m3
	drho_surf=3300.

	phase_assemblage_varies_with_C=.true.
	c_dependent_heating=.true.   ! whether internal heating rate depends on C
	dHeat_dbasalt=1.
	dHeat_dprim=10.

	delT0_expan=6.        ! related to expansivity pressure-dependence
	ak_expan=1.4          !  ditto

	core_model='Buffett'
	core_superheat=0.0	! leave this at 0, change botT_val instead
	core_Kppm=359.5		! K ppm in core

	tcond_dimensional=3.0
	deltaT_dimensional=2500.0 !2500.0
	g_dimensional=9.81
	dens_dimensional=3300.   ! used in thermal conductivity, viscosity p calc
	Cp_dimensional=1200.     ! specific heat capacity J/kg/K
	Cp_dimensional_basalt=1000.     ! specific heat capacity J/kg/K
	Cp_dimensional_TTG=1000.     ! specific heat capacity J/kg/K
	expan_dimensional=3.e-5 !5.e-5  ! expansivity in K^-1
  &end	


 &boundaries
	x_bc='ww' !'rr'
	y_bc='ww' !'rr'
	topT_mode='iso' !'TidallyLocked'
	!topT_locked_subsolar=300.0
	!topT_locked_farside =300.0
	!topT_mode='radiative'	Tsurf_eqm=300.0
	topT_val=300.0 !1300.0
	atmosphere_heatloss_factor=1.0
	botT_mode='iso'
	botT_val=4500.
	topV_mode='free-slip'
	botV_mode='free-slip'
  &end

 &t_init
	imode_t='bndry_layers' !'bndry_layers' !'BasaltSnow' !'cells' !'degree1'
	amp_t=100.0	       !0.	       !10.0		! in K
	blthick=10.e3		! in km
	T0_init=1900. !1900. !1600. !1800.           ! initial potential temperature in K
	perturbe_scale     	= 400.0
  &end

 &timein
	finish_at_time=1.5e9 !4.5e9    ! in years
	dt_write=10.e6 !1e6 !2.5e6		!1.e7          ! in years
	nsteps=200000 !5000000
	nwrite=200 !100 !250
	PBSTimeRequested=24 !120 ! in hours (the code will save/stop 15min before to avoid output pb)
	iord=2
	! 6 and 3 crashed
	alpha_adv=1.0
	alpha_diff=1e3 !1.e4 !1.e3 !0.6
	advection_scheme='MPDATA'
	diffusion_implicit=.true.	!.false.
	diffusion_beta=1.0
	diffusion_errmax=1.e-6
	diffusion_alpha=0.7
	diffusion_nrelax=3
  &end

 &viscosity
	ietalaw=1                   ! Arrhenius
	PressureDepRheology=.true.  ! P- not depth-dependent ! P-dep does not work in YY geom!!
	PressureDepVact=.true.      ! Vact decreases with pressure

	diffusion_creep=.true.
	dislocation_creep=.false. !.false.
	plasticity=.false. !.true.
	phase_dep_Eeta=.true.

	eta0=1.e20 !1.e21 !1.e20             ! in Pa s
	T0_eta=1600.
	d0_eta=0.0
	stress0_eta=1.0e6      	! in Pa
	Ts_eta=-1.              ! negative sets it to surface T
	n_eta = 3.5 ! now represents a matrix

	! (deformation mechanism,phase,system)


!values used by Rozel/Lourenco
	! Olivine system, diffusion creep, in J/mol & m3/mol
	E_eta(1,4,1)=300.0e3 V_eta(1,4,1)=5.0e-6  Pdecay_V(1,4,1)=   1.0e30 ! Ol
	E_eta(1,3,1)=300.0e3 V_eta(1,3,1)=5.0e-6  Pdecay_V(1,3,1)=   1.0e30 ! TZ
	E_eta(1,2,1)=370.0e3 V_eta(1,2,1)=3.65e-6 Pdecay_V(1,2,1)= 200.0e9  ! PV
	E_eta(1,1,1)=162.0e3 V_eta(1,1,1)=1.4e-6  Pdecay_V(1,1,1)=1610.0e9  ! PPV

	! pyroxene-garnet system, diffusion creep
	E_eta(1,5,2)=300.0e3 V_eta(1,5,2)=5.0e-6   Pdecay_V(1,5,2)=   1.0e30 ! Bs
	E_eta(1,4,2)=300.0e3 V_eta(1,4,2)=5.0e-6   Pdecay_V(1,4,2)=   1.0e30 ! Px
	E_eta(1,3,2)=300.0e3 V_eta(1,3,2)=5.0e-6   Pdecay_V(1,3,2)=   1.0e30 ! Gt
	E_eta(1,2,2)=370.0e3 V_eta(1,2,2)=3.65e-6  Pdecay_V(1,2,2)= 200.0e9  ! PV
	E_eta(1,1,2)=162.0e3 V_eta(1,1,2)=1.4e-6   Pdecay_V(1,1,2)=1610.0e9  ! PPV

	! very important to define rheology of phase system-6 sys_ccrust
	! c_crust system, diffusion creep
	E_eta(1,1,3)=300.0e3 V_eta(1,1,3)=5.0e-6   Pdecay_V(1,1,3)=   1.0e30 ! Bs
	E_eta(1,1,4)=300.0e3 V_eta(1,1,4)=5.0e-6   Pdecay_V(1,1,4)=   1.0e30 ! Bs
	
	E_eta(1,2,6)=300.0e3 V_eta(1,2,6)=5.0e-6   Pdecay_V(1,2,6)=   1.0e30 ! Bs
	E_eta(1,1,6)=370.0e3 V_eta(1,1,6)=3.65e-6   Pdecay_V(1,1,6)=   200.0e9 ! PV

	! Olivine system, dislocation creep, in J/mol & m3/mol
	E_eta(2,4,1)=530.0e3 V_eta(2,4,1)=1.0e-5  Pdecay_V(2,4,1)=   1.0e30 ! Ol
	E_eta(2,3,1)=530.0e3 V_eta(2,3,1)=1.0e-5  Pdecay_V(2,3,1)=   1.0e30 ! TZ
	E_eta(2,2,1)=530.0e3 V_eta(2,2,1)=1.0e-5  Pdecay_V(2,2,1)=   1.0e30 ! PV
	E_eta(2,1,1)=530.0e3 V_eta(2,1,1)=1.0e-5  Pdecay_V(2,1,1)=   1.0e30 ! PPV

	! pyroxene-garnet system, dislocation creep
	E_eta(2,5,2)=530.0e3 V_eta(2,5,2)=1.0e-5   Pdecay_V(2,5,2)=   1.0e30 ! Bs
	E_eta(2,4,2)=530.0e3 V_eta(2,4,2)=1.0e-5   Pdecay_V(2,4,2)=   1.0e30 ! Px
	E_eta(2,3,2)=530.0e3 V_eta(2,3,2)=1.0e-5   Pdecay_V(2,3,2)=   1.0e30 ! Gt
	E_eta(2,2,2)=530.0e3 V_eta(2,2,2)=1.0e-5   Pdecay_V(2,2,2)=   1.0e30 ! PV
	E_eta(2,1,2)=530.0e3 V_eta(2,1,2)=1.0e-5   Pdecay_V(2,1,2)=   1.0e30 ! PPV

	E_eta(2,2,6)=530.0e3 V_eta(2,2,6)=1.0e-5   Pdecay_V(2,2,6)=   1.0e30 ! Bs
	E_eta(2,1,6)=530.0e3 V_eta(2,1,6)=1.0e-5   Pdecay_V(2,1,6)=   1.0e30 ! Bs

	eta_max=1.e24 !1.e28
	eta_min=1.e18
	visc_interp_law='g'

	deta_p_correct_jumps=.true.
	deta_p(5,1)=1.     ! garnet (instead of plag) (eclogite<->basalt)
	deta_p(5,2)=1.
	deta_p(4,1)=1.     ! shallow mantle
	deta_p(4,2)=1.
	deta_p(3,1)=1.     ! transition zone
	deta_p(3,2)=1.
	deta_p(2,1)=10.    ! perovskite
	deta_p(2,2)=10.
	deta_p(1,1)=0.1     ! pPv ! cannot yet be different than perovskite if using GS evolution
	deta_p(1,2)=0.1
	!TTG crust PT
	deta_p(1,6)=1.
	
   !...Compositional modulation of viscosity
	deta_basalt					   = 1 !0.3162 !0.1
	deta_primordial			   = 10.
	deta_archean    				= 100.0		!dehydration of cratonic lithosphere
	deta_proterozoic 				= 0.01
	deta_phanerozoic 				= 1.
	deta_ccrust 			   	= 0.1	!1.0	!0.01	!1.  
!	etalaw_basalt					= 1
	etalaw_basalt					= 1 ! 9 for new treatment (two different exponential interpolations between Bz-Pyrolite and between Pyrolite-Hz -> must set deta_Hz)
	etalaw_primordial				= 1
	etalaw_archean					= 1
	etalaw_proterozoic			= 1
	etalaw_phanerozoic			= 1
	d0_eta_cutoff_HzPyBs       = 6.6e5 ! no comp-dependence of eta in LM
	deta_Hz                    = 1 !3.162 ! >1  
	force_visc_modulation      = .false. !.true.

	!...influence of water on viscosity
	etalaw_water               = 10 !10 ! 1
	deta_water                 = 0.316228 ! 1.0
	c0eta_water                = 0.01 !0.01 ! in weight% 100 ppm
	
	!...Plastic yielding parameters
	c_dependent_yieldpars=.false.

	cohesion_eta = 1. !1.e12
	frictionCoeff_eta =0.2
	stressY_eta=20.e6 !1e8 !4e7 !100.e6 !50.e6      ! MPa constant ('ductile') yld stress @p=0
	dstressY_eta_dp=0.01 !0.01 !0.005 !0.01      ! gradient of the ductile yield stress

	stressY_archean		= 4e8 !5.1891e+04	!3.3e7		!1.e5  ! ('ductile') yld stress @p=0
	dstressY_archean	= 0.005 !0.0079		!0.079		!2.e6  ! gradient of the ductile yield stress
	frictionCoeff_archean	= 1.e12 	! Byerlee's law friction coefficient
	cohesion_archean 	= 1.e12

!	stressY_eta		= 100e6 !100.e6 !50.e6      ! MPa constant ('ductile') yld stress @p=0
!	dstressY_eta_dp		= 0.005 !0.01      ! gradient of the ductile yield stress
!	stressY_eta		= 5.1891e+03	!3.3e6		!40 MPa || 2.5e6 (30 MPa) || 1.6e6 (20 MPa) || 3.1e6 (37 MPa) || 1.e4 (37 MPa, Rolf et al.)  ! ('ductile') yld stress @p=0
!	dstressY_eta_dp		= 0.0079		!0.0079	!2.e5 (0.26 MPa/km)  ! gradient of the ductile yield stress
!	frictionCoeff_eta	= 1.e12 	! Byerlee's law friction coefficient
!	cohesion_eta 		= 1.e12
	
!	stressY_archean		= 100e7	!5.1891e+04	!3.3e7		!1.e5  ! ('ductile') yld stress @p=0
!	dstressY_archean	= 0.005	!0.0079		!0.079		!2.e6  ! gradient of the ductile yield stress
!	frictionCoeff_archean	= 1.e12 	! Byerlee's law friction coefficient
!	cohesion_archean 	= 1.e12
	
	stressY_proterozoic		= 3.e6		! ('ductile') yld stress @p=0
	dstressY_proterozoic		= 0.0   	! gradient of the ductile yield stress
	frictionCoeff_proterozoic	= 0.5   	! Byerlee's law friction coefficient
	cohesion_proterozoic 		= 0.0	
	
	stressY_phanerozoic		= 5.e4		! ('ductile') yld stress @p=0
	dstressY_phanerozoic		= 0.0   	! gradient of the ductile yield stress
	frictionCoeff_phanerozoic	= 0.5   	! Byerlee's law friction coefficient
	cohesion_phanerozoic 		= 0.0	
	
	!...Simple melt viscosity reduction
	eta_melt =.false. !.true.
	melt_phase_has_solid_viscosity=.true.
	etalaw_melt=2
	deta_melt=1 !0.1		!Tackley 2000, G3

	eta_conv     = 0.001
	maxits_eta   = 100
	alpha_eta=0.9          ! relaxation parameter for nonlinear viscosity iterations
&end

 &iteration
	maxits=20
	normalize_res_by_eta=.true.
	errmax=1.e-3
	relax_kernel='direct' !'classic' !'direct'
	alpha_mom=0.7
	alpha_cont=0.9
	redblack=.false.
  &end

 &multi 
	nrelax1=15
	nrelax2=15
	maxcoarseits=200
	alpha_multi=1.0
	nhmin=4
	nzmin=4
	nzpnmin=1
	more_coarse_its=.true.
	f_cycle=.true.
	matrix_dep_pinterp=.true.
  &end

 &grainsize
	!
	RenormRheoParsToAnticipateGS=.false. !.false. ! will change try to generate effective viscosity
	! jumps and choose activation volumes/rheological prefactors to get a realistic
	! viscosity profile.
	chiUM = 10. !0.1 !1.0 ! high chi favors diffusion creep
	chiLM = 10. !10. !1.0
	!
	ftopGS = 1e-1 !1e-1 !1.e-5 ! not fluxes, these are f parameters following Rozel 2010 approach
	fbotGS = 1e-6 !1e-7 !1.e-5
	!	
	fastgrowth = .false.
	!
	GS_ForcedPiezometric = .false.     ! Forces the grain size at its stress-dependent state
	GS_TwoPhases = .false. !.false.              ! Two phase for Zener pinning
	!GS_PiezometerModel = 'Rozeletal2010' !'homogeneous' ! Temperature-pressure-dependent piezometer ?
	!
	grainsize0_eta = 1.  ! GS is divided by this in the viscosity equation in diffusion creep
	grainsize_n_eta = 3.0 !3. ! exponent to grain size in viscosity law
	transition_depth_GS(1) = 410.e3  ! Olivine - wadsleyite
	transition_depth_GS(2) = 520.e3  ! wadsleyite - ringwoodite
	transition_depth_GS(3) = 660.e3  ! Upper to tower mantle
	transition_depth_GS(4) = 2740.e3 ! PV to PPV
	GSAfterPhaseTrans   = 5.e0 ! microns
	curvDownThrough660  = 5.e0 ! microns
	!
	GS_fG0         = 0.01 ! Partitioning parameter (cf Rozel 11)
	GS_fI0         = 0.01 ! Partitioning parameter (cf Bercovici 12)
	!
	! Phase 1
	!GG_k0(1)       = 2.49813e7 ! micron^2/s -> only works for p=2
	!GG_p(1)        = 2.0       ! Grain growth exponent
	!GG_E(1)        = 2.e5      ! J/mol
	!GG_k0(1)       = 3.9811e6  ! micron^4.5/s  (Yamazaki 05 -- Ringwoodite)
	!GG_p(1)        = 4.5       ! Grain growth exponent
	!GG_E(1)        = 4.14e5    ! J/mol
	
	! for composition-dependent grain growth!
	! k0 Hiraga = 0.06*exp(30 fEn*(fEn-1.1))
	! if there is 20% of basalt then
	! k0 Hiraga = 0.06*exp(30*0.2*(0.2-1.1)) = 0.000270995
	! to stay consisten with current implementation, k0 should then be multiplied
	! by exp(E/(R*1633.15))
	! this gives for E=400 kJ/mol : k0ref=0.000270995*exp(4e5/8.314/1633.15) = 1.68665e9

  	GG_k0(1)       = 1.68665e9 ! micron^5/s  (Hiraga for 20% basalt)
	GG_p(1)        = 5.        ! Grain growth exponent
	GG_E(1)        = 4e5       ! J/mol
	!
	GS_InitSize(1) = 1e2       ! microns
	GS_gamma(1)    = 1.e6      ! 1 J/m^2 = 1 Pa m^3 / m^2 = 1e6 Pa micron
	!
	! Phase 2
	GG_k0(2)       = 3.9811e6 ! micron^4.5/h -> only works for p=4.5
	GG_p(2)        = 4.5       ! Grain growth exponent
	GG_E(2)        = 4.14e5      ! J/mol
	GS_InitSize(2) = 1e2       ! microns
	GS_gamma(2)    = 1.e6      ! 1 J/m^2 = 1 Pa m^3 / m^2 = 1e6 Pa micron
	!
	! Interfaces between the two phases
	curv_k0        = 74943.9 !74943.9   ! micron^2/h -> only works for p=2
	curv_E         = 2e5 !2.e5      ! assumed identical to GG
	curv_q         = 1.5 !1.5       ! Leads to nice localisation in Bercovici 12
	curv_gamma     = 1.e6      ! assumed identical to individual GS
	curv_Init      = 1.e2      ! set to min(GS1,GS2) in default pars
  &end

 &ioin
	! only if try_continue=.true.
	hdf5_input_folder="+hdf5"
	!hdf5_input_folder="Case2_128_courant0.8_MPDATA" ! no "/" at the end please
	!hdf5_input_folder="Case2_128_courant6" ! no "/" at the end please
	restart_from_meshed_fields_only=.false.
	!
	hdf5_output_folder="+hdf5" ! no "/" at the end please
	output_file_stem='+op/earthDIM' ! This is not used anymore because of hdf5 output
	MaxFileSizeAllowed=1000000 ! bits
	MaxFileSizeAllowedTra=10000000 ! bits

	output_format='both' !'both'     ! options are 'auto','old','hdf' or 'both'
	input_format='old' !'old'  ! options are 'auto','old' or 'hdf'
	
	! top switch it on again, uncomment "call write_frame" in main.f90
	t_write=.true.     ! temperature
	c_write=.true.     ! composition
	cont_write=.false. ! continents
	rheo_write=.false. ! rheology (diffusion vs dislocation)
	ph_write = .false. ! phase field
	bs_write=.true.	   ! basalt fraction
	hz_write=.true.	   ! harzburgite fraction
	TTG_write = .true.
	cc_write = .false.
	primordial_write=.false. ! primordial fraction
	f_write=.true.     ! melt fraction
	Tsol_write = .false. ! lots of information about melting
	rho_write = .true. ! density
	svel_write = .false. ! seismic velocities
	pvel_write = .false.
	bvel_write = .false.
	vp_write=.true.    ! velocity & pressure
	vd_write=.true.    ! viscous dissipation
	eta_write=.true.   ! viscosity
	edot_write=.true.  ! strain rate
	edot_components_write = .true.
	age_write=.true.   ! age (since last melted)
	stress_write =.true. !CCC
	topo_write=.true.  ! topography (CMB & surface)
	!crust_write=.true. ! crustal thickness
	crust_write=.true. !CCC ! crustal thickness
	!g_write=.true.     ! geoid and topography corrected for self-gravitation
	g_write=.true.     ! geoid and topography corrected for self-gravitation
	hpe_write=.true.
	tra_write=.true.   ! tracers
	water_write = .true.
	GrainSize_write=.true.
	delete_old_trafiles=.true.
	trapercell_write=.true.
	K_Ar_write=.false.
	Sm_Nd_write=.true.
	Lu_Hf_write=.true.
	U_Th_Pb_He_write=.false.
	K_U_Th_write = .true.
	Detailed_SmNdLuHf_Cdep_report=.true.
	Mg_write = .true.
	
	tseries_format='ascii'
	rprof_format='ascii'
  &end

 &compin
  &end

 &melt
	melt_phase_systems=.true.
	harzburgite_melts=.true.
	fractional_xtallisation_n_melting=.true.
	melt_segregation=.false.
	K0_dimensional=1.e-9
	magma_effective_tcond=.false. !.true.
	magma_tcond_max=1e3 !1.e4 seems to fail with alpha_diff 1e8
	MagmaSelfEruptingTimeScale=1e5 ! Yrs

	!-----IF NOT SolidusLiquidusInterpolate--------------
	!!solidus_function='Hirschmann'
	!solidus_function='simple'
	!liquidus_function = 'simple'
	!p_dependent_solidus = .true. !.false.     ! whether depends on pressure rather than depth
	!p_dependent_liquidus = .false. !.false.
	!liquidus_function_basalt = 'TTGSizova'
	!solidus_function_basalt ='TTGSizova' ! 'TTGMoyen'
	!wet_solidus_Moyen = .false.
	!effective_solidus_Moyen = .false.
	!hydrated_basalt_Sizova=.true.
	!dry_basalt_Sizova=.true.
	!delta_solidus_bas_TTG=100.	! lower solidus of TTG compared to basalt (in K)
	!c_dependent_solidus=.true.            ! increases solidus due to depletion
	!Cf_dependent_Tmelting=.true.
	!
	!-----ELSE IF SolidusLiquidusInterpolate-------------
	SolidusLiquidusInterpolate = .true. !.true.
	!
	alpha_BasPyrTSolidusKink  = 0.3
	alpha_PyrHarzTSolidusKink = 0.2
	alpha_BasPyrCompKink      = 0.2
	alpha_PyrHarzCompKink     = 0.7
	!
	alpha_MeltFracBs = 1.2
  	alpha_MeltFracHz = 1.2
	!
	BasWaterSolidusInterpNonLinearity  = 0.15
	HarzWaterSolidusInterpNonLinearity = 0.15
	PyrWaterSolidusInterpNonLinearity  = 0.15
	BasPyrSolidusCompNonLinearity      = 0.15
	!
	DTsolHzPyrDry        = 200. !this can ben changed (default 200)
	DeltaTSolDryWetHarz  = 200. !(200 this should really not be changed unless testing)
	!
	solidus_dry_basalt   = 'pertermann&Andr'
	solidus_wet_basalt   = 'MoyenLowAndrault'
	solidus_dry_pyrolite = 'simple'
	solidus_wet_pyrolite = 'KesselLitasovEx'
	solidus_dry_harz     = 'Maaloe04&Param'
	solidus_wet_harz     = 'Maaloe04&Param'
	liquidus_basalt      = 'pertermann&Andr'
	liquidus_pyrolite    = 'fiquet2010'
	!------------------------------------------------------


	latent_heat=600e3                     ! in J/kg
	latent_heat_basalt=380e3                     ! in J/kg
	latent_heat_TTG=300e3                     ! in J/kg

	HalfH2OSatBasedTTGform=.true.
	H2OThresholdBasedTTGform=.false.
	H2OThresholdTTGform=0.05 ! weight per cent (0.1wpc=1000ppm)
	forbidTTGformation=.false.
	SumBasTTGForCrustDetect=.true.
	
	! eruption-intrusion related parameters
	! ----> basalt
	eruption=.true.
	erupt_fraction=0.3
	erupt_mode='all'
	intrusion=.true.
	intrude_fraction=0.7
	intrude_position='base_crust' !'surface' ! 'mid_crust'
	! ----> TTG
	erupt_fraction_TTG=0.3
	intrude_fraction_TTG=0.7
	cumulate_ei=.false.
	depletion=.true. !.true.
	depletion_fraction =0.9 ! 0.6

	d_erupt_Earth=300.e3              ! maximum eruption depth in meters 
	d_intrude=300.e3

	WaterSolub_LM_Harz   = 0.01 !0.005 !wght%
	WaterSolub_LM_Bas    = 0.01 !0.005 !wght%
	WaterSolub_LM_TTG    = 0.01 !0.005 !wght%

  &end


 &continents
        imode_cont                                      = 'simple' !'bipolar'
        distribution_mode                               = 'auto'        !'manual'
!       polygon_name                                    = '6conts31.xy'
!       nl                                              = 353 !2079 !2005
        ncont                                           = 0 ! also change imode_tra, cont_tracers
        !cont_startpos(1,1)                              = 1.57
        !cont_startpos(1,2)                              = 3.14
        !cont_startpos(2,1)                              = 0.0
        !cont_startpos(2,2)                              = 0.0
        cont_radius(1)                                  = 0.5
        cont_radius(2)                                  = 0.5
        cont_radius(3)                                  = 0.  !0.25
        cont_radius(4)                                  = 0.  !0.25
        cont_radius(5)                                  = 0.  !0.25
        cont_radius(6)                                  = 0.  !0.25
        patchy_conts                                    = .false. !rectangular is .true. otherwise cylindrical
        tapered_edges                                   = .false.
        taper_angle                                     = 0.

!       cont_crust                                      = .false.
        cont_crust                                      = .false.       !.true.

        proterozoic_belts                               = .false. !.true.
        phanerozoic_belts                               = .false.
        w_belt_prot                                     = 0.2
        w_belt_phan                                     = 0.1
        proterozoic_sutures                             = .false.
        phanerozoic_sutures                             = .false.
        nsuture                                         = 1
        w_suture_prot                                   = 0.2
        w_suture_phan                                   = 0.1
        random_sutures                                  = .false.
        threeD_sutures                                  = .false.
        suture_fraction(1)                              = -1.
        suture_fraction(2)                              = -1.           ! negative values switch off this material

        fourier_coeff                                   = .false.        !correlation added CJ_Aug14
        n_harmonics                                     = 20            !nytot/2 (has to be less than this)
!        z_temp(:,1)                                     = 1.0,0.25      !0.138, 0.086   !400-250 km lower and upper bounds where the coeffcients for T and C are averaged
!        z_comp(:,1)                                     = 0.035,0.0     !0.0173, 0.0    !50-0 km
        z_temp(:,1)                                     = 2890.e3,722.5e3
        z_comp(:,1)                                     = 101.1e3,0.0
  &end

 &atm_stuff
  &end

 &tracersin
	basalt_harzburgite=.true.

	harz_bas_TTG_cc = .true. !.true. ! true switches off basalt_harzburgite

	tracers_merge_radius_cutoff_factor = 0.5 ! initially defined as radius_cutoff_factor in tracers.f90, now moved to par file
	! 1 means 0.5 grid spacings (in the shortest direction)
	tracers_merge_TYPEPOS_cutoff = 0.1 ! considers tracer type (TYPEPOS)
	! Recommended cutoff with harz_bas_TTG_cc melting system: 0.05
	tracers_merge_EMPOS_cutoff = 0.1 ! considers tracer emplacement (EMPOS) to not merge erupted tracers(1) with intruded ones(2)
	! Recommended cutoff with harz_bas_TTG_cc melting system: 0.1
	tracers_merge_TTGSOURCEPOS_cutoff = 0.05 ! considers TTG source type (TTGSOURCEPOS:1,2,3) while merging
	! Recommended cutoff with harz_bas_TTG_cc melting system: 0.05


	Ctr_lininterp=.true.
	WaterSaturationConnolly = .true.
	ntracers_per_cell=20 !30 !25 !20
	imode_tra='even+ran' !'even+ran+BasaltSnow' !'even' !'continents+ran'
	!imode_tra='even+ran' !'even' !'continents+ran'

	BasaltSnow_AverageDripsSpacing = 3e5 !4e5
	BasaltSnow_MinDripRadius_m     = 1e4 !1e4
	BasaltSnow_MaxDripRadius_m     = 5e4 !5e4
       	BasaltSnow_MinDripDT           = 1e2 !1e2
	BasaltSnow_MaxDripDT           = 1e2 !5e2
	BasaltSnow_DownTo              = 1e6 !1e6
	BasaltSnow_PresentDay_PG_in_Hz = 0.25
	CMBHotSphericalAnomaliesRadius = 1e5

	tracers_everywhere=.true.
	d_crust=2890.e3                ! in meters
	d_archean=231.e3	!0.08	!231 km	! Initial thickness of archean continents (see Rolf and Tackley, GRL 2011)
	d_primordial=0.0 !440.0e3
	track_GrainSize   = .false. !.false.
	primordial_layer = .false. 	! Include primordial layer	
	! these should be made dimensional
	d_ccrust=0.028	!0.014		!40 km		! Initial thickness of continental crust
	d_proterozoic=0.15		! Initial thickness of proterozoic conts.
	d_phanerozoic=0.10		! Initial thickness of phanerozoic conts.
	B_ccrust=-2.4		!-0.8	  !-600 kg/m3	! Buoyancy ratio of continental crust
	B_archean=-0.24	!-0.4		!-0.2	  !-100 kg/m3	! Buoyancy ratio of archean material
	B_proterozoic=0.		! Buoyancy ratio of proterozoic material
	B_phanerozoic=0.		! Buoyancy ratio of phanerozoic material
	B_primordial=0.      	! Buoyancy ratio of primordial material

	tracers_temperature = .true.
	tracers_timemelt = .true.
	traceelement_water= .true.
	ingas_water = .true.

	WaterFullSatSurfIngas = .true. !.true.
	topH2O_val = 0.1 !0.1 ! in weight%   -- if WaterFullSatSurfIngas==.false. --
	ingas_depth = 10.e3 !10.e3 ! in m (if dimensional)
	initialConcentration_water = 0.01 !0.01 ! %

	outgas_fraction_water = 0.0
	outgas_fraction_Ar = 0.0
	outgas_fraction_He = 0.0
	outgas_fraction_carbon = 0.0
	outgas_fraction_nitrogen = 0.0

	IntrudedBasaltHydrationFraction = 1.0 ! 1 by default for the moment, other not implemented
	tracers_advord = 4
	tracers_interp2ord = .true.
	tracers_merge_whole_cell = .true.
	tracers_merge_supercells = .false. !.false.        ! if .true. then considers out-of-cell tracers for merging
	merge_erupting_tracers = .false. ! true => merge erupting with existing; false=>make new tracers for new crust 

	!if not using U, K and Th
	traceelement_hpe=.false.
	Dpartition_hpe=0.01             	 !0.1
	Dpartition_BasToTTG_hpe=0.01
	Dpartition_sTTG2mTTG_hpe=0.01

	!important for Sm/Nd/Lu/Hf
	DepthDependentPartitionCoefficients=.true.
	TE_InitialState_DpDepth="highP" !"lowP" ! "mediumP" ! "highP"

	traceelement_K40_U235_U238_Th232=.true.
	traceelement_Sm146_Nd142=.false. !.true.
	traceelement_Lu176_Hf176=.false. !.true.
	traceelement_Sm147_Nd143=.false. !.true.
	
	! partitioning in basaltic melt production -------------
	! plagioclase peridotite
	Dpartition_0_30km_Sm=0.125
	Dpartition_0_30km_Nd=0.093
	Dpartition_0_30km_Lu=0.175
	Dpartition_0_30km_Hf=0.103
	! spinel peridotite
	Dpartition_30_90km_Sm=0.122
	Dpartition_30_90km_Nd=0.081
	Dpartition_30_90km_Lu=0.179
	Dpartition_30_90km_Hf=0.103
	! deep mantle
	Dpartition_Sm=0.203
	Dpartition_Nd=0.095
	Dpartition_Lu=5.006
	Dpartition_Hf=0.285

	! harzburgite melt ----------------
	Dpartition_HzMelt_Sm=0.004
	Dpartition_HzMelt_Nd=0.002
	Dpartition_HzMelt_Lu=0.069
	Dpartition_HzMelt_Hf=0.01

	! partitioning in TTGs melts ------------------
	! low and medium pressure TTGs (only used if DepthDependentPartitionCoefficients=.true.)
	Dpartition_BasToTTG_LMP_Sm = 1.63
	Dpartition_BasToTTG_LMP_Nd = 0.99
	Dpartition_BasToTTG_LMP_Lu = 3.37
        Dpartition_BasToTTG_LMP_Hf = 0.65
	! high pressure TTGs (and default)
	Dpartition_BasToTTG_Sm = 1.01 
	Dpartition_BasToTTG_Nd = 0.34
	Dpartition_BasToTTG_Lu = 10.02
	Dpartition_BasToTTG_Hf = 0.6
	! solid TTG to molten TTG
	Dpartition_sTTG2mTTG_Sm = 0.8
	Dpartition_sTTG2mTTG_Nd = 1.0
	Dpartition_sTTG2mTTG_Lu = 0.5
	Dpartition_sTTG2mTTG_Hf = 0.9



	!DpartitionHzmelt for K,U and Th are using default
	Dpartition_water=0.01
	Dpartition_K=0.01      ! values from Xie & Tackley (2004ab)
	Dpartition_U=0.007
	Dpartition_Th=0.008 ! 0.07 in the JGR paper
	Dpartition_BasToTTG_water = 0.01
	Dpartition_BasToTTG_K     = 0.017 !an average for low and high P Dp
	Dpartition_BasToTTG_U     = 0.06
	Dpartition_BasToTTG_Th    = 0.045 !an average for low and high P Dp

	Dpartition_sTTG2mTTG_water = 0.01
	Dpartition_sTTG2mTTG_K     = 0.3
	Dpartition_sTTG2mTTG_U     = 0.6
	Dpartition_sTTG2mTTG_Th    = 1.0

	! These are from Xie & Tackley 2004 PEPI (He & Ar)
	!  in atoms per gram
	!initialConcentration_238U =9.22e13  ! at 3.6Gyr B.P.
	!initialConcentration_235U =1.34e13  ! at 3.6Gyr B.P.
	!initialConcentration_232Th=2.48e14  ! at 3.6Gyr B.P.
	!initialConcentration_40K  =3.44e15  ! at 3.6Gyr B.P.
	! These are from Xie & Tackley 2004 JGR (U-PB & Sm-Nd)
	!  in atoms per gram
	!initialConcentration_238U =8.12e13  ! at 3.6Gyr B.P.
	!initialConcentration_235U =1.17e13  ! at 3.6Gyr B.P.
	!initialConcentration_232Th=2.18e14  ! at 3.6Gyr B.P.

	!initial age is 4.4500 Ga

	! from Martin Guitreau
	initialConcentration_176Hf=5.426532E13
	initialConcentration_177Hf=1.938983E14
	initialConcentration_176Lu=7.121517E12
	initialConcentration_144Nd=1.345771E15
	initialConcentration_142Nd=1.536473E15
	initialConcentration_143Nd=6.820932E14
	initialConcentration_147Sm=2.715604E14
	initialConcentration_146Sm=1.792180E11

	!initialConcentration_238U =8.12e13  ! at 3.6Gyr B.P.
	!initialConcentration_235U =1.17e13  ! at 3.6Gyr B.P.
	!initialConcentration_232Th=2.18e14  ! at 3.6Gyr B.P.
	!initialConcentration_40K  =3.44e15  ! at 3.6Gyr B.P.
	! Antoine->extrapolation using half lives back from 3.6BP
	initialConcentration_238U =8.89665e13  ! at 4.45Gyr B.P.
	initialConcentration_235U =1.23957e13  ! at 4.45Gyr B.P.
	initialConcentration_232Th=2.24452e14  ! at 4.45Gyr B.P.
	initialConcentration_40K  =5.51553e15  ! at 4.45Gyr B.P.
	AgeGyrForInitialTEValues=4.45 !age at which the initial values for the TE are valid
	DelayRealTimeByGyrs=0.45 !time in Gyr (decays all radioactive elements by the given time)
	
	
	track_MgNumber=.true. !.true.
	adapt_rho_Mg=.false. !.true.
  &end

 &plot
	npix=500000
	plot_file_stem='+im/Earth'
	dots=.false.
	t_plot=.false.
	auto_t_scale=.false.
	t_superadiabatic=.false.
	p_plot=.false.
	pd_plot=.false.
	c_plot=.false.
	bs_plot=.false.
	hz_plot=.false.
	TTG_plot=.false.
	cc_plot=.false.	
	f_plot=.false.
	v_plot=.false.
	eta_plot=.false.
	stress_plot=.false.
	tcond_plot=.false.
	ph_plot=.false.
	hpe_plot=.false.
	tra_plot=.false.
	trapercell_plot=.false.
	K_Ar_plot=.false.
	Sm_Nd_plot=.false.
	Lu_Hf_plot=.false.
	U_Th_Pb_He_plot=.false.
  &end
