forked from ESCOMP/CICE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathice_step_mod.F90
1746 lines (1453 loc) · 74.9 KB
/
ice_step_mod.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
!=======================================================================
!
! Contains CICE component driver routines common to all drivers.
!
! authors Elizabeth C. Hunke, LANL
! Philip W. Jones, LANL
! William H. Lipscomb, LANL
!
! 2008 ECH: created module by moving subroutines from drivers/cice4/
! 2014 ECH: created column package
module ice_step_mod
use ice_kinds_mod
use ice_blocks, only: block, get_block
use ice_blocks, only: nx_block, ny_block
use ice_constants, only: c0, c1, c1000, c4, p25
use ice_constants, only: field_loc_center, field_loc_NEcorner, &
field_loc_Nface, field_loc_Eface, &
field_type_scalar, field_type_vector
use ice_domain, only: halo_info, nblocks, blocks_ice
use ice_domain_size, only: max_blocks
use ice_exit, only: abort_ice
use ice_fileunits, only: nu_diag
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_prep_radiation
use icepack_intfc, only: icepack_step_therm1
use icepack_intfc, only: icepack_step_therm2
use icepack_intfc, only: icepack_aggregate
use icepack_intfc, only: icepack_step_ridge
use icepack_intfc, only: icepack_step_wavefracture
use icepack_intfc, only: icepack_step_radiation
use icepack_intfc, only: icepack_ocn_mixed_layer, icepack_atm_boundary
use icepack_intfc, only: icepack_biogeochemistry, icepack_load_ocean_bio_array
use icepack_intfc, only: icepack_max_algae, icepack_max_nbtrcr, icepack_max_don
use icepack_intfc, only: icepack_max_doc, icepack_max_dic, icepack_max_aero
use icepack_intfc, only: icepack_max_fe, icepack_max_iso
use icepack_intfc, only: icepack_query_parameters
use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes
use icepack_intfc, only: icepack_query_tracer_indices
implicit none
private
public :: step_therm1, step_therm2, step_dyn_horiz, step_dyn_ridge, &
step_snow, prep_radiation, step_radiation, ocean_mixed_layer, &
update_state, biogeochemistry, step_dyn_wave, step_prep
real (kind=dbl_kind), dimension (:,:,:), allocatable :: &
uvelT_icep, & ! uvel for wind stress computation in icepack
vvelT_icep ! vvel for wind stress computation in icepack
!=======================================================================
contains
!=======================================================================
subroutine save_init
! saves initial values for aice, aicen, vicen, vsnon
use ice_state, only: aice, aicen, aice_init, aicen_init, &
vicen, vicen_init, vsnon, vsnon_init
character(len=*), parameter :: subname = '(save_init)'
!-----------------------------------------------------------------
! Save the ice area passed to the coupler (so that history fields
! can be made consistent with coupler fields).
! Save the initial ice area and volume in each category.
!-----------------------------------------------------------------
aice_init = aice
aicen_init = aicen
vicen_init = vicen
vsnon_init = vsnon
end subroutine save_init
!=======================================================================
subroutine step_prep
! prep for step, called outside nblock loop
use ice_flux, only: uatm, vatm, uatmT, vatmT
use ice_grid, only: grid_atm_dynu, grid_atm_dynv, grid_average_X2Y
use ice_state, only: uvel, vvel
logical (kind=log_kind) :: &
highfreq ! highfreq flag
logical (kind=log_kind), save :: &
first_call = .true. ! first call flag
character(len=*), parameter :: subname = '(step_prep)'
! Save initial state
call save_init
! Compute uatmT, vatmT
call grid_average_X2Y('S',uatm,grid_atm_dynu,uatmT,'T')
call grid_average_X2Y('S',vatm,grid_atm_dynv,vatmT,'T')
!-----------------------------------------------------------------
! Compute uvelT_icep, vvelT_icep
!-----------------------------------------------------------------
if (first_call) then
allocate(uvelT_icep(nx_block,ny_block,max_blocks))
allocate(vvelT_icep(nx_block,ny_block,max_blocks))
uvelT_icep = c0
vvelT_icep = c0
endif
call icepack_query_parameters(highfreq_out=highfreq)
if (highfreq) then
call grid_average_X2Y('A', uvel, 'U', uvelT_icep, 'T')
call grid_average_X2Y('A', vvel, 'U', vvelT_icep, 'T')
endif
first_call = .false.
end subroutine step_prep
!=======================================================================
!
! Scales radiation fields computed on the previous time step.
!
! authors: Elizabeth Hunke, LANL
subroutine prep_radiation (iblk)
use ice_domain_size, only: ncat, nilyr, nslyr
use ice_flux, only: scale_factor, swvdr, swvdf, swidr, swidf, &
alvdr_ai, alvdf_ai, alidr_ai, alidf_ai, &
alvdr_init, alvdf_init, alidr_init, alidf_init
use ice_arrays_column, only: fswsfcn, fswintn, &
fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf, &
fswpenln, Sswabsn, Iswabsn
use ice_state, only: aice, aicen
use ice_timers, only: ice_timer_start, ice_timer_stop, timer_sw
integer (kind=int_kind), intent(in) :: &
iblk ! block index
! local variables
integer (kind=int_kind) :: &
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
i, j ! horizontal indices
type (block) :: &
this_block ! block information for current block
character(len=*), parameter :: subname = '(prep_radiation)'
call ice_timer_start(timer_sw,iblk) ! shortwave
alvdr_init(:,:,iblk) = c0
alvdf_init(:,:,iblk) = c0
alidr_init(:,:,iblk) = c0
alidf_init(:,:,iblk) = c0
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
!-----------------------------------------------------------------
! Compute netsw scaling factor (new netsw / old netsw)
!-----------------------------------------------------------------
do j = jlo, jhi
do i = ilo, ihi
alvdr_init(i,j,iblk) = alvdr_ai(i,j,iblk)
alvdf_init(i,j,iblk) = alvdf_ai(i,j,iblk)
alidr_init(i,j,iblk) = alidr_ai(i,j,iblk)
alidf_init(i,j,iblk) = alidf_ai(i,j,iblk)
call icepack_prep_radiation (scale_factor=scale_factor(i,j,iblk), &
aice = aice (i,j, iblk), aicen = aicen (i,j, :,iblk), &
swvdr = swvdr (i,j, iblk), swvdf = swvdf (i,j, iblk), &
swidr = swidr (i,j, iblk), swidf = swidf (i,j, iblk), &
alvdr_ai = alvdr_ai(i,j, iblk), alvdf_ai = alvdf_ai(i,j, iblk), &
alidr_ai = alidr_ai(i,j, iblk), alidf_ai = alidf_ai(i,j, iblk), &
fswsfcn = fswsfcn (i,j, :,iblk), fswintn = fswintn (i,j, :,iblk), &
fswthrun = fswthrun(i,j, :,iblk), &
fswthrun_vdr = fswthrun_vdr(i,j, :,iblk), &
fswthrun_vdf = fswthrun_vdf(i,j, :,iblk), &
fswthrun_idr = fswthrun_idr(i,j, :,iblk), &
fswthrun_idf = fswthrun_idf(i,j, :,iblk), &
fswpenln = fswpenln(i,j,:,:,iblk), &
Sswabsn = Sswabsn (i,j,:,:,iblk), Iswabsn = Iswabsn (i,j,:,:,iblk))
enddo ! i
enddo ! j
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
call ice_timer_stop(timer_sw,iblk) ! shortwave
end subroutine prep_radiation
!=======================================================================
!
! Driver for updating ice and snow internal temperatures and
! computing thermodynamic growth rates and coupler fluxes.
!
! authors: William H. Lipscomb, LANL
subroutine step_therm1 (dt, iblk)
use ice_arrays_column, only: ffracn, dhsn, &
Cdn_ocn, Cdn_ocn_skin, Cdn_ocn_floe, Cdn_ocn_keel, Cdn_atm_ratio, &
Cdn_atm, Cdn_atm_skin, Cdn_atm_floe, Cdn_atm_rdg, Cdn_atm_pond, &
hfreebd, hdraft, hridge, distrdg, hkeel, dkeel, lfloe, dfloe, &
fswsfcn, fswintn, Sswabsn, Iswabsn, meltsliqn, meltsliq, &
fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf
use ice_calendar, only: yday
use ice_domain_size, only: ncat, nilyr, nslyr, n_iso, n_aero, nfsd
use ice_flux, only: frzmlt, sst, Tf, strocnxT_iavg, strocnyT_iavg, rsiden, fbot, Tbot, Tsnice, &
meltsn, melttn, meltbn, congeln, snoicen, uatmT, vatmT, wlat, &
wind, rhoa, potT, Qa, zlvl, zlvs, strax, stray, flatn, fsensn, fsurfn, fcondtopn, &
flw, fsnow, fpond, sss, mlt_onset, frz_onset, fcondbotn, fcondbot, fsloss, &
frain, Tair, strairxT, strairyT, fsurf, fcondtop, fsens, &
flat, fswabs, flwout, evap, evaps, evapi, Tref, Qref, Uref, fresh, fsalt, fhocn, &
fswthru, fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, &
meltt, melts, meltb, congel, snoice, &
flatn_f, fsensn_f, fsurfn_f, fcondtopn_f, &
send_i2x_per_cat, fswthrun_ai, dsnow
use ice_flux_bgc, only: dsnown, faero_atm, faero_ocn, fiso_atm, fiso_ocn, &
Qa_iso, Qref_iso, fiso_evap, HDO_ocn, H2_16O_ocn, H2_18O_ocn
use ice_grid, only: lmask_n, lmask_s, tmask
use ice_state, only: aice, aicen, aicen_init, vicen_init, &
vice, vicen, vsno, vsnon, trcrn, vsnon_init
#ifdef CICE_IN_NEMO
use ice_state, only: aice_init
#endif
#ifdef CESMCOUPLED
use ice_prescribed_mod, only: prescribed_ice
#else
logical (kind=log_kind) :: &
prescribed_ice ! if .true., use prescribed ice instead of computed
#endif
real (kind=dbl_kind), intent(in) :: &
dt ! time step (s)
integer (kind=int_kind), intent(in) :: &
iblk ! block index
! local variables
#ifdef CICE_IN_NEMO
real (kind=dbl_kind) :: &
raice ! reciprocal of ice concentration
#endif
integer (kind=int_kind) :: &
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
i, j , & ! horizontal indices
n , & ! thickness category index
k, kk ! indices for aerosols
integer (kind=int_kind) :: &
ntrcr, nt_apnd, nt_hpnd, nt_ipnd, nt_alvl, nt_vlvl, nt_Tsfc, &
nt_iage, nt_FY, nt_qice, nt_sice, nt_aero, nt_qsno, nt_fsd, &
nt_isosno, nt_isoice, nt_rsnw, nt_smice, nt_smliq
logical (kind=log_kind) :: &
tr_iage, tr_FY, tr_iso, tr_aero, tr_pond, &
tr_pond_lvl, tr_pond_topo, calc_Tsfc, snwgrain
real (kind=dbl_kind) :: &
puny ! a very small number
real (kind=dbl_kind), dimension(n_aero,2,ncat) :: &
aerosno, aeroice ! kg/m^2
real (kind=dbl_kind), dimension(n_iso,ncat) :: &
isosno, isoice ! kg/m^2
real (kind=dbl_kind), dimension(nslyr,ncat) :: &
rsnwn, smicen, smliqn
type (block) :: &
this_block ! block information for current block
character(len=*), parameter :: subname = '(step_therm1)'
call icepack_query_parameters(puny_out=puny)
call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc)
call icepack_query_parameters(snwgrain_out=snwgrain)
call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
call icepack_query_tracer_flags( &
tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_iso_out=tr_iso, &
tr_aero_out=tr_aero, tr_pond_out=tr_pond, &
tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo)
call icepack_query_tracer_indices( &
nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, &
nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, nt_Tsfc_out=nt_Tsfc, &
nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_fsd_out=nt_fsd, &
nt_qice_out=nt_qice, nt_sice_out=nt_sice, &
nt_aero_out=nt_aero, nt_qsno_out=nt_qsno, &
nt_rsnw_out=nt_rsnw, nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, &
nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
#ifndef CESMCOUPLED
prescribed_ice = .false.
#endif
rsnwn (:,:) = c0
smicen (:,:) = c0
smliqn (:,:) = c0
isoice (:,:) = c0
aerosno(:,:,:) = c0
aeroice(:,:,:) = c0
#ifdef CICE_IN_NEMO
do j = 1, ny_block
do i = 1, nx_block
!---------------------------------------------------------------
! Scale frain and fsnow by ice concentration as these fields
! are supplied by NEMO multiplied by ice concentration
!---------------------------------------------------------------
if (aice_init(i,j,iblk) > puny) then
raice = c1 / aice_init(i,j,iblk)
frain(i,j,iblk) = frain(i,j,iblk)*raice
fsnow(i,j,iblk) = fsnow(i,j,iblk)*raice
else
frain(i,j,iblk) = c0
fsnow(i,j,iblk) = c0
endif
enddo ! i
enddo ! j
#endif
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
if (snwgrain) then
do n = 1, ncat
do k = 1, nslyr
rsnwn (k,n) = trcrn(i,j,nt_rsnw +k-1,n,iblk)
smicen(k,n) = trcrn(i,j,nt_smice+k-1,n,iblk)
smliqn(k,n) = trcrn(i,j,nt_smliq+k-1,n,iblk)
enddo
enddo
endif ! snwgrain
if (tr_iso) then ! trcrn(nt_iso*) has units kg/m^3
do n=1,ncat
do k=1,n_iso
isosno(k,n) = trcrn(i,j,nt_isosno+k-1,n,iblk) * vsnon_init(i,j,n,iblk)
isoice(k,n) = trcrn(i,j,nt_isoice+k-1,n,iblk) * vicen_init(i,j,n,iblk)
enddo
enddo
endif ! tr_iso
if (tr_aero) then ! trcrn(nt_aero) has units kg/m^3
do n=1,ncat
do k=1,n_aero
aerosno (k,:,n) = &
trcrn(i,j,nt_aero+(k-1)*4 :nt_aero+(k-1)*4+1,n,iblk) &
* vsnon_init(i,j,n,iblk)
aeroice (k,:,n) = &
trcrn(i,j,nt_aero+(k-1)*4+2:nt_aero+(k-1)*4+3,n,iblk) &
* vicen_init(i,j,n,iblk)
enddo
enddo
endif ! tr_aero
if (tmask(i,j,iblk)) then
call icepack_step_therm1(dt=dt, &
aicen_init = aicen_init (i,j,:,iblk), &
vicen_init = vicen_init (i,j,:,iblk), &
vsnon_init = vsnon_init (i,j,:,iblk), &
aice = aice (i,j, iblk), &
aicen = aicen (i,j,:,iblk), &
vice = vice (i,j, iblk), &
vicen = vicen (i,j,:,iblk), &
vsno = vsno (i,j, iblk), &
vsnon = vsnon (i,j,:,iblk), &
uvel = uvelT_icep (i,j, iblk), &
vvel = vvelT_icep (i,j, iblk), &
Tsfc = trcrn (i,j,nt_Tsfc,:,iblk), &
zqsn = trcrn (i,j,nt_qsno:nt_qsno+nslyr-1,:,iblk), &
zqin = trcrn (i,j,nt_qice:nt_qice+nilyr-1,:,iblk), &
zSin = trcrn (i,j,nt_sice:nt_sice+nilyr-1,:,iblk), &
alvl = trcrn (i,j,nt_alvl,:,iblk), &
vlvl = trcrn (i,j,nt_vlvl,:,iblk), &
apnd = trcrn (i,j,nt_apnd,:,iblk), &
hpnd = trcrn (i,j,nt_hpnd,:,iblk), &
ipnd = trcrn (i,j,nt_ipnd,:,iblk), &
iage = trcrn (i,j,nt_iage,:,iblk), &
FY = trcrn (i,j,nt_FY ,:,iblk), &
afsdn = trcrn (i,j,nt_fsd:nt_fsd+nfsd-1,:,iblk), &
rsnwn = rsnwn (:,:), &
smicen = smicen (:,:), &
smliqn = smliqn (:,:), &
aerosno = aerosno (:,:,:), &
aeroice = aeroice (:,:,:), &
isosno = isosno (:,:), &
isoice = isoice (:,:), &
uatm = uatmT (i,j, iblk), &
vatm = vatmT (i,j, iblk), &
wind = wind (i,j, iblk), &
zlvl = zlvl (i,j, iblk), &
zlvs = zlvs (i,j, iblk), &
Qa = Qa (i,j, iblk), &
Qa_iso = Qa_iso (i,j,:,iblk), &
rhoa = rhoa (i,j, iblk), &
Tair = Tair (i,j, iblk), &
Tref = Tref (i,j, iblk), &
Qref = Qref (i,j, iblk), &
Qref_iso = Qref_iso (i,j,:,iblk), &
Uref = Uref (i,j, iblk), &
Cdn_atm_ratio= Cdn_atm_ratio(i,j, iblk), &
Cdn_ocn = Cdn_ocn (i,j, iblk), &
Cdn_ocn_skin = Cdn_ocn_skin(i,j, iblk), &
Cdn_ocn_floe = Cdn_ocn_floe(i,j, iblk), &
Cdn_ocn_keel = Cdn_ocn_keel(i,j, iblk), &
Cdn_atm = Cdn_atm (i,j, iblk), &
Cdn_atm_skin = Cdn_atm_skin(i,j, iblk), &
Cdn_atm_floe = Cdn_atm_floe(i,j, iblk), &
Cdn_atm_pond = Cdn_atm_pond(i,j, iblk), &
Cdn_atm_rdg = Cdn_atm_rdg (i,j, iblk), &
hfreebd = hfreebd (i,j, iblk), &
hdraft = hdraft (i,j, iblk), &
hridge = hridge (i,j, iblk), &
distrdg = distrdg (i,j, iblk), &
hkeel = hkeel (i,j, iblk), &
dkeel = dkeel (i,j, iblk), &
lfloe = lfloe (i,j, iblk), &
dfloe = dfloe (i,j, iblk), &
strax = strax (i,j, iblk), &
stray = stray (i,j, iblk), &
strairxT = strairxT (i,j, iblk), &
strairyT = strairyT (i,j, iblk), &
potT = potT (i,j, iblk), &
sst = sst (i,j, iblk), &
sss = sss (i,j, iblk), &
Tf = Tf (i,j, iblk), &
strocnxT = strocnxT_iavg(i,j, iblk), &
strocnyT = strocnyT_iavg(i,j, iblk), &
fbot = fbot (i,j, iblk), &
Tbot = Tbot (i,j, iblk), &
Tsnice = Tsnice (i,j, iblk), &
frzmlt = frzmlt (i,j, iblk), &
rsiden = rsiden (i,j,:,iblk), &
wlat = wlat (i,j, iblk), &
fsnow = fsnow (i,j, iblk), &
frain = frain (i,j, iblk), &
fpond = fpond (i,j, iblk), &
fsloss = fsloss (i,j, iblk), &
fsurf = fsurf (i,j, iblk), &
fsurfn = fsurfn (i,j,:,iblk), &
fcondtop = fcondtop (i,j, iblk), &
fcondtopn = fcondtopn (i,j,:,iblk), &
fcondbot = fcondbot (i,j, iblk), &
fcondbotn = fcondbotn (i,j,:,iblk), &
fswsfcn = fswsfcn (i,j,:,iblk), &
fswintn = fswintn (i,j,:,iblk), &
fswthrun = fswthrun (i,j,:,iblk), &
fswthrun_vdr = fswthrun_vdr (i,j,:,iblk),&
fswthrun_vdf = fswthrun_vdf (i,j,:,iblk),&
fswthrun_idr = fswthrun_idr (i,j,:,iblk),&
fswthrun_idf = fswthrun_idf (i,j,:,iblk),&
fswabs = fswabs (i,j, iblk), &
flwout = flwout (i,j, iblk), &
Sswabsn = Sswabsn (i,j,:,:,iblk), &
Iswabsn = Iswabsn (i,j,:,:,iblk), &
flw = flw (i,j, iblk), &
fsens = fsens (i,j, iblk), &
fsensn = fsensn (i,j,:,iblk), &
flat = flat (i,j, iblk), &
flatn = flatn (i,j,:,iblk), &
evap = evap (i,j, iblk), &
evaps = evaps (i,j, iblk), &
evapi = evapi (i,j, iblk), &
fresh = fresh (i,j, iblk), &
fsalt = fsalt (i,j, iblk), &
fhocn = fhocn (i,j, iblk), &
fswthru = fswthru (i,j, iblk), &
fswthru_vdr = fswthru_vdr (i,j, iblk), &
fswthru_vdf = fswthru_vdf (i,j, iblk), &
fswthru_idr = fswthru_idr (i,j, iblk), &
fswthru_idf = fswthru_idf (i,j, iblk), &
flatn_f = flatn_f (i,j,:,iblk), &
fsensn_f = fsensn_f (i,j,:,iblk), &
fsurfn_f = fsurfn_f (i,j,:,iblk), &
fcondtopn_f = fcondtopn_f (i,j,:,iblk), &
faero_atm = faero_atm (i,j,1:n_aero,iblk), &
faero_ocn = faero_ocn (i,j,1:n_aero,iblk), &
fiso_atm = fiso_atm (i,j,:,iblk), &
fiso_ocn = fiso_ocn (i,j,:,iblk), &
fiso_evap = fiso_evap (i,j,:,iblk), &
HDO_ocn = HDO_ocn (i,j, iblk), &
H2_16O_ocn = H2_16O_ocn (i,j, iblk), &
H2_18O_ocn = H2_18O_ocn (i,j, iblk), &
dhsn = dhsn (i,j,:,iblk), &
ffracn = ffracn (i,j,:,iblk), &
meltt = meltt (i,j, iblk), &
melttn = melttn (i,j,:,iblk), &
meltb = meltb (i,j, iblk), &
meltbn = meltbn (i,j,:,iblk), &
melts = melts (i,j, iblk), &
meltsn = meltsn (i,j,:,iblk), &
congel = congel (i,j, iblk), &
congeln = congeln (i,j,:,iblk), &
snoice = snoice (i,j, iblk), &
snoicen = snoicen (i,j,:,iblk), &
dsnow = dsnow (i,j, iblk), &
dsnown = dsnown (i,j,:,iblk), &
meltsliq = meltsliq (i,j, iblk), &
meltsliqn = meltsliqn (i,j,:,iblk), &
lmask_n = lmask_n (i,j, iblk), &
lmask_s = lmask_s (i,j, iblk), &
mlt_onset = mlt_onset (i,j, iblk), &
frz_onset = frz_onset (i,j, iblk), &
yday=yday, prescribed_ice=prescribed_ice)
!-----------------------------------------------------------------
! handle per-category i2x fields, no merging
!-----------------------------------------------------------------
if (send_i2x_per_cat) then
do n = 1, ncat
! TODO (mvertens, 2018-12-22): do we need to add the band separated quantities
! for MOM6 here also?
fswthrun_ai(i,j,n,iblk) = fswthrun(i,j,n,iblk)*aicen_init(i,j,n,iblk)
enddo ! ncat
endif
endif
if (snwgrain) then
do n = 1, ncat
do k = 1, nslyr
trcrn(i,j,nt_rsnw +k-1,n,iblk) = rsnwn (k,n)
trcrn(i,j,nt_smice+k-1,n,iblk) = smicen(k,n)
trcrn(i,j,nt_smliq+k-1,n,iblk) = smliqn(k,n)
enddo
enddo
endif ! snwgrain
if (tr_iso) then
do n = 1, ncat
if (vicen(i,j,n,iblk) > puny) &
isoice(:,n) = isoice(:,n)/vicen(i,j,n,iblk)
if (vsnon(i,j,n,iblk) > puny) &
isosno(:,n) = isosno(:,n)/vsnon(i,j,n,iblk)
do k = 1, n_iso
trcrn(i,j,nt_isosno+k-1,n,iblk) = isosno(k,n)
trcrn(i,j,nt_isoice+k-1,n,iblk) = isoice(k,n)
enddo
enddo
endif ! tr_iso
if (tr_aero) then
do n = 1, ncat
if (vicen(i,j,n,iblk) > puny) &
aeroice(:,:,n) = aeroice(:,:,n)/vicen(i,j,n,iblk)
if (vsnon(i,j,n,iblk) > puny) &
aerosno(:,:,n) = aerosno(:,:,n)/vsnon(i,j,n,iblk)
do k = 1, n_aero
do kk = 1, 2
trcrn(i,j,nt_aero+(k-1)*4+kk-1,n,iblk)=aerosno(k,kk,n)
trcrn(i,j,nt_aero+(k-1)*4+kk+1,n,iblk)=aeroice(k,kk,n)
enddo
enddo
enddo
endif ! tr_aero
enddo ! i
enddo ! j
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
end subroutine step_therm1
!=======================================================================
! Driver for thermodynamic changes not needed for coupling:
! transport in thickness space, lateral growth and melting.
!
! authors: William H. Lipscomb, LANL
! Elizabeth C. Hunke, LANL
subroutine step_therm2 (dt, iblk)
use ice_arrays_column, only: hin_max, ocean_bio, wave_sig_ht, &
wave_spectrum, wavefreq, dwavefreq, &
first_ice, bgrid, cgrid, igrid, &
d_afsd_latg, d_afsd_newi, d_afsd_latm, d_afsd_weld
use ice_calendar, only: yday
use ice_domain_size, only: ncat, nilyr, nslyr, nblyr, nfsd
use ice_flux, only: fresh, frain, fpond, frzmlt, frazil, frz_onset, &
fsalt, Tf, sss, salinz, fhocn, rsiden, wlat, &
meltl, frazil_diag
use ice_flux_bgc, only: flux_bio, faero_ocn, &
fiso_ocn, HDO_ocn, H2_16O_ocn, H2_18O_ocn
use ice_grid, only: tmask
use ice_state, only: aice, aicen, aice0, trcr_depend, &
aicen_init, vicen_init, trcrn, vicen, vsnon, &
trcr_base, n_trcr_strata, nt_strata
real (kind=dbl_kind), intent(in) :: &
dt ! time step
integer (kind=int_kind), intent(in) :: &
iblk ! block index
! local variables
integer (kind=int_kind) :: &
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
i, j ! horizontal indices
integer (kind=int_kind) :: &
ntrcr, nbtrcr, nltrcr
logical (kind=log_kind) :: &
tr_fsd, & ! floe size distribution tracers
z_tracers ! vertical biogeochemistry
type (block) :: &
this_block ! block information for current block
character(len=*), parameter :: subname = '(step_therm2)'
call icepack_query_parameters(z_tracers_out=z_tracers)
call icepack_query_tracer_sizes(ntrcr_out=ntrcr, nbtrcr_out=nbtrcr)
call icepack_query_tracer_flags(tr_fsd_out=tr_fsd)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
! nltrcr is only used as a zbgc flag in icepack (number of zbgc tracers > 0)
if (z_tracers) then
nltrcr = 1
else
nltrcr = 0
endif
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
if (tmask(i,j,iblk)) then
! significant wave height for FSD
if (tr_fsd) &
wave_sig_ht(i,j,iblk) = c4*SQRT(SUM(wave_spectrum(i,j,:,iblk)*dwavefreq(:)))
call icepack_step_therm2(dt=dt, &
hin_max = hin_max (:), &
aicen = aicen (i,j,:,iblk), &
vicen = vicen (i,j,:,iblk), &
vsnon = vsnon (i,j,:,iblk), &
aicen_init = aicen_init(i,j,:,iblk), &
vicen_init = vicen_init(i,j,:,iblk), &
trcrn = trcrn (i,j,:,:,iblk), &
aice0 = aice0 (i,j, iblk), &
aice = aice (i,j, iblk), &
trcr_depend= trcr_depend(:), &
trcr_base = trcr_base(:,:), &
n_trcr_strata = n_trcr_strata(:), &
nt_strata = nt_strata(:,:), &
Tf = Tf (i,j, iblk), &
sss = sss (i,j, iblk), &
salinz = salinz (i,j,:,iblk), &
rsiden = rsiden (i,j,:,iblk), &
meltl = meltl (i,j, iblk), &
wlat = wlat (i,j, iblk), &
frzmlt = frzmlt (i,j, iblk), &
frazil = frazil (i,j, iblk), &
frain = frain (i,j, iblk), &
fpond = fpond (i,j, iblk), &
fresh = fresh (i,j, iblk), &
fsalt = fsalt (i,j, iblk), &
fhocn = fhocn (i,j, iblk), &
faero_ocn = faero_ocn (i,j,:,iblk), &
first_ice = first_ice (i,j,:,iblk), &
flux_bio = flux_bio (i,j,1:nbtrcr,iblk), &
ocean_bio = ocean_bio (i,j,1:nbtrcr,iblk), &
frazil_diag= frazil_diag(i,j,iblk), &
frz_onset = frz_onset (i,j, iblk), &
yday = yday, &
fiso_ocn = fiso_ocn (i,j,:,iblk), &
HDO_ocn = HDO_ocn (i,j, iblk), &
H2_16O_ocn = H2_16O_ocn(i,j, iblk), &
H2_18O_ocn = H2_18O_ocn(i,j, iblk), &
wave_sig_ht= wave_sig_ht(i,j,iblk), &
wave_spectrum = wave_spectrum(i,j,:,iblk), &
wavefreq = wavefreq(:), &
dwavefreq = dwavefreq(:), &
d_afsd_latg= d_afsd_latg(i,j,:,iblk),&
d_afsd_newi= d_afsd_newi(i,j,:,iblk),&
d_afsd_latm= d_afsd_latm(i,j,:,iblk),&
d_afsd_weld= d_afsd_weld(i,j,:,iblk))
endif ! tmask
enddo ! i
enddo ! j
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
end subroutine step_therm2
!=======================================================================
!
! finalize thermo updates
!
! authors: Elizabeth Hunke, LANL
subroutine update_state (dt, daidt, dvidt, dvsdt, dagedt, offset)
use ice_domain_size, only: ncat
! use ice_grid, only: tmask
use ice_state, only: aicen, trcrn, vicen, vsnon, &
aice, trcr, vice, vsno, aice0, trcr_depend, &
bound_state, trcr_base, nt_strata, n_trcr_strata
use ice_flux, only: Tf
use ice_timers, only: ice_timer_start, ice_timer_stop, timer_bound, timer_updstate
real (kind=dbl_kind), intent(in) :: &
dt ! time step
real (kind=dbl_kind), dimension(:,:,:), intent(inout), optional :: &
daidt, & ! change in ice area per time step
dvidt, & ! change in ice volume per time step
dvsdt, & ! change in snow volume per time step
dagedt ! change in ice age per time step
real (kind=dbl_kind), intent(in), optional :: &
offset ! d(age)/dt time offset = dt for thermo, 0 for dyn
integer (kind=int_kind) :: &
iblk, & ! block index
i,j, & ! horizontal indices
ntrcr, & !
nt_iage !
logical (kind=log_kind) :: &
tr_iage !
character(len=*), parameter :: subname='(update_state)'
call ice_timer_start(timer_updstate)
call icepack_query_tracer_flags(tr_iage_out=tr_iage)
call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
call icepack_query_tracer_indices(nt_iage_out=nt_iage)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
!-------------------------------------------------------------------
! Ghost cell updates for state variables.
!-------------------------------------------------------------------
call ice_timer_start(timer_bound)
call bound_state (aicen, &
vicen, vsnon, &
ntrcr, trcrn)
call ice_timer_stop(timer_bound)
!$OMP PARALLEL DO PRIVATE(iblk,i,j) SCHEDULE(runtime)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
!-----------------------------------------------------------------
! Aggregate the updated state variables (includes ghost cells).
!-----------------------------------------------------------------
! if (tmask(i,j,iblk)) &
call icepack_aggregate(aicen = aicen(i,j,:,iblk), &
trcrn = trcrn(i,j,:,:,iblk), &
vicen = vicen(i,j,:,iblk), &
vsnon = vsnon(i,j,:,iblk), &
aice = aice (i,j, iblk), &
trcr = trcr (i,j,:,iblk), &
vice = vice (i,j, iblk), &
vsno = vsno (i,j, iblk), &
aice0 = aice0(i,j, iblk), &
trcr_depend = trcr_depend(:), &
trcr_base = trcr_base(:,:), &
n_trcr_strata = n_trcr_strata(:), &
nt_strata = nt_strata(:,:), &
Tf = Tf(i,j,iblk))
if (present(offset)) then
!-----------------------------------------------------------------
! Compute thermodynamic area and volume tendencies.
!-----------------------------------------------------------------
if (present(daidt)) daidt(i,j,iblk) = (aice(i,j,iblk) - daidt(i,j,iblk)) / dt
if (present(dvidt)) dvidt(i,j,iblk) = (vice(i,j,iblk) - dvidt(i,j,iblk)) / dt
if (present(dvsdt)) dvsdt(i,j,iblk) = (vsno(i,j,iblk) - dvsdt(i,j,iblk)) / dt
if (present(dagedt) .and. tr_iage) then
if (offset > c0) then ! thermo
if (trcr(i,j,nt_iage,iblk) > c0) &
dagedt(i,j,iblk) = (trcr(i,j,nt_iage,iblk) &
- dagedt(i,j,iblk) - offset) / dt
else ! dynamics
dagedt(i,j,iblk) = (trcr(i,j,nt_iage,iblk) &
- dagedt(i,j,iblk)) / dt
endif
endif ! tr_iage
endif ! present(offset)
enddo ! i
enddo ! j
enddo ! iblk
!$OMP END PARALLEL DO
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
call ice_timer_stop(timer_updstate)
end subroutine update_state
!=======================================================================
!
! Run one time step of wave-fracturing the floe size distribution
!
! authors: Lettie Roach, NIWA
! Elizabeth C. Hunke, LANL
subroutine step_dyn_wave (dt)
use ice_arrays_column, only: wave_spectrum, &
d_afsd_wave, wavefreq, dwavefreq
use ice_domain_size, only: ncat, nfsd, nfreq
use ice_state, only: trcrn, aicen, aice, vice
use ice_timers, only: ice_timer_start, ice_timer_stop, timer_column, &
timer_fsd
real (kind=dbl_kind), intent(in) :: &
dt ! time step
! local variables
type (block) :: &
this_block ! block information for current block
integer (kind=int_kind) :: &
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
iblk, & ! block index
i, j ! horizontal indices
character (len=char_len) :: wave_spec_type
character(len=*), parameter :: subname = '(step_dyn_wave)'
call ice_timer_start(timer_column)
call ice_timer_start(timer_fsd)
call icepack_query_parameters(wave_spec_type_out=wave_spec_type)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
d_afsd_wave(i,j,:,iblk) = c0
call icepack_step_wavefracture(wave_spec_type = wave_spec_type, &
dt = dt, nfreq = nfreq, &
aice = aice (i,j, iblk), &
vice = vice (i,j, iblk), &
aicen = aicen (i,j,:, iblk), &
wave_spectrum = wave_spectrum(i,j,:, iblk), &
wavefreq = wavefreq (:), &
dwavefreq = dwavefreq (:), &
trcrn = trcrn (i,j,:,:,iblk), &
d_afsd_wave = d_afsd_wave (i,j,:, iblk))
end do ! i
end do ! j
end do ! iblk
!$OMP END PARALLEL DO
call ice_timer_stop(timer_fsd)
call ice_timer_stop(timer_column)
end subroutine step_dyn_wave
!=======================================================================
!
! Run one time step of dynamics and horizontal transport.
! NOTE: The evp and transport modules include boundary updates, so
! they cannot be done inside a single block loop.
!
! authors: William H. Lipscomb, LANL
! Elizabeth C. Hunke, LANL
subroutine step_dyn_horiz (dt)
use ice_boundary, only: ice_HaloUpdate
use ice_dyn_evp, only: evp
use ice_dyn_eap, only: eap
use ice_dyn_vp, only: implicit_solver
use ice_dyn_shared, only: kdyn
use ice_flux, only: strocnxU, strocnyU, strocnxT_iavg, strocnyT_iavg
use ice_flux, only: init_history_dyn
use ice_grid, only: grid_average_X2Y
use ice_state, only: aiU
use ice_transport_driver, only: advection, transport_upwind, transport_remap
real (kind=dbl_kind), intent(in) :: &
dt ! dynamics time step
! local variables
type (block) :: &
this_block ! block information for current block
integer (kind=int_kind) :: &
ilo,ihi,jlo,jhi, & ! beginning and end of physical domain
iblk, & ! block index
i, j ! horizontal indices
real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: &
work1, & ! temporary
work2 ! temporary
character(len=*), parameter :: subname = '(step_dyn_horiz)'
call init_history_dyn ! initialize dynamic history variables
!-----------------------------------------------------------------
! Ice dynamics (momentum equation)
!-----------------------------------------------------------------
if (kdyn == 1) call evp (dt)
if (kdyn == 2) call eap (dt)
if (kdyn == 3) call implicit_solver (dt)
!-----------------------------------------------------------------
! Compute strocnxT_iavg, strocnyT_iavg for thermo and coupling
!-----------------------------------------------------------------
! strocn computed on U, N, E as needed. Map strocn U divided by aiU to T
! conservation requires aiU be divided before averaging
work1 = c0
work2 = c0
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block)
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk), iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
if (aiU(i,j,iblk) /= c0) then
work1(i,j,iblk) = strocnxU(i,j,iblk)/aiU(i,j,iblk)
work2(i,j,iblk) = strocnyU(i,j,iblk)/aiU(i,j,iblk)
endif
enddo
enddo
enddo