-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathglide_setup.F90
More file actions
3450 lines (2870 loc) · 163 KB
/
Copy pathglide_setup.F90
File metadata and controls
3450 lines (2870 loc) · 163 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
347
348
349
350
351
352
353
354
355
356
357
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
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
438
439
440
441
442
443
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
583
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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
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
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
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
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
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
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!
! glide_setup.F90 - part of the Community Ice Sheet Model (CISM)
!
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!
! Copyright (C) 2005-2018
! CISM contributors - see AUTHORS file for list of contributors
!
! This file is part of CISM.
!
! CISM is free software: you can redistribute it and/or modify it
! under the terms of the Lesser GNU General Public License as published
! by the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! CISM is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! Lesser GNU General Public License for more details.
!
! You should have received a copy of the Lesser GNU General Public License
! along with CISM. If not, see <http://www.gnu.org/licenses/>.
!
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#ifdef HAVE_CONFIG_H
#include "config.inc"
#endif
#include "glide_mask.inc"
module glide_setup
! general routines for initialisation, etc, called from top-level glimmer subroutines
use glimmer_global, only: dp
implicit none
private
public :: glide_readconfig, glide_printconfig, glide_scale_params, &
glide_load_sigma, glide_read_sigma, glide_calc_sigma, glide_get_zocn
!-------------------------------------------------------------------------
contains
!-------------------------------------------------------------------------
subroutine glide_readconfig(model,config)
! read Glide configuration file
! Note: sigma coordinates are handled by a subsequent call to glide_read_sigma
use glide_types
use glimmer_config
implicit none
type(glide_global_type) :: model !> model instance
type(ConfigSection), pointer :: config !> structure holding sections of configuration file
! local variables
type(ConfigSection), pointer :: section
! read grid size parameters
call GetSection(config,section,'grid')
if (associated(section)) then
call handle_grid(section, model)
end if
! read time parameters
call GetSection(config,section,'time')
if (associated(section)) then
call handle_time(section, model)
end if
! read options parameters
call GetSection(config,section,'options')
if (associated(section)) then
call handle_options(section, model)
end if
!read options for higher-order computation
call GetSection(config,section,'ho_options')
if (associated(section)) then
call handle_ho_options(section, model)
end if
!read options for computation using an external dycore -- Doug Ranken 04/20/12
call GetSection(config,section,'external_dycore_options')
if (associated(section)) then
call handle_dycore_options(section, model)
end if
! read parameters
!TODO - Put some sets of related parameters in their own section
call GetSection(config,section,'parameters')
if (associated(section)) then
call handle_parameters(section, model)
end if
! read geothermal heat flux
! NOTE: The [GTHF] section is ignored unless model%options%gthf = GTHF_COMPUTE
if (model%options%gthf == GTHF_COMPUTE) then
call GetSection(config,section,'GTHF')
if (associated(section)) then
call handle_gthf(section, model)
end if
endif
! read isostasy
! NOTE: The [isostasy] section is ignored unless model%options%isostasy = ISOSTASY_COMPUTE
if (model%options%isostasy == ISOSTASY_COMPUTE) then
call GetSection(config,section,'isostasy')
if (associated(section)) then
call handle_isostasy(section, model)
end if
endif
! Till options are not currently supported
! read till parameters
!! call GetSection(config,section,'till_options')
!! if (associated(section)) then
!! call handle_till_options(section, model)
!! end if
! Construct the list of necessary restart variables based on the config options
! selected by the user in the config file.
! (Glint restart variables are handled separately by Glint setup routines.)
! This is done regardless of whether or not a restart ouput file is going
! to be created for this run, but this information is needed before setting up outputs. MJH 1/17/13
call define_glide_restart_variables(model%options)
end subroutine glide_readconfig
!-------------------------------------------------------------------------
subroutine glide_printconfig(model)
!> print model configuration to log
use glimmer_log
use glide_types
implicit none
type(glide_global_type) :: model !> model instance
call write_log_div
call print_grid(model)
call print_time(model)
call print_options(model)
call print_parameters(model)
call print_gthf(model)
call print_isostasy(model)
!! call print_till_options(model) ! disabled for now
end subroutine glide_printconfig
!-------------------------------------------------------------------------
subroutine glide_scale_params(model)
!> scale parameters
use glide_types
use glimmer_physcon, only: scyr
use glimmer_paramets, only: thk0, tim0, len0, vel0, vis0, acc0, tau0
implicit none
type(glide_global_type) :: model !> model instance
model%numerics%dttem = model%numerics%ntem * model%numerics%tinc
! convert dt and dttem from yr to scaled time units
model%numerics%dt = model%numerics%tinc * scyr / tim0
model%numerics%dttem = model%numerics%dttem * scyr / tim0
! allow for subcycling of ice transport
model%numerics%dt_transport = model%numerics%dt / real(model%numerics%subcyc, dp)
model%numerics%thklim = model%numerics%thklim / thk0
model%numerics%thklim_temp = model%numerics%thklim_temp / thk0
model%numerics%thck_gradient_ramp = model%numerics%thck_gradient_ramp / thk0
model%numerics%dew = model%numerics%dew / len0
model%numerics%dns = model%numerics%dns / len0
! scale calving parameters
model%calving%marine_limit = model%calving%marine_limit / thk0
model%calving%timescale = model%calving%timescale * scyr ! convert from yr to s
model%calving%cliff_timescale = model%calving%cliff_timescale * scyr ! convert from yr to s
model%calving%eigencalving_constant = model%calving%eigencalving_constant / scyr ! convert from m/yr/Pa to m/s/Pa
model%calving%damage_constant = model%calving%damage_constant / scyr ! convert from yr^{-1} to s^{-1}
model%calving%lateral_rate_max = model%calving%lateral_rate_max / scyr ! convert from m/yr to m/s
! scale periodic offsets for ISMIP-HOM
model%numerics%periodic_offset_ew = model%numerics%periodic_offset_ew / thk0
model%numerics%periodic_offset_ns = model%numerics%periodic_offset_ns / thk0
! scale glide basal traction parameters
model%velowk%trc0 = vel0 * len0 / (thk0**2)
model%velowk%btrac_const = model%paramets%btrac_const/model%velowk%trc0/scyr
model%velowk%btrac_max = model%paramets%btrac_max / model%velowk%trc0/scyr
model%velowk%btrac_slope = model%paramets%btrac_slope*acc0/model%velowk%trc0
! scale basal melting parameters (1/yr -> 1/s, or m/yr -> m/s)
model%basal_melt%bmlt_float_omega = model%basal_melt%bmlt_float_omega / scyr
model%basal_melt%bmlt_float_const = model%basal_melt%bmlt_float_const / scyr
model%basal_melt%bmlt_float_depth_meltmax = model%basal_melt%bmlt_float_depth_meltmax / scyr
model%basal_melt%bmlt_float_depth_frzmax = model%basal_melt%bmlt_float_depth_frzmax / scyr
model%basal_melt%bmlt_float_depth_meltmin = model%basal_melt%bmlt_float_depth_meltmin / scyr
! scale basal inversion parameters
!TODO - Leave buffer units as meters?
model%inversion%babc_timescale = model%inversion%babc_timescale * scyr ! convert yr to s
model%inversion%bmlt_timescale = model%inversion%bmlt_timescale * scyr ! convert yr to s
model%inversion%bmlt_max_melt = model%inversion%bmlt_max_melt / scyr ! convert m/yr to m/s
model%inversion%bmlt_max_freeze = model%inversion%bmlt_max_freeze / scyr ! convert m/yr to m/s
model%inversion%thck_threshold = model%inversion%thck_threshold / thk0
model%inversion%thck_flotation_buffer = model%inversion%thck_flotation_buffer / thk0
model%inversion%dbmlt_dtemp_scale = model%inversion%dbmlt_dtemp_scale / scyr ! m/yr/degC to m/s/degC
model%inversion%bmlt_basin_timescale = model%inversion%bmlt_basin_timescale * scyr ! yr to s
! scale SMB/acab parameters
model%climate%overwrite_acab_value = model%climate%overwrite_acab_value*tim0/(scyr*thk0)
model%climate%overwrite_acab_minthck = model%climate%overwrite_acab_minthck / thk0
end subroutine glide_scale_params
!-------------------------------------------------------------------------
subroutine glide_read_sigma(model,config)
! read sigma levels from configuration file, if present
! called immediately after glide_readconfig
use glide_types
use glimmer_config
use glimmer_log
implicit none
type(glide_global_type) :: model !> model instance
type(ConfigSection), pointer :: config !> structure holding sections of configuration file
! local variables
type(ConfigSection), pointer :: section
! read sigma levels
! NOTE: The [sigma] section is ignored unless model%options%which_sigma = SIGMA_CONFIG
if (model%options%which_sigma == SIGMA_CONFIG) then
call GetSection(config,section,'sigma')
if (associated(section)) then
call handle_sigma(section, model)
else
model%options%which_sigma = SIGMA_COMPUTE_GLIDE ! default to standard sigma levels
call write_log('No [sigma] section present; will compute standard Glide sigma levels')
end if
endif
end subroutine glide_read_sigma
!-------------------------------------------------------------------------
subroutine glide_load_sigma(model,unit)
! Compute sigma coordinates or read them from a file
! Note: This subroutine is called from glide_initialise or glissade_initialise.
! If sigma levels are provided in the config file, then they are read
! in by glide_read_sigma, and model%options%which_sigma is set to
! SIGMA_CONFIG, in which case this subroutine does nothing.
use glide_types
use glimmer_log
use glimmer_filenames
use cism_parallel, only: main_task, broadcast
implicit none
! Arguments
type(glide_global_type),intent(inout) :: model !> Ice model to use
integer, intent(in) :: unit !> Logical file unit to use.
!> (Must not already be in use)
! Internal variables
integer :: up,upn
logical :: there
real(dp) :: level
! Beginning of code
upn=model%general%upn
select case(model%options%which_sigma)
case(SIGMA_COMPUTE_GLIDE) ! compute standard Glide sigma levels
do up = 1,upn
level = real(up-1,kind=dp) / real(upn-1,kind=dp)
model%numerics%sigma(up) = glide_calc_sigma(level, 2.d0)
end do
call write_log('Computing Glide sigma levels')
case(SIGMA_EXTERNAL) ! read from external file
if (main_task) inquire (exist=there, file=process_path(model%funits%sigfile))
call broadcast(there)
if (.not.there) then
call write_log('Sigma levels file: '//trim(process_path(model%funits%sigfile))// &
' does not exist',GM_FATAL)
end if
call write_log('Reading sigma file: '//process_path(model%funits%sigfile))
if (main_task) then
open(unit,file=process_path(model%funits%sigfile))
read(unit,'(f9.7)',err=10,end=10) (model%numerics%sigma(up), up=1,upn)
close(unit)
end if
call broadcast(model%numerics%sigma)
case(SIGMA_CONFIG) ! read from config file
! sigma levels have already been read from glide_read_sigma
call write_log('Getting sigma levels from configuration file')
case(SIGMA_COMPUTE_EVEN)
do up = 1,upn
model%numerics%sigma(up) = real(up-1,kind=dp) / real(upn-1,kind=dp)
enddo
call write_log('Computing evenly spaced sigma levels')
case(SIGMA_COMPUTE_PATTYN)
do up = 1,upn
if (up == 1) then
model%numerics%sigma(up) = 0.d0
else if (up == upn) then
model%numerics%sigma(up) = 1.d0
else
level = real(up-1,kind=dp) / real(upn-1,kind=dp)
model%numerics%sigma(up) = glide_calc_sigma_pattyn(level)
end if
enddo
call write_log('Computing Pattyn sigma levels')
end select
! Compute stagsigma (= sigma values at layers midpoints)
model%numerics%stagsigma(1:upn-1) = &
(model%numerics%sigma(1:upn-1) + model%numerics%sigma(2:upn)) / 2.0_dp
! Compute stagwbndsigma, adding the boundaries to stagsigma
model%numerics%stagwbndsigma(1:upn-1) = model%numerics%stagsigma(1:upn-1)
model%numerics%stagwbndsigma(0) = 0.d0
model%numerics%stagwbndsigma(upn) = 1.d0
call print_sigma(model)
return
10 call write_log('something wrong with sigma coord file',GM_FATAL)
end subroutine glide_load_sigma
!--------------------------------------------------------------------------------
function glide_calc_sigma(x,n)
implicit none
real(dp) :: glide_calc_sigma, x, n
glide_calc_sigma = (1-(x+1)**(-n)) / (1-2**(-n))
end function glide_calc_sigma
!--------------------------------------------------------------------------------
function glide_calc_sigma_pattyn(x)
! Implements an alternate set of sigma levels that encourages better
! convergence for higher-order velocities
implicit none
real(dp) :: glide_calc_sigma_pattyn, x
glide_calc_sigma_pattyn = &
(-2.5641025641d-4)*(41d0*x)**2+3.5256410256d-2*(41d0*x)-8.0047080075d-13
end function glide_calc_sigma_pattyn
!-------------------------------------------------------------------------
subroutine glide_get_zocn(model,config)
! Read ocean grid information, if present, from the config file.
! Called after glide_readconfig
use glide_types
use glimmer_config
use glimmer_log
use cism_parallel, only: main_task
implicit none
type(glide_global_type) :: model !> model instance
type(ConfigSection), pointer :: config !> structure holding sections of configuration file
! local variables
type(ConfigSection), pointer :: section
character(len=512) :: message
character(len=16) :: message_tmp
integer :: k
! Check for section [grid_ocn]
call GetSection(config,section,'grid_ocn')
if (associated(section)) then
call GetValue(section,'nzocn',model%ocean_data%nzocn)
call GetValue(section,'dzocn',model%ocean_data%dzocn) ! m
call GetValue(section,'nbasin',model%ocean_data%nbasin)
call write_log(' ')
write(message,*) 'number of ocean levels : ',model%ocean_data%nzocn
call write_log(trim(message))
if (.not.associated(model%ocean_data%zocn)) &
allocate(model%ocean_data%zocn(model%ocean_data%nzocn))
if ( size(model%ocean_data%zocn) /= model%ocean_data%nzocn )then
write(message,*) 'size of zocn : ',size(model%ocean_data%zocn)
call write_log(trim(message))
call write_log (' zocn is allocated to be too small', GM_FATAL)
end if
! There are two ways to get zocn levels:
! (1) Compute uniform levels based on dzocn. This is done if dzocn is set to a nonzero value in the config file.
! (2) Load zocn levels from the config file. This is done if dzocn = 0 (the default value).
! Note: By convention, k = 1 is the top level, and z becomes more negative with increasing k.
! If the input zocn levels do not satisfy this criterion (or if dzocn and zocn are not in the config file),
! The code aborts with an error message.
if (model%ocean_data%dzocn > 0.0d0) then
call write_log (' Computing zocn levels based on dzocn')
write(message,*) 'dz (m) for ocean levels : ',model%ocean_data%dzocn
call write_log(trim(message))
do k = 1, model%ocean_data%nzocn
model%ocean_data%zocn(k) = -model%ocean_data%dzocn * (real(k,dp) - 0.5d0)
enddo
else
call write_log (' Reading zocn levels from config file')
call GetValue(section,'zocn',model%ocean_data%zocn, model%ocean_data%nzocn)
do k = 2, model%ocean_data%nzocn
if (model%ocean_data%zocn(k-1) - model%ocean_data%zocn(k) < 1.0d0) then
write(message,*) 'nzocn, zocn =', model%ocean_data%nzocn, model%ocean_data%zocn(:)
call write_log(trim(message))
write(message,*) 'Must have zocn decreasing with increasing k in the [grid_ocn] section'
call write_log(message, GM_FATAL)
endif
enddo
endif
if (model%ocean_data%nzocn > 1) then
call write_log('')
call write_log('zocn levels (m):')
call write_log('------------------')
message = ''
do k = 1, model%ocean_data%nzocn
write(message_tmp,'(f8.1)') model%ocean_data%zocn(k)
message = trim(message)//trim(message_tmp)
enddo
call write_log(trim(message))
call write_log('')
endif
if (model%ocean_data%nbasin >= 1) then
call write_log('')
write(message,*) 'number of ocean basins: ', model%ocean_data%nbasin
call write_log(trim(message))
else
call write_log('No ocean basins')
endif
else ! no 'grid_ocn' section
! Allocate and initialize model%ocean_data%zocn.
! Note: Coupled CESM runs require this array to be allocated, even if CISM
! is not receiving realistic ocean forcing fields (as of Jan. 2021).
model%ocean_data%nzocn = get_nzocn(model)
if (.not.associated(model%ocean_data%zocn)) &
allocate(model%ocean_data%zocn(model%ocean_data%nzocn))
model%ocean_data%zocn(:) = 0.0d0
if (model%options%whichbmlt_float == BMLT_FLOAT_THERMAL_FORCING) then
write(message,*) 'Must have a [grid_ocn] section to use the thermal forcing option'
call write_log(message, GM_FATAL)
endif
endif ! associated(section)
end subroutine glide_get_zocn
!--------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! private procedures
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! grid sizes
subroutine handle_grid(section, model)
use glimmer_config
use glide_types
use glimmer_filenames
implicit none
type(ConfigSection), pointer :: section
type(glide_global_type) :: model
call GetValue(section,'ewn',model%general%ewn)
call GetValue(section,'nsn',model%general%nsn)
call GetValue(section,'upn',model%general%upn)
call GetValue(section,'dew',model%numerics%dew)
call GetValue(section,'dns',model%numerics%dns)
call GetValue(section,'sigma_file',model%funits%sigfile)
call GetValue(section,'nx_block', model%general%nx_block)
call GetValue(section,'ny_block', model%general%ny_block)
call GetValue(section,'global_bc',model%general%global_bc)
! We set this flag to one to indicate we've got a sigfile name.
! A warning/error is generated if sigma levels are specified in some other way
! and mangle the name
if (trim(model%funits%sigfile) /= '') then
model%funits%sigfile = filenames_inputname(model%funits%sigfile)
model%options%which_sigma = SIGMA_EXTERNAL
end if
end subroutine handle_grid
!--------------------------------------------------------------------------------
subroutine print_grid(model)
use glide_types
use glimmer_log
implicit none
type(glide_global_type) :: model
character(len=512) :: message
call write_log('Grid specification')
call write_log('------------------')
write(message,*) 'ewn : ',model%general%ewn
call write_log(trim(message))
write(message,*) 'nsn : ',model%general%nsn
call write_log(trim(message))
write(message,*) 'upn : ',model%general%upn
call write_log(trim(message))
write(message,*) 'EW grid spacing : ',model%numerics%dew
call write_log(trim(message))
write(message,*) 'NS grid spacing : ',model%numerics%dns
call write_log(trim(message))
if (model%general%nx_block > 0 .and. model%general%ny_block> 0) then
write(message,*) 'nx_block :', model%general%nx_block
call write_log(trim(message))
write(message,*) 'ny_block :', model%general%ny_block
call write_log(trim(message))
endif
if (model%general%global_bc==GLOBAL_BC_PERIODIC) then
write(message,*) 'Periodic global boundary conditions'
call write_log(trim(message))
elseif (model%general%global_bc==GLOBAL_BC_OUTFLOW) then
write(message,*) 'Outflow global boundary conditions; scalars in global halo will be set to zero'
call write_log(trim(message))
elseif (model%general%global_bc==GLOBAL_BC_NO_PENETRATION) then
write(message,*) 'No-penetration global boundary conditions; outflow set to zero at global boundaries'
call write_log(trim(message))
elseif (model%general%global_bc==GLOBAL_BC_NO_ICE) then
write(message,*) 'No-ice global boundary conditions; scalars set to zero adjacent to global boundaries'
call write_log(trim(message))
else
write(message,*) ('Error: Invalid option for global_bc')
call write_log(trim(message), GM_FATAL)
endif
write(message,*) 'sigma file : ',trim(model%funits%sigfile)
call write_log(trim(message))
call write_log('')
end subroutine print_grid
!--------------------------------------------------------------------------------
! time
subroutine handle_time(section, model)
use glimmer_config
use glide_types
implicit none
type(ConfigSection), pointer :: section
type(glide_global_type) :: model
! Set dt_input_option to specify whether the dynamic timestep (model%numerics%tinc)
! is based on dt (the timestep in years) or nsteps_per_year in the config file.
! The default (dt_input_option = DT_IN_YEARS) is to read dt directly,
! but the nsteps_per_year option allows more flexibility.
! Typically, we want an integral number of timesteps per year,
! e.g., if running coupled with the mass balance timestep of 1 year,
! or if writing output at annual intervals.
! Note: This used to be called dt_option; renamed to avoid a naming conflict with CESM.
call GetValue(section,'tstart',model%numerics%tstart)
call GetValue(section,'tend',model%numerics%tend)
call GetValue(section,'dt_input_option',model%options%dt_input_option)
call GetValue(section,'dt',model%numerics%tinc)
call GetValue(section,'nsteps_per_year',model%numerics%nsteps_per_year)
call GetValue(section,'subcyc',model%numerics%subcyc)
call GetValue(section,'adaptive_cfl_threshold', model%numerics%adaptive_cfl_threshold)
call GetValue(section,'ntem',model%numerics%ntem)
call GetValue(section,'profile',model%numerics%profile_period)
call GetValue(section,'idiag',model%numerics%idiag)
call GetValue(section,'jdiag',model%numerics%jdiag)
!Note: Either dt_diag or ndiag can be specified in the config file.
! If dt_diag is specified, it is used to compute ndiag. (Output is written every ndiag timesteps.)
call GetValue(section,'dt_diag',model%numerics%dt_diag)
call GetValue(section,'ndiag',model%numerics%ndiag)
! If the time step was entered in number of steps per year, then set the timestep in years.
! If the time step was entered in years, then set nsteps_per_year.
if (model%options%dt_input_option == DT_STEPS_PER_YEAR) then
if (model%numerics%nsteps_per_year > 0) then
model%numerics%tinc = 1.d0 / real(model%numerics%nsteps_per_year, dp)
else
call write_log('Must set nsteps_per_year > 0 with this dt option', GM_FATAL)
endif
else ! input dt (in years) directly
if (model%numerics%tinc > 0.0d0) then
model%numerics%nsteps_per_year = nint(1.d0/model%numerics%tinc)
else
call write_log('Must set dt > 0.0 with this dt option', GM_FATAL)
endif
endif ! dt_input_option
end subroutine handle_time
!--------------------------------------------------------------------------------
subroutine print_time(model)
use glide_types
use glimmer_log
implicit none
type(glide_global_type) :: model
character(len=100) :: message
call write_log('Time steps')
call write_log('----------')
write(message,*) 'start time (yr) : ',model%numerics%tstart
call write_log(message)
write(message,*) 'end time (yr) : ',model%numerics%tend
call write_log(message)
write(message,*) 'time step (yr) : ',model%numerics%tinc
call write_log(message)
if (model%numerics%nsteps_per_year > 0) then
write(message,*) 'nsteps per year : ',model%numerics%nsteps_per_year
call write_log(message)
endif
write(message,*) 'thermal dt factor : ',model%numerics%ntem
call write_log(message)
if ( (model%numerics%ntem < 1.0d0) .or. &
(floor(model%numerics%ntem) /= model%numerics%ntem) ) then
call write_log('ntem is a multiplier on the basic time step. It should be a positive integer. Aborting.',GM_FATAL)
endif
if (model%options%whichdycore == DYCORE_GLIDE) then ! Glide option only
write(message,*) 'profile frequency : ',model%numerics%profile_period
call write_log(message)
endif
if (model%numerics%dt_diag > 0.d0) then
write(message,*) 'diagnostic interval (years):',model%numerics%dt_diag
call write_log(message)
elseif (model%numerics%ndiag > 0) then
write(message,*) 'diagnostic interval (steps):',model%numerics%ndiag
call write_log(message)
endif
!WHL - Written to log in glide_init_diag
! write(message,*) 'idiag : ',model%numerics%idiag
! call write_log(message)
! write(message,*) 'jdiag : ',model%numerics%jdiag
! call write_log(message)
call write_log('')
end subroutine print_time
!--------------------------------------------------------------------------------
! options
subroutine handle_options(section, model)
use glimmer_config
use glide_types
implicit none
type(ConfigSection), pointer :: section
type(glide_global_type) :: model
call GetValue(section,'dycore',model%options%whichdycore)
call GetValue(section,'evolution',model%options%whichevol)
call GetValue(section,'temperature',model%options%whichtemp)
call GetValue(section,'temp_init',model%options%temp_init)
call GetValue(section,'flow_law',model%options%whichflwa)
call GetValue(section,'slip_coeff',model%options%whichbtrc)
call GetValue(section,'basal_water',model%options%whichbwat)
call GetValue(section,'bmlt_float',model%options%whichbmlt_float)
call GetValue(section,'bmlt_float_thermal_forcing_param',model%options%bmlt_float_thermal_forcing_param)
call GetValue(section,'bmlt_float_ismip6_magnitude',model%options%bmlt_float_ismip6_magnitude)
call GetValue(section,'ocean_data_domain',model%options%ocean_data_domain)
call GetValue(section,'ocean_data_extrapolate',model%options%ocean_data_extrapolate)
call GetValue(section,'enable_bmlt_anomaly',model%options%enable_bmlt_anomaly)
call GetValue(section,'basal_mass_balance',model%options%basal_mbal)
call GetValue(section,'smb_input',model%options%smb_input)
call GetValue(section,'smb_input_function',model%options%smb_input_function)
call GetValue(section,'artm_input_function',model%options%artm_input_function)
call GetValue(section,'nlev_smb',model%climate%nlev_smb)
call GetValue(section,'enable_acab_anomaly',model%options%enable_acab_anomaly)
call GetValue(section,'enable_artm_anomaly',model%options%enable_artm_anomaly)
call GetValue(section,'overwrite_acab',model%options%overwrite_acab)
call GetValue(section,'gthf',model%options%gthf)
call GetValue(section,'isostasy',model%options%isostasy)
call GetValue(section,'marine_margin',model%options%whichcalving)
call GetValue(section,'calving_init',model%options%calving_init)
call GetValue(section,'calving_domain',model%options%calving_domain)
call GetValue(section,'apply_calving_mask', model%options%apply_calving_mask)
call GetValue(section,'remove_icebergs', model%options%remove_icebergs)
call GetValue(section,'remove_isthmuses', model%options%remove_isthmuses)
call GetValue(section,'expand_calving_mask', model%options%expand_calving_mask)
call GetValue(section,'limit_marine_cliffs', model%options%limit_marine_cliffs)
call GetValue(section,'cull_calving_front', model%options%cull_calving_front)
call GetValue(section,'adjust_input_thickness', model%options%adjust_input_thickness)
call GetValue(section,'smooth_input_topography', model%options%smooth_input_topography)
call GetValue(section,'adjust_input_topography', model%options%adjust_input_topography)
call GetValue(section,'read_lat_lon',model%options%read_lat_lon)
call GetValue(section,'dm_dt_diag',model%options%dm_dt_diag)
call GetValue(section,'diag_minthck',model%options%diag_minthck)
call GetValue(section,'vertical_integration',model%options%whichwvel)
call GetValue(section,'periodic_ew',model%options%periodic_ew)
call GetValue(section,'sigma',model%options%which_sigma)
call GetValue(section,'ioparams',model%funits%ncfile)
!Note: Previously, the terms 'hotstart' and 'restart' were both supported in the config file.
! Going forward, only 'restart' is supported.
call GetValue(section,'restart',model%options%is_restart)
call GetValue(section,'restart_extend_velo',model%options%restart_extend_velo)
! These are not currently supported
!call GetValue(section,'basal_proc',model%options%which_bproc)
end subroutine handle_options
!--------------------------------------------------------------------------------
!Higher order options
subroutine handle_ho_options(section, model)
use glimmer_config
use glide_types
implicit none
type(ConfigSection), pointer :: section
type(glide_global_type) :: model
call GetValue(section, 'compute_blocks', model%options%compute_blocks)
call GetValue(section, 'which_ho_efvs', model%options%which_ho_efvs)
call GetValue(section, 'which_ho_disp', model%options%which_ho_disp)
call GetValue(section, 'which_ho_thermal_timestep', model%options%which_ho_thermal_timestep)
call GetValue(section, 'which_ho_babc', model%options%which_ho_babc)
call GetValue(section, 'use_c_space_factor', model%options%use_c_space_factor)
call GetValue(section, 'which_ho_beta_limit', model%options%which_ho_beta_limit)
call GetValue(section, 'which_ho_cp_inversion', model%options%which_ho_cp_inversion)
call GetValue(section, 'which_ho_bmlt_inversion', model%options%which_ho_bmlt_inversion)
call GetValue(section, 'which_ho_bmlt_basin_inversion', model%options%which_ho_bmlt_basin_inversion)
call GetValue(section, 'which_ho_bwat', model%options%which_ho_bwat)
call GetValue(section, 'which_ho_effecpress', model%options%which_ho_effecpress)
call GetValue(section, 'which_ho_resid', model%options%which_ho_resid)
call GetValue(section, 'which_ho_nonlinear', model%options%which_ho_nonlinear)
call GetValue(section, 'which_ho_sparse', model%options%which_ho_sparse)
call GetValue(section, 'which_ho_approx', model%options%which_ho_approx)
call GetValue(section, 'which_ho_precond', model%options%which_ho_precond)
call GetValue(section, 'which_ho_gradient', model%options%which_ho_gradient)
call GetValue(section, 'which_ho_gradient_margin', model%options%which_ho_gradient_margin)
call GetValue(section, 'which_ho_vertical_remap', model%options%which_ho_vertical_remap)
call GetValue(section, 'which_ho_assemble_beta', model%options%which_ho_assemble_beta)
call GetValue(section, 'which_ho_assemble_taud', model%options%which_ho_assemble_taud)
call GetValue(section, 'which_ho_assemble_bfric', model%options%which_ho_assemble_bfric)
call GetValue(section, 'which_ho_assemble_lateral', model%options%which_ho_assemble_lateral)
call GetValue(section, 'which_ho_calving_front', model%options%which_ho_calving_front)
call GetValue(section, 'which_ho_ground', model%options%which_ho_ground)
call GetValue(section, 'which_ho_fground_no_glp', model%options%which_ho_fground_no_glp)
call GetValue(section, 'which_ho_ground_bmlt', model%options%which_ho_ground_bmlt)
call GetValue(section, 'which_ho_flotation_function', model%options%which_ho_flotation_function)
call GetValue(section, 'block_inception', model%options%block_inception)
call GetValue(section, 'remove_ice_caps', model%options%remove_ice_caps)
call GetValue(section, 'force_retreat', model%options%force_retreat)
call GetValue(section, 'which_ho_ice_age', model%options%which_ho_ice_age)
call GetValue(section, 'glissade_maxiter', model%options%glissade_maxiter)
call GetValue(section, 'linear_solve_ncheck', model%options%linear_solve_ncheck)
call GetValue(section, 'linear_maxiters', model%options%linear_maxiters)
call GetValue(section, 'linear_tolerance', model%options%linear_tolerance)
end subroutine handle_ho_options
!--------------------------------------------------------------------------------
! Handles external dycore options -- Doug Ranken 03/26/12
subroutine handle_dycore_options(section, model)
use glimmer_config
use glide_types
implicit none
type(ConfigSection), pointer :: section
type(glide_global_type) :: model
call GetValue(section, 'external_dycore_type', model%options%external_dycore_type)
call GetValue(section, 'dycore_input_file', model%options%dycore_input_file)
if (model%options%external_dycore_type .eq. 1) model%options%whichdycore = 4 ! DYCORE_BISICLES
if (model%options%external_dycore_type .eq. 2) model%options%whichdycore = 3 ! DYCORE_ALBANYFELIX
print *,"In handle_dycore_options, external dycore type, input file = ", &
model%options%external_dycore_type,model%options%dycore_input_file
! print *,"In handle_dycore_options, whichdycore = ",model%options%whichdycore
end subroutine handle_dycore_options
!--------------------------------------------------------------------------------
subroutine print_options(model)
use glide_types
use glimmer_log
use cism_parallel, only: tasks
implicit none
type(glide_global_type) :: model
character(len=500) :: message
! basic Glide/Glimmer options
character(len=*), dimension(0:4), parameter :: dycore = (/ &
'glide ', & ! Glimmer SIA
'glam ', & ! Payne-Price finite difference; no longer supported
'glissade ', & ! prototype finite element
'albany-felix ', & ! External Albany-FELIX finite element
'bisicles ' /) ! External BISICLES-Chombo FVM
character(len=*), dimension(0:2), parameter :: compute_blocks = (/ &
'compute on all blocks ', &
'compute on active blocks only ', &
'inquire the number of active blocks'/)
character(len=*), dimension(0:5), parameter :: evolution = (/ &
'pseudo-diffusion ', &
'ADI scheme ', &
'iterated diffusion ', &
'incremental remapping ', &
'1st order upwind ', &
'thickness fixed at initial value ' /)
character(len=*), dimension(0:3), parameter :: temperature = (/ &
'isothermal ', &
'prognostic temperature', &
'constant in time ', &
'prognostic enthalpy ' /)
character(len=*), dimension(0:4), parameter :: temp_init = (/ &
'set to 0 C ', &
'set to surface air temp ', &
'linear vertical profile ', &
'advective-diffusive balance ',&
'temp from external file ' /)
character(len=*), dimension(0:2), parameter :: flow_law = (/ &
'uniform factor flwa ', &
'Paterson and Budd (T = -5 C)', &
'Paterson and Budd ' /)
!TODO - Rename slip_coeff to which_btrc?
character(len=*), dimension(0:5), parameter :: slip_coeff = (/ &
'no basal sliding ', &
'constant basal traction', &
'constant where bwat > 0', &
'constant where T = Tpmp', &
'linear function of bmlt', &
'tanh function of bwat ' /)
character(len=*), dimension(0:3), parameter :: basal_water = (/ &
'none ', &
'local water balance ', &
'local + steady-state flux', &
'Constant value (= 10 m) ' /)
! basal proc model is disabled for now.
!! character(len=*), dimension(0:2), parameter :: which_bproc = (/ &
!! 'Basal proc mod disabled ' , &
!! 'Basal proc, high res. ' , &
!! 'Basal proc, fast calc. ' /)
character(len=*), dimension(0:0), parameter :: which_bproc = (/ &
'Basal process model disabled ' /)
character(len=*), dimension(0:1), parameter :: b_mbal = (/ &
'not in continuity eqn', &
'in continuity eqn ' /)
character(len=*), dimension(0:6), parameter :: which_bmlt_float = (/ &
'none ', &
'MISMIP+ melt rate profile ', &
'constant melt rate ', &
'depth-dependent melt rate ', &
'melt rate from external file ', &
'melt rate from MISOMIP T/S profile ', &
'melt rate from thermal forcing ' /)
character(len=*), dimension(0:3), parameter :: bmlt_float_thermal_forcing_param = (/ &
'quadratic function of thermal forcing ', &
'ISMIP6 local quadratic ', &
'ISMIP6 nonlocal quadratic ', &
'ISMIP6 nonlocal quadratic, slope-dependent' /)
character(len=*), dimension(0:2), parameter :: bmlt_float_ismip6_magnitude = (/ &
'lowest forcing magnitude ', &
'median forcing magnitude ', &
'highest forcing magnitude ' /)
character(len=*), dimension(0:2), parameter :: ocean_data_domain = (/ &
'ocean data computed internally by CISM', &
'ocean data read from external file ', &
'ocean data from coupler via Glad ' /)
character(len=*), dimension(0:1), parameter :: ocean_data_extrapolate = (/ &
'ocean data not extrapolated to cavities', &
'ocean data extrapolated to cavities ' /)
character(len=*), dimension(0:1), parameter :: smb_input = (/ &
'SMB input in units of m/yr ice ', &
'SMB input in units of mm/yr w.e.' /)
character(len=*), dimension(0:2), parameter :: smb_input_function = (/ &
'SMB input as function of (x,y) ', &
'SMB and d(SMB)/dz input as function of (x,y)', &
'SMB input as function of (x,y,z) ' /)
character(len=*), dimension(0:2), parameter :: artm_input_function = (/ &
'artm input as function of (x,y) ', &
'artm and d(artm)/dz input as function of (x,y)', &
'artm input as function of (x,y,z) ' /)
character(len=*), dimension(0:2), parameter :: overwrite_acab = (/ &
'do not overwrite acab anywhere ', &
'overwrite acab where input acab = 0 ', &
'overwrite acab where input thck <= minthck' /)
! NOTE: Set gthf = 1 in the config file to read the geothermal heat flux from an input file.
! Otherwise it will be overwritten, even if the 'bheatflx' field is present.
character(len=*), dimension(0:2), parameter :: gthf = (/ &
'uniform geothermal flux ', &
'read flux from file, if present ', &
'compute flux from diffusion eqn ' /)
! NOTE: This option has replaced the old do_isos option
character(len=*), dimension(0:1), parameter :: isostasy = (/ &
'no isostasy calculation ', &
'compute isostasy with model ' /)
!TODO - Change 'marine_margin' to 'calving'? Would have to modify many config files
character(len=*), dimension(0:9), parameter :: marine_margin = (/ &
'no calving law ', &
'remove all floating ice ', &
'remove fraction of floating ice ', &
'relaxed bedrock threshold ', &
'present bedrock threshold ', &
'calving based on grid location ', &
'ice thickness threshold ', &
'eigencalving scheme ', &
'damage-based calving scheme ', &
'Huybrechts grounding-line scheme' /)
character(len=*), dimension(0:1), parameter :: init_calving = (/ &
'no calving at initialization ', &
'ice calves at initialization ' /)
character(len=*), dimension(0:1), parameter :: domain_calving = (/ &
'calving only at the ocean edge ', &
'calving in all cells where criterion is met'/)
character(len=*), dimension(0:1), parameter :: dm_dt_diag = (/ &