-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathFV3GFS_io.F90
3184 lines (2956 loc) · 141 KB
/
FV3GFS_io.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 FV3GFS_io_mod
!-----------------------------------------------------------------------
! gfs_physics_driver_mod defines the GFS physics routines used by
! the GFDL FMS system to obtain tendencies and boundary fluxes due
! to the physical parameterizations and processes that drive
! atmospheric time tendencies for use by other components, namely
! the atmospheric dynamical core.
!
! NOTE: This module currently supports only the operational GFS
! parameterizations as of September 2015. Further development
! is needed to support the full suite of physical
! parameterizations present in the GFS physics package.
!-----------------------------------------------------------------------
!
!--- FMS/GFDL modules
use block_control_mod, only: block_control_type
use mpp_mod, only: mpp_error, mpp_pe, mpp_root_pe, &
mpp_chksum, NOTE, FATAL
use fms_mod, only: file_exist, stdout
use fms_io_mod, only: restart_file_type, free_restart_type, &
register_restart_field, &
restore_state, save_restart
use mpp_domains_mod, only: domain1d, domain2d, domainUG
use time_manager_mod, only: time_type
use diag_manager_mod, only: register_diag_field, send_data
use diag_axis_mod, only: get_axis_global_length, get_diag_axis, &
get_diag_axis_name
use diag_data_mod, only: output_fields, max_output_fields
use diag_util_mod, only: find_input_field
use constants_mod, only: grav, rdgas
use physcons, only: con_tice !saltwater freezing temp (K)
!
!--- GFS_typedefs
use GFS_typedefs, only: GFS_sfcprop_type, GFS_control_type, &
GFS_data_type, kind_phys
use GFS_restart, only: GFS_restart_type
use GFS_diagnostics, only: GFS_externaldiag_type
!
!-----------------------------------------------------------------------
implicit none
private
!--- public interfaces ---
public FV3GFS_restart_read, FV3GFS_restart_write
public FV3GFS_GFS_checksum
public fv3gfs_diag_register, fv3gfs_diag_output
#ifdef use_WRTCOMP
public fv_phys_bundle_setup
#endif
!--- GFDL filenames
character(len=32) :: fn_oro = 'oro_data.nc'
character(len=32) :: fn_oro_ls = 'oro_data_ls.nc'
character(len=32) :: fn_oro_ss = 'oro_data_ss.nc'
character(len=32) :: fn_srf = 'sfc_data.nc'
character(len=32) :: fn_phy = 'phy_data.nc'
!--- GFDL FMS netcdf restart data types
type(restart_file_type) :: Oro_restart, Sfc_restart, Phy_restart
type(restart_file_type) :: Oro_ls_restart, Oro_ss_restart
!--- GFDL FMS restart containers
character(len=32), allocatable, dimension(:) :: oro_name2, sfc_name2, sfc_name3
real(kind=kind_phys), allocatable, target, dimension(:,:,:) :: oro_var2, sfc_var2, phy_var2, sfc_var3ice
character(len=32), allocatable, dimension(:) :: oro_ls_ss_name
real(kind=kind_phys), allocatable, target, dimension(:,:,:) :: oro_ls_var, oro_ss_var
real(kind=kind_phys), allocatable, target, dimension(:,:,:,:) :: sfc_var3, phy_var3
!--- Noah MP restart containers
real(kind=kind_phys), allocatable, target, dimension(:,:,:,:) :: sfc_var3sn,sfc_var3eq,sfc_var3zn
real(kind=kind_phys) :: zhour
!
integer, parameter :: r8 = kind_phys
integer :: tot_diag_idx = 0
integer :: total_outputlevel = 0
integer :: isco,ieco,jsco,jeco,levo,num_axes_phys
integer :: fhzero, ncld, nsoil, imp_physics, landsfcmdl, k
real(4) :: dtp
logical :: lprecip_accu
character(len=64) :: Sprecip_accu
integer,dimension(:), allocatable :: nstt, nstt_vctbl, all_axes
character(20),dimension(:), allocatable :: axis_name, axis_name_vert
real(4), dimension(:,:,:), allocatable, target :: buffer_phys_bl, buffer_phys_nb
real(4), dimension(:,:,:,:), allocatable, target :: buffer_phys_windvect
real(kind=kind_phys),dimension(:,:),allocatable :: lon, lat, uwork
real(kind=kind_phys),dimension(:,:,:),allocatable:: uwork3d
logical :: uwork_set = .false.
character(128) :: uwindname
integer, parameter, public :: DIAG_SIZE = 500
real, parameter :: missing_value = 9.99e20_r8
real, parameter:: stndrd_atmos_ps = 101325.0_r8
real, parameter:: stndrd_atmos_lapse = 0.0065_r8
real, parameter:: drythresh = 1.e-4_r8, zero = 0.0_r8, one = 1.0_r8
real, parameter:: min_lake_orog = 200.0_r8
real(kind=kind_phys), parameter :: timin = 173.0_r8 ! minimum temperature allowed for snow/ice
!--- miscellaneous other variables
logical :: use_wrtgridcomp_output = .FALSE.
logical :: module_is_initialized = .FALSE.
CONTAINS
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!
! PUBLIC SUBROUTINES
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!
!--------------------
! FV3GFS_restart_read
!--------------------
subroutine FV3GFS_restart_read (GFS_Data, GFS_Restart, Atm_block, Model, fv_domain, warm_start)
type(GFS_data_type), intent(inout) :: GFS_Data(:)
type(GFS_restart_type), intent(inout) :: GFS_Restart
type(block_control_type), intent(in) :: Atm_block
type(GFS_control_type), intent(inout) :: Model
type(domain2d), intent(in) :: fv_domain
logical, intent(in) :: warm_start
!--- read in surface data from chgres
call sfc_prop_restart_read (GFS_Data%Sfcprop, Atm_block, Model, fv_domain, warm_start)
!--- read in physics restart data
call phys_restart_read (GFS_Restart, Atm_block, Model, fv_domain)
end subroutine FV3GFS_restart_read
!---------------------
! FV3GFS_restart_write
!---------------------
subroutine FV3GFS_restart_write (GFS_Data, GFS_Restart, Atm_block, Model, fv_domain, timestamp)
type(GFS_data_type), intent(inout) :: GFS_Data(:)
type(GFS_restart_type), intent(inout) :: GFS_Restart
type(block_control_type), intent(in) :: Atm_block
type(GFS_control_type), intent(in) :: Model
type(domain2d), intent(in) :: fv_domain
character(len=32), optional, intent(in) :: timestamp
!--- write surface data from chgres
call sfc_prop_restart_write (GFS_Data%Sfcprop, Atm_block, Model, fv_domain, timestamp)
!--- write physics restart data
call phys_restart_write (GFS_Restart, Atm_block, Model, fv_domain, timestamp)
end subroutine FV3GFS_restart_write
!--------------------
! FV3GFS_GFS_checksum
!--------------------
subroutine FV3GFS_GFS_checksum (Model, GFS_Data, Atm_block)
!--- interface variables
type(GFS_control_type), intent(in) :: Model
type(GFS_data_type), intent(in) :: GFS_Data(:)
type (block_control_type), intent(in) :: Atm_block
!--- local variables
integer :: outunit, j, i, ix, nb, isc, iec, jsc, jec, lev, ct, l, ntr
integer :: nsfcprop2d, idx_opt
real(kind=kind_phys), allocatable :: temp2d(:,:,:)
real(kind=kind_phys), allocatable :: temp3d(:,:,:,:)
real(kind=kind_phys), allocatable :: temp3dlevsp1(:,:,:,:)
character(len=32) :: name
isc = Model%isc
iec = Model%isc+Model%nx-1
jsc = Model%jsc
jec = Model%jsc+Model%ny-1
lev = Model%levs
ntr = size(GFS_Data(1)%Statein%qgrs,3)
if (Model%lsm == Model%lsm_noahmp) then
nsfcprop2d = 156
elseif (Model%lsm == Model%lsm_ruc) then
nsfcprop2d = 125
if (Model%rdlai) then
nsfcprop2d = nsfcprop2d + 1
endif
else
nsfcprop2d = 102
endif
allocate (temp2d(isc:iec,jsc:jec,nsfcprop2d+Model%ntot3d+Model%nctp))
allocate (temp3d(isc:iec,jsc:jec,1:lev,14+Model%ntot3d+2*ntr))
allocate (temp3dlevsp1(isc:iec,jsc:jec,1:lev+1,3))
temp2d = zero
temp3d = zero
temp3dlevsp1 = zero
do j=jsc,jec
do i=isc,iec
nb = Atm_block%blkno(i,j)
ix = Atm_block%ixp(i,j)
!--- statein pressure
temp2d(i,j, 1) = GFS_Data(nb)%Statein%pgr(ix)
temp2d(i,j, 2) = GFS_Data(nb)%Sfcprop%slmsk(ix)
temp2d(i,j, 3) = GFS_Data(nb)%Sfcprop%tsfc(ix)
temp2d(i,j, 4) = GFS_Data(nb)%Sfcprop%tisfc(ix)
temp2d(i,j, 5) = GFS_Data(nb)%Sfcprop%snowd(ix)
temp2d(i,j, 6) = GFS_Data(nb)%Sfcprop%zorl(ix)
temp2d(i,j, 7) = GFS_Data(nb)%Sfcprop%fice(ix)
temp2d(i,j, 8) = GFS_Data(nb)%Sfcprop%hprime(ix,1)
temp2d(i,j, 9) = GFS_Data(nb)%Sfcprop%sncovr(ix)
temp2d(i,j,10) = GFS_Data(nb)%Sfcprop%snoalb(ix)
temp2d(i,j,11) = GFS_Data(nb)%Sfcprop%alvsf(ix)
temp2d(i,j,12) = GFS_Data(nb)%Sfcprop%alnsf(ix)
temp2d(i,j,13) = GFS_Data(nb)%Sfcprop%alvwf(ix)
temp2d(i,j,14) = GFS_Data(nb)%Sfcprop%alnwf(ix)
temp2d(i,j,15) = GFS_Data(nb)%Sfcprop%facsf(ix)
temp2d(i,j,16) = GFS_Data(nb)%Sfcprop%facwf(ix)
temp2d(i,j,17) = GFS_Data(nb)%Sfcprop%slope(ix)
temp2d(i,j,18) = GFS_Data(nb)%Sfcprop%shdmin(ix)
temp2d(i,j,19) = GFS_Data(nb)%Sfcprop%shdmax(ix)
temp2d(i,j,20) = GFS_Data(nb)%Sfcprop%tg3(ix)
temp2d(i,j,21) = GFS_Data(nb)%Sfcprop%vfrac(ix)
temp2d(i,j,22) = GFS_Data(nb)%Sfcprop%vtype(ix)
temp2d(i,j,23) = GFS_Data(nb)%Sfcprop%stype(ix)
temp2d(i,j,24) = GFS_Data(nb)%Sfcprop%uustar(ix)
temp2d(i,j,25) = GFS_Data(nb)%Sfcprop%oro(ix)
temp2d(i,j,26) = GFS_Data(nb)%Sfcprop%oro_uf(ix)
temp2d(i,j,27) = GFS_Data(nb)%Sfcprop%hice(ix)
temp2d(i,j,28) = GFS_Data(nb)%Sfcprop%weasd(ix)
temp2d(i,j,29) = GFS_Data(nb)%Sfcprop%canopy(ix)
temp2d(i,j,30) = GFS_Data(nb)%Sfcprop%ffmm(ix)
temp2d(i,j,31) = GFS_Data(nb)%Sfcprop%ffhh(ix)
temp2d(i,j,32) = GFS_Data(nb)%Sfcprop%f10m(ix)
temp2d(i,j,33) = GFS_Data(nb)%Sfcprop%tprcp(ix)
temp2d(i,j,34) = GFS_Data(nb)%Sfcprop%srflag(ix)
if (Model%lsm == Model%lsm_noah .or. Model%lsm == Model%lsm_noahmp .or. Model%lsm == Model%lsm_noah_wrfv4) then
temp2d(i,j,35) = GFS_Data(nb)%Sfcprop%slc(ix,1)
temp2d(i,j,36) = GFS_Data(nb)%Sfcprop%slc(ix,2)
temp2d(i,j,37) = GFS_Data(nb)%Sfcprop%slc(ix,3)
temp2d(i,j,38) = GFS_Data(nb)%Sfcprop%slc(ix,4)
temp2d(i,j,39) = GFS_Data(nb)%Sfcprop%smc(ix,1)
temp2d(i,j,40) = GFS_Data(nb)%Sfcprop%smc(ix,2)
temp2d(i,j,41) = GFS_Data(nb)%Sfcprop%smc(ix,3)
temp2d(i,j,42) = GFS_Data(nb)%Sfcprop%smc(ix,4)
temp2d(i,j,43) = GFS_Data(nb)%Sfcprop%stc(ix,1)
temp2d(i,j,44) = GFS_Data(nb)%Sfcprop%stc(ix,2)
temp2d(i,j,45) = GFS_Data(nb)%Sfcprop%stc(ix,3)
temp2d(i,j,46) = GFS_Data(nb)%Sfcprop%stc(ix,4)
elseif (Model%lsm == Model%lsm_ruc) then
temp2d(i,j,35) = GFS_Data(nb)%Sfcprop%sh2o(ix,1)
temp2d(i,j,36) = GFS_Data(nb)%Sfcprop%sh2o(ix,2)
temp2d(i,j,37) = GFS_Data(nb)%Sfcprop%sh2o(ix,3)
! Combine levels 4 to lsoil_lsm (9 for RUC) into one
temp2d(i,j,38) = sum(GFS_Data(nb)%Sfcprop%sh2o(ix,4:Model%lsoil_lsm))
temp2d(i,j,39) = GFS_Data(nb)%Sfcprop%smois(ix,1)
temp2d(i,j,40) = GFS_Data(nb)%Sfcprop%smois(ix,2)
temp2d(i,j,41) = GFS_Data(nb)%Sfcprop%smois(ix,3)
! Combine levels 4 to lsoil_lsm (9 for RUC) into one
temp2d(i,j,42) = sum(GFS_Data(nb)%Sfcprop%smois(ix,4:Model%lsoil_lsm))
temp2d(i,j,43) = GFS_Data(nb)%Sfcprop%tslb(ix,1)
temp2d(i,j,44) = GFS_Data(nb)%Sfcprop%tslb(ix,2)
temp2d(i,j,45) = GFS_Data(nb)%Sfcprop%tslb(ix,3)
! Combine levels 4 to lsoil_lsm (9 for RUC) into one
temp2d(i,j,46) = sum(GFS_Data(nb)%Sfcprop%tslb(ix,4:Model%lsoil_lsm))
endif ! LSM choice
temp2d(i,j,47) = GFS_Data(nb)%Sfcprop%t2m(ix)
temp2d(i,j,48) = GFS_Data(nb)%Sfcprop%q2m(ix)
temp2d(i,j,49) = GFS_Data(nb)%Coupling%nirbmdi(ix)
temp2d(i,j,50) = GFS_Data(nb)%Coupling%nirdfdi(ix)
temp2d(i,j,51) = GFS_Data(nb)%Coupling%visbmdi(ix)
temp2d(i,j,52) = GFS_Data(nb)%Coupling%visdfdi(ix)
temp2d(i,j,53) = GFS_Data(nb)%Coupling%nirbmui(ix)
temp2d(i,j,54) = GFS_Data(nb)%Coupling%nirdfui(ix)
temp2d(i,j,55) = GFS_Data(nb)%Coupling%visbmui(ix)
temp2d(i,j,56) = GFS_Data(nb)%Coupling%visdfui(ix)
temp2d(i,j,57) = GFS_Data(nb)%Coupling%sfcdsw(ix)
temp2d(i,j,58) = GFS_Data(nb)%Coupling%sfcnsw(ix)
temp2d(i,j,59) = GFS_Data(nb)%Coupling%sfcdlw(ix)
temp2d(i,j,60) = GFS_Data(nb)%Grid%xlon(ix)
temp2d(i,j,61) = GFS_Data(nb)%Grid%xlat(ix)
temp2d(i,j,62) = GFS_Data(nb)%Grid%xlat_d(ix)
temp2d(i,j,63) = GFS_Data(nb)%Grid%sinlat(ix)
temp2d(i,j,64) = GFS_Data(nb)%Grid%coslat(ix)
temp2d(i,j,65) = GFS_Data(nb)%Grid%area(ix)
temp2d(i,j,66) = GFS_Data(nb)%Grid%dx(ix)
if (Model%ntoz > 0) then
temp2d(i,j,67) = GFS_Data(nb)%Grid%ddy_o3(ix)
endif
if (Model%h2o_phys) then
temp2d(i,j,68) = GFS_Data(nb)%Grid%ddy_h(ix)
endif
temp2d(i,j,69) = GFS_Data(nb)%Cldprop%cv(ix)
temp2d(i,j,70) = GFS_Data(nb)%Cldprop%cvt(ix)
temp2d(i,j,71) = GFS_Data(nb)%Cldprop%cvb(ix)
temp2d(i,j,72) = GFS_Data(nb)%Radtend%sfalb(ix)
temp2d(i,j,73) = GFS_Data(nb)%Radtend%coszen(ix)
temp2d(i,j,74) = GFS_Data(nb)%Radtend%tsflw(ix)
temp2d(i,j,75) = GFS_Data(nb)%Radtend%semis(ix)
temp2d(i,j,76) = GFS_Data(nb)%Radtend%coszdg(ix)
temp2d(i,j,77) = GFS_Data(nb)%Radtend%sfcfsw(ix)%upfxc
temp2d(i,j,78) = GFS_Data(nb)%Radtend%sfcfsw(ix)%upfx0
temp2d(i,j,79) = GFS_Data(nb)%Radtend%sfcfsw(ix)%dnfxc
temp2d(i,j,80) = GFS_Data(nb)%Radtend%sfcfsw(ix)%dnfx0
temp2d(i,j,81) = GFS_Data(nb)%Radtend%sfcflw(ix)%upfxc
temp2d(i,j,82) = GFS_Data(nb)%Radtend%sfcflw(ix)%upfx0
temp2d(i,j,83) = GFS_Data(nb)%Radtend%sfcflw(ix)%dnfxc
temp2d(i,j,84) = GFS_Data(nb)%Radtend%sfcflw(ix)%dnfx0
temp2d(i,j,85) = GFS_Data(nb)%Sfcprop%tiice(ix,1)
temp2d(i,j,86) = GFS_Data(nb)%Sfcprop%tiice(ix,2)
idx_opt = 87
if (Model%lsm == Model%lsm_noahmp) then
temp2d(i,j,idx_opt) = GFS_Data(nb)%Sfcprop%snowxy(ix)
temp2d(i,j,idx_opt+1) = GFS_Data(nb)%Sfcprop%tvxy(ix)
temp2d(i,j,idx_opt+2) = GFS_Data(nb)%Sfcprop%tgxy(ix)
temp2d(i,j,idx_opt+3) = GFS_Data(nb)%Sfcprop%canicexy(ix)
temp2d(i,j,idx_opt+4) = GFS_Data(nb)%Sfcprop%canliqxy(ix)
temp2d(i,j,idx_opt+5) = GFS_Data(nb)%Sfcprop%eahxy(ix)
temp2d(i,j,idx_opt+6) = GFS_Data(nb)%Sfcprop%tahxy(ix)
temp2d(i,j,idx_opt+7) = GFS_Data(nb)%Sfcprop%cmxy(ix)
temp2d(i,j,idx_opt+8) = GFS_Data(nb)%Sfcprop%chxy(ix)
temp2d(i,j,idx_opt+9) = GFS_Data(nb)%Sfcprop%fwetxy(ix)
temp2d(i,j,idx_opt+10) = GFS_Data(nb)%Sfcprop%sneqvoxy(ix)
temp2d(i,j,idx_opt+11) = GFS_Data(nb)%Sfcprop%alboldxy(ix)
temp2d(i,j,idx_opt+12) = GFS_Data(nb)%Sfcprop%qsnowxy(ix)
temp2d(i,j,idx_opt+13) = GFS_Data(nb)%Sfcprop%wslakexy(ix)
temp2d(i,j,idx_opt+14) = GFS_Data(nb)%Sfcprop%zwtxy(ix)
temp2d(i,j,idx_opt+15) = GFS_Data(nb)%Sfcprop%waxy(ix)
temp2d(i,j,idx_opt+16) = GFS_Data(nb)%Sfcprop%wtxy(ix)
temp2d(i,j,idx_opt+17) = GFS_Data(nb)%Sfcprop%lfmassxy(ix)
temp2d(i,j,idx_opt+18) = GFS_Data(nb)%Sfcprop%rtmassxy(ix)
temp2d(i,j,idx_opt+19) = GFS_Data(nb)%Sfcprop%stmassxy(ix)
temp2d(i,j,idx_opt+20) = GFS_Data(nb)%Sfcprop%woodxy(ix)
temp2d(i,j,idx_opt+21) = GFS_Data(nb)%Sfcprop%stblcpxy(ix)
temp2d(i,j,idx_opt+22) = GFS_Data(nb)%Sfcprop%fastcpxy(ix)
temp2d(i,j,idx_opt+23) = GFS_Data(nb)%Sfcprop%xsaixy(ix)
temp2d(i,j,idx_opt+24) = GFS_Data(nb)%Sfcprop%xlaixy(ix)
temp2d(i,j,idx_opt+25) = GFS_Data(nb)%Sfcprop%taussxy(ix)
temp2d(i,j,idx_opt+26) = GFS_Data(nb)%Sfcprop%smcwtdxy(ix)
temp2d(i,j,idx_opt+27) = GFS_Data(nb)%Sfcprop%deeprechxy(ix)
temp2d(i,j,idx_opt+28) = GFS_Data(nb)%Sfcprop%rechxy(ix)
temp2d(i,j,idx_opt+29) = GFS_Data(nb)%Sfcprop%snicexy(ix,-2)
temp2d(i,j,idx_opt+30) = GFS_Data(nb)%Sfcprop%snicexy(ix,-1)
temp2d(i,j,idx_opt+31) = GFS_Data(nb)%Sfcprop%snicexy(ix,0)
temp2d(i,j,idx_opt+32) = GFS_Data(nb)%Sfcprop%snliqxy(ix,-2)
temp2d(i,j,idx_opt+33) = GFS_Data(nb)%Sfcprop%snliqxy(ix,-1)
temp2d(i,j,idx_opt+34) = GFS_Data(nb)%Sfcprop%snliqxy(ix,0)
temp2d(i,j,idx_opt+35) = GFS_Data(nb)%Sfcprop%tsnoxy(ix,-2)
temp2d(i,j,idx_opt+36) = GFS_Data(nb)%Sfcprop%tsnoxy(ix,-1)
temp2d(i,j,idx_opt+37) = GFS_Data(nb)%Sfcprop%tsnoxy(ix,0)
temp2d(i,j,idx_opt+38) = GFS_Data(nb)%Sfcprop%smoiseq(ix,1)
temp2d(i,j,idx_opt+39) = GFS_Data(nb)%Sfcprop%smoiseq(ix,2)
temp2d(i,j,idx_opt+40) = GFS_Data(nb)%Sfcprop%smoiseq(ix,3)
temp2d(i,j,idx_opt+41) = GFS_Data(nb)%Sfcprop%smoiseq(ix,4)
temp2d(i,j,idx_opt+42) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,-2)
temp2d(i,j,idx_opt+43) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,-1)
temp2d(i,j,idx_opt+44) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,0)
temp2d(i,j,idx_opt+45) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,1)
temp2d(i,j,idx_opt+46) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,2)
temp2d(i,j,idx_opt+47) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,3)
temp2d(i,j,idx_opt+48) = GFS_Data(nb)%Sfcprop%zsnsoxy(ix,4)
temp2d(i,j,idx_opt+49) = GFS_Data(nb)%Sfcprop%albdvis_lnd(ix)
temp2d(i,j,idx_opt+50) = GFS_Data(nb)%Sfcprop%albdnir_lnd(ix)
temp2d(i,j,idx_opt+51) = GFS_Data(nb)%Sfcprop%albivis_lnd(ix)
temp2d(i,j,idx_opt+52) = GFS_Data(nb)%Sfcprop%albinir_lnd(ix)
temp2d(i,j,idx_opt+53) = GFS_Data(nb)%Sfcprop%emis_lnd(ix)
idx_opt = 141
elseif (Model%lsm == Model%lsm_ruc) then
temp2d(i,j,idx_opt) = GFS_Data(nb)%Sfcprop%wetness(ix)
temp2d(i,j,idx_opt+1) = GFS_Data(nb)%Sfcprop%clw_surf_land(ix)
temp2d(i,j,idx_opt+2) = GFS_Data(nb)%Sfcprop%clw_surf_ice(ix)
temp2d(i,j,idx_opt+3) = GFS_Data(nb)%Sfcprop%qwv_surf_land(ix)
temp2d(i,j,idx_opt+4) = GFS_Data(nb)%Sfcprop%qwv_surf_ice(ix)
temp2d(i,j,idx_opt+5) = GFS_Data(nb)%Sfcprop%tsnow_land(ix)
temp2d(i,j,idx_opt+6) = GFS_Data(nb)%Sfcprop%tsnow_ice(ix)
temp2d(i,j,idx_opt+7) = GFS_Data(nb)%Sfcprop%snowfallac_land(ix)
temp2d(i,j,idx_opt+8) = GFS_Data(nb)%Sfcprop%snowfallac_ice(ix)
temp2d(i,j,idx_opt+9) = GFS_Data(nb)%Sfcprop%sncovr_ice(ix)
temp2d(i,j,idx_opt+10) = GFS_Data(nb)%Sfcprop%albdvis_lnd(ix)
temp2d(i,j,idx_opt+11) = GFS_Data(nb)%Sfcprop%albdnir_lnd(ix)
temp2d(i,j,idx_opt+12) = GFS_Data(nb)%Sfcprop%albivis_lnd(ix)
temp2d(i,j,idx_opt+13) = GFS_Data(nb)%Sfcprop%albinir_lnd(ix)
temp2d(i,j,idx_opt+14) = GFS_Data(nb)%Sfcprop%sfalb_lnd(ix)
temp2d(i,j,idx_opt+15) = GFS_Data(nb)%Sfcprop%sfalb_lnd_bck(ix)
temp2d(i,j,idx_opt+16) = GFS_Data(nb)%Sfcprop%albdvis_ice(ix)
temp2d(i,j,idx_opt+17) = GFS_Data(nb)%Sfcprop%albdnir_ice(ix)
temp2d(i,j,idx_opt+18) = GFS_Data(nb)%Sfcprop%albivis_ice(ix)
temp2d(i,j,idx_opt+19) = GFS_Data(nb)%Sfcprop%albinir_ice(ix)
temp2d(i,j,idx_opt+20) = GFS_Data(nb)%Sfcprop%sfalb_ice(ix)
temp2d(i,j,idx_opt+21) = GFS_Data(nb)%Sfcprop%emis_lnd(ix)
temp2d(i,j,idx_opt+22) = GFS_Data(nb)%Sfcprop%emis_ice(ix)
idx_opt = 110
if (Model%rdlai) then
temp2d(i,j,idx_opt+23) = GFS_Data(nb)%Sfcprop%xlaixy(ix)
idx_opt = idx_opt + 1
endif
endif
if (Model%nstf_name(1) > 0) then
temp2d(i,j,idx_opt ) = GFS_Data(nb)%Sfcprop%tref(ix)
temp2d(i,j,idx_opt+ 1) = GFS_Data(nb)%Sfcprop%z_c(ix)
temp2d(i,j,idx_opt+ 2) = GFS_Data(nb)%Sfcprop%c_0(ix)
temp2d(i,j,idx_opt+ 3) = GFS_Data(nb)%Sfcprop%c_d(ix)
temp2d(i,j,idx_opt+ 4) = GFS_Data(nb)%Sfcprop%w_0(ix)
temp2d(i,j,idx_opt+ 5) = GFS_Data(nb)%Sfcprop%w_d(ix)
temp2d(i,j,idx_opt+ 6) = GFS_Data(nb)%Sfcprop%xt(ix)
temp2d(i,j,idx_opt+ 7) = GFS_Data(nb)%Sfcprop%xs(ix)
temp2d(i,j,idx_opt+ 8) = GFS_Data(nb)%Sfcprop%xu(ix)
temp2d(i,j,idx_opt+ 9) = GFS_Data(nb)%Sfcprop%xz(ix)
temp2d(i,j,idx_opt+10) = GFS_Data(nb)%Sfcprop%zm(ix)
temp2d(i,j,idx_opt+11) = GFS_Data(nb)%Sfcprop%xtts(ix)
temp2d(i,j,idx_opt+12) = GFS_Data(nb)%Sfcprop%xzts(ix)
temp2d(i,j,idx_opt+13) = GFS_Data(nb)%Sfcprop%ifd(ix)
temp2d(i,j,idx_opt+14) = GFS_Data(nb)%Sfcprop%dt_cool(ix)
temp2d(i,j,idx_opt+15) = GFS_Data(nb)%Sfcprop%qrain(ix)
endif
do l = 1,Model%ntot2d
temp2d(i,j,nsfcprop2d+l) = GFS_Data(nb)%Tbd%phy_f2d(ix,l)
enddo
do l = 1,Model%nctp
temp2d(i,j,nsfcprop2d+Model%ntot2d+l) = GFS_Data(nb)%Tbd%phy_fctd(ix,l)
enddo
temp3dlevsp1(i,j,:, 1) = GFS_Data(nb)%Statein%phii(ix,:)
temp3dlevsp1(i,j,:, 2) = GFS_Data(nb)%Statein%prsi(ix,:)
temp3dlevsp1(i,j,:, 3) = GFS_Data(nb)%Statein%prsik(ix,:)
temp3d(i,j,:, 1) = GFS_Data(nb)%Statein%phil(ix,:)
temp3d(i,j,:, 2) = GFS_Data(nb)%Statein%prsl(ix,:)
temp3d(i,j,:, 3) = GFS_Data(nb)%Statein%prslk(ix,:)
temp3d(i,j,:, 4) = GFS_Data(nb)%Statein%ugrs(ix,:)
temp3d(i,j,:, 5) = GFS_Data(nb)%Statein%vgrs(ix,:)
temp3d(i,j,:, 6) = GFS_Data(nb)%Statein%vvl(ix,:)
temp3d(i,j,:, 7) = GFS_Data(nb)%Statein%tgrs(ix,:)
temp3d(i,j,:, 8) = GFS_Data(nb)%Stateout%gu0(ix,:)
temp3d(i,j,:, 9) = GFS_Data(nb)%Stateout%gv0(ix,:)
temp3d(i,j,:,10) = GFS_Data(nb)%Stateout%gt0(ix,:)
temp3d(i,j,:,11) = GFS_Data(nb)%Radtend%htrsw(ix,:)
temp3d(i,j,:,12) = GFS_Data(nb)%Radtend%htrlw(ix,:)
temp3d(i,j,:,13) = GFS_Data(nb)%Radtend%swhc(ix,:)
temp3d(i,j,:,14) = GFS_Data(nb)%Radtend%lwhc(ix,:)
do l = 1,Model%ntot3d
temp3d(i,j,:,14+l) = GFS_Data(nb)%Tbd%phy_f3d(ix,:,l)
enddo
do l = 1,ntr
temp3d(i,j,:,14+Model%ntot3d+l) = GFS_Data(nb)%Statein%qgrs(ix,:,l)
temp3d(i,j,:,14+Model%ntot3d+ntr+l) = GFS_Data(nb)%Stateout%gq0(ix,:,l)
enddo
enddo
enddo
outunit = stdout()
do i = 1,nsfcprop2d+Model%ntot2d+Model%nctp
write (name, '(i3.3,3x,4a)') i, ' 2d '
write(outunit,100) name, mpp_chksum(temp2d(:,:,i:i))
enddo
do i = 1,3
write (name, '(i2.2,3x,4a)') i, ' 3d levsp1'
write(outunit,100) name, mpp_chksum(temp3dlevsp1(:,:,:,i:i))
enddo
do i = 1,14+Model%ntot3d+2*ntr
write (name, '(i2.2,3x,4a)') i, ' 3d levs'
write(outunit,100) name, mpp_chksum(temp3d(:,:,:,i:i))
enddo
100 format("CHECKSUM::",A32," = ",Z20)
deallocate(temp2d)
deallocate(temp3d)
deallocate(temp3dlevsp1)
end subroutine FV3GFS_GFS_checksum
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!
! PRIVATE SUBROUTINES
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!----------------------------------------------------------------------
! sfc_prop_restart_read
!----------------------------------------------------------------------
! creates and populates a data type which is then used to "register"
! restart variables with the GFDL FMS restart subsystem.
! calls a GFDL FMS routine to restore the data from a restart file.
! calculates sncovr if it is not present in the restart file.
!
! calls: register_restart_field, restart_state, free_restart
!
! opens: oro_data.tile?.nc, sfc_data.tile?.nc
!
!----------------------------------------------------------------------
subroutine sfc_prop_restart_read (Sfcprop, Atm_block, Model, fv_domain, warm_start)
!--- interface variable definitions
type(GFS_sfcprop_type), intent(inout) :: Sfcprop(:)
type (block_control_type), intent(in) :: Atm_block
type(GFS_control_type), intent(inout) :: Model
type (domain2d), intent(in) :: fv_domain
logical, intent(in) :: warm_start
!--- local variables
integer :: i, j, k, ix, lsoil, num, nb, i_start, j_start, i_end, j_end
integer :: isc, iec, jsc, jec, npz, nx, ny
integer :: id_restart
integer :: nvar_o2, nvar_s2m, nvar_s2o, nvar_s3
integer :: nvar_oro_ls_ss
integer :: nvar_s2r, nvar_s2mp, nvar_s3mp, isnow
real(kind=kind_phys), pointer, dimension(:,:) :: var2_p => NULL()
real(kind=kind_phys), pointer, dimension(:,:,:) :: var3_p => NULL()
real(kind=kind_phys), pointer, dimension(:,:,:) :: var3_p1 => NULL()
real(kind=kind_phys), pointer, dimension(:,:,:) :: var3_p2 => NULL()
real(kind=kind_phys), pointer, dimension(:,:,:) :: var3_p3 => NULL()
!--- local variables for sncovr calculation
integer :: vegtyp
logical :: mand
real(kind=kind_phys) :: rsnow, tem, tem1
nvar_o2 = 19
nvar_oro_ls_ss = 10
nvar_s2o = 18
if (Model%lsm == Model%lsm_ruc .and. warm_start) then
if(Model%rdlai) then
nvar_s2r = 24
else
nvar_s2r = 23
end if
nvar_s3 = 5
else
if(Model%rdlai) then
nvar_s2r = 1
else
nvar_s2r = 0
endif
nvar_s3 = 3
endif
if (Model%lsm == Model%lsm_noahmp) then
nvar_s2mp = 34 !mp 2D
nvar_s3mp = 5 !mp 3D
else
nvar_s2mp = 0 !mp 2D
nvar_s3mp = 0 !mp 3D
endif
isc = Atm_block%isc
iec = Atm_block%iec
jsc = Atm_block%jsc
jec = Atm_block%jec
npz = Atm_block%npz
nx = (iec - isc + 1)
ny = (jec - jsc + 1)
!--- OROGRAPHY FILE
if (.not. allocated(oro_name2)) then
!--- allocate the various containers needed for orography data
allocate(oro_name2(nvar_o2))
allocate(oro_var2(nx,ny,nvar_o2))
oro_var2 = -9999._kind_phys
oro_name2(1) = 'stddev' ! hprime(ix,1)
oro_name2(2) = 'convexity' ! hprime(ix,2)
oro_name2(3) = 'oa1' ! hprime(ix,3)
oro_name2(4) = 'oa2' ! hprime(ix,4)
oro_name2(5) = 'oa3' ! hprime(ix,5)
oro_name2(6) = 'oa4' ! hprime(ix,6)
oro_name2(7) = 'ol1' ! hprime(ix,7)
oro_name2(8) = 'ol2' ! hprime(ix,8)
oro_name2(9) = 'ol3' ! hprime(ix,9)
oro_name2(10) = 'ol4' ! hprime(ix,10)
oro_name2(11) = 'theta' ! hprime(ix,11)
oro_name2(12) = 'gamma' ! hprime(ix,12)
oro_name2(13) = 'sigma' ! hprime(ix,13)
oro_name2(14) = 'elvmax' ! hprime(ix,14)
oro_name2(15) = 'orog_filt' ! oro
oro_name2(16) = 'orog_raw' ! oro_uf
oro_name2(17) = 'land_frac' ! land fraction [0:1]
!--- variables below here are optional
oro_name2(18) = 'lake_frac' ! lake fraction [0:1]
oro_name2(19) = 'lake_depth' ! lake depth(m)
!--- register the 2D fields
do num = 1,nvar_o2
var2_p => oro_var2(:,:,num)
if (trim(oro_name2(num)) == 'lake_frac' .or. trim(oro_name2(num)) == 'lake_depth') then
id_restart = register_restart_field(Oro_restart, fn_oro, oro_name2(num), var2_p, domain=fv_domain, mandatory=.false.)
else
id_restart = register_restart_field(Oro_restart, fn_oro, oro_name2(num), var2_p, domain=fv_domain)
endif
enddo
nullify(var2_p)
endif
!--- read the orography restart/data
call mpp_error(NOTE,'reading topographic/orographic information from INPUT/oro_data.tile*.nc')
call restore_state(Oro_restart)
!--- copy data into GFS containers
!$omp parallel do default(shared) private(i, j, nb, ix)
do nb = 1, Atm_block%nblks
!--- 2D variables
do ix = 1, Atm_block%blksz(nb)
i = Atm_block%index(nb)%ii(ix) - isc + 1
j = Atm_block%index(nb)%jj(ix) - jsc + 1
!--- stddev
! Sfcprop(nb)%hprim(ix) = oro_var2(i,j,1)
!--- hprime(1:14)
Sfcprop(nb)%hprime(ix,1) = oro_var2(i,j,1)
Sfcprop(nb)%hprime(ix,2) = oro_var2(i,j,2)
Sfcprop(nb)%hprime(ix,3) = oro_var2(i,j,3)
Sfcprop(nb)%hprime(ix,4) = oro_var2(i,j,4)
Sfcprop(nb)%hprime(ix,5) = oro_var2(i,j,5)
Sfcprop(nb)%hprime(ix,6) = oro_var2(i,j,6)
Sfcprop(nb)%hprime(ix,7) = oro_var2(i,j,7)
Sfcprop(nb)%hprime(ix,8) = oro_var2(i,j,8)
Sfcprop(nb)%hprime(ix,9) = oro_var2(i,j,9)
Sfcprop(nb)%hprime(ix,10) = oro_var2(i,j,10)
Sfcprop(nb)%hprime(ix,11) = oro_var2(i,j,11)
Sfcprop(nb)%hprime(ix,12) = oro_var2(i,j,12)
Sfcprop(nb)%hprime(ix,13) = oro_var2(i,j,13)
Sfcprop(nb)%hprime(ix,14) = oro_var2(i,j,14)
!--- oro
Sfcprop(nb)%oro(ix) = oro_var2(i,j,15)
!--- oro_uf
Sfcprop(nb)%oro_uf(ix) = oro_var2(i,j,16)
Sfcprop(nb)%landfrac(ix) = -9999.0
Sfcprop(nb)%lakefrac(ix) = -9999.0
Sfcprop(nb)%landfrac(ix) = oro_var2(i,j,17) !land frac [0:1]
Sfcprop(nb)%lakefrac(ix) = oro_var2(i,j,18) !lake frac [0:1]
Sfcprop(nb)%lakedepth(ix) = oro_var2(i,j,19) !lake depth [m] !YWu
enddo
enddo
nvar_s2m = 39
if (Model%cplwav) then
nvar_s2m = nvar_s2m + 1
endif
!--- deallocate containers and free restart container
deallocate(oro_name2, oro_var2)
call free_restart_type(Oro_restart)
!--- Modify/read-in additional orographic static fields for GSL drag suite
if (Model%gwd_opt==3 .or. Model%gwd_opt==33 .or. &
Model%gwd_opt==2 .or. Model%gwd_opt==22 ) then
if (.not. allocated(oro_ls_ss_name)) then
!--- allocate the various containers needed for orography data
allocate(oro_ls_ss_name(nvar_oro_ls_ss))
allocate(oro_ls_var(nx,ny,nvar_oro_ls_ss))
allocate(oro_ss_var(nx,ny,nvar_oro_ls_ss))
oro_ls_ss_name(1) = 'stddev'
oro_ls_ss_name(2) = 'convexity'
oro_ls_ss_name(3) = 'oa1'
oro_ls_ss_name(4) = 'oa2'
oro_ls_ss_name(5) = 'oa3'
oro_ls_ss_name(6) = 'oa4'
oro_ls_ss_name(7) = 'ol1'
oro_ls_ss_name(8) = 'ol2'
oro_ls_ss_name(9) = 'ol3'
oro_ls_ss_name(10) = 'ol4'
!--- register the 2D fields
do num = 1,nvar_oro_ls_ss
var2_p => oro_ls_var(:,:,num)
id_restart = register_restart_field(Oro_ls_restart, fn_oro_ls, &
oro_ls_ss_name(num), var2_p, domain=fv_domain)
enddo
nullify(var2_p)
do num = 1,nvar_oro_ls_ss
var2_p => oro_ss_var(:,:,num)
id_restart = register_restart_field(Oro_ss_restart, fn_oro_ss, &
oro_ls_ss_name(num), var2_p, domain=fv_domain)
enddo
nullify(var2_p)
endif
!--- read new GSL created orography restart/data
call mpp_error(NOTE,'reading topographic/orographic information from &
&INPUT/oro_data_ls.tile*.nc')
call restore_state(Oro_ls_restart)
call mpp_error(NOTE,'reading topographic/orographic information from &
&INPUT/oro_data_ss.tile*.nc')
call restore_state(Oro_ss_restart)
do nb = 1, Atm_block%nblks
!--- 2D variables
do ix = 1, Atm_block%blksz(nb)
i = Atm_block%index(nb)%ii(ix) - isc + 1
j = Atm_block%index(nb)%jj(ix) - jsc + 1
! Replace hprime(1:10) with GSL oro stat data only when using GSL
! drag suite with large scale GWD and blocking as part of unified drag
! suite. Otherwise, original oro stat data is used.
if ( (Model%gwd_opt==3 .or. Model%gwd_opt==33) .or. &
( (Model%gwd_opt==2 .or. Model%gwd_opt==22) .and. &
Model%do_gsl_drag_ls_bl ) ) then
!--- assign hprime(1:10) and hprime(15:24) with new oro stat data
Sfcprop(nb)%hprime(ix,1) = oro_ls_var(i,j,1)
Sfcprop(nb)%hprime(ix,2) = oro_ls_var(i,j,2)
Sfcprop(nb)%hprime(ix,3) = oro_ls_var(i,j,3)
Sfcprop(nb)%hprime(ix,4) = oro_ls_var(i,j,4)
Sfcprop(nb)%hprime(ix,5) = oro_ls_var(i,j,5)
Sfcprop(nb)%hprime(ix,6) = oro_ls_var(i,j,6)
Sfcprop(nb)%hprime(ix,7) = oro_ls_var(i,j,7)
Sfcprop(nb)%hprime(ix,8) = oro_ls_var(i,j,8)
Sfcprop(nb)%hprime(ix,9) = oro_ls_var(i,j,9)
Sfcprop(nb)%hprime(ix,10) = oro_ls_var(i,j,10)
endif
Sfcprop(nb)%hprime(ix,15) = oro_ss_var(i,j,1)
Sfcprop(nb)%hprime(ix,16) = oro_ss_var(i,j,2)
Sfcprop(nb)%hprime(ix,17) = oro_ss_var(i,j,3)
Sfcprop(nb)%hprime(ix,18) = oro_ss_var(i,j,4)
Sfcprop(nb)%hprime(ix,19) = oro_ss_var(i,j,5)
Sfcprop(nb)%hprime(ix,20) = oro_ss_var(i,j,6)
Sfcprop(nb)%hprime(ix,21) = oro_ss_var(i,j,7)
Sfcprop(nb)%hprime(ix,22) = oro_ss_var(i,j,8)
Sfcprop(nb)%hprime(ix,23) = oro_ss_var(i,j,9)
Sfcprop(nb)%hprime(ix,24) = oro_ss_var(i,j,10)
enddo
enddo
call free_restart_type(Oro_ls_restart)
call free_restart_type(Oro_ss_restart)
endif
!--- SURFACE FILE
if (.not. allocated(sfc_name2)) then
!--- allocate the various containers needed for restarts
allocate(sfc_name2(nvar_s2m+nvar_s2o+nvar_s2mp+nvar_s2r))
allocate(sfc_name3(0:nvar_s3+nvar_s3mp))
allocate(sfc_var2(nx,ny,nvar_s2m+nvar_s2o+nvar_s2mp+nvar_s2r),sfc_var3ice(nx,ny,Model%kice))
if (Model%lsm == Model%lsm_noah .or. Model%lsm == Model%lsm_noahmp .or. Model%lsm == Model%lsm_noah_wrfv4 .or. (.not.warm_start)) then
allocate(sfc_var3(nx,ny,Model%lsoil,nvar_s3))
else if (Model%lsm == Model%lsm_ruc) then
allocate(sfc_var3(nx,ny,Model%lsoil_lsm,nvar_s3))
end if
sfc_var2 = -9999.0_r8
sfc_var3 = -9999.0_r8
sfc_var3ice= -9999.0_r8
!
if (Model%lsm == Model%lsm_noahmp) then
allocate(sfc_var3sn(nx,ny,-2:0,4:6))
allocate(sfc_var3eq(nx,ny,1:4,7:7))
allocate(sfc_var3zn(nx,ny,-2:4,8:8))
sfc_var3sn = -9999.0_r8
sfc_var3eq = -9999.0_r8
sfc_var3zn = -9999.0_r8
end if
!--- names of the 2D variables to save
sfc_name2(1) = 'slmsk'
sfc_name2(2) = 'tsea' !tsfc
sfc_name2(3) = 'sheleg' !weasd
sfc_name2(4) = 'tg3'
sfc_name2(5) = 'zorl'
sfc_name2(6) = 'alvsf'
sfc_name2(7) = 'alvwf'
sfc_name2(8) = 'alnsf'
sfc_name2(9) = 'alnwf'
sfc_name2(10) = 'facsf'
sfc_name2(11) = 'facwf'
sfc_name2(12) = 'vfrac'
sfc_name2(13) = 'canopy'
sfc_name2(14) = 'f10m'
sfc_name2(15) = 't2m'
sfc_name2(16) = 'q2m'
sfc_name2(17) = 'vtype'
sfc_name2(18) = 'stype'
sfc_name2(19) = 'uustar'
sfc_name2(20) = 'ffmm'
sfc_name2(21) = 'ffhh'
sfc_name2(22) = 'hice'
sfc_name2(23) = 'fice'
sfc_name2(24) = 'tisfc'
sfc_name2(25) = 'tprcp'
sfc_name2(26) = 'srflag'
sfc_name2(27) = 'snwdph' !snowd
sfc_name2(28) = 'shdmin'
sfc_name2(29) = 'shdmax'
sfc_name2(30) = 'slope'
sfc_name2(31) = 'snoalb'
!--- variables below here are optional
sfc_name2(32) = 'sncovr'
sfc_name2(33) = 'tsfcl' !temp on land portion of a cell
sfc_name2(34) = 'zorll' !zorl on land portion of a cell
sfc_name2(35) = 'zorli' !zorl on ice portion of a cell
sfc_name2(36) = 'snodl' !snowd on land portion of a cell
sfc_name2(37) = 'tsfc' !tsfc composite
sfc_name2(38) = 'zorl' !zorl composite
sfc_name2(39) = 'weasdl'!weasd on land portion of a cell
if(Model%cplwav) then
sfc_name2(nvar_s2m) = 'zorlwav' !zorl on land portion of a cell
endif
!--- NSSTM inputs only needed when (nstf_name(1) > 0) .and. (nstf_name(2)) == 0)
sfc_name2(nvar_s2m+1) = 'tref'
sfc_name2(nvar_s2m+2) = 'z_c'
sfc_name2(nvar_s2m+3) = 'c_0'
sfc_name2(nvar_s2m+4) = 'c_d'
sfc_name2(nvar_s2m+5) = 'w_0'
sfc_name2(nvar_s2m+6) = 'w_d'
sfc_name2(nvar_s2m+7) = 'xt'
sfc_name2(nvar_s2m+8) = 'xs'
sfc_name2(nvar_s2m+9) = 'xu'
sfc_name2(nvar_s2m+10) = 'xv'
sfc_name2(nvar_s2m+11) = 'xz'
sfc_name2(nvar_s2m+12) = 'zm'
sfc_name2(nvar_s2m+13) = 'xtts'
sfc_name2(nvar_s2m+14) = 'xzts'
sfc_name2(nvar_s2m+15) = 'd_conv'
sfc_name2(nvar_s2m+16) = 'ifd'
sfc_name2(nvar_s2m+17) = 'dt_cool'
sfc_name2(nvar_s2m+18) = 'qrain'
!
! Only needed when Noah MP LSM is used - 34 2D
!
if (Model%lsm == Model%lsm_noahmp) then
sfc_name2(nvar_s2m+19) = 'snowxy'
sfc_name2(nvar_s2m+20) = 'tvxy'
sfc_name2(nvar_s2m+21) = 'tgxy'
sfc_name2(nvar_s2m+22) = 'canicexy'
sfc_name2(nvar_s2m+23) = 'canliqxy'
sfc_name2(nvar_s2m+24) = 'eahxy'
sfc_name2(nvar_s2m+25) = 'tahxy'
sfc_name2(nvar_s2m+26) = 'cmxy'
sfc_name2(nvar_s2m+27) = 'chxy'
sfc_name2(nvar_s2m+28) = 'fwetxy'
sfc_name2(nvar_s2m+29) = 'sneqvoxy'
sfc_name2(nvar_s2m+30) = 'alboldxy'
sfc_name2(nvar_s2m+31) = 'qsnowxy'
sfc_name2(nvar_s2m+32) = 'wslakexy'
sfc_name2(nvar_s2m+33) = 'zwtxy'
sfc_name2(nvar_s2m+34) = 'waxy'
sfc_name2(nvar_s2m+35) = 'wtxy'
sfc_name2(nvar_s2m+36) = 'lfmassxy'
sfc_name2(nvar_s2m+37) = 'rtmassxy'
sfc_name2(nvar_s2m+38) = 'stmassxy'
sfc_name2(nvar_s2m+39) = 'woodxy'
sfc_name2(nvar_s2m+40) = 'stblcpxy'
sfc_name2(nvar_s2m+41) = 'fastcpxy'
sfc_name2(nvar_s2m+42) = 'xsaixy'
sfc_name2(nvar_s2m+43) = 'xlaixy'
sfc_name2(nvar_s2m+44) = 'taussxy'
sfc_name2(nvar_s2m+45) = 'smcwtdxy'
sfc_name2(nvar_s2m+46) = 'deeprechxy'
sfc_name2(nvar_s2m+47) = 'rechxy'
sfc_name2(nvar_s2m+48) = 'albdvis_lnd'
sfc_name2(nvar_s2m+49) = 'albdnir_lnd'
sfc_name2(nvar_s2m+50) = 'albivis_lnd'
sfc_name2(nvar_s2m+51) = 'albinir_lnd'
sfc_name2(nvar_s2m+52) = 'emis_lnd'
else if (Model%lsm == Model%lsm_ruc .and. warm_start) then
sfc_name2(nvar_s2m+19) = 'wetness'
sfc_name2(nvar_s2m+20) = 'clw_surf_land'
sfc_name2(nvar_s2m+21) = 'clw_surf_ice'
sfc_name2(nvar_s2m+22) = 'qwv_surf_land'
sfc_name2(nvar_s2m+23) = 'qwv_surf_ice'
sfc_name2(nvar_s2m+24) = 'tsnow_land'
sfc_name2(nvar_s2m+25) = 'tsnow_ice'
sfc_name2(nvar_s2m+26) = 'snowfall_acc_land'
sfc_name2(nvar_s2m+27) = 'snowfall_acc_ice'
sfc_name2(nvar_s2m+28) = 'sncovr_ice'
sfc_name2(nvar_s2m+29) = 'albdvis_lnd'
sfc_name2(nvar_s2m+30) = 'albdnir_lnd'
sfc_name2(nvar_s2m+31) = 'albivis_lnd'
sfc_name2(nvar_s2m+32) = 'albinir_lnd'
sfc_name2(nvar_s2m+33) = 'sfalb_lnd'
sfc_name2(nvar_s2m+34) = 'sfalb_lnd_bck'
sfc_name2(nvar_s2m+35) = 'albdvis_ice'
sfc_name2(nvar_s2m+36) = 'albdnir_ice'
sfc_name2(nvar_s2m+37) = 'albivis_ice'
sfc_name2(nvar_s2m+38) = 'albinir_ice'
sfc_name2(nvar_s2m+39) = 'sfalb_ice'
sfc_name2(nvar_s2m+40) = 'emis_lnd'
sfc_name2(nvar_s2m+41) = 'emis_ice'
if (Model%rdlai) then
sfc_name2(nvar_s2m+42) = 'lai'
endif
else if (Model%lsm == Model%lsm_ruc .and. Model%rdlai) then
sfc_name2(nvar_s2m+19) = 'lai'
endif
!--- register the 2D fields
do num = 1,nvar_s2m
var2_p => sfc_var2(:,:,num)
if (trim(sfc_name2(num)) == 'sncovr'.or. trim(sfc_name2(num)) == 'tsfcl' .or. trim(sfc_name2(num)) == 'zorll' &
.or. trim(sfc_name2(num)) == 'zorli' .or. trim(sfc_name2(num)) == 'zorlwav' &
.or. trim(sfc_name2(num)) == 'snodl' .or. trim(sfc_name2(num)) == 'weasdl' &
.or. trim(sfc_name2(num)) == 'tsfc' .or. trim(sfc_name2(num)) == 'zorl') then
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=fv_domain, mandatory=.false.)
else
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=fv_domain)
endif
enddo
if (Model%nstf_name(1) > 0) then
mand = .false.
if (Model%nstf_name(2) == 0) mand = .true.
do num = nvar_s2m+1,nvar_s2m+nvar_s2o
var2_p => sfc_var2(:,:,num)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=fv_domain, mandatory=mand)
enddo
endif
if (Model%lsm == Model%lsm_ruc) then ! nvar_s2mp = 0
do num = nvar_s2m+nvar_s2o+1, nvar_s2m+nvar_s2o+nvar_s2r
var2_p => sfc_var2(:,:,num)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=fv_domain)
enddo
endif ! mp/ruc
! Noah MP register only necessary only lsm = 2, not necessary has values
if (nvar_s2mp > 0) then
mand = .false.
do num = nvar_s2m+nvar_s2o+1,nvar_s2m+nvar_s2o+nvar_s2mp
var2_p => sfc_var2(:,:,num)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name2(num), var2_p, domain=fv_domain, mandatory=mand)
enddo
endif ! noahmp
nullify(var2_p)
endif ! if not allocated
if (Model%lsm == Model%lsm_noah .or. Model%lsm == Model%lsm_noahmp .or. Model%lsm == Model%lsm_noah_wrfv4 .or. (.not.warm_start)) then
!--- names of the 3D variables to save
sfc_name3(1) = 'stc'
sfc_name3(2) = 'smc'
sfc_name3(3) = 'slc'
if (Model%lsm == Model%lsm_noahmp) then
sfc_name3(4) = 'snicexy'
sfc_name3(5) = 'snliqxy'
sfc_name3(6) = 'tsnoxy'
sfc_name3(7) = 'smoiseq'
sfc_name3(8) = 'zsnsoxy'
endif
else if (Model%lsm == Model%lsm_ruc) then
!--- names of the 2D variables to save
sfc_name3(1) = 'tslb'
sfc_name3(2) = 'smois'
sfc_name3(3) = 'sh2o'
sfc_name3(4) = 'smfr'
sfc_name3(5) = 'flfr'
endif
!--- register the 3D fields
sfc_name3(0) = 'tiice'
var3_p => sfc_var3ice(:,:,:)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name3(0), var3_p, domain=fv_domain, mandatory=.false.)
do num = 1,nvar_s3
var3_p => sfc_var3(:,:,:,num)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name3(num), var3_p, domain=fv_domain)
enddo
if (Model%lsm == Model%lsm_noahmp) then
mand = .false.
do num = nvar_s3+1,nvar_s3+3
var3_p1 => sfc_var3sn(:,:,:,num)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name3(num), var3_p1, domain=fv_domain,mandatory=mand)
enddo
var3_p2 => sfc_var3eq(:,:,:,7)
id_restart = register_restart_field(Sfc_restart, fn_srf, sfc_name3(7), var3_p2, domain=fv_domain,mandatory=mand)
var3_p3 => sfc_var3zn(:,:,:,8)
id_restart = register_restart_fIeld(Sfc_restart, fn_srf, sfc_name3(8), var3_p3, domain=fv_domain,mandatory=mand)
nullify(var3_p1)
nullify(var3_p2)
nullify(var3_p3)
endif !mp
nullify(var3_p)
!--- Noah MP define arbitrary value (number layers of snow) to indicate
!coldstart(sfcfile doesn't include noah mp fields) or not
if (Model%lsm == Model%lsm_noahmp) then
sfc_var2(1,1,nvar_s2m+19) = -66666.0_r8
endif
!--- read the surface restart/data
call mpp_error(NOTE,'reading surface properties data from INPUT/sfc_data.tile*.nc')
call restore_state(Sfc_restart)
! write(0,*)' stype read in min,max=',minval(sfc_var2(:,:,35)),maxval(sfc_var2(:,:,35)),' sfc_name2=',sfc_name2(35)
! write(0,*)' stype read in min,max=',minval(sfc_var2(:,:,18)),maxval(sfc_var2(:,:,18))
! write(0,*)' sfc_var2=',sfc_var2(:,:,12)
!--- place the data into the block GFS containers
!$omp parallel do default(shared) private(i, j, nb, ix, lsoil)
do nb = 1, Atm_block%nblks
do ix = 1, Atm_block%blksz(nb)
i = Atm_block%index(nb)%ii(ix) - isc + 1