-
Notifications
You must be signed in to change notification settings - Fork 318
/
mksurfdat.F90
1589 lines (1326 loc) · 68.7 KB
/
mksurfdat.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
program mksurfdat
!-----------------------------------------------------------------------
!BOP
!
! !PROGRAM: mksurfdat
!
! !DESCRIPTION:
! Creates land model surface dataset from original "raw" data files.
! Surface dataset contains model grid, pfts, inland water, glacier,
! soil texture, soil color, LAI and SAI, urban fraction, and urban
! parameters.
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8, r4 => shr_kind_r4
use fileutils , only : opnfil, getavu
use mklaiMod , only : mklai
use mkpctPftTypeMod , only : pct_pft_type, get_pct_p2l_array, get_pct_l2g_array, update_max_array
use mkpftConstantsMod , only : natpft_lb, natpft_ub, cft_lb, cft_ub, num_cft
use mkpftMod , only : pft_idx, pft_frc, mkpft, mkpftInit, mkpft_parse_oride
use mksoilMod , only : soil_sand, soil_clay, mksoiltex, mksoilInit, &
soil_color, mksoilcol, mkorganic, &
soil_fmax, mkfmax
use mkvocefMod , only : mkvocef
use mklanwatMod , only : mklakwat, mkwetlnd, mklakparams
use mkglacierregionMod , only : mkglacierregion
use mkglcmecMod , only : nglcec, mkglcmec, mkglcmecInit, mkglacier
use mkharvestMod , only : mkharvest, mkharvest_init, mkharvest_fieldname
use mkharvestMod , only : mkharvest_numtypes, mkharvest_parse_oride
use mkharvestMod , only : harvestDataType
use mkurbanparCommonMod, only : mkelev
use mkurbanparMod , only : mkurbanInit, mkurban, mkurbanpar, numurbl
use mkutilsMod , only : normalize_classes_by_gcell
use mkfileMod , only : mkfile
use mkvarpar , only : nlevsoi, elev_thresh
use mkvarctl
use nanMod , only : nan, bigint
use mkncdio , only : check_ret, ncd_put_time_slice
use mkdomainMod , only : domain_type, domain_read_map, domain_read, &
domain_write
use mkgdpMod , only : mkgdp
use mkpeatMod , only : mkpeat
use mksoildepthMod , only : mksoildepth
use mkagfirepkmonthMod , only : mkagfirepkmon
use mktopostatsMod , only : mktopostats
use mkVICparamsMod , only : mkVICparams
use mkCH4inversionMod , only : mkCH4inversion
!
! !ARGUMENTS:
implicit none
include 'netcdf.inc'
!
! !REVISION HISTORY:
! Authors: Gordon Bonan, Sam Levis and Mariana Vertenstein
! Revised: Nan Rosenbloom to add fmax processing.
! 3/18/08: David Lawrence added organic matter processing
! 1/22/09: Keith Oleson added urban parameter processing
! 2/11/13: Sam Levis added abm, peat, and gdp processing for new fire model
!
!
! !LOCAL VARIABLES:
!EOP
integer :: nsoicol ! number of model color classes
integer :: k,m,n ! indices
integer :: ni,nj,ns_o ! indices
integer :: ier ! error status
integer :: ndiag,nfdyn ! unit numbers
integer :: ncid ! netCDF id
integer :: omode ! netCDF output mode
integer :: varid ! netCDF variable id
integer :: ret ! netCDF return status
integer :: ntim ! time sample for dynamic land use
integer :: year ! year for dynamic land use
integer :: year2 ! year for dynamic land use for harvest file
logical :: all_veg ! if gridcell will be 100% vegetated land-cover
real(r8) :: suma ! sum for error check
character(len=256) :: fgrddat ! grid data file
character(len=256) :: fsurdat ! output surface data file name (if blank, do not output a surface dataset)
character(len=256) :: fsurlog ! output surface log file name
character(len=256) :: fdyndat ! dynamic landuse data file name
character(len=256) :: fname ! generic filename
character(len=256) :: fhrvname ! generic harvest filename
character(len=256) :: string ! string read in
integer :: t1 ! timer
real(r8),parameter :: p5 = 0.5_r8 ! constant
real(r8),parameter :: p25 = 0.25_r8 ! constant
real(r8), allocatable :: landfrac_pft(:) ! PFT data: % land per gridcell
real(r8), allocatable :: pctlnd_pft(:) ! PFT data: % of gridcell for PFTs
real(r8), allocatable :: pctlnd_pft_dyn(:) ! PFT data: % of gridcell for dyn landuse PFTs
integer , allocatable :: pftdata_mask(:) ! mask indicating real or fake land type
type(pct_pft_type), allocatable :: pctnatpft(:) ! % of grid cell that is nat veg, and breakdown into PFTs
type(pct_pft_type), allocatable :: pctnatpft_max(:) ! % of grid cell maximum PFTs of the time series
type(pct_pft_type), allocatable :: pctcft(:) ! % of grid cell that is crop, and breakdown into CFTs
type(pct_pft_type), allocatable :: pctcft_max(:) ! % of grid cell maximum CFTs of the time series
type(pct_pft_type), allocatable :: pctcft_saved(:) ! version of pctcft saved from the initial call to mkpft
real(r8), pointer :: harvest1D(:) ! harvest 1D data: normalized harvesting
real(r8), pointer :: harvest2D(:,:) ! harvest 1D data: normalized harvesting
real(r8), allocatable :: pctgla(:) ! percent of grid cell that is glacier
real(r8), allocatable :: pctglc_gic(:) ! percent of grid cell that is gic (% of glc landunit)
real(r8), allocatable :: pctglc_icesheet(:) ! percent of grid cell that is ice sheet (% of glc landunit)
real(r8), allocatable :: pctglcmec(:,:) ! glacier_mec pct coverage in each class (% of landunit)
real(r8), allocatable :: topoglcmec(:,:) ! glacier_mec sfc elevation in each gridcell and class
real(r8), allocatable :: pctglcmec_gic(:,:) ! GIC pct coverage in each class (% of landunit)
real(r8), allocatable :: pctglcmec_icesheet(:,:) ! icesheet pct coverage in each class (% of landunit)
real(r8), allocatable :: elevclass(:) ! glacier_mec elevation classes
integer, allocatable :: glacier_region(:) ! glacier region ID
real(r8), allocatable :: pctlak(:) ! percent of grid cell that is lake
real(r8), allocatable :: pctwet(:) ! percent of grid cell that is wetland
real(r8), allocatable :: pcturb(:) ! percent of grid cell that is urbanized (total across all urban classes)
real(r8), allocatable :: urbn_classes(:,:) ! percent cover of each urban class, as % of total urban area
real(r8), allocatable :: urbn_classes_g(:,:)! percent cover of each urban class, as % of grid cell
real(r8), allocatable :: elev(:) ! glc elevation (m)
real(r8), allocatable :: fmax(:) ! fractional saturated area
integer , allocatable :: soicol(:) ! soil color
real(r8), allocatable :: pctsand(:,:) ! soil texture: percent sand
real(r8), allocatable :: pctclay(:,:) ! soil texture: percent clay
real(r8), allocatable :: ef1_btr(:) ! Isoprene emission factor for broadleaf
real(r8), allocatable :: ef1_fet(:) ! Isoprene emission factor for fine/everg
real(r8), allocatable :: ef1_fdt(:) ! Isoprene emission factor for fine/dec
real(r8), allocatable :: ef1_shr(:) ! Isoprene emission factor for shrubs
real(r8), allocatable :: ef1_grs(:) ! Isoprene emission factor for grasses
real(r8), allocatable :: ef1_crp(:) ! Isoprene emission factor for crops
real(r8), allocatable :: organic(:,:) ! organic matter density (kg/m3)
real(r8), allocatable :: gdp(:) ! GDP (x1000 1995 US$/capita)
real(r8), allocatable :: fpeat(:) ! peatland fraction of gridcell
real(r8), allocatable :: soildepth(:) ! soil depth (m)
integer , allocatable :: agfirepkmon(:) ! agricultural fire peak month
integer , allocatable :: urban_region(:) ! urban region ID
real(r8), allocatable :: topo_stddev(:) ! standard deviation of elevation (m)
real(r8), allocatable :: slope(:) ! topographic slope (degrees)
real(r8), allocatable :: vic_binfl(:) ! VIC b parameter (unitless)
real(r8), allocatable :: vic_ws(:) ! VIC Ws parameter (unitless)
real(r8), allocatable :: vic_dsmax(:) ! VIC Dsmax parameter (mm/day)
real(r8), allocatable :: vic_ds(:) ! VIC Ds parameter (unitless)
real(r8), allocatable :: lakedepth(:) ! lake depth (m)
real(r8), allocatable :: f0(:) ! max fractional inundated area (unitless)
real(r8), allocatable :: p3(:) ! coefficient for qflx_surf_lag for finundated (s/mm)
real(r8), allocatable :: zwt0(:) ! decay factor for finundated (m)
real(r8) :: std_elev = -999.99_r8 ! Standard deviation of elevation (m) to use for entire grid
integer, allocatable :: harvind1D(:) ! Indices of 1D harvest fields
integer, allocatable :: harvind2D(:) ! Indices of 2D harvest fields
! NOTE(bja, 2015-01) added to work around a ?bug? causing 1x1_urbanc_alpha to abort. See
!/glade/p/cesm/cseg/inputdata/lnd/clm2/surfdata_map/README_c141219
logical :: urban_skip_abort_on_invalid_data_check
type(domain_type) :: ldomain
character(len=32) :: subname = 'mksrfdat' ! program name
type(harvestDataType) :: harvdata
namelist /clmexp/ &
mksrf_fgrid, &
mksrf_gridtype, &
mksrf_fvegtyp, &
mksrf_fhrvtyp, &
mksrf_fsoitex, &
mksrf_forganic, &
mksrf_fsoicol, &
mksrf_fvocef, &
mksrf_flakwat, &
mksrf_fwetlnd, &
mksrf_fglacier, &
mksrf_fglacierregion, &
mksrf_furbtopo, &
mksrf_fmax, &
mksrf_furban, &
mksrf_flai, &
mksrf_fdynuse, &
mksrf_fgdp, &
mksrf_fpeat, &
mksrf_fsoildepth, &
mksrf_fabm, &
mksrf_ftopostats, &
mksrf_fvic, &
mksrf_fch4, &
nglcec, &
numpft, &
soil_color, &
soil_sand, &
soil_fmax, &
soil_clay, &
pft_idx, &
pft_frc, &
all_urban, &
no_inlandwet, &
map_fpft, &
map_flakwat, &
map_fwetlnd, &
map_fglacier, &
map_fglacierregion, &
map_fsoitex, &
map_fsoicol, &
map_furban, &
map_furbtopo, &
map_fmax, &
map_forganic, &
map_fvocef, &
map_flai, &
map_fharvest, &
map_fgdp, &
map_fpeat, &
map_fsoildepth, &
map_fabm, &
map_ftopostats, &
map_fvic, &
map_fch4, &
gitdescribe, &
outnc_large_files, &
outnc_double, &
outnc_dims, &
fsurdat, &
fdyndat, &
fsurlog, &
std_elev, &
urban_skip_abort_on_invalid_data_check
!-----------------------------------------------------------------------
! ======================================================================
! Read input namelist
! ======================================
! Must specify settings for the output grid:
! ======================================
! mksrf_fgrid -- Grid dataset
! ======================================
! Must specify settings for input high resolution datafiles
! ======================================
! mksrf_fglacier - Glacier dataset
! mksrf_fglacierregion - Glacier region ID dataset
! mksrf_flai ----- Leaf Area Index dataset
! mksrf_flakwat -- Lake water dataset
! mksrf_fwetlnd -- Wetland water dataset
! mksrf_forganic - Organic soil carbon dataset
! mksrf_fmax ----- Max fractional saturated area dataset
! mksrf_fsoicol -- Soil color dataset
! mksrf_fsoitex -- Soil texture dataset
! mksrf_furbtopo-- Topography dataset (for limiting urban areas)
! mksrf_furban --- Urban dataset
! mksrf_fvegtyp -- PFT vegetation type dataset
! mksrf_fhrvtyp -- harvest type dataset
! mksrf_fvocef -- Volatile Organic Compund Emission Factor dataset
! mksrf_fgdp ----- GDP dataset
! mksrf_fpeat ---- Peatland dataset
! mksrf_fsoildepth Soil depth dataset
! mksrf_fabm ----- Agricultural fire peak month dataset
! mksrf_ftopostats Topography statistics dataset
! mksrf_fvic ----- VIC parameters dataset
! mksrf_fch4 ----- inversion-derived CH4 parameters dataset
! ======================================
! Must specify mapping file for the different datafiles above
! ======================================
! map_fpft -------- Mapping for mksrf_fvegtyp
! map_flakwat ----- Mapping for mksrf_flakwat
! map_fwetlnd ----- Mapping for mksrf_fwetlnd
! map_fglacier ---- Mapping for mksrf_fglacier
! map_fglacierregion - Mapping for mksrf_fglacierregion
! map_fsoitex ----- Mapping for mksrf_fsoitex
! map_fsoicol ----- Mapping for mksrf_fsoicol
! map_furban ------ Mapping for mksrf_furban
! map_furbtopo ---- Mapping for mksrf_furbtopo
! map_fmax -------- Mapping for mksrf_fmax
! map_forganic ---- Mapping for mksrf_forganic
! map_fvocef ------ Mapping for mksrf_fvocef
! map_flai -------- Mapping for mksrf_flai
! map_fharvest ---- Mapping for mksrf_flai harvesting
! map_fgdp -------- Mapping for mksrf_fgdp
! map_fpeat ------- Mapping for mksrf_fpeat
! map_fsoildepth -- Mapping for mksrf_fsoildepth
! map_fabm -------- Mapping for mksrf_fabm
! map_ftopostats -- Mapping for mksrf_ftopostats
! map_fvic -------- Mapping for mksrf_fvic
! map_fch4 -------- Mapping for mksrf_fch4
! ======================================
! Optionally specify setting for:
! ======================================
! mksrf_fdynuse ----- ASCII text file that lists each year of pft files to use
! mksrf_gridtype ---- Type of grid (default is 'global')
! outnc_double ------ If output should be in double precision
! outnc_large_files - If output should be in NetCDF large file format
! nglcec ------------ If you want to change the number of Glacier elevation classes
! gitdescribe ------- Description of this version from git
! ======================================
! Optional settings to change values for entire area
! ======================================
! all_urban --------- If entire area is urban
! no_inlandwet ------ If wetland should be set to 0% over land
! soil_color -------- If you want to change the soil_color to this value everywhere
! soil_clay --------- If you want to change the soil_clay % to this value everywhere
! soil_fmax --------- If you want to change the soil_fmax to this value everywhere
! soil_sand --------- If you want to change the soil_sand % to this value everywhere
! pft_idx ----------- If you want to change to 100% veg covered with given PFT indices
! pft_frc ----------- Fractions that correspond to the pft_idx above
! ==================
! numpft (if different than default of 16)
! ======================================
! Optional settings to work around urban bug?
! ======================================
! urban_skip_abort_on_invalid_data_check
! ======================================================================
write(6,*) 'Attempting to initialize control settings .....'
mksrf_gridtype = 'global'
outnc_large_files = .false.
outnc_double = .true.
all_urban = .false.
no_inlandwet = .true.
! default value for bug work around
urban_skip_abort_on_invalid_data_check = .false.
read(5, clmexp, iostat=ier)
if (ier /= 0) then
write(6,*)'error: namelist input resulted in error code ',ier
call abort()
endif
write (6,*) 'Attempting to create surface boundary data .....'
write (6,'(72a1)') ("-",n=1,60)
! ----------------------------------------------------------------------
! Error check namelist input
! ----------------------------------------------------------------------
if (urban_skip_abort_on_invalid_data_check) then
write(6, *) "WARNING: aborting on invalid data check in urban has been disabled!"
write(6, *) "WARNING: urban data may be invalid!"
end if
if (mksrf_fgrid /= ' ')then
fgrddat = mksrf_fgrid
write(6,*)'mksrf_fgrid = ',mksrf_fgrid
else
write (6,*)'must specify mksrf_fgrid'
call abort()
endif
if (trim(mksrf_gridtype) == 'global' .or. &
trim(mksrf_gridtype) == 'regional') then
write(6,*)'mksrf_gridtype = ',trim(mksrf_gridtype)
else
write(6,*)'mksrf_gridtype = ',trim(mksrf_gridtype)
write (6,*)'illegal mksrf_gridtype, must be global or regional '
call abort()
endif
if ( outnc_large_files )then
write(6,*)'Output file in NetCDF 64-bit large_files format'
end if
if ( outnc_double )then
write(6,*)'Output ALL data in file as 64-bit'
end if
if ( all_urban )then
write(6,*) 'Output ALL data in file as 100% urban'
end if
if ( no_inlandwet )then
write(6,*) 'Set wetland to 0% over land'
end if
if (nglcec <= 0) then
write(6,*) 'nglcec must be at least 1'
call abort()
end if
!
! Call module initialization routines
!
call mksoilInit( )
call mkpftInit( all_urban, all_veg )
allocate ( elevclass(nglcec+1) )
call mkglcmecInit (elevclass)
call mkurbanInit (mksrf_furban)
if ( all_veg )then
write(6,*) 'Output ALL data in file as 100% vegetated'
end if
! ----------------------------------------------------------------------
! Determine land model grid, fractional land and land mask
! ----------------------------------------------------------------------
write(6,*)'calling domain_read'
if ( .not. domain_read_map(ldomain, fgrddat) )then
call domain_read(ldomain, fgrddat)
end if
write(6,*)'finished domain_read'
! Invalidate mask and frac for ldomain
!ldomain%mask = bigint
!ldomain%frac = nan
! Determine if will have 1d output
if (ldomain%ni /= -9999 .and. ldomain%nj /= -9999) then
write(6,*)'fsurdat is 2d lat/lon grid'
write(6,*)'nlon= ',ldomain%ni,' nlat= ',ldomain%nj
if (outnc_dims == 1) then
write(6,*)' writing output file in 1d gridcell format'
end if
else
write(6,*)'fsurdat is 1d gridcell grid'
outnc_dims = 1
end if
outnc_1d = .false.
if ((ldomain%ni == -9999 .and. ldomain%nj == -9999) .or. outnc_dims==1) then
outnc_1d = .true.
write(6,*)'output file will be 1d'
end if
! ----------------------------------------------------------------------
! Allocate and initialize dynamic memory
! ----------------------------------------------------------------------
ns_o = ldomain%ns
allocate ( landfrac_pft(ns_o) , &
pctlnd_pft(ns_o) , &
pftdata_mask(ns_o) , &
pctnatpft(ns_o) , &
pctnatpft_max(ns_o) , &
pctcft(ns_o) , &
pctcft_max(ns_o) , &
pctcft_saved(ns_o) , &
pctgla(ns_o) , &
pctlak(ns_o) , &
pctwet(ns_o) , &
pcturb(ns_o) , &
urban_region(ns_o) , &
urbn_classes(ns_o,numurbl) , &
urbn_classes_g(ns_o,numurbl) , &
pctsand(ns_o,nlevsoi) , &
pctclay(ns_o,nlevsoi) , &
soicol(ns_o) , &
gdp(ns_o) , &
fpeat(ns_o) , &
soildepth(ns_o) , &
agfirepkmon(ns_o) , &
topo_stddev(ns_o) , &
slope(ns_o) , &
vic_binfl(ns_o) , &
vic_ws(ns_o) , &
vic_dsmax(ns_o) , &
vic_ds(ns_o) , &
lakedepth(ns_o) , &
f0(ns_o) , &
p3(ns_o) , &
zwt0(ns_o) , &
glacier_region(ns_o) )
landfrac_pft(:) = spval
pctlnd_pft(:) = spval
pftdata_mask(:) = -999
pctgla(:) = spval
pctlak(:) = spval
pctwet(:) = spval
pcturb(:) = spval
urban_region(:) = -999
urbn_classes(:,:) = spval
urbn_classes_g(:,:) = spval
pctsand(:,:) = spval
pctclay(:,:) = spval
soicol(:) = -999
gdp(:) = spval
fpeat(:) = spval
soildepth(:) = spval
agfirepkmon(:) = -999
topo_stddev(:) = spval
slope(:) = spval
vic_binfl(:) = spval
vic_ws(:) = spval
vic_dsmax(:) = spval
vic_ds(:) = spval
lakedepth(:) = spval
f0(:) = spval
p3(:) = spval
zwt0(:) = spval
glacier_region(:) = -999
! ----------------------------------------------------------------------
! Open diagnostic output log file
! ----------------------------------------------------------------------
if (fsurlog == ' ') then
write(6,*)' must specify fsurlog in namelist'
stop
else
ndiag = getavu(); call opnfil (fsurlog, ndiag, 'f')
end if
if (urban_skip_abort_on_invalid_data_check) then
write(ndiag, *) "WARNING: aborting on invalid data check in urban has been disabled!"
write(ndiag, *) "WARNING: urban data may be invalid!"
end if
if (mksrf_fgrid /= ' ')then
write (ndiag,*)'using fractional land data from file= ', &
trim(mksrf_fgrid),' to create the surface dataset'
endif
if (trim(mksrf_gridtype) == 'global' .or. &
trim(mksrf_gridtype) == 'regional') then
write(6,*)'mksrf_gridtype = ',trim(mksrf_gridtype)
endif
write(ndiag,*) 'PFTs from: ',trim(mksrf_fvegtyp)
write(ndiag,*) 'harvest from: ',trim(mksrf_fhrvtyp)
write(ndiag,*) 'fmax from: ',trim(mksrf_fmax)
write(ndiag,*) 'glaciers from: ',trim(mksrf_fglacier)
write(ndiag,*) ' with: ', nglcec, ' glacier elevation classes'
write(ndiag,*) 'glacier region ID from: ',trim(mksrf_fglacierregion)
write(ndiag,*) 'urban topography from: ',trim(mksrf_furbtopo)
write(ndiag,*) 'urban from: ',trim(mksrf_furban)
write(ndiag,*) 'inland lake from: ',trim(mksrf_flakwat)
write(ndiag,*) 'inland wetland from: ',trim(mksrf_fwetlnd)
write(ndiag,*) 'soil texture from: ',trim(mksrf_fsoitex)
write(ndiag,*) 'soil organic from: ',trim(mksrf_forganic)
write(ndiag,*) 'soil color from: ',trim(mksrf_fsoicol)
write(ndiag,*) 'VOC emission factors from: ',trim(mksrf_fvocef)
write(ndiag,*) 'gdp from: ',trim(mksrf_fgdp)
write(ndiag,*) 'peat from: ',trim(mksrf_fpeat)
write(ndiag,*) 'soil depth from: ',trim(mksrf_fsoildepth)
write(ndiag,*) 'abm from: ',trim(mksrf_fabm)
write(ndiag,*) 'topography statistics from: ',trim(mksrf_ftopostats)
write(ndiag,*) 'VIC parameters from: ',trim(mksrf_fvic)
write(ndiag,*) 'CH4 parameters from: ',trim(mksrf_fch4)
write(ndiag,*)' mapping for pft ',trim(map_fpft)
write(ndiag,*)' mapping for lake water ',trim(map_flakwat)
write(ndiag,*)' mapping for wetland ',trim(map_fwetlnd)
write(ndiag,*)' mapping for glacier ',trim(map_fglacier)
write(ndiag,*)' mapping for glacier region ',trim(map_fglacierregion)
write(ndiag,*)' mapping for soil texture ',trim(map_fsoitex)
write(ndiag,*)' mapping for soil color ',trim(map_fsoicol)
write(ndiag,*)' mapping for soil organic ',trim(map_forganic)
write(ndiag,*)' mapping for urban ',trim(map_furban)
write(ndiag,*)' mapping for fmax ',trim(map_fmax)
write(ndiag,*)' mapping for VOC pct emis ',trim(map_fvocef)
write(ndiag,*)' mapping for harvest ',trim(map_fharvest)
write(ndiag,*)' mapping for lai/sai ',trim(map_flai)
write(ndiag,*)' mapping for urb topography ',trim(map_furbtopo)
write(ndiag,*)' mapping for GDP ',trim(map_fgdp)
write(ndiag,*)' mapping for peatlands ',trim(map_fpeat)
write(ndiag,*)' mapping for soil depth ',trim(map_fsoildepth)
write(ndiag,*)' mapping for ag fire pk month ',trim(map_fabm)
write(ndiag,*)' mapping for topography stats ',trim(map_ftopostats)
write(ndiag,*)' mapping for VIC parameters ',trim(map_fvic)
write(ndiag,*)' mapping for CH4 parameters ',trim(map_fch4)
if (mksrf_fdynuse /= ' ') then
write(6,*)'mksrf_fdynuse = ',trim(mksrf_fdynuse)
end if
! ----------------------------------------------------------------------
! Make surface dataset fields
! ----------------------------------------------------------------------
! Make PFTs [pctnatpft, pctcft] from dataset [fvegtyp]
call mkpft(ldomain, mapfname=map_fpft, fpft=mksrf_fvegtyp, &
ndiag=ndiag, allow_no_crops=.false., &
pctlnd_o=pctlnd_pft, pctnatpft_o=pctnatpft, pctcft_o=pctcft)
! Create harvesting data at model resolution
call mkharvest_init( ns_o, spval, harvdata, mksrf_fhrvtyp )
if ( .not. any(pft_frc > 0.0_r8 ) )then
call mkharvest( ldomain, mapfname=map_fharvest, datfname=mksrf_fhrvtyp, &
ndiag=ndiag, harvdata=harvdata )
end if
! Save the version of pctcft before any corrections are made. In particular, we want
! to save the version before remove_small_cover is called.
pctcft_saved = pctcft
! Make inland water [pctlak, pctwet] [flakwat] [fwetlnd]
call mklakwat (ldomain, mapfname=map_flakwat, datfname=mksrf_flakwat, &
ndiag=ndiag, zero_out=all_urban.or.all_veg, lake_o=pctlak)
call mkwetlnd (ldomain, mapfname=map_fwetlnd, datfname=mksrf_fwetlnd, &
ndiag=ndiag, zero_out=all_urban.or.all_veg.or.no_inlandwet, swmp_o=pctwet)
! Make glacier fraction [pctgla] from [fglacier] dataset
call mkglacier (ldomain, mapfname=map_fglacier, datfname=mksrf_fglacier, &
ndiag=ndiag, zero_out=all_urban.or.all_veg, glac_o=pctgla)
! Make glacier region ID [glacier_region] from [fglacierregion] dataset
call mkglacierregion (ldomain, mapfname=map_fglacierregion, &
datfname=mksrf_fglacierregion, ndiag=ndiag, &
glacier_region_o = glacier_region)
! Make soil texture [pctsand, pctclay] [fsoitex]
call mksoiltex (ldomain, mapfname=map_fsoitex, datfname=mksrf_fsoitex, &
ndiag=ndiag, sand_o=pctsand, clay_o=pctclay)
! Make soil color classes [soicol] [fsoicol]
call mksoilcol (ldomain, mapfname=map_fsoicol, datfname=mksrf_fsoicol, &
ndiag=ndiag, soil_color_o=soicol, nsoicol=nsoicol)
! Make fmax [fmax] from [fmax] dataset
allocate(fmax(ns_o))
fmax(:) = spval
call mkfmax (ldomain, mapfname=map_fmax, datfname=mksrf_fmax, &
ndiag=ndiag, fmax_o=fmax)
! Make GDP data [gdp] from [gdp]
call mkgdp (ldomain, mapfname=map_fgdp, datfname=mksrf_fgdp, &
ndiag=ndiag, gdp_o=gdp)
! Make peat data [fpeat] from [peatf]
call mkpeat (ldomain, mapfname=map_fpeat, datfname=mksrf_fpeat, &
ndiag=ndiag, peat_o=fpeat)
! Make soil depth data [soildepth] from [soildepthf]
call mksoildepth (ldomain, mapfname=map_fsoildepth, datfname=mksrf_fsoildepth, &
ndiag=ndiag, soildepth_o=soildepth)
! Make agricultural fire peak month data [abm] from [abm]
call mkagfirepkmon (ldomain, mapfname=map_fabm, datfname=mksrf_fabm, &
ndiag=ndiag, agfirepkmon_o=agfirepkmon)
! Make urban fraction [pcturb] from [furban] dataset
call mkurban (ldomain, mapfname=map_furban, datfname=mksrf_furban, &
ndiag=ndiag, zero_out=all_veg, urbn_o=pcturb, urbn_classes_o=urbn_classes, &
region_o=urban_region)
! Make elevation [elev] from [ftopo, ffrac] dataset
! Used only to screen pcturb
! Screen pcturb by elevation threshold from elev dataset
if ( .not. all_urban .and. .not. all_veg )then
allocate(elev(ns_o))
elev(:) = spval
! NOTE(wjs, 2016-01-15) This uses the 'TOPO_ICE' variable for historical reasons
! (this same dataset used to be used for glacier-related purposes as well).
! TODO(wjs, 2016-01-15) A better solution for this urban screening would probably
! be to modify the raw urban data; in that case, I believe we could remove
! furbtopo.
call mkelev (ldomain, mapfname=map_furbtopo, datfname=mksrf_furbtopo, &
varname='TOPO_ICE', ndiag=ndiag, elev_o=elev)
where (elev .gt. elev_thresh)
pcturb = 0._r8
end where
deallocate(elev)
end if
! Compute topography statistics [topo_stddev, slope] from [ftopostats]
call mktopostats (ldomain, mapfname=map_ftopostats, datfname=mksrf_ftopostats, &
ndiag=ndiag, topo_stddev_o=topo_stddev, slope_o=slope, std_elev=std_elev)
! Make VIC parameters [binfl, ws, dsmax, ds] from [fvic]
call mkVICparams (ldomain, mapfname=map_fvic, datfname=mksrf_fvic, ndiag=ndiag, &
binfl_o=vic_binfl, ws_o=vic_ws, dsmax_o=vic_dsmax, ds_o=vic_ds)
! Make lake depth [lakedepth] from [flakwat]
call mklakparams (ldomain, mapfname=map_flakwat, datfname=mksrf_flakwat, ndiag=ndiag, &
lakedepth_o=lakedepth)
! Make inversion-derived CH4 parameters [f0, p3, zwt0] from [fch4]
call mkCH4inversion (ldomain, mapfname=map_fch4, datfname=mksrf_fch4, ndiag=ndiag, &
f0_o=f0, p3_o=p3, zwt0_o=zwt0)
! Make organic matter density [organic] [forganic]
allocate (organic(ns_o,nlevsoi))
organic(:,:) = spval
call mkorganic (ldomain, mapfname=map_forganic, datfname=mksrf_forganic, &
ndiag=ndiag, organic_o=organic)
! Make VOC emission factors for isoprene &
! [ef1_btr,ef1_fet,ef1_fdt,ef1_shr,ef1_grs,ef1_crp]
allocate ( ef1_btr(ns_o) , &
ef1_fet(ns_o) , &
ef1_fdt(ns_o) , &
ef1_shr(ns_o) , &
ef1_grs(ns_o) , &
ef1_crp(ns_o) )
ef1_btr(:) = 0._r8
ef1_fet(:) = 0._r8
ef1_fdt(:) = 0._r8
ef1_shr(:) = 0._r8
ef1_grs(:) = 0._r8
ef1_crp(:) = 0._r8
call mkvocef (ldomain, mapfname=map_fvocef, datfname=mksrf_fvocef, ndiag=ndiag, &
ef_btr_o=ef1_btr, ef_fet_o=ef1_fet, ef_fdt_o=ef1_fdt, &
ef_shr_o=ef1_shr, ef_grs_o=ef1_grs, ef_crp_o=ef1_crp)
! Do landuse changes such as for the poles, etc.
call change_landuse( ldomain, dynpft=.false. )
do n = 1,ns_o
! Assume wetland and/or lake when dataset landmask implies ocean
! (assume medium soil color (15) and loamy texture).
! Also set pftdata_mask here
if (pctlnd_pft(n) < 1.e-6_r8) then
pftdata_mask(n) = 0
soicol(n) = 15
pctwet(n) = 100._r8 - pctlak(n)
pcturb(n) = 0._r8
pctgla(n) = 0._r8
call pctnatpft(n)%set_pct_l2g(0._r8)
call pctcft(n)%set_pct_l2g(0._r8)
pctsand(n,:) = 43._r8
pctclay(n,:) = 18._r8
organic(n,:) = 0._r8
else
pftdata_mask(n) = 1
end if
! Truncate all percentage fields on output grid. This is needed to
! insure that wt is zero (not a very small number such as
! 1e-16) where it really should be zero
do k = 1,nlevsoi
pctsand(n,k) = float(nint(pctsand(n,k)))
pctclay(n,k) = float(nint(pctclay(n,k)))
end do
pctlak(n) = float(nint(pctlak(n)))
pctwet(n) = float(nint(pctwet(n)))
pctgla(n) = float(nint(pctgla(n)))
! Make sure sum of land cover types does not exceed 100. If it does,
! subtract excess from most dominant land cover.
suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n)
if (suma > 250._r4) then
write (6,*) subname, ' error: sum of pctlak, pctwet,', &
'pcturb and pctgla is greater than 250%'
write (6,*)'n,pctlak,pctwet,pcturb,pctgla= ', &
n,pctlak(n),pctwet(n),pcturb(n),pctgla(n)
call abort()
else if (suma > 100._r4) then
pctlak(n) = pctlak(n) * 100._r8/suma
pctwet(n) = pctwet(n) * 100._r8/suma
pcturb(n) = pcturb(n) * 100._r8/suma
pctgla(n) = pctgla(n) * 100._r8/suma
end if
end do
call normalizencheck_landuse(ldomain)
! Write out sum of PFT's
do k = natpft_lb,natpft_ub
suma = 0._r8
do n = 1,ns_o
suma = suma + pctnatpft(n)%get_one_pct_p2g(k)
enddo
write(6,*) 'sum over domain of pft ',k,suma
enddo
write(6,*)
do k = cft_lb,cft_ub
suma = 0._r8
do n = 1,ns_o
suma = suma + pctcft(n)%get_one_pct_p2g(k)
enddo
write(6,*) 'sum over domain of cft ',k,suma
enddo
write(6,*)
! Make final values of percent urban by class
! This call needs to occur after all corrections are made to pcturb
call normalize_classes_by_gcell(urbn_classes, pcturb, urbn_classes_g)
! Make glacier multiple elevation classes [pctglcmec,topoglcmec] from [fglacier] dataset
! This call needs to occur after pctgla has been adjusted for the final time
allocate (pctglcmec(ns_o,nglcec), &
topoglcmec(ns_o,nglcec), &
pctglcmec_gic(ns_o,nglcec), &
pctglcmec_icesheet(ns_o,nglcec))
allocate (pctglc_gic(ns_o))
allocate (pctglc_icesheet(ns_o))
pctglcmec(:,:) = spval
topoglcmec(:,:) = spval
pctglcmec_gic(:,:) = spval
pctglcmec_icesheet(:,:) = spval
pctglc_gic(:) = spval
pctglc_icesheet(:) = spval
call mkglcmec (ldomain, mapfname=map_fglacier, &
datfname_fglacier=mksrf_fglacier, ndiag=ndiag, &
pctglcmec_o=pctglcmec, topoglcmec_o=topoglcmec, &
pctglcmec_gic_o=pctglcmec_gic, pctglcmec_icesheet_o=pctglcmec_icesheet, &
pctglc_gic_o=pctglc_gic, pctglc_icesheet_o=pctglc_icesheet)
! Determine fractional land from pft dataset
do n = 1,ns_o
landfrac_pft(n) = pctlnd_pft(n)/100._r8
end do
! ----------------------------------------------------------------------
! Create surface dataset
! ----------------------------------------------------------------------
! Create netCDF surface dataset.
! If fsurdat is blank, then we do not write a surface dataset - but we may still
! write a dynamic landuse file. This is useful if we are creating many datasets at
! once, and don't want duplicate surface datasets.
!
! TODO(wjs, 2016-01-26) Ideally, we would also avoid doing the processing of
! variables that are just needed by the surface dataset (not by the dynamic landuse
! file). However, this would require some analysis of the above code, to determine
! which processing is needed (directly or indirectly) in order to create a dynamic
! landuse file.
if (fsurdat /= ' ') then
call mkfile(ldomain, trim(fsurdat), harvdata, dynlanduse = .false.)
call domain_write(ldomain, fsurdat)
call check_ret(nf_open(trim(fsurdat), nf_write, ncid), subname)
call check_ret(nf_set_fill (ncid, nf_nofill, omode), subname)
! Write fields OTHER THAN lai, sai, heights, and urban parameters to netcdf surface dataset
call check_ret(nf_inq_varid(ncid, 'natpft', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, (/(n,n=natpft_lb,natpft_ub)/)), subname)
if (num_cft > 0) then
call check_ret(nf_inq_varid(ncid, 'cft', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, (/(n,n=cft_lb,cft_ub)/)), subname)
end if
call check_ret(nf_inq_varid(ncid, 'PFTDATA_MASK', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, pftdata_mask), subname)
call check_ret(nf_inq_varid(ncid, 'LANDFRAC_PFT', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, landfrac_pft), subname)
call check_ret(nf_inq_varid(ncid, 'mxsoil_color', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, nsoicol), subname)
call check_ret(nf_inq_varid(ncid, 'SOIL_COLOR', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, soicol), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_SAND', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctsand), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_CLAY', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctclay), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_WETLAND', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctwet), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_LAKE', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctlak), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_GLACIER', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctgla), subname)
call check_ret(nf_inq_varid(ncid, 'GLACIER_REGION', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, glacier_region), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_GLC_MEC', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctglcmec), subname)
call check_ret(nf_inq_varid(ncid, 'GLC_MEC', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, elevclass), subname)
call check_ret(nf_inq_varid(ncid, 'TOPO_GLC_MEC', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, topoglcmec), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_GLC_MEC_GIC', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctglcmec_gic), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_GLC_MEC_ICESHEET', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctglcmec_icesheet), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_GLC_GIC', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctglc_gic), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_GLC_ICESHEET', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, pctglc_icesheet), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_URBAN', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, urbn_classes_g), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_NATVEG', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, get_pct_l2g_array(pctnatpft)), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_CROP', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, get_pct_l2g_array(pctcft)), subname)
call check_ret(nf_inq_varid(ncid, 'PCT_NAT_PFT', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, get_pct_p2l_array(pctnatpft)), subname)
if (num_cft > 0) then
call check_ret(nf_inq_varid(ncid, 'PCT_CFT', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, get_pct_p2l_array(pctcft)), subname)
end if
call harvdata%getFieldsIdx( harvind1D, harvind2D )
do k = 1, harvdata%num1Dfields()
call check_ret(nf_inq_varid(ncid, trim(mkharvest_fieldname(harvind1D(k),constant=.true.)), varid), subname)
harvest1D => harvdata%get1DFieldPtr( harvind1D(k), output=.true. )
call check_ret(nf_put_var_double(ncid, varid, harvest1D), subname)
end do
do k = 1, harvdata%num2Dfields()
call check_ret(nf_inq_varid(ncid, trim(mkharvest_fieldname(harvind2D(k),constant=.true.)), varid), subname)
harvest2D => harvdata%get2DFieldPtr( harvind2D(k), output=.true. )
call check_ret(nf_put_var_double(ncid, varid, harvest2D), subname)
end do
deallocate( harvind1D, harvind2D )
call check_ret(nf_inq_varid(ncid, 'FMAX', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, fmax), subname)
call check_ret(nf_inq_varid(ncid, 'gdp', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, gdp), subname)
call check_ret(nf_inq_varid(ncid, 'peatf', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, fpeat), subname)
! call check_ret(nf_inq_varid(ncid, 'Avg_Depth_Median', varid), subname)
call check_ret(nf_inq_varid(ncid, 'zbedrock', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, soildepth), subname)
call check_ret(nf_inq_varid(ncid, 'abm', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, agfirepkmon), subname)
call check_ret(nf_inq_varid(ncid, 'SLOPE', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, slope), subname)
call check_ret(nf_inq_varid(ncid, 'STD_ELEV', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, topo_stddev), subname)
call check_ret(nf_inq_varid(ncid, 'binfl', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, vic_binfl), subname)
call check_ret(nf_inq_varid(ncid, 'Ws', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, vic_ws), subname)
call check_ret(nf_inq_varid(ncid, 'Dsmax', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, vic_dsmax), subname)
call check_ret(nf_inq_varid(ncid, 'Ds', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, vic_ds), subname)
call check_ret(nf_inq_varid(ncid, 'LAKEDEPTH', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, lakedepth), subname)
call check_ret(nf_inq_varid(ncid, 'F0', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, f0), subname)
call check_ret(nf_inq_varid(ncid, 'P3', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, p3), subname)
call check_ret(nf_inq_varid(ncid, 'ZWT0', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, zwt0), subname)
call check_ret(nf_inq_varid(ncid, 'EF1_BTR', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, ef1_btr), subname)
call check_ret(nf_inq_varid(ncid, 'EF1_FET', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, ef1_fet), subname)
call check_ret(nf_inq_varid(ncid, 'EF1_FDT', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, ef1_fdt), subname)
call check_ret(nf_inq_varid(ncid, 'EF1_SHR', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, ef1_shr), subname)
call check_ret(nf_inq_varid(ncid, 'EF1_GRS', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, ef1_grs), subname)
call check_ret(nf_inq_varid(ncid, 'EF1_CRP', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, ef1_crp), subname)
call check_ret(nf_inq_varid(ncid, 'ORGANIC', varid), subname)
call check_ret(nf_put_var_double(ncid, varid, organic), subname)
call check_ret(nf_inq_varid(ncid, 'URBAN_REGION_ID', varid), subname)
call check_ret(nf_put_var_int(ncid, varid, urban_region), subname)