-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtidal_mixing.F90
4310 lines (3508 loc) · 160 KB
/
tidal_mixing.F90
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
!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
module tidal_mixing
!BOP
! !MODULE: tidal_mixing
!
! !DESCRIPTION:
! This module computes the time-independent part of the tidally
! driven mixing coefficients.
!
! !DESCRIPTION:
! This module contains tidal-mixing method and initialization routines,
! including multiple options for tidal energy formulations and tidal mixing
! parameterization schemes.
!
! The user can select from three main tidal-mixing methods and four
! tidal energy initialization files. Additionally, the user can opt
! to modulate the 3D Egbert & Ray and Green & Nycander tidal energy fields
! with an 18.6-year lunar cycle and use with either the Schmittner (3D)
! method or the Jayne (2D) method.
!
! Note that the tidal energy field in the Polzin/Melet method evolves in
! time as a function of N(bottom); this form of tidal energy may optionally
! be selected for use in the Jayne method.
!
!
! Tidal Mixing Methods:
! ====================
!
! 1) tidal_mixing_method_jayne
! _________________________
!
! Jayne, S. R., and L. C. St. Laurent, 2001: Parameterizing tidal
! dissipation over rough topography. Geophys. Res. Lett.,
! v28, 811-814.
!
! Simmons, H. L., S. R. Jayne, L. C. St. Laurent, and
! A. J. Weaver, 2004: Tidally driven mixing in a numerical
! model of the ocean general circulation. Ocean Modelling,
! vol 6, 245-263.
!
! Jayne, Steven R., 2009: The Impact of Abyssal Mixing
! Parameterizations in an Ocean General Circulation Model.
! JPO, vol 39, 1756-1775.
!
! 2) tidal_mixing_method_polzin (based on Melet 2013)
! ________________________________________________
!
! Polzin, K. L., 2009: An abyssal recipe. Ocean Modelling,
! vol 30, 298-309
!
! Melet, A. et al, 2013: Sensitivity of the ocean state to the
! vertical distribution of the internal-tide-driven mixing.
! J. Phys Oceanography, vol 43, 602-615
!
! 3) tidal_mixing_method_schmittner
! ______________________________
!
! Schmittner, A. and G.D. Egbert, 2014: An improved parameterization
! of tidal mixing for ocean models. Geosci. Model Dev., 7, 211-224, 2014
!
! Tidal Energy Input Files:
! ========================
!
! 1) tidal_energy_arbic (Arbic 2014)
! __________________
!
!
! 2) tidal_energy_jayne (Jayne 2009)
! __________________
!
!
! 3) tidal_energy_ERO3 (Egbert and Ray 2003)
! _________________
!
!
! 4) tidal_energy_GN13 (Green and Nycander 2013)
! _________________
!
! 5) tidal_energy_LGM0 (Wilmes) !active research -- do not use
! _________________
!
! 6) tidal_energy_LGMi5g21 (Wilmes) !active research -- do not use
! _____________________
!
! 7) tidal_energy_LGMi6g21 (Wilmes) !active research -- do not use
! _____________________
!
!
! The following combinations of tidal energy files and options are allowed:
!
! MIXING METHOD --> Jayne Polzin Schmittner
! ENERGY FILE /
! |
! V
! Arbic 2014 yes yes no
!
! Jayne 2009 yes yes no
!
! Egbert & Ray 2003 yes(2D) yes(2D) yes(3D)
!
! Green & Nycander 2013 yes(2D) yes(2D) yes(3D)
!
! LGM0 Wilmes yes(2D) yes(2D) yes(3D)
!
! LGMi5g21 Wilmes yes(2D) yes(2D) yes(3D)
!
! LGMi6g21 Wilmes yes(2D) yes(2D) yes(3D)
!
! Notes on initialization flow control:
! 1) init_tidal_mixing1 (tidal_mixing.F90) read tidal-mixing namelist variables
! ------------------
! 2) init_ts (initial.F90)
! -------
! |
! +-> init_restart (restart.F90) needs ltidal_lunar_cycle for LNC restart
! ------------
! 3) init_vertical_mix (vertical_mix.F90)
! -----------------
! |
! +-> init_tidal_mixing2 (tidal_mixing.F90) complete initialization of tidally driven vert. mixing
! ------------------
! |
! +-> init_tidal_ts (tidal_mixing.F90) initialize LNC; on restart uses info from init_restart
! -------------
! |
! +-> init_vmix_kpp (vmix_kpp.F90) needs info from init_tidal_mixing1,init_tidal_mixing2,init_restart
! -------------
! |
! +-> cvmix_compute_Schmittner_invariant (cvmix_tidal.F90) needs nlev from init_vmix_kpp
! ----------------------------------
! |
! +-> cvmix_compute_Schmittner (cvmix_tidal.F90) needs q*E(x,y,z) from init_tidal_mixing2
! ------------------------
!
! !REVISION HISTORY:
! SVN:$Id$
! !USES
use kinds_mod
use blocks
use broadcast
use communicate
use constants
use cvmix_tidal
use domain_size
use domain
use exit_mod
use gather_scatter
use global_reductions
use grid
use io
use io_tools
use io_types
use passive_tracer_tools
use registry
use shr_sys_mod
use tavg
use time_management
use timers
implicit none
private
save
! !PUBLIC MEMBER FUNCTIONS:
public :: init_tidal_mixing1
public :: init_tidal_mixing2
public :: init_tidal_ts
public :: tidal_compute_diff
public :: tidal_compute_diff_polzin
public :: tidal_N2_integral
public :: tidal_zstarp_inv
public :: tidal_accumulate_tavg
public :: tidal_accumulate_tavg_once
public :: tidal_ts_driver
public :: tidal_min_regions_set
! !PUBLIC DATA MEMBERS:
real (r8), dimension(:,:,:,:), allocatable, public :: &
TIDAL_DIFF, &! diffusivity due to tidal mixing
TIDAL_N2, &! buoyancy with no floor
TIDAL_N2_eps ! buoyancy with epsilon floor
real (r8), dimension(:,:,:,:), allocatable, public :: &
TIDAL_COEF_3D ! time-independent coefficients for tidal-mixing methods
! FIXME(mnl,2016-01) -- moved from init -> module level for use by cvmix
! branch of vmix_kpp; refactoring CVMix will let
! this go back to init (and get deallocated there)
! njn01: this comment now applies to TIDAL_ENERGY_FLUX_2D
public :: TIDAL_ENERGY_FLUX_2D
public :: TIDAL_QE_2D
public :: TIDAL_QE_3D
public :: tavg_TIDAL_DIFF
public :: tavg_TIDAL_COEF_3D
public :: tavg_REGION_BOX3D
interface tidal_min_regions_set
module procedure tidal_min_regions_set_cvmixT
module procedure tidal_min_regions_set_cvmixF
end interface
interface tidal_N2_integral
module procedure tidal_N2_integral_clmn
module procedure tidal_N2_integral_3D
end interface
interface tidal_zstarp_inv
module procedure tidal_zstarp_inv_clmn
module procedure tidal_zstarp_inv_3D
end interface
interface tidal_compute_diff_polzin
module procedure tidal_compute_diff_polzin_clmn
module procedure tidal_compute_diff_polzin_2D
end interface
!-----------------------------------------------------------------------
!
! choices for tidal mixing method
!
!-----------------------------------------------------------------------
integer (int_kind), public, parameter :: &! integer ids for tidal mixing method
tidal_mixing_method_jayne = 1, &! Jayne & St. Laurent 2001; Simmons et al 2004
tidal_mixing_method_polzin = 2, &! Polzin, K.L. 2009; Melet et al 2013
tidal_mixing_method_schmittner = 3 ! Schmittner & Egbert 2013
integer (int_kind), public :: tidal_mixing_method_itype
!-----------------------------------------------------------------------
!
! choices for tidal energy input file
!
!-----------------------------------------------------------------------
integer (int_kind), public, parameter :: &! integer ids for tidal energy input file
tidal_energy_arbic = 1, &! Arbic 2014
tidal_energy_jayne = 2, &! Jayne 2009
tidal_energy_ER03 = 3, &! Egbert & Ray 2003
tidal_energy_GN13 = 4, &! Green & Nycander 2013
tidal_energy_LGM0 = 5, &! LGM 0ybp Wilmes active research do not use without author permission
tidal_energy_LGMi5g21 = 6, &! LGM 21kybpi5g Wilmes active research do not use without author permission
tidal_energy_LGMi6g21 = 7 ! LGM 21kybpig6 Wilmes active research do not use without author permission
integer (int_kind), public :: &
tidal_energy_itype ! tidal energy input file selected
!-----------------------------------------------------------------------
!
! tidal maxima and minima; LAT and LON for regional boxes
!
!-----------------------------------------------------------------------
real (r8),public :: tidal_mix_max ! upper limit for TIDAL_DIFF
integer (int_kind), public, parameter :: max_tidal_min_regions = 9 ! max number of regions
integer (int_kind), public :: num_tidal_min_regions ! number of regions
logical (log_kind), public :: ltidal_min_regions ! apply min TIDAL_DIFF in regions
character (char_len), dimension(max_tidal_min_regions),public :: &
tidal_min_regions_name
real (r8),dimension(max_tidal_min_regions),public :: &
tidal_min_values, & ! minimum tidal-mixing values in specified regions
tidal_TLATmin_regions, & ! lower TLAT limit in specified regions
tidal_TLATmax_regions ,& ! upper TLAT limit in specified regions
tidal_TLONmin_regions, & ! lower TLON limit in specified regions
tidal_TLONmax_regions ! upper TLON limit in specified regions
integer (int_kind),dimension(max_tidal_min_regions),public :: &
tidal_min_regions_klevels ! apply min over lowest k levels
integer (int_kind),dimension(:,:,:,:), allocatable :: REGION_BOX3D
logical (log_kind), public :: ltidal_max ! cap TIDAL_DIFF at tidal_mix_max
character (char_len) :: tidal_mixing_method_choice ! choice of tidal mixing method option
character (char_len) :: tidal_energy_choice ! choice of tidal energy input file option
!-----------------------------------------------------------------------
!
! module logical control
!
!-----------------------------------------------------------------------
logical (log_kind) :: lccsm_control_compatible !backwards compatibility with ccsm4 control
logical (log_kind), public :: ltidal_schmittner_socn !apply Schmittner southern ocean mod
logical (log_kind), public :: ltidal_stabc !apply tidal diffusion stability controls
logical (log_kind), public :: ltidal_lunar_cycle !activate 18.6-year lunar nodal cycle (LNC)
logical (log_kind), public :: ltidal_lunar_cycle_read_restart !read LNC info from restart file
logical (log_kind) :: ltidal_lunar_cycle_print = .false. !print output diagnostics
logical (log_kind), public :: ltidal_melet_plot = .false. !create melet figure plot
logical (log_kind), public :: ltidal_mixing !activate tidal mixing parameterization
!-----------------------------------------------------------------------
!
! support for reading tidal-energy input data files
!
!-----------------------------------------------------------------------
character (char_len_long) :: tidal_energy_file ! tidal energy input file (generic )
character (char_len_long) :: tidal_vars_file_polz ! tidal vars input file polzin
character (char_len) :: &! 'bin' or 'nc'
tidal_energy_file_fmt, &! tidal energy input file format generic
tidal_vars_file_fmt_polz ! tidal vars input file format polzin
type (datafile) :: &
tidal_mixing_file_in ! io file descriptor
type (io_dim) :: &
i_dim, &! dimension descriptors for horiz dims
j_dim, &
k_dim ! dimension descriptor for vertical dim
type (io_field_desc) :: &
H2_P_D, &! field descriptor for input H2_P flux
TIDAL_ENERGY_FLUX_D, &! field descriptor for input energy flux
TCK1_D, &! for diurnal lunar
TCM2_D, &! for semidiurnal lunar
TCO1_D, &! for diurnal solar
TCS2_D, &! for semidirunal solar
U_P_D ! for input U_P
!-----------------------------------------------------------------------
!
! general module variables
!
!-----------------------------------------------------------------------
real (r8), dimension(:,:,:,:), allocatable :: &
TIDAL_QE_3D, &! q*E(x,y,z) g/s^3
VERTICAL_FUNC, &
VERTICAL_NUM
real (r8), dimension(:,:,:), allocatable :: &
TIDAL_QE_2D, &! q*E(x,y) g/s^3
TIDAL_COEF_2D ! time-independent coefficients for tidal-mixing methods
real (r8), dimension(:,:,:), target, allocatable :: &
TIDAL_ENERGY_FLUX_2D ! E(x,y) = input tidal energy flux at T-grid points (W/m^2)
real (r8) :: &
tidal_eps_n2, &! lower limit N**2
tidal_gamma_rhor, &! tidal_mixing_efficiency/rho_fw
zetar ! reciprocal of vertical decay scale for turbulence (cm)
real (r8), public :: &
tidal_local_mixing_fraction ! fraction of energy available for mixing local to the generation region
!-----------------------------------------------------------------------
!
! Polzin formulation variables. Note that while the suffixes _P and _polz
! are chosen to reference Polzin, the actual implementation is ala Melet 2013
!
!-----------------------------------------------------------------------
real (r8), dimension(:,:,:), target,allocatable :: &
HTINV, &! 1/HT
H2_P, &! bottom roughness used in Polzin scheme
U_P ! sqrt(barotropic tide variance) used in Polzin scheme
real (r8) :: &
coef_polz, &! coefficient used in Polzin option
kappa_polz, &! wavenumber scale for topographic roughness
mu_polz, &! mu, a nondimensional constant
mixing_eff_coef_polz, &! fraction of local internal-tide energy dissipation
nb_ref_polz, &! reference value for N at sea bottom
omega2_polz, &! omega**2
zstar_inv_coeff_polz ! coefficient of 1/zstar_polz
!-----------------------------------------------------------------------
!
! Schmittner method variables
!
!-----------------------------------------------------------------------
character (char_len) :: &
tidal_vert_decay_option_schm ! suboption for schmittner method: 'SSJ02' or 'P09'
logical (log_kind) :: &
ltidal_all_TC_coefs_eq_1, &! if .true., weight all TC equally for plotting (*c1)
ltidal_all_TC_coefs_eq_p33 ! if .true., weight all TC equally for plotting (*p33)
real (r8), dimension(:,:,:,:), allocatable :: &
TANH_SCHM_3D
real (r8), dimension(:,:,:), allocatable :: &
TANH_TLAT_SCHM
real (r8), dimension(:), allocatable :: &
decay_fn, &! vert. decay fn, in Schmittner method
tanhzw_schm
real (r8) :: &
hab, &! height above bottom -- Schmittner method
tidal_diss_lim_TC ! dissipation limit for tidal-energy-constituent data
!-----------------------------------------------------------------------
!
! ER03 and NG13 tidal constituent variables
! Energy flux out of the barotropic tide as estimated by
! by Egbert using satellite altimetry or Green and Nycander (W/m^2)
!
!-----------------------------------------------------------------------
real (r8), dimension(:,:,:,:), target, allocatable :: &
TCK1, &! diurnal lunar
TCM2, &! semidiurnal lunar
TCO1, &! diurnal solar
TCS2 ! semidirunal solar
!-----------------------------------------------------------------------------
!
! support for 18.6-year lunar cycle modulation (Lunar Nodal Cycle -- LNC)
!
!-----------------------------------------------------------------------------
integer (int_kind), parameter :: &
ntidal_ts_TC = 4, &! number of tidal constituents (m2,s2,k1,o1)
tidal_ts_DATA_max = 1000.0_r8*366.00_r8, &! 1000+ years daily data, any calendar
tidal_ts_NSTEPS_max = 1000 ! 1000 steps per day, max
character (char_len_long), dimension(ntidal_ts_TC) :: &
tidal_energy_ts_files ! LNC timeseries filename
character (char_len) :: &
tidal_energy_ts_calendar, &! LNC timeseries calendar
tidal_energy_ts_file_fmt ! LNC timeseries file format
integer (int_kind) :: &
tidal_energy_ts_data_first_year, &! year of first ts data year used; this year is
! aligned with tidal_energy_ts_model_yr_align
! eg, ...model_year_align = 1
! ...ts_year_first = 1948
tidal_energy_ts_data_first_month, &! first month of first ts data year used
tidal_energy_ts_data_first_day, &! first day of first ts data year used
tidal_energy_ts_data_final_year, &! year of last ts data year used
tidal_energy_ts_data_final_month, &! last month of last ts data year used
tidal_energy_ts_data_final_day, &! last day of last ts data year used
tidal_energy_ts_model_yr_align ! model year that is aligned with tidal_energy_ts_data_first_year
!-----------------------------------------------------------------------
!
! public LNC variables
!
!-----------------------------------------------------------------------
integer (int_kind), public :: tidal_ts_data_ind_low
integer (int_kind), public :: tidal_ts_data_ind_high
integer (int_kind), public :: tidal_ts_data_day_of_year
type :: tidal_ts_desc
character(char_len_long), dimension(ntidal_ts_TC):: &
filenames ! tidal modulation input timeseries filename
character(char_len) :: &
fmt, &! tidal modulation input timeseries file format
data_calendar ! data calendar ('gregorian', '365')
logical(log_kind) :: &
calendar_mismatch ! if data calendar is gregorian and model calendar is 365
integer(kind=int_kind) :: &
model_first_year, &! first model year aligned with data_first_year
model_month_first, &! first model month aligned with data_first_month
model_day_first, &! first model day aligned with data_first_day
data_first_year, &! first data year aligned with model_first_year
data_first_month, &! first data month aligned with model_month_first
data_first_day, &! first data day aligned with model_day_first
data_final_year, &! final data year used
data_final_month, &! final data month used
data_final_day, &! final data day used
data_day_of_year, &! data day number now in use [1,366]
data_day_of_year_first, &! first data day number [1,366]
data_ind_low, &! data index lower bound
data_ind_high, &! data index upper bound
data_ind_first, &! data index at beginning of data cycle
data_ind_final, &! data index at end of data cycle
data_npoints, &! number of timeseries data point selected
k1, &! index for K1 tidal constituent
m2, &! index for M2 tidal constituent
o1, &! index for O1 tidal constituent
s2 ! index for S2 tidal constituent
integer(kind=int_kind), dimension(tidal_ts_DATA_max) :: &
data_year, &! data year now in use
data_month, &! data month now in use
data_day ! data day now in use
real(kind=r8), dimension(tidal_ts_NSTEPS_max) :: &
factor, &! factor by which tidal energy components are
! multiplied in 18.6-year lunar cycle
w1, &! daily weight lower
w2 ! daily weight upper
real(kind=r8), dimension(tidal_ts_DATA_max,ntidal_ts_TC) :: &
data ! timeseries data values
end type
type (tidal_ts_desc) :: &
tidal_ts
!-----------------------------------------------------------------------
!
! ids for tidal-mixing-related time-averaged history fields
!
!-----------------------------------------------------------------------
integer (int_kind) :: &
tavg_H2_P, &! id for Polzin scheme H2_P
tavg_POLZIN_EQ2, &! id for Jayne, Polzin, or Schmittner 2D
tavg_TCK1, &! id for Schmittner diurnal lunar
tavg_TCM2, &! id for Schmittner semidiurnal lunar
tavg_TCO1, &! id for Schmittner diurnal solar
tavg_TCS2, &! id for Schmittner semidirunal solar
tavg_TIDAL_COEF_3D, &! id for TIDAL_COEF_3D
tavg_TIDAL_DIFF, &! id for TIDAL_DIFF
tavg_TIDAL_ENERGY_FLUX_2D, &! id for Jayne, Polzin, or Schmittner 2D
tavg_TIDAL_GAMMA_EPS, &! id for Gamma*epsilon
tavg_TIDAL_N2, &! id for N**2 (no floor)
tavg_TIDAL_N2_eps, &! id for N**2 (epsilon floor)
tavg_TIDAL_QE_2D, &! id for Jayne or Polzin q*E
tavg_TIDAL_QE_3D, &! id for TIDAL_QE_3D (q*E)
tavg_REGION_BOX3D, &! id for REGION_BOX3D (dimensionless)
tavg_U_P, &! id for Polzin scheme U_P
tavg_VERTICAL_FUNC ! id for time-independent vertical function
integer (int_kind) :: &! fields to be used in Melet comparison:
tavg_TEMP1_1p5km, &! id for temperature in [1km,1.5km] in 62-level models only
tavg_TEMP1_2km, &! id for temperature in [1km,2km] in 62-level models only
tavg_TEMP1_3km, &! id for temperature in [1km,3km] in 62-level models only
tavg_TEMP2_3km, &! id for temperature in [2km,3km] in 62-level models only
tavg_TEMP3p5_6km, &! id for temperature in [3.5km,6km] in 62-level models only
tavg_TEMP2_4km, &! id for temperature in [2km,4km] in 62-level models only
tavg_TEMP4_6km ! id for temperature in [4km,6km] in 62-level models only
!-----------------------------------------------------------------------------
!
! module timer
!
!-----------------------------------------------------------------------------
integer(kind=int_kind) :: timer_tidal_ts ! timer for 18.6-year LNC overhead
!-----------------------------------------------------------------------------
!
! misc
!
!-----------------------------------------------------------------------------
character (char_len_long) :: string ! generic string
character (char_len_long) :: tidal_energy_string ! string describing tidal energy field
character (char_len) :: subname ! generic subroutine name
!... development diagnostics -- comparison with UVIC results
logical (log_kind) :: ltidal_compare_VIC
real (r8) horiz_TIDAL_QE_3D(1:km)
real (kind=r8), dimension(18), public :: sum_vic_TE, sum_dz
real (kind=r8), dimension(18), public :: zw_vic = (/5000., 13000., 24000., 38000., 55000., &
75000., 98000., 124000., 153000., 185000., 220000., 258000., 299000., &
343000., 390000., 440000., 493000., 549000. /)
! 343000., 390000., 440000., 493000., 549000., 608000./)
real (r8),public :: &
tidal_mixing_efficiency, &! mixing efficiency
vertical_decay_scale ! vertical decay scale for turbulence (cm)
!EOP
!EOC
!***********************************************************************
contains
!***********************************************************************
!BOP
! !IROUTINE: init_tidal_mixing1
! !INTERFACE:
subroutine init_tidal_mixing1
! !DESCRIPTION:
! Only reads tidal-mixing namelist. Must be read prior to calling read_restart.
! init_tidal_mixing2 initializes everything else.
! !REVISION HISTORY:
! same as module
!EOP
!BOC
!-----------------------------------------------------------------------
!
! input namelist
!
!-----------------------------------------------------------------------
namelist /tidal_nml/ tidal_local_mixing_fraction, &
ltidal_all_TC_coefs_eq_1, &
ltidal_all_TC_coefs_eq_p33, &
ltidal_max, &
ltidal_schmittner_socn, &
ltidal_stabc, &
ltidal_lunar_cycle, &
ltidal_melet_plot, &
ltidal_mixing, &
tidal_diss_lim_TC, &
tidal_energy_choice, &
tidal_energy_file, &
tidal_energy_file_fmt, &
tidal_energy_ts_files, &
tidal_energy_ts_file_fmt, &
tidal_energy_ts_calendar, &
tidal_energy_ts_model_yr_align, &
tidal_energy_ts_data_first_year, &
tidal_energy_ts_data_first_month, &
tidal_energy_ts_data_first_day , &
tidal_energy_ts_data_final_year, &
tidal_energy_ts_data_final_month, &
tidal_energy_ts_data_final_day , &
tidal_eps_n2, &
tidal_mix_max, &
tidal_mixing_efficiency, &
tidal_mixing_method_choice, &
tidal_vars_file_polz, &
tidal_vars_file_fmt_polz, &
tidal_vert_decay_option_schm, &
ltidal_min_regions, &
num_tidal_min_regions, &
tidal_min_regions_name, &
tidal_min_regions_klevels, &
tidal_min_values, &
tidal_TLATmin_regions, &
tidal_TLATmax_regions, &
tidal_TLONmin_regions, &
tidal_TLONmax_regions, &
vertical_decay_scale
!-----------------------------------------------------------------------
!
! local variables
!
!-----------------------------------------------------------------------
integer (int_kind) :: &
elapsed_days, &! temp var for day calculation
elapsed_days_jan1, &! temp var for day calculation
iblock, &! block index
ii, &
i,j, &! horizontal indices
i_size = 1, &! default allocation x
j_size = 1, &! default allocation y
k_size = 1, &! default allocation z
k,k1, &! vertical level indices
nml_error, &! namelist i/o error flag
nu ! i/o unit number
integer (int_kind), dimension(:,:), allocatable :: REGION_BOX2D_G
integer (int_kind), dimension(:,:,:), allocatable :: REGION_BOX2D
logical (log_kind), dimension(max_tidal_min_regions) :: wrap
real (r8), dimension(:,:), allocatable :: TLON_G, TLAT_G
real (r8), dimension(:,:,:), allocatable :: &
WORK ! WORK array
type (block) :: &
this_block ! block information for current block
!-----------------------------------------------------------------------
!
! set defaults for tidal parameters, then read them from namelist
!
!-----------------------------------------------------------------------
tidal_local_mixing_fraction = 0.33_r8
ltidal_all_TC_coefs_eq_1 = .false.
ltidal_all_TC_coefs_eq_p33 = .false.
ltidal_max = .true.
ltidal_compare_VIC = .false.
ltidal_schmittner_socn = .false.
ltidal_stabc = .true.
ltidal_melet_plot = .false.
ltidal_mixing = .false.
tidal_diss_lim_TC = 0.0e02_r8 !cm or 225.0e02_r8
tidal_energy_choice = 'unknown_tidal_energy_choice'
tidal_energy_file = 'unknown_tidal_energy_file'
tidal_energy_file_fmt = 'unknown_tidal_energy_file_fmt'
tidal_energy_ts_files = 'unknown_tidal_ts_file'
tidal_energy_ts_file_fmt = 'unknown_tidal_ts_file_fmt'
tidal_energy_ts_calendar = 'unknown_tidal_ts_file_calendar'
tidal_energy_ts_model_yr_align = 1
tidal_energy_ts_data_first_year = 1948
tidal_energy_ts_data_first_month = 1
tidal_energy_ts_data_first_day = 1
tidal_energy_ts_data_final_year = 2009
tidal_energy_ts_data_final_month = 1
tidal_energy_ts_data_final_day = 1
tidal_eps_n2 = 1.0e-8_r8
tidal_mix_max = 100.0_r8
tidal_mixing_efficiency = 0.20_r8
tidal_mixing_method_choice = 'unknown_tidal_mixing_method_choice'
tidal_vars_file_polz = 'unknown_vars_energy_file_polz'
tidal_vars_file_fmt_polz = 'nc'
tidal_vert_decay_option_schm = 'SSJ02'
vertical_decay_scale = 500.0e02_r8
tidal_min_regions_name = ' '
ltidal_min_regions = .false.
num_tidal_min_regions = 3
tidal_min_values = 20.0_r8
tidal_min_regions_klevels = 6
!-----------------------------------------------------------------------
!
! read namelist input and broadcast variables
!
!-----------------------------------------------------------------------
if (my_task == master_task) then
open (nml_in, file=nml_filename, status='old',iostat=nml_error)
if (nml_error /= 0) then
nml_error = -1
else
nml_error = 1
endif
do while (nml_error > 0)
read(nml_in, nml=tidal_nml,iostat=nml_error)
end do
if (nml_error == 0) close(nml_in)
endif
call broadcast_scalar (nml_error, master_task)
if (nml_error /= 0) then
call exit_POP (SigAbort, 'ERROR reading tidal_nml')
endif
!-----------------------------------------------------------------------
!
! document namelist in output log file
!
!-----------------------------------------------------------------------
if (my_task == master_task) then
write(stdout,blank_fmt)
write(stdout,ndelim_fmt)
write(stdout,blank_fmt)
write(stdout,*) ' Tidal mixing information'
write(stdout,blank_fmt)
!-----------------------------------------------------------------------
!
! tidal mixing method
!
!-----------------------------------------------------------------------
select case (tidal_mixing_method_choice(1:3))
case ('jay')
tidal_mixing_method_itype = tidal_mixing_method_jayne
string = 'Jayne'
case ('pol')
tidal_mixing_method_itype = tidal_mixing_method_polzin
string = 'Polzin/Melet'
case ('sch','Sch')
tidal_mixing_method_itype = tidal_mixing_method_schmittner
string = 'Schmittner'
case default
tidal_mixing_method_itype = -1000
string = 'Unknown'
end select
write(stdout,*) trim(string)// ' Tidal Mixing'
!-----------------------------------------------------------------------
!
! tidal energy file
!
!-----------------------------------------------------------------------
select case (tidal_energy_choice(1:4))
case ('arbi')
tidal_energy_string = 'Arbic'
tidal_energy_itype = tidal_energy_arbic
case ('jayn')
tidal_energy_string = 'Jayne'
tidal_energy_itype = tidal_energy_jayne
case ('ER03','er03')
tidal_energy_string = 'ER03'
tidal_energy_itype = tidal_energy_ER03
case ('GN13','gn13')
tidal_energy_string = 'GN13'
tidal_energy_itype = tidal_energy_GN13
case ('LGM0','lgm0')
tidal_energy_string = 'LGM0 -- research only do not use without author permission'
tidal_energy_itype = tidal_energy_LGM0
case ('LGMi','lgmi')
select case (tidal_energy_choice(1:8))
case('LGMi5g21','lgmi5g21')
tidal_energy_string = 'LGMi5g21 -- research only do not use without author permission'
tidal_energy_itype = tidal_energy_LGMi5g21
case('LGMi6g21','lgmi6g21')
tidal_energy_string = 'LGMi6g21 -- research only do not use without author permission'
tidal_energy_itype = tidal_energy_LGMi6g21
end select
case default
tidal_energy_itype = -1000
tidal_energy_string = 'Unknown'
end select
write(stdout,*) 'with '//trim(tidal_energy_string)// ' Tidal Energy file'
write(stdout,blank_fmt)
write(stdout,*) ' tidal_nml namelist:'
write(stdout,blank_fmt)
write(stdout,tidal_nml)
write(stdout,blank_fmt)
endif
call broadcast_scalar (tidal_local_mixing_fraction, master_task)
call broadcast_scalar (ltidal_all_TC_coefs_eq_1, master_task)
call broadcast_scalar (ltidal_all_TC_coefs_eq_p33, master_task)
call broadcast_scalar (ltidal_max, master_task)
call broadcast_scalar (ltidal_schmittner_socn, master_task)
call broadcast_scalar (ltidal_stabc, master_task)
call broadcast_scalar (ltidal_lunar_cycle, master_task)
call broadcast_scalar (ltidal_mixing, master_task)
call broadcast_scalar (tidal_diss_lim_TC, master_task)
call broadcast_scalar (tidal_energy_choice, master_task)
call broadcast_scalar (tidal_energy_itype, master_task)
call broadcast_scalar (tidal_energy_file, master_task)
call broadcast_scalar (tidal_energy_file_fmt, master_task)
call broadcast_scalar (tidal_energy_ts_file_fmt, master_task)
call broadcast_scalar (tidal_energy_ts_calendar, master_task)
call broadcast_scalar (tidal_energy_ts_model_yr_align, master_task)
call broadcast_scalar (tidal_energy_ts_data_first_year, master_task)
call broadcast_scalar (tidal_energy_ts_data_first_month, master_task)
call broadcast_scalar (tidal_energy_ts_data_first_day, master_task)
call broadcast_scalar (tidal_energy_ts_data_final_year, master_task)
call broadcast_scalar (tidal_energy_ts_data_final_month, master_task)
call broadcast_scalar (tidal_energy_ts_data_final_day, master_task)
call broadcast_scalar (tidal_eps_n2, master_task)
call broadcast_scalar (tidal_mix_max, master_task)
call broadcast_scalar (tidal_mixing_efficiency, master_task)
call broadcast_scalar (tidal_mixing_method_choice, master_task)
call broadcast_scalar (tidal_mixing_method_itype, master_task)
call broadcast_scalar (tidal_vars_file_polz, master_task)
call broadcast_scalar (tidal_vars_file_fmt_polz, master_task)
call broadcast_scalar (tidal_vert_decay_option_schm, master_task)
call broadcast_scalar (vertical_decay_scale, master_task)
call broadcast_scalar (tidal_energy_string, master_task)
call broadcast_scalar (num_tidal_min_regions, master_task)
call broadcast_scalar (ltidal_min_regions, master_task)
!... loop over vectors one element at a time
do ii=1,num_tidal_min_regions
call broadcast_scalar (tidal_min_regions_name(ii), master_task)
call broadcast_scalar (tidal_min_values(ii), master_task)
call broadcast_scalar (tidal_TLATmin_regions(ii), master_task)
call broadcast_scalar (tidal_TLATmax_regions(ii), master_task)
call broadcast_scalar (tidal_TLONmin_regions(ii), master_task)
call broadcast_scalar (tidal_TLONmax_regions(ii), master_task)
enddo
!... loop over vectors one element at a time
do ii=1,ntidal_ts_TC
call broadcast_scalar (tidal_energy_ts_files(ii), master_task)
enddo
call register_string('tidal_energy_'//trim(tidal_energy_string))
!-----------------------------------------------------------------------
!
! if applying a tidal-mixing floor in specified regions, define the
! mask now
!
!-----------------------------------------------------------------------
if (ltidal_min_regions) then
!... document regions in output log file
if (my_task == master_task) then
do ii=1,num_tidal_min_regions
write(stdout,1100) '(init_tidal_mixing1) num_region = ', ii
write(stdout,1101) '(init_tidal_mixing1) tidal_min_regions_name = ', trim(tidal_min_regions_name(ii))
write(stdout,1102) '(init_tidal_mixing1) tidal_TLATmin_regions = ', tidal_TLATmin_regions(ii)
write(stdout,1102) '(init_tidal_mixing1) tidal_TLATmax_regions = ', tidal_TLATmax_regions(ii)
write(stdout,1102) '(init_tidal_mixing1) tidal_TLONmin_regions = ', tidal_TLONmin_regions(ii)
write(stdout,1102) '(init_tidal_mixing1) tidal_TLONmax_regions = ', tidal_TLONmax_regions(ii)
write(stdout,*) ' '
call shr_sys_flush(stdout)
enddo !num_region
endif !my_task
!... determine if longitude is wrapped
do ii=1,num_tidal_min_regions
if ( tidal_TLONmin_regions(ii) .le. tidal_TLONmax_regions(ii)) then
!... no wrap
wrap(ii) = .false.
else
!... assume box wraps around 360, so add 360 to max
wrap(ii) = .true.
call document ('init_tidal_mixing1','box wraps around 360 for tidal region box ', ii)
endif
enddo ! ii
!... create 2D global tidal-region box mask
allocate (REGION_BOX2D_G(nx_global,ny_global)); REGION_BOX2D_G = 0
!... create 2D global LAT,LON in degrees
allocate (TLON_G(nx_global,ny_global),TLAT_G(nx_global,ny_global))
call gather_global(TLON_G, TLON, master_task,distrb_clinic)
call gather_global(TLAT_G, TLAT, master_task,distrb_clinic)
TLON_G = TLON_G*radian
TLAT_G = TLAT_G*radian
if (my_task == master_task) then
do ii=1,num_tidal_min_regions
write(stdout,1104)'(init_tidal_mixing1) tidal-mixing region latitudes/longitudes = ', trim(tidal_min_regions_name(ii))
do j=1,ny_global
do i=1,nx_global
if(TLAT_G(i,j) .ge. tidal_TLATmin_regions(ii) .and. &
TLAT_G(i,j) .le. tidal_TLATmax_regions(ii) ) then
if (.not. wrap(ii)) then
if (TLON_G(i,j) .ge. tidal_TLONmin_regions(ii) .and. &
TLON_G(i,j) .le. tidal_TLONmax_regions(ii)) then
REGION_BOX2D_G(i,j) = ii
write(stdout,1105) &
'(init_tidal_mixing1) REGION_BOX2D_G(i,j), TLATmin, TLAT_G(i,j), TLATmax, TLONmin, TLON_G(i,j), TLONmax ', &
REGION_BOX2D_G(i,j), &
tidal_TLATmin_regions(ii), TLAT_G(i,j),tidal_TLATmax_regions(ii), &
tidal_TLONmin_regions(ii), TLON_G(i,j),tidal_TLONmax_regions(ii)
endif
else ! box longitudes wrap around 360
if ((TLON_G(i,j) .ge. tidal_TLONmin_regions(ii)) .and. &
(TLON_G(i,j) .le. 360.0_r8 ) .or. &
(TLON_G(i,j) .le. tidal_TLONmax_regions(ii))) then
REGION_BOX2D_G(i,j) = ii
write(stdout,1105) &
'(init_tidal_mixing1) REGION_BOX2D_G(i,j), TLATmin, TLAT_G(i,j), TLATmax, TLONmin, TLON_G(i,j), TLONmax ', &
REGION_BOX2D_G(i,j), &
tidal_TLATmin_regions(ii), TLAT_G(i,j),tidal_TLATmax_regions(ii), &
tidal_TLONmin_regions(ii), TLON_G(i,j),tidal_TLONmax_regions(ii)
endif
endif ! wrap
endif ! lat
enddo ! i
enddo ! j
enddo ! ii
endif ! master_task
!... create 2D local tidal-region box mask
allocate (REGION_BOX2D (nx_block,ny_block, nblocks_clinic)); REGION_BOX2D = 0
allocate (REGION_BOX3D (nx_block,ny_block,km,nblocks_clinic)); REGION_BOX3D = 0
call scatter_global(REGION_BOX2D, REGION_BOX2D_G, master_task, distrb_clinic, &
field_loc_center, field_type_scalar)
!... sanity test; note that non-zero REGION_BOX2D are not on master_task -- see the cesm log file
if (my_task == master_task) then
if (any(REGION_BOX2D_G .ne. 0)) then
write(stdout,*) '(init_tidal_mixing1) not all REGION_BOX2D_G values are zero'
else
write(stdout,*) '(init_tidal_mixing1) ALL REGION_BOX2D_G values are zero'
call exit_POP (SigAbort, 'ERROR ALL REGION_BOX2D_G values are zero')
endif
endif ! master_task
if (any(REGION_BOX2D .ne. 0)) then
write(stdout,*) my_task, ': (init_tidal_mixing1) not all REGION_BOX2D values are zero'
else
write(stdout,*) my_task, ': (init_tidal_mixing1) ALL REGION_BOX2D values are zero'
endif
!... create 3D local tidal-region box mask
do iblock = 1,nblocks_clinic
do ii=1,num_tidal_min_regions
do k=1,km
do j=1,ny_block
do i=1,nx_block
if (REGION_BOX2D(i,j,iblock) == ii ) then
if ( tidal_min_regions_klevels(ii) == 2 .and. k > 2) then
if (k == KMT(i,j,iblock)-1 .or. k == KMT(i,j,iblock)-2) then
REGION_BOX3D(i,j,k,iblock) = ii
endif
else if (tidal_min_regions_klevels(ii) == 6 .and. k > 6) then
if (k == KMT(i,j,iblock)-1 .or. k == KMT(i,j,iblock)-2 .or. &
k == KMT(i,j,iblock)-3 .or. k == KMT(i,j,iblock)-4 .or. &
k == KMT(i,j,iblock)-5 .or. k == KMT(i,j,iblock)-6 ) then
REGION_BOX3D(i,j,k,iblock) = ii
endif
endif
endif ! REGION_BOX2D > 0
enddo ! i
enddo ! j