input.f90 165 KB
Newer Older
Lena Noack's avatar
Lena Noack committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
!>
!> Reads input file "input.txt" and automatically non-dimensionalizes if needed
!>
!> @author Lena Noack
!> @date November 2013

module input
!  use mpi
  INCLUDE 'use_mpi.f90' 
  use precision
  use parameters
  use mpifunc
  implicit none
contains

16
  subroutine input_read(pA,pC,pD,pE,pF,pG,pH,pI,pL,pM,pN,pO,pP,pS,pT,pV,pW,pX)
Lena Noack's avatar
Lena Noack committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    type(param_A),intent(inout)::pA !< adaptive or non-uniform grid
    type(param_C),intent(inout)::pC !< continents and plate tectonics
    type(param_D),intent(inout)::pD !< density variations by phase transitions
    type(param_E),intent(inout)::pE !< 1D thermal evolution
    type(param_F),intent(inout)::pF !< factors for non- and back-dimensionalization
    type(param_G),intent(inout)::pG !< geometry
    type(param_H),intent(inout)::pH !< tidal heating
    type(param_I),intent(inout)::pI !< (initial) input data (temperature is stored extra)
    type(param_M),intent(inout)::pM !< melt
    type(param_L),intent(inout)::pL !< paraLlel version
    type(param_N),intent(inout)::pN !< numerical parameters
    type(param_O),intent(inout)::pO !< output, restart and time step
    type(param_P),intent(inout)::pP !< particles
    type(param_S),intent(inout)::pS !< strain and strain rate
    type(param_T),intent(inout)::pT !< (initial) temperature data
    type(param_V),intent(inout)::pV !< viscosity
    type(param_W),intent(inout)::pW !< weak zone benchmark
34
    type(param_X),intent(inout)::pX !< concentrations and outgassing
Lena Noack's avatar
Lena Noack committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  
    real(dp)::val,e_gamT,e_gamP,pref,resolution=0.0_dp
    character(20)::var,equal

    integer::rank,nprocs,ierr,surfT0,UseSecondInput,ReadNondimValues,k
    real(dp),allocatable::vals_t(:,:)
    integer::n_t
    real(dp)::Mantle_count,Core_count,vol
    INCLUDE 'get_mpi.f90'

    if (v_mpi) then
      CALL MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) ! Find this processor number
      CALL MPI_COMM_SIZE(MPI_COMM_WORLD,nprocs,ierr)
    else
      rank = 0
      nprocs = 1
    endif


    if (rank.eq.0) then ! exchange of input values at the end

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !! First step: determine possible nondimensionalization factors !!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    ! ToDo: Instead of MPI exchanges at the end, make a loop starting hear for each rank -> each rank open and closes file after rank before stopped -> incl. MPI_BARRIER at the end

    surfT0 = 0
    UseSecondInput = 0
    ReadNondimValues = 0

    !> read-in parameters needed for nondimensionalization from input file
    open(42,file="input.txt",form='formatted',status='unknown')
    read(42,*) var,equal,val
    do while(var /= "EOF")
      select case(var)
        case("dim")
          pG%dim=int(val)       !< 2=2D for all geometries, 3=3D only for box version
          write(*,*) var,"=",pG%dim
        case("DimValues")
          pE%DimValues=int(val)
        case("Tbottom")
          pT%Tbottom=val
        case("Ttop")
          if (val.lt.0.0_dp) then
            pT%Ttop = -val
            surfT0 = 1
          else
            pT%Ttop = val
            surfT0 = 0
          endif
        case("rmin")      
          pG%rmin=val
        case("rmax")  
          pG%rmax=val
        case("IntStruct")
          pE%IntStruct = int(val)
        case("inner_bound")
          pG%inner_bound=int(val)
        case("grain_size")
          pI%grain_size=val
        case("Ra")
          pI%Ra=val
        case("g")   !gravity acceleration
          pI%gravity=val
        case("alpha")!thermal expansion coefficient
          pI%alpha=val
        case("Cp")
          pI%Cp=val
        case("rho")!Density (boussinesq)
          pI%rho=val
        case("kappa")  !thermal diffusivity
          pI%kappa=val
        case("H0")  !heat generation rate, if dimensional, then in W/kg (will be multiplied with rho further down)
          pI%H0=val
        case("k")  !thermal conductivity
          pI%k=val
        case("eta_ref") ! use reference viscosity to calculate Rayleigh number (Ra is not used then)
          pF%eta_ref=val
        case("OS_SuL") ! additional surface layer on top of domain
          if (val.gt.0.0_dp) then
            pG%rmax = pG%rmax+val
          endif
        case("C_U")
          pI%C_U=val ! in ppb
        case("C_Th")
          pI%C_Th=val ! in ppb
        case("C_K")
          pI%C_K=val ! in ppm
        case("UseSecondInput")
125
126
127
          if (val.ne.0) UseSecondInput = 1          
        case("read_profs")
          pI%read_profs = int(val)
Lena Noack's avatar
Lena Noack committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
        case("ReadNondimValues")
          if (val.ne.0) ReadNondimValues = 1 ! uses pre-defined non-dimensionalization values provided in "prof.res"
      end select
      read(42,*) var,equal,val
    end do
    close(42)

    !> read some specific data from second input file, such that code can be run from a script
    if (UseSecondInput.eq.1) then
      open(44,file="input2.txt",form='formatted',status='unknown')
      read(44,*) var,equal,val
      do while(var /= "EOF")
       select case(var)
        case("Tbottom")
          pT%Tbottom=val
        case("Ttop")
          pT%Ttop=val
        case("rmin")
          pG%rmin=val
Lena HPC's avatar
Lena HPC committed
147
148
        case("rmax")
          pG%rmax=val
Lena Noack's avatar
Lena Noack committed
149
150
        case("eta_ref") ! use reference viscosity to calculate Rayleigh number (Ra is not used then)
          pF%eta_ref=val
mariehln's avatar
mariehln committed
151
152
153
154
155
156
157
158
        case("crust_ini")
          pC%crust_ini=val
        case("add_crust")
          pM%add_crust=int(val)
        case("Crust_Lambda")
          pM%Lambda=val
        case("Dreg")
          pE%Dreg=val
Lena Noack's avatar
Lena Noack committed
159
160
161
162
163
164
165
166
167
168
169
170
171
       end select
       read(44,*) var,equal,val
      end do
      close(44)
    endif

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!  Second step: create and save nondimensionalization factors  !!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    if (ReadNondimValues.eq.1) then
      ! uses pre-defined non-dimensionalization values provided in "prof.res"
      n_t = 1000
172
173
      if (pI%read_profs.eq.3) n_t = 100

Lena Noack's avatar
Lena Noack committed
174
175
176
177
178
179
180
181
182
183
      Mantle_count = 0.0_dp
      Core_count = 0.0_dp
      pI%Cp = 0.0_dp
      pI%Cp_c = 0.0_dp
      pI%Rc = 0.0_dp
      pI%rho_c = 0.0_dp
      pI%rho = 0.0_dp
      pI%k = 0.0_dp
      pI%gravity = 0.0_dp
      pI%alpha = 0.0_dp
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

      if (pI%read_profs.eq.3) then
       ! profiles provided by Caroline Dorn

        allocate( vals_t(n_t,10) )
        !     1         2        3         4         5       6       7             8              9           10
        ! gravity(k),pnew(k),rho_min(k),radius(k),tempr(k),c_p(k),alpha_v(k),bulkmodulus(k),shearmodulus(k),kcount
        open(70,file="material_parm_model.ddat",form='formatted',status='unknown')
          do k=1,n_t
            read(70, *) vals_t(n_t+1-k,:) ! surface values at n_t
          enddo
        close(70)

       do k=1,n_t
        if (k.lt.n_t) then
          ! either core or mantle            
          vol = 4.0_dp/3.0_dp*acos(-1.0_dp) * (vals_t(n_t+1-k,4)**3-vals_t(n_t-k,4)**3)
          if (vals_t(n_t+1-k,7).gt.0.0_dp) then ! alpha zero in core, non-zero in mantle
            Mantle_count = Mantle_count + vol
            pI%Cp = pI%Cp + vals_t(n_t+1-k,6)*vol
            pI%rho = pI%rho + vals_t(n_t+1-k,3)*vol
            pI%k = pI%k +  vol * (3.48_dp+0.1171_dp*vals_t(n_t+1-k,2)*1.0e-9_dp) * (300.0_dp/vals_t(n_t+1-k,5))**0.31_dp  ! Tosi et al 2013, pv + per, profile B
            !pI%gravity = pI%gravity + vals_t(n_t+1-k,1)*vol
            pI%alpha = pI%alpha + vals_t(n_t+1-k,7)*vol
          else
209
            if (vals_t(n_t+2-k,7).gt.0.0_dp) pI%Rc = 0.5_dp*(vals_t(n_t+2-k,4)+vals_t(n_t+1-k,4))*1000.0_dp
210
211
212
213
214
215
216
217
218
            Core_count = Core_count + vol
            pI%Cp_c = pI%Cp_c + vals_t(n_t+1-k,6)*vol
            pI%rho_c = pI%rho_c + vals_t(n_t+1-k,3)*vol
          endif
        endif
       enddo
       pI%Rp = vals_t(n_t,4) * 1000.0_dp
       pI%gravity = vals_t(n_t,1)

Lena HPC's avatar
Lena HPC committed
219
      else if (pI%read_profs.ge.4) then
220
221
       ! profiles provided by CHIC routine

222
223
224
225
226
227
228
229
230
       !if (pI%read_profs.ge.4) then
       !  allocate( vals_t(n_t,11) )
       !else
       !  allocate( vals_t(n_t,13) )
       !endif
       allocate( vals_t(n_t,14) )

       !     1         2      3       4         5       6    7         8        9    10    11     12  13  14
       ! gravity(k),pnew(k),rho(k),radius(k),tempr(k),Tm(k),c_p(k),alpha_v(k),gr(k),KT(k),KS(k),GS(k),k_e,mat
231
       open(70,file="profs.res",form='formatted',status='unknown')
Lena Noack's avatar
Lena Noack committed
232
233
234
        do k=1,n_t
          read(70, *) vals_t(n_t+1-k,:) ! surface values at n_t
        enddo
235
       close(70)
Lena Noack's avatar
Lena Noack committed
236

237
       do k=1,n_t
Lena Noack's avatar
Lena Noack committed
238
239
240
        if (k.lt.n_t) then
          ! either core or mantle            
          vol = 4.0_dp/3.0_dp*acos(-1.0_dp) * (vals_t(n_t+1-k,4)**3-vals_t(n_t-k,4)**3)
241
          if (vals_t(n_t+1-k,14).lt.8.0_dp) then
Lena Noack's avatar
Lena Noack committed
242
            Mantle_count = Mantle_count + vol
243
            pI%Cp = pI%Cp + vals_t(n_t+1-k,7)*vol
Lena Noack's avatar
Lena Noack committed
244
            pI%rho = pI%rho + vals_t(n_t+1-k,3)*vol
245
246
            pI%k = pI%k +  vol * (3.48_dp+0.1171_dp*vals_t(n_t+1-k,2)) * (300.0_dp/vals_t(n_t+1-k,5))**0.31_dp  ! Tosi et al 2013, pv + per, profile B
            !pI%gravity = pI%gravity + vals_t(n_t+1-k,1)*vol
247
            pI%alpha = pI%alpha + vals_t(n_t+1-k,8)*1.0e-5_dp*vol
Lena Noack's avatar
Lena Noack committed
248
          else
249
            if (vals_t(n_t+2-k,14).lt.8.0_dp) pI%Rc = 0.5_dp*(vals_t(n_t+1-k,4)+vals_t(n_t-k,4))
Lena Noack's avatar
Lena Noack committed
250
            Core_count = Core_count + vol
251
            pI%Cp_c = pI%Cp_c + vals_t(n_t+1-k,7)*vol
Lena Noack's avatar
Lena Noack committed
252
253
254
            pI%rho_c = pI%rho_c + vals_t(n_t+1-k,3)*vol
          endif
        endif
255
256
257
258
259
       enddo
       pI%Rp = vals_t(n_t,4)
       pI%gravity = vals_t(n_t,1)

      endif ! different read-profs versions
Lena Noack's avatar
Lena Noack committed
260
261
262
263
264
265

      pI%Cp = pI%Cp / Mantle_count
      pI%Cp_c = pI%Cp_c / Core_count
      pI%rho = pI%rho / Mantle_count
      pI%rho_c = pI%rho_c / Core_count
      pI%k = pI%k / Mantle_count
266
      !pI%gravity = pI%gravity / Mantle_count
Lena Noack's avatar
Lena Noack committed
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
      pI%alpha = pI%alpha / Mantle_count
      pI%kappa = pI%k / pI%rho / pI%Cp

      pG%rmin = pI%Rc
      pG%rmax = pI%Rp

      pF%D = pI%Rp - pI%Rc
      pF%kappa = pI%kappa
      pF%g = pI%gravity
      pF%rho = pI%rho
      pF%Cp = pI%Cp
      pF%alpha = pI%alpha
      pF%k = pI%k

      pF%time_yr = 3600.0_dp*365.25_dp*24.0_dp*pF%kappa/pF%D**2 ! yr -> non-dimensional
      pF%grain = pF%D !non-dim with mantle thickness

      write(*,*) "pF%Cp=",pF%Cp,", pF%k=",pF%k,", pF%g=",pF%g,", pF%rho=",pF%rho,", pF%D=",pF%D,", pF%alpha=",pF%alpha

      if (pI%H0.ne.1.0_dp) pI%H0 = pI%H0 * pF%rho
287
      !if(pG%inner_bound.eq.0) then  ! bottom-heated and mixed-heated convection
Lena Noack's avatar
Lena Noack committed
288
        pF%DeltaT=abs(pT%Tbottom-pT%Ttop)
289
290
291
292
293
294
295
296
297
      !elseif(pG%inner_bound.eq.1) then ! purely internally-heated convection
      !  if (pI%H0.eq.1.0_dp) then ! use Ra as internal Rayleigh number
      !    pF%DeltaT=abs(pT%Tbottom-pT%Ttop)
      !  else
      !    pF%DeltaT=pF%D**2*pI%H0/pF%k
      !  endif
      !else
      !  if (rank.eq.0) write(*,*) "error: wrong value for inner_bound in the input file"
      !endif
Lena Noack's avatar
Lena Noack committed
298
299
300
301
302
303
304
305
306
307
308
309
      if (surfT0.eq.1) then ! temp increases from Ttop to 1+Ttop
        pF%Ts = 0.0_dp
      else ! temp increases from 0 to 1
        pF%Ts = pT%Ttop ! works for both Celsius and Kelvin
      endif

      if (pF%eta_ref.eq.0.0_dp) then
        pF%eta_ref = pF%rho*pF%g*pF%D**3*pF%alpha*pF%DeltaT/(pI%Ra*pF%kappa)
      else
        if (rank.eq.0) write(*,*) "-----------------------------------------------"
        if (rank.eq.0) write(*,*) "Recalculate Ra, instead of ",pI%Ra
        pI%Ra = pF%rho*pF%g*pF%D**3*pF%alpha*pF%DeltaT/(pF%eta_ref*pF%kappa)
310
        pI%RaB = pF%rho*pF%g*pF%D**3/(pF%eta_ref*pF%kappa) ! for ALA term and lithostatic pressure term in stokes, RaB = Ra * B
311
        if (rank.eq.0) write(*,*) "  use now Ra=",pI%Ra," and use Ra*B=",pI%RaB
Lena Noack's avatar
Lena Noack committed
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
        if (rank.eq.0) write(*,*) "-----------------------------------------------"
      endif
      pI%eta_ref = pI%eta_ref / pF%eta_ref

      if (rank.eq.0) write(*,*) "Ref values (D,t_yr,DeltaT,Ts,eta_ref):"
      if (rank.eq.0) write(*,*) pF%D,pF%time_yr,pF%DeltaT,pF%Ts,pF%eta_ref
      pF%R = pV%R
      if (rank.eq.0) write(*,*) "-----------------------------------------------"


    else if (((pI%rho.eq.1.0_dp).and.(pE%IntStruct.eq.0)).or.(pE%DimValues.eq.1)) then
      ! already nondim values or when dim values used in code (is also 1 if density not set and hence non-dim input-file)
      write(*,*) "No automatic non-dimensionalization needed",pI%rho,pE%IntStruct,pE%DimValues
      if (pF%eta_ref.eq.0.0_dp) then
        pF%eta_ref = 1.0_dp
        pI%eta_ref = 1.0_dp
      endif
      if ((pE%DimValues.eq.1).and.(pG%dim.le.1)) then ! Ra is calculated via pI%rho...
        pI%Ra = 1.0_dp
        pI%eta_ref = pF%eta_ref
        pF%eta_ref = 1.0_dp
      endif
    else                  ! all parameters have to be non-dimensionalized
      write(*,*) "Automatic non-dimensionalization",pI%rho,pE%IntStruct,pE%DimValues
      pF%D = pG%rmax - pG%rmin
      if (pF%D.eq.0.0_dp) pF%D = 1000000.0_dp ! reference value in case radii are determined from interior structure model
      pF%g = pI%gravity
      if (pI%gravity.eq.1.0_dp) pF%g = 10.0_dp ! reference value in case g is determined from interior structure model
      pF%rho = pI%rho
      if (pI%rho.eq.1.0_dp) pF%rho = 4000.0_dp ! reference value in case rho is determined from interior structure model
      pF%Cp = pI%Cp
      pF%alpha = pI%alpha
      if (pI%alpha.eq.1.0_dp) pF%alpha = 2.0e-5_dp ! reference value in case alpha is determined from interior structure model
      pF%k = pI%k
      if (pI%k.eq.1.0_dp) pF%k = 10.0_dp ! reference value in case k is determined from interior structure model
Lena Noack's avatar
Lena Noack committed
347
348
349
350
351
352
353
354
355
356
357

      pF%kappa = pI%kappa
      if (pF%k.ne.pF%kappa*pF%Cp*pF%rho) then
        write(*,*) "Error: k needs to be equal to kappa*Cp*rho -> re-set non-dim factor kappa to ", pF%k/(pF%Cp*pF%rho)
        pF%kappa = pF%k/(pF%Cp*pF%rho)
        pI%kappa = pF%kappa
      endif

      write(*,*) "pF%Cp=",pF%Cp,", pF%k=",pF%k,", pF%g=",pF%g,", pF%rho=",pF%rho,", pF%D=",pF%D,", pF%alpha=",pF%alpha

      pF%time_yr = 3600.0_dp*365.25_dp*24.0_dp*pI%kappa/pF%D**2 ! yr -> non-dimensional
Lena Noack's avatar
Lena Noack committed
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
      pF%grain = pF%D !non-dim with mantle thickness, not with ref_grain-size ! pI%grain_size
      if (pI%H0.ne.1.0_dp) pI%H0 = pI%H0 * pF%rho
      if(pG%inner_bound.eq.0) then  ! bottom-heated and mixed-heated convection
        pF%DeltaT=abs(pT%Tbottom-pT%Ttop)
      elseif(pG%inner_bound.eq.1) then ! purely internally-heated convection
        if (pI%H0.eq.1.0_dp) then ! use Ra as internal Rayleigh number
          pF%DeltaT=abs(pT%Tbottom-pT%Ttop)
        else
          pF%DeltaT=pF%D**2*pI%H0/pI%k
        endif
      else
        if (rank.eq.0) write(*,*) "error: wrong value for inner_bound in the input file"
      endif
      if (surfT0.eq.1) then ! temp increases from Ttop to 1+Ttop
        pF%Ts = 0.0_dp
      else ! temp increases from 0 to 1
        pF%Ts = pT%Ttop ! works for both Celsius and Kelvin
      endif

      pI%eta_ref = 1.0_dp ! dimensionless reference viscosity 
      if (pF%eta_ref.eq.0.0_dp) then
        pF%eta_ref = pI%rho*pI%gravity*pF%D**3*pI%alpha*pF%DeltaT/(pI%Ra*pI%kappa)
      else
        if (rank.eq.0) write(*,*) "-----------------------------------------------"
        if (rank.eq.0) write(*,*) "Recalculate Ra, instead of ",pI%Ra
        pI%Ra = pI%rho*pI%gravity*pF%D**3*pI%alpha*pF%DeltaT/(pF%eta_ref*pI%kappa)
384
        pI%RaB = pI%rho*pI%gravity*pF%D**3/(pF%eta_ref*pI%kappa) ! for ALA term and lithostatic pressure term in stokes, RaB = Ra * B
385
        if (rank.eq.0) write(*,*) "  use now Ra=",pI%Ra," and use Ra*B=",pI%RaB
Lena Noack's avatar
Lena Noack committed
386
387
388
389
390
391
392
393
394
395
        if (rank.eq.0) write(*,*) "-----------------------------------------------"
      endif
      if (rank.eq.0) write(*,*) "Ref values (D,t_yr,DeltaT,Ts,eta_ref):"
      if (rank.eq.0) write(*,*) pF%d,pF%time_yr,pF%DeltaT,pF%Ts,pF%eta_ref
      pF%R = pV%R
      if (rank.eq.0) write(*,*) "-----------------------------------------------"
    endif
    pI%D = (pG%rmax - pG%rmin)/pF%D


Lena Noack's avatar
Lena Noack committed
396
397
398
399
!    if (pF%k.ne.pF%kappa*pF%Cp*pF%rho) then
!      write(*,*) "Error: k needs to be equal to kappa*Cp*rho -> re-set non-dim factor to ", pF%kappa*pF%Cp*pF%rho
!      pF%k = pF%kappa*pF%Cp*pF%rho
!    endif
Lena Noack's avatar
Lena Noack committed
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!   Third step: nondimensionalize already read-in parameters   !!
    !!        (if already nondimensional, nothing changes)          !!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    pT%Tbottom = (pT%Tbottom - pF%Ts) / pF%DeltaT
    pT%Ttop = (pT%Ttop - pF%Ts) / pF%DeltaT
    pG%rmax = pG%rmax / pF%D
    pG%rmin = pG%rmin / pF%D
    pI%grain_size = pI%grain_size / pF%grain
    pI%gravity = pI%gravity / pF%g
    pI%alpha = pI%alpha / pF%alpha
    pI%Cp = pI%Cp / pF%Cp
    pI%rho = pI%rho / pF%rho
    pI%kappa = pI%kappa / pF%kappa
    if (pI%C_U.eq.0.0_dp) pI%H0 = pI%H0 * pF%D**2 / (pF%DeltaT * pF%k) ! otherwise already non-dimensional enrichment/depletion factor
    pI%k = pI%k / pF%k

    pV%R = pV%R / pF%R
    pI%Rp = pG%rmax
    pI%Rc = pG%rmin
    pG%save_rmin=pG%rmin
    pG%save_rmax=pG%rmax

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !! Fourth step: read-in and nondimensionalize all other parameters !!
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    pE%Dlcr = 100.0_dp/pF%D
    pI%H0U238=pI%H0
    e_gamT = 0.0_dp
    e_gamP = 0.0_dp
    pref = 0.0_dp

    !> read in data from input file
    open(42,file="input.txt",form='formatted',status='unknown')
    read(42,*) var,equal,val
mariehln's avatar
mariehln committed
438
    read(42,*) var,equal,val
Lena Noack's avatar
Lena Noack committed
439
440
    do while(var /= "EOF")
      select case(var)
441
442
443
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! Print parameters from above !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lena Noack's avatar
Lena Noack committed
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
        case("Tbottom")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%Tbottom
        case("Ttop")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%Ttop
        case("rmin")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pG%rmin
        case("rmax")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pG%rmax
        case("inner_bound")
          if (rank.eq.0) write(*,*) var,"=",pG%inner_bound
        case("grain_size")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%grain_size
        case("Ra")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Ra
        case("g")  
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%gravity
        case("alpha")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%alpha
        case("Cp")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Cp
        case("rho")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%rho
        case("kappa") 
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%kappa
        case("H0")  
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%H0
        case("k")  
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%k
        case("eta_ref") 
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pF%eta_ref
        case("C_U")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%C_U
        case("C_Th")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%C_Th
        case("C_K")
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%C_K
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
        !! G: Geometry-related parameters !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
        case("geometry")  !< either 2D cartesian box (geometry=0), 2D spherical annulus (geometry=1) or 2D cylindrical shell (geometry=2)
          pG%geom=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%geom
!        case("dim")
!          pG%dim=val       !< 2=2D for all geometries, 3=3D only for box version
!          if (rank.eq.0) write(*,*) var,"=",pG%dim
        case("nl")
          pG%nl=int(val )
          if (rank.eq.0) write(*,*) var,"=",pG%nl
        case("ny")
          pG%ny=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%ny
        case("nr")
          pG%nr=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%nr
        case("resolution")
          resolution=val/pF%D  ! resolution that should be used, re-sets nl, ny and nr depending on mantle thickness and phi_factor
        case("lmin")
          pG%lmin=val / pF%D
          pG%save_lmin=pG%lmin
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pG%lmin
        case("lmax")
          pG%lmax=val / pF%D
          pG%save_lmax=pG%lmax
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pG%lmax
        case("ymin")
          pG%ymin=val / pF%D
          pG%save_ymin=pG%ymin
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pG%ymin
        case("ymax")
          pG%ymax=val / pF%D
          pG%save_ymax=pG%ymax
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pG%ymax
        case("noslip_t")
          pG%noslip_t=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%noslip_t
        case("noslip_b")
          pG%noslip_b=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%noslip_b
        case("noslip_w")
          pG%noslip_w=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%noslip_w
        case("phi_factor")
          pG%phi_factor=val
          if (rank.eq.0) write(*,*) var,"=",pG%phi_factor
        case("theta_factor")
          pG%theta_factor=val
          if (rank.eq.0) write(*,*) var,"=",pG%theta_factor
        case("outer_bound")
          pG%outer_bound=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%outer_bound
        case("open_b_bound")
          pG%open_b_bound=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%open_b_bound
        case("periodic")
          pG%periodic=int(val)
          if (rank.eq.0) write(*,*) var,"=",pG%periodic
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! O: Output-related parameters !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        case("last_snap") ! set one to continue from last time step
          pO%last_snap=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%last_snap
        case("use_snap") ! set to number of output from which simulation should continue
          pO%use_snap=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%use_snap
        case("start_snap") ! set in addition to 1 to start the simulation from last_snap / use_snap time step but with t=0
          pO%start_snap=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%start_snap
        case("min_outer")
          pO%min_outer=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%min_outer
        case("max_outer")
          pO%max_outer=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%max_outer
        case("max_inner")
          pO%max_inner=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%max_inner
        case("max_inner_init")
          pO%max_inner_init=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%max_inner_init
        case("max_inner_TS")
          pO%max_inner_TS=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%max_inner_TS
        case("nbiter")
          pO%nbiteration=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%nbiteration
        case("no_init_out")
          pO%no_init_out=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%no_init_out
        case("iter_out")
          pO%iter_output=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%iter_output
        case("t_output")
          pO%t_output=val * pF%time_yr ! yr -> nondim
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pO%t_output
        case("FirstOutput")
          pO%FirstOutput=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%FirstOutput
        case("tmax")
Marie-Helene Deproost's avatar
Marie-Helene Deproost committed
583
         pO%tmax=val * pF%time_yr ! yr -> nondim
Lena Noack's avatar
Lena Noack committed
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pO%tmax
        case("output_lid")
          pO%output_lid=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%output_lid
        case("output_compr")
          pO%OutputCompr=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%OutputCompr
        case("Cdt")
          pO%CourantCoeff=val 
          if (rank.eq.0) write(*,*) var,"=",pO%CourantCoeff
        case("dt_ini")
          pO%dt_ini=val * pF%time_yr ! yr -> nondim
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pO%dt_ini
        case("dt_min")
          pO%dt_min=val * pF%time_yr ! yr -> nondim
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pO%dt_min
        case("dt_max")
          pO%dt_max=val * pF%time_yr ! yr -> nondim
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pO%dt_max
        case("nmesures")
          pO%nmesures=int(val)
          if (rank.eq.0) write(*,*) var,"=",pO%nmesures
        case("conv")
          pO%convSS=val
          if (rank.eq.0) write(*,*) var,"=",pO%convSS
        case("convV")
          pO%convV=val 
          if (rank.eq.0) write(*,*) var,"=",pO%convV
        case("convT")
          pO%convT=val 
          if (rank.eq.0) write(*,*) var,"=",pO%convT
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! T: Temperature-related parameters !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        case("Tini")
          pT%Tini=(val-pF%Ts)/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%Tini
        case("s_bot")
          pT%s_bot=val/pF%D
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%s_bot
        case("s_top")
          pT%s_top=val/pF%D
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%s_top
        case("isotherm")
          pT%isotherm=(val-pF%Ts)/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%isotherm
        case("ampl")
          pT%ampl=val
          if (rank.eq.0) write(*,*) var,"=",pT%ampl
        case("sph_l")
          pT%sph_l=int(val)
          if (rank.eq.0) write(*,*) var,"=",pT%sph_l
        case("sph_y")
          pT%sph_y=int(val)
          if (rank.eq.0) write(*,*) var,"=",pT%sph_y
        case("linear")
          pT%linear=int(val)
          if (rank.eq.0) write(*,*) var,"=",pT%linear
        case("T0")
          pT%T0=val/pF%DeltaT
          if ((pE%DimValues.eq.1).or.(surfT0.eq.1)) pT%T0=0.0_dp ! since dimensional temperature is used
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%T0
        case("adiabat")
          pT%adiabat=val*pF%D/(1000.0_dp*pF%DeltaT)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%adiabat
        case("Tmin")
          pT%Tmin=(val-pF%Ts)/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%Tmin
        case("Tmax")
          pT%Tmax=(val-pF%Ts)/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%Tmax
655
656
657
        case("DeltaTc")
          pT%DeltaTc=val/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%DeltaTc
Lena HPC's avatar
Lena HPC committed
658
659
660
        case("CutSolidus")
          if (val.ne.0) pT%CutSolidus=.true.
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pT%CutSolidus
Lena Noack's avatar
Lena Noack committed
661
662
663
664
665
666
667
668
669
670
671
672
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! I: Input parameters for simulation !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        case("Di") ! in dimensional version: set to 1 and then Di is calculated automatically
          pI%Di=val * pF%alpha*pF%g*pF%D/pF%Cp
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Di
        case("DiT") ! in dimensional version: set to 1 and then Di is calculated automatically
          pI%DiT=val * pF%alpha*pF%g*pF%D/pF%Cp
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%DiT
        case("B") ! in dimensional version: choose B=1, then B is calculated correctly, otherwise chemical buocancy directly scales with B
          pI%B=val / (pF%DeltaT * pF%alpha)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%B
673
        case("drho") ! density change upon depletion (e.g. pyrolite to harzburghite), scaled to 100% depletion (since multiplied with actual depletion, which is typically max 30%)
674
          if (val.lt.0.0_dp) then
675
676
677
678
679
            pI%drho = 1.0_dp ! melt depletion not filled up by new material
          else
            pI%drho = val / pF%rho ! density change from pyrolite to harzburgite (in average 220 kg/m³)
          endif
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%drho
Lena Noack's avatar
Lena Noack committed
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
        case("Le")
          pI%Le=val
          if (rank.eq.0) write(*,*) var,"=",pI%Le
        case("LeV")
          pI%LeV=val
          if (rank.eq.0) write(*,*) var,"=",pI%LeV
        case("comp_init") ! composition is always non-dimensional... is linked to density though
          pI%comp_init=val
          if (rank.eq.0) write(*,*) var,"=",pI%comp_init
        case("comp_ampl")
          pI%comp_ampl=val
          if (rank.eq.0) write(*,*) var,"=",pI%comp_ampl
        case("rhogD") ! set to 1 in dimensional version, is automatically set (in GPa)
          pI%rhogD=val * pF%rho * pF%g * pF%D * 1.0e-9
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%rhogD
Lena Noack's avatar
Lena Noack committed
695
696
697
        !case("p_surf") ! in Pa or non-dimensional
        !  pI%p_surf=val * pF%D**2 / (pF%kappa * pF%eta_ref)
        !  if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%p_surf
Lena Noack's avatar
Lena Noack committed
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
        case("C_ref")
          pI%C_ref=val
          if (rank.eq.0) write(*,*) var,"=",pI%C_ref
        case("lambda")  ! exp(-lambda * t), in dimensional version set in [1/yr] ! NOTE: in the version with different heat species instead the half-life-time is used, i.e. lambda_i = ln(2)/half-life_i
          if (pI%C_U.ne.0.0_dp) then
            pI%lambda=val
          else
            pI%lambda=val / pF%time_yr 
          endif
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%lambda
        case("k_max") 
          pI%k_max=val / pF%k
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%k_max
        case("k_l")
          pI%k_l=val / pF%k
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%k_l
        case("k_cr")
          pI%k_cr=val / pF%k
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%k_cr
        case("k_r")
          pI%k_r=val / pF%k
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%k_r
        case("mantle_w_H2O")
          pI%mantle_w_H2O=val
          if (rank.eq.0) write(*,*) var,"=",pI%mantle_w_H2O
        case("mantle_w_r")
          pI%mantle_w_r=val
          if (rank.eq.0) write(*,*) var,"=",pI%mantle_w_r
        case("mantle_fr_angl")
          pI%mantle_fr_angl=val
          if (rank.eq.0) write(*,*) var,"=",pI%mantle_fr_angl
        case("mantle_fr_angl_m")
          pI%mantle_fr_angl_m=val
          if (rank.eq.0) write(*,*) var,"=",pI%mantle_fr_angl_m
        case("mantle_fr_coh")
          pI%mantle_fr_coh=val * pF%D**2 / (pF%kappa * pF%eta_ref)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%mantle_fr_coh
        case("Tm_ref")
          pI%Tm_ref=(val-pF%Ts)/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Tm_ref
        case("rho_ref") ! TODO: Delete? "rho" is already reference density...
          pI%rho_ref=val/pF%rho
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%rho_ref
        case("rho_cr")
          pI%rho_cr=val/pF%rho
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%rho_cr
        case("rho_r")
          pI%rho_r=val/pF%rho
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%rho_r
        case("rho_c")       
          pI%rho_c=val/pF%rho
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%rho_c
        case("Cp_cr")       
          pI%Cp_cr=val/pF%Cp
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Cp_cr
        case("Cp_r")
          pI%Cp_r=val/pF%Cp
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Cp_r
        case("Cp_c") 
          pI%Cp_c=val/pF%Cp
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Cp_c
!        case("H0U238")
!          pI%H0U238=val * pF%D**2/(pF%DeltaT * pF%k)
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%H0U238
!        case("t12U238")
!          pI%t12U238=val * pF%time_yr
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%t12U238
!        case("X0U238")
!          pI%X0U238=val * pF%rho
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%X0U238
!        case("H0U235")
!          pI%H0U235=val * pF%D**2/(pF%DeltaT * pF%k)
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%H0U235
!        case("t12U235")
!          pI%t12U235=val * pF%time_yr
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%t12U235
!        case("X0U235")
!          pI%X0U235=val * pF%rho
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%X0U235
!        case("H0Th232")
!          pI%H0Th232=val * pF%D**2/(pF%DeltaT * pF%k)
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%H0Th232
!        case("t12Th232")
!          pI%t12Th232=val * pF%time_yr
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%t12Th232
!        case("X0Th232")
!          pI%X0Th232=val * pF%rho
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%X0Th232
!        case("H0K40")
!          pI%H0K40=val * pF%D**2/(pF%DeltaT * pF%k)
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%H0K40
!        case("t12K40")
!          pI%t12K40=val * pF%time_yr
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%t12K40
!        case("X0K40")
!          pI%X0K40=val * pF%rho
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%X0K40
!        case("C_U")
!          pI%C_U=val ! in ppb
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%C_U
!        case("C_Th")
!          pI%C_Th=val ! in ppb
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%C_Th
!        case("C_K")
!          pI%C_K=val ! in ppm
!          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%C_K
        case("CoreCooling")
          pI%CCool = int(val)
          if (rank.eq.0) write(*,*) var,"=",pI%CCool
        case("alpha_c")
          pI%alpha_c = val/pF%alpha
          if (rank.eq.0) write(*,*) var,"=",pI%alpha_c
        case("Compressible")
          pI%compress = val
          if (rank.eq.0) write(*,*) var,"=",pI%compress
        case("Compr_a1")
          pI%a1 = val/pF%alpha
          if (rank.eq.0) write(*,*) var,"=",pI%a1
        case("Compr_a2")
          pI%a2 = val/pF%alpha
          if (rank.eq.0) write(*,*) var,"=",pI%a2
        case("Compr_a3")
          pI%a3 = val/pF%alpha
          if (rank.eq.0) write(*,*) var,"=",pI%a3
        case("Compr_a4")
          pI%a4 = val*pF%rho*pF%g*pF%D*1.0e-9
          if (rank.eq.0) write(*,*) var,"=",pI%a4
        case("Compr_Gr")
          pI%Gr = val
          if (rank.eq.0) write(*,*) var,"=",pI%Gr
        case("TinclTref")
          pI%TinclTref = int(val)
          if (rank.eq.0) write(*,*) var,"=",pI%TinclTref
        case("Psurf")
Lena Noack's avatar
Lena Noack committed
832
          pI%Psurf = val*1.0e+9_dp*pF%D**2/(pF%kappa*pF%eta_ref) 
Lena Noack's avatar
Lena Noack committed
833
834
835
836
837
838
839
840
841
842
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pI%Psurf," (pI)"
          pE%Psurf = val*1.0e+9_dp/(pF%D*pF%rho*pF%g)
          pM%Psurf = pE%Psurf
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pE%Psurf," (pE)"
        case("mu")
          pI%mu = val
          if (rank.eq.0) write(*,*) var,"=",pI%mu
        case("read_profs")
          pI%read_profs = int(val)
          if (rank.eq.0) write(*,*) var,"=",pI%read_profs
Lena Noack's avatar
Lena Noack committed
843
844
845
        case("ec_model")
          pI%ec_model = int(val)
          if (rank.eq.0) write(*,*) var,"=",pI%ec_model
846
847
848
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! H: Heating parameters    !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lena Noack's avatar
Lena Noack committed
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
        case("eccentricity")
          pH%eccentricity = val
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%eccentricity
        case("shear_modulus")
          pH%shear_modulus = val * pF%D**2 / (pF%kappa * pF%eta_ref)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%shear_modulus
        case("shear_modulus_c")
          pH%shear_modulus_c = val * pF%D**2 / (pF%kappa * pF%eta_ref)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%shear_modulus_c
        case("rho_av")
          pH%rho_av = val / pF%rho
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%rho_av
        case("diss_fact")
          pH%diss_fact = val
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%diss_fact
        case("orb_period")
          pH%orb_period = val/ (pF%D**2 / pF%kappa) * 3600.0_dp * 24.0_dp
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%orb_period
        case("TidHeat") 
          pH%TidHeat = int(val)
          pH%G_fac = pF%k * pF%DeltaT * pF%D**6 / pF%kappa**5
          pH%mu_fac = pF%kappa * pF%eta_ref / (pF%rho * pF%g * pF%D**3)
          pH%TidH_fac = pF%kappa**5 * pF%rho / (pF%D**5 * pF%k * pF%DeltaT * pF%g)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%TidHeat
        case("TidHeatAdapt") 
874
          pH%TidHeatAdapt = int(val)
Lena Noack's avatar
Lena Noack committed
875
876
877
878
879
880
881
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%TidHeatAdapt
        case("k2") 
          pH%k2 = val
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%k2
        case("eta_ref_c") 
          pH%eta_ref_c = val
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pH%eta_ref_c
882
883
884
885
886
887
888
        case("use_magn_H") 
          pH%use_magn_H = val
          if (pH%use_magn_H.lt.0.0_dp) pH%use_magn_H = pH%use_magn_H*0.0001_dp*pF%D**2*pF%rho/(pF%k*pF%DeltaT) ! fix value given in erg/(sg) = 1e-4 W/kg
          if (rank.eq.0) write(*,*) var,"=",pH%use_magn_H
        case("stop_magm_oc")
          pH%stop_magm_oc = int(val)
          if (rank.eq.0) write(*,*) var,"=",pH%stop_magm_oc
Lena Noack's avatar
Lena Noack committed
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! P: Particle-related parameters !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        case("use_part")
          pP%use_part=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%use_part
        case("part_depth")
          pP%part_depth=val
          if (pP%part_depth.ne.1.0_dp) then
            pP%part_depth=pP%part_depth/pF%D
          endif
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pP%part_depth
        case("part_pref")
          pP%part_pref=val
          if (rank.eq.0) write(*,*) var,"=",pP%part_pref
        case("part_n")
          pP%part_n=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%part_n
        case("part_n_cell")
          pP%part_n_cell=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%part_n_cell
        case("max_part")
          pP%max_part=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%max_part
        case("min_part")
          pP%min_part=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%min_part
        case("restart_p")
          pP%restart_p=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%restart_p
        case("part_rk")
          pP%rk=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%rk
        case("bnd_l")
          pP%bnd_l=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%bnd_l
        case("bnd_y")
          pP%bnd_y=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%bnd_y
        case("bnd_r")
          pP%bnd_r=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%bnd_r
        case("moveRef")
          pP%moveRef=int(val)
          if (rank.eq.0) write(*,*) var,"=",pP%moveRef
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !! M: Melt-related parameters !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        case("use_melt")
          pM%use_melt=int(val)
          if (rank.eq.0) write(*,*) var,"=",pM%use_melt
        case("use_lat_heat")
          pM%use_lat_heat=int(val)
          if (rank.eq.0) write(*,*) var,"=",pM%use_lat_heat
        case("add_crust")
          pM%add_crust=int(val)
          if (rank.eq.0) write(*,*) var,"=",pM%add_crust
        case("melt_extract")
          pM%melt_extract=int(val)
          if (rank.eq.0) write(*,*) var,"=",pM%melt_extract
        case("add_crust_depth")
          pM%add_crust_depth=val/pF%D
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%add_crust_depth
        case("add_crust_incr")
          pM%add_crust_incr=int(val)
          if (rank.eq.0) write(*,*) var,"=",pM%add_crust_incr
        case("No_del")
          pM%No_del=int(val)
          if (rank.eq.0) write(*,*) var,"=",pM%No_del
        case("max_depl") ! always between 0 and 1 
          pM%max_depl=val
          if (rank.eq.0) write(*,*) var,"=",pM%max_depl
        case("dehydr_melt") ! always between 0 and max_depl
          pM%dehydr_melt=val
          if (rank.eq.0) write(*,*) var,"=",pM%dehydr_melt
        case("serp_instable_m") ! in m  ! depth = 100km (Liu et al. 1996) [s_i_T / s_i_P1 / s_i_P2 are ignored]
          pM%serp_instable_m=val/pF%D
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%serp_instable_m
        case("serp_instable_T") ! in C or K, similar the other temperatures! if serp_instable_m=0 then 600 C (Ruepke et al., 2004, EPSL) [s_i_P1 / s_i_P2 are ignored] 
          pM%serp_instable_T=(val-pF%Ts)/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%serp_instable_T
        case("serp_instable_P1") ! in GPa ! if s_i_m = s_i_T=0 then: instability-depth = serp_instable_P1 - serp_instable_P2 * T'
          pM%serp_instable_P1=val * 1.0e+9 / (pF%rho * pF%g * pF%D)
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%serp_instable_P1
        case("serp_instable_P2") ! in GPa/C or GPa/K ! Irifune et al., 1998: 13.94 GPa - 0.0136*T GPa/C !TODO: OK if Ts=0, otherwise this needs to be changed, maybe add a Ts_C value?
          pM%serp_instable_P2=(val * 1.0e+9 / (pF%rho * pF%g * pF%D)) / pF%DeltaT !(val * 1.0e+9 / (pF%rho * pf%g * pF%D) - pF%Ts) / pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%serp_instable_P2
        case("serp_instable_w") ! in %
          pM%serp_instable_w=val
          if (rank.eq.0) write(*,*) var,"=",pM%serp_instable_w
        case("serp_instable_w_T") ! in %/C
          pM%serp_instable_w_T=val * pF%DeltaT ! change this if not Celcius but Kelvin is used and Ts!=0
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%serp_instable_w_T
        case("serp_instable_w_max") ! in %
          pM%serp_instable_w_max=val
          if (rank.eq.0) write(*,*) var,"=",pM%serp_instable_w_max
        case("satur_w1") ! in ppm: satur_w1[ppm] * (p/GPa)^0.6 + satur_w2[ppm] * (p/GPa)
          pM%satur_w1=val
          if (rank.eq.0) write(*,*) var,"=",pM%satur_w1
        case("satur_w2") ! in ppm
          pM%satur_w2=val
          if (rank.eq.0) write(*,*) var,"=",pM%satur_w2
        case("satur_exp") 
          pM%satur_exp=val
          if (rank.eq.0) write(*,*) var,"=",pM%satur_exp
        case("sol_hyd")
          pM%sol_hyd=val/pF%DeltaT
          if (rank.eq.0) write(*,*) var,"=",val," -> ",pM%sol_hyd
        case("sol_hyd_exp")
          pM%sol_hyd_exp=val
          if (rank.eq.0) write(*,*) var,"=",pM%sol_hyd_exp
        case("entropy") ! in J/(kgK), standard value would be 300 J/kg K
For faster browsing, not all history is shown. View entire blame