-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcrtm_interface.f90
3559 lines (3217 loc) · 143 KB
/
crtm_interface.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 crtm_interface
!$$$ module documentation block
! . . .
! module: crtm_interface module for setuprad. Calculates profile and calls crtm
! prgmmr:
!
! abstract: crtm_interface module for setuprad. Initializes CRTM, Calculates profile and
! calls CRTM and destroys initialization
!
! program history log:
! 2010-08-17 Derber - initial creation from intrppx
! 2011-05-06 merkova/todling - add use of q-clear calculation for AIRS
! 2011-04-08 li - (1) Add nst_gsi, itref,idtw, idtc, itz_tr to apply NSST.
! - (2) Use Tz instead of Ts as water surface temperature when nst_gsi > 1
! - (3) add tzbgr as one of the out dummy variable
! - (4) Include tz_tr in ts calculation over water
! - (5) Change minmum temperature of water surface from 270.0 to 271.0
! 2011-07-04 todling - fixes to run either single or double precision
! 2011-09-20 hclin - modified for modis_aod
! (1) The jacobian of wrfchem/gocart p25 species (not calculated in CRTM)
! is derived from dust1 and dust2
! (2) skip loading geometry and surface structures for modis_aod
! (3) separate jacobian calculation for modis_aod
! 2012-01-17 sienkiewicz - pass date to crtm for SSU cell pressure
! 2013-02-25 zhu - add cold_start option for regional applications
! 2013-10-19 todling - metguess now holds background
! 2013-11-16 todling - merge in latest DTC AOD development;
! revisit handling of green-house-gases
! 2014-01-01 li - change the protection of data_s(itz_tr)
! 2014-02-26 zhu - add non zero jacobian
! 2014-04-27 eliu - add call crtm_forward to calculate clear-sky Tb under all-sky condition
! 2015-09-10 zhu - generalize enabling all-sky and using aerosol (radiance_mod & radmod) in radiance
! assimilation. use n_clouds_jac,cloud_names_jac,n_aerosols_jac,aerosol_names_jac,
! n_clouds_fwd,cloud_names_fwd, etc for difference sensors and channels
! - add handling of mixed_use of channels in a sensor (some are clear-sky, others all-sky)
! 2016-06-03 collard - Added changes to allow for historical naming conventions
! 2017-02-24 zhu/todling - remove gmao cloud fraction treatment
! 2018-01-12 collard - Force all satellite and solar zenith angles to be >= 0.
! 2019-03-13 eliu - add precipitation component
! 2019-03-13 eliu - add quality control to identify areas with cold-air outbreak
! 2019-03-13 eliu - add calculation of GFDL cloud fraction
! 2019-03-22 Wei/Martin - Added VIIRS AOD capability alongside MODIS AOD
!
!
! subroutines included:
! sub init_crtm
! sub call_crtm
! sub destroy_crtm
!
! attributes:
! language: f90
! machine:
!
!$$$ end documentation block
use kinds,only: r_kind,i_kind,r_single
use crtm_module, only: crtm_atmosphere_type,crtm_surface_type,crtm_geometry_type, &
crtm_options_type,crtm_rtsolution_type,crtm_destroy,crtm_options_destroy, &
crtm_options_create,crtm_options_associated,success,crtm_atmosphere_create, &
crtm_surface_create,crtm_k_matrix,crtm_forward, &
ssu_input_setvalue, &
crtm_channelinfo_type, &
crtm_surface_destroy, crtm_surface_associated, crtm_surface_zero, &
crtm_atmosphere_associated, &
crtm_atmosphere_destroy,crtm_atmosphere_zero, &
crtm_rtsolution_type, crtm_rtsolution_create, &
crtm_rtsolution_destroy, crtm_rtsolution_associated, &
crtm_irlandcoeff_classification, &
crtm_kind => fp, &
crtm_microwave_sensor => microwave_sensor
use gridmod, only: lat2,lon2,nsig,msig,nvege_type,regional,wrf_mass_regional,netcdf,use_gfs_ozone
use mpeu_util, only: die
use crtm_aod_module, only: crtm_aod_k
use radiance_mod, only: n_actual_clouds,cloud_names,n_clouds_fwd,cloud_names_fwd, &
n_clouds_jac,cloud_names_jac,n_actual_aerosols,aerosol_names,n_aerosols_fwd,aerosol_names_fwd, &
n_aerosols_jac,aerosol_names_jac,rad_obs_type,cw_cv,ql_cv
use control_vectors, only: lcalc_gfdl_cfrac
use ncepnems_io, only: imp_physics
implicit none
private
public init_crtm ! Subroutine initializes crtm for specified instrument
public call_crtm ! Subroutine creates profile for crtm, calls crtm, then adjoint of create
public destroy_crtm ! Subroutine destroys initialization for crtm
public sensorindex
public surface
public isatid ! = 1 index of satellite id
public itime ! = 2 index of analysis relative obs time
public ilon ! = 3 index of grid relative obs location (x)
public ilat ! = 4 index of grid relative obs location (y)
public ilzen_ang ! = 5 index of local (satellite) zenith angle (radians)
public ilazi_ang ! = 6 index of local (satellite) azimuth angle (radians)
public iscan_ang ! = 7 index of scan (look) angle (radians)
public iscan_pos ! = 8 index of integer scan position
public iszen_ang ! = 9 index of solar zenith angle (degrees)
public isazi_ang ! = 10 index of solar azimuth angle (degrees)
public ifrac_sea ! = 11 index of ocean percentage
public ifrac_lnd ! = 12 index of land percentage
public ifrac_ice ! = 13 index of ice percentage
public ifrac_sno ! = 14 index of snow percentage
public its_sea ! = 15 index of ocean temperature
public its_lnd ! = 16 index of land temperature
public its_ice ! = 17 index of ice temperature
public its_sno ! = 18 index of snow temperature
public itsavg ! = 19 index of average temperature
public ivty ! = 20 index of vegetation type
public ivfr ! = 21 index of vegetation fraction
public isty ! = 22 index of soil type
public istp ! = 23 index of soil temperature
public ism ! = 24 index of soil moisture
public isn ! = 25 index of snow depth
public izz ! = 26 index of surface height
public idomsfc ! = 27 index of dominate surface type
public isfcr ! = 28 index of surface roughness
public iff10 ! = 29 index of ten meter wind factor
public ilone ! = 30 index of earth relative longitude (degrees)
public ilate ! = 31 index of earth relative latitude (degrees)
public iclr_sky ! = 7 index of clear sky amount (goes_img, seviri,abi,ahi)
public isst_navy ! = 7 index of navy sst retrieval (K) (avhrr_navy)
public idata_type ! = 32 index of data type (151=day, 152=night, avhrr_navy)
public iclavr ! = 32 index of clavr cloud flag (avhrr)
public isst_hires ! = 33 index of interpolated hires sst
public itref ! = 34/36 index of Tr
public idtw ! = 35/37 index of d(Tw)
public idtc ! = 36/38 index of d(Tc)
public itz_tr ! = 37/39 index of d(Tz)/d(Tr)
! For TMI and GMI
public iedge_log ! = 32 ! index, if obs is to be obleted beause of locating near scan edges.
! For GMI 1CR (obstype=='gmi') data channel 10-13.
public ilzen_ang2 ! = 33 index of local (satellite) zenith angle (radians)
public ilazi_ang2 ! = 34 index of local (satellite) azimuth angle (radians)
public iscan_ang2 ! = 35 index of scan (look) angle (radians)
public iszen_ang2 ! = 36 index of solar zenith angle (degrees)
public isazi_ang2 ! = 37 index of solar azimuth angle (degrees)
! Note other module variables are only used within this routine
character(len=*), parameter :: myname='crtm_interface'
! Indices for the CRTM NPOESS EmisCoeff file
integer(i_kind), parameter :: INVALID_LAND = 0
integer(i_kind), parameter :: COMPACTED_SOIL = 1
integer(i_kind), parameter :: TILLED_SOIL = 2
integer(i_kind), parameter :: IRRIGATED_LOW_VEGETATION = 5
integer(i_kind), parameter :: MEADOW_GRASS = 6
integer(i_kind), parameter :: SCRUB = 7
integer(i_kind), parameter :: BROADLEAF_FOREST = 8
integer(i_kind), parameter :: PINE_FOREST = 9
integer(i_kind), parameter :: TUNDRA = 10
integer(i_kind), parameter :: GRASS_SOIL = 11
integer(i_kind), parameter :: BROADLEAF_PINE_FOREST = 12
integer(i_kind), parameter :: GRASS_SCRUB = 13
integer(i_kind), parameter :: URBAN_CONCRETE = 15
integer(i_kind), parameter :: BROADLEAF_BRUSH = 17
integer(i_kind), parameter :: WET_SOIL = 18
integer(i_kind), parameter :: SCRUB_SOIL = 19
real(r_kind) , save ,allocatable,dimension(:,:) :: aero ! aerosol (guess) profiles at obs location
real(r_kind) , save ,allocatable,dimension(:,:) :: aero_conc ! aerosol (guess) concentrations at obs location
real(r_kind) , save ,allocatable,dimension(:) :: auxrh ! temporary array for rh profile as seen by CRTM
character(len=20),save,allocatable,dimension(:) :: ghg_names ! names of green-house gases
integer(i_kind), save ,allocatable,dimension(:) :: icloud ! cloud index for those considered here
integer(i_kind), save ,allocatable,dimension(:) :: jcloud ! cloud index for those fed to CRTM
real(r_kind) , save ,allocatable,dimension(:,:) :: cloud ! cloud considered here
real(r_kind) , save ,allocatable,dimension(:,:) :: cloudefr ! effective radius of cloud type in CRTM
real(r_kind) , save ,allocatable,dimension(:,:) :: cloud_cont ! cloud content fed into CRTM
real(r_kind) , save ,allocatable,dimension(:,:) :: cloud_efr ! effective radius of cloud type in CRTM
real(r_kind) , save ,allocatable,dimension(:) :: cf ! cloud fraction
real(r_kind) , save ,allocatable,dimension(:) :: ni,nr ! ice and rain number concentration
real(r_kind) , save ,allocatable,dimension(:) :: hwp_guess ! column total for each hydrometeor
real(r_kind) , save ,allocatable,dimension(:) :: table,table2,tablew ! GFDL saturation water vapor pressure tables
real(r_kind) , save ,allocatable,dimension(:) :: des2,desw ! GFDL saturation water vapor presure
real(r_kind) , save ,allocatable,dimension(:) :: lcloud4crtm_wk ! cloud info usage index for each channel
integer(i_kind),save, allocatable,dimension(:) :: map_to_crtm_ir
integer(i_kind),save, allocatable,dimension(:) :: map_to_crtm_mwave
integer(i_kind),save, allocatable,dimension(:) :: icw
integer(i_kind),save, allocatable,dimension(:) :: iaero_jac
integer(i_kind),save :: isatid,itime,ilon,ilat,ilzen_ang,ilazi_ang,iscan_ang
integer(i_kind),save :: iscan_pos,iszen_ang,isazi_ang,ifrac_sea,ifrac_lnd,ifrac_ice
integer(i_kind),save :: ifrac_sno,its_sea,its_lnd,its_ice,its_sno,itsavg
integer(i_kind),save :: ivty,ivfr,isty,istp,ism,isn,izz,idomsfc,isfcr,iff10,ilone,ilate
integer(i_kind),save :: iclr_sky,isst_navy,idata_type,isst_hires,iclavr
integer(i_kind),save :: itref,idtw,idtc,itz_tr,istype
integer(i_kind),save :: sensorindex
integer(i_kind),save :: ico2,ico24crtm
integer(i_kind),save :: n_actual_aerosols_wk ! number of aerosols considered
integer(i_kind),save :: n_aerosols_fwd_wk ! number of aerosols considered
integer(i_kind),save :: n_aerosols_jac_wk ! number of aerosols considered
integer(i_kind),save :: n_actual_clouds_wk ! number of clouds considered
integer(i_kind),save :: n_clouds_fwd_wk ! number of clouds considered
integer(i_kind),save :: n_clouds_jac_wk ! number of clouds considered
integer(i_kind),save :: n_ghg ! number of green-house gases
integer(i_kind),save :: itsen,iqv,ioz,ius,ivs,isst
integer(i_kind),save :: indx_p25, indx_dust1, indx_dust2
logical ,save :: lwind
logical ,save :: cld_sea_only_wk
logical ,save :: lprecip_wk
logical ,save :: mixed_use
logical ,save :: use_gfdl_qsat
integer(i_kind), parameter :: min_n_absorbers = 2
integer(i_kind),save :: iedge_log
integer(i_kind),save :: ilzen_ang2,ilazi_ang2,iscan_ang2,iszen_ang2,isazi_ang2
type(crtm_atmosphere_type),save,dimension(1) :: atmosphere
type(crtm_surface_type),save,dimension(1) :: surface
type(crtm_geometry_type),save,dimension(1) :: geometryinfo
type(crtm_options_type),save,dimension(1) :: options
type(crtm_channelinfo_type),save,dimension(1) :: channelinfo
type(crtm_atmosphere_type),save,allocatable,dimension(:,:):: atmosphere_k
type(crtm_atmosphere_type),save,allocatable,dimension(:,:):: atmosphere_k_clr
type(crtm_surface_type),save,allocatable,dimension(:,:):: surface_k
type(crtm_surface_type),save,allocatable,dimension(:,:):: surface_k_clr
type(crtm_rtsolution_type),save,allocatable,dimension(:,:):: rtsolution
type(crtm_rtsolution_type),save,allocatable,dimension(:,:):: rtsolution0
type(crtm_rtsolution_type),save,allocatable,dimension(:,:):: rtsolution_clr
type(crtm_rtsolution_type),save,allocatable,dimension(:,:):: rtsolution_k
type(crtm_rtsolution_type),save,allocatable,dimension(:,:):: rtsolution_k_clr
! Mapping land surface type of GFS to CRTM
! Notes: index 0 is water, and index 13 is ice. The two indices are not
! used and just assigned to COMPACTED_SOIL. Also, since there
! is currently one relevant mapping for the global we apply
! 'crtm' in the naming convention.
integer(i_kind), parameter, dimension(0:13) :: gfs_to_crtm=(/COMPACTED_SOIL, &
BROADLEAF_FOREST, BROADLEAF_FOREST, BROADLEAF_PINE_FOREST, PINE_FOREST, &
PINE_FOREST, BROADLEAF_BRUSH, SCRUB, SCRUB, SCRUB_SOIL, TUNDRA, &
COMPACTED_SOIL, TILLED_SOIL, COMPACTED_SOIL/)
! Mapping surface classification to CRTM
integer(i_kind), parameter :: USGS_N_TYPES = 24
integer(i_kind), parameter :: IGBP_N_TYPES = 20
integer(i_kind), parameter :: GFS_N_TYPES = 13
integer(i_kind), parameter :: SOIL_N_TYPES = 16
integer(i_kind), parameter :: GFS_SOIL_N_TYPES = 9
integer(i_kind), parameter :: GFS_VEGETATION_N_TYPES = 13
integer(i_kind), parameter, dimension(1:USGS_N_TYPES) :: usgs_to_npoess=(/URBAN_CONCRETE, &
COMPACTED_SOIL, IRRIGATED_LOW_VEGETATION, GRASS_SOIL, MEADOW_GRASS, &
MEADOW_GRASS, MEADOW_GRASS, SCRUB, GRASS_SCRUB, MEADOW_GRASS, &
BROADLEAF_FOREST, PINE_FOREST, BROADLEAF_FOREST, PINE_FOREST, &
BROADLEAF_PINE_FOREST, INVALID_LAND, WET_SOIL, WET_SOIL, &
IRRIGATED_LOW_VEGETATION, TUNDRA, TUNDRA, TUNDRA, TUNDRA, &
INVALID_LAND/)
integer(i_kind), parameter, dimension(1:IGBP_N_TYPES) :: igbp_to_npoess=(/PINE_FOREST, &
BROADLEAF_FOREST, PINE_FOREST, BROADLEAF_FOREST, BROADLEAF_PINE_FOREST, &
SCRUB, SCRUB_SOIL, BROADLEAF_BRUSH, BROADLEAF_BRUSH, SCRUB, BROADLEAF_BRUSH, &
TILLED_SOIL, URBAN_CONCRETE, TILLED_SOIL, INVALID_LAND, COMPACTED_SOIL, &
INVALID_LAND, TUNDRA, TUNDRA, TUNDRA/)
integer(i_kind), parameter, dimension(1:USGS_N_TYPES) :: usgs_to_usgs=(/1, &
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, &
20, 21, 22, 23, 24/)
integer(i_kind), parameter, dimension(1:IGBP_N_TYPES) :: igbp_to_igbp=(/1, &
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, &
20/)
integer(i_kind), parameter, dimension(1:IGBP_N_TYPES) :: igbp_to_gfs=(/4, &
1, 5, 2, 3, 8, 9, 6, 6, 7, 8, 12, 7, 12, 13, 11, 0, 10, 10, 11/)
integer(i_kind), parameter, dimension(1:USGS_N_TYPES) :: usgs_to_gfs=(/7, &
12, 12, 12, 12, 12, 7, 9, 8, 6, 2, 5, 1, 4, 3, 0, 8, 8, 11, 10, 10, &
10, 11, 13/)
! Mapping soil types to CRTM
! The CRTM soil types for microwave calculations are based on the
! GFS use of the 9 category Zobler dataset. The regional soil types
! are based on a 16 category representation of FAO/STATSGO.
integer(i_kind), parameter, dimension(1:SOIL_N_TYPES) :: map_soil_to_crtm=(/1, &
1, 4, 2, 2, 8, 7, 2, 6, 5, 2, 3, 8, 1, 6, 9/)
contains
subroutine init_crtm(init_pass,mype_diaghdr,mype,nchanl,nreal,isis,obstype,radmod)
!$$$ subprogram documentation block
! . . . .
! subprogram: init_crtm initializes things for use with call to crtm from setuprad
!
! prgmmr: derber org: np2 date: 2010-08-17
!
! abstract: initialize things for use with call to crtm from setuprad.
!
! program history log:
! 2010-08-17 derber
! 2011-02-16 todling - add calculation of rh when aerosols are available
! 2011-05-03 todling - merge with Min-Jeong's MW cloudy radiance; combine w/ metguess
! 2011-05-20 mccarty - add atms wmo_sat_id hack (currently commented out)
! 2011-07-20 zhu - modified codes for lcw4crtm
! 2012-03-12 yang - modify to use ch4,n2o,and co
! 2012-12-03 eliu - add logic for RH total
! 2014-01-31 mkim - add flexibility in the variable lcw4crtm for the case when ql and
! qi are separate control variables for all-sky MW radiance DA
! 2014-04-27 eliu - add capability to call CRTM forward model to calculate
! clear-sky Tb under all-sky condition
! 2015-09-20 zhu - use centralized radiance info from radiance_mod: rad_obs_type,
! n_clouds_jac,cloud_names_jac,n_aerosols_jac,aerosol_names_jac,etc
! 2015-09-04 J.Jung - Added mods for CrIS full spectral resolution (FSR) and
! CRTM subset code for CrIS.
! 2019-04-25 H.Liu - Add nreal into the namelist to allow flexible SST variable index assigned
!
! input argument list:
! init_pass - state of "setup" processing
! mype_diaghdr - processor to produce output from crtm
! mype - current processor
! nchanl - number of channels
! isis - instrument/sensor character string
! obstype - observation type
! nreal - number of descriptor information in data_s
!
! output argument list:
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$
use gsi_bundlemod, only: gsi_bundlegetpointer
use gsi_chemguess_mod, only: gsi_chemguess_bundle ! for now, a common block
use gsi_chemguess_mod, only: gsi_chemguess_get
use gsi_metguess_mod, only: gsi_metguess_bundle ! for now, a common block
use gsi_metguess_mod, only: gsi_metguess_get
use crtm_module, only: mass_mixing_ratio_units,co2_id,o3_id,crtm_init, &
crtm_channelinfo_subset, crtm_channelinfo_n_channels, toa_pressure,max_n_layers, &
volume_mixing_ratio_units,h2o_id,ch4_id,n2o_id,co_id
use radinfo, only: crtm_coeffs_path
use radinfo, only: radjacindxs,radjacnames,jpch_rad,nusis,nuchan
use aeroinfo, only: aerojacindxs
use gridmod, only: fv3_full_hydro
use gridmod, only: fv3_cmaq_regional
use chemmod, only: crtm_aerosol_model,crtm_aerosolcoeff_format,crtm_aerosolcoeff_file
use mpeu_util, only: getindex
use constants, only: zero,max_varname_length
use obsmod, only: dval_use
use gsi_io, only: verbose
implicit none
! argument
logical ,intent(in) :: init_pass
integer(i_kind),intent(in) :: nchanl,mype_diaghdr,mype,nreal
character(20) ,intent(in) :: isis
character(10) ,intent(in) :: obstype
type(rad_obs_type),intent(in) :: radmod
! local parameters
character(len=*), parameter :: myname_=myname//'*init_crtm'
integer(i_kind), parameter :: length = 2621 ! length of GFL qsat table
! local variables
integer(i_kind) :: ier,ii,error_status
integer(i_kind) :: k, subset_start, subset_end
logical :: Load_AerosolCoeff,Load_CloudCoeff
character(50) Aerosol_Model, AerosolCoeff_File,AerosolCoeff_Format
character(len=20),dimension(1) :: sensorlist
integer(i_kind) :: indx,iii,icloud4crtm
! ...all "additional absorber" variables
integer(i_kind) :: j,icount
integer(i_kind) :: ig
integer(i_kind) :: n_absorbers
logical quiet
logical print_verbose
use_gfdl_qsat=.false.
print_verbose=.false.
if(verbose)print_verbose=.true.
isst=-1
ivs=-1
ius=-1
ioz=-1
iqv=-1
itsen=-1
! Get indexes of variables composing the jacobian
indx =getindex(radjacnames,'tsen')
if(indx>0) itsen=radjacindxs(indx)
indx =getindex(radjacnames,'q' )
if(indx>0) iqv=radjacindxs(indx)
indx =getindex(radjacnames,'oz')
if(indx>0) ioz=radjacindxs(indx)
indx =getindex(radjacnames,'u')
if(indx>0) ius=radjacindxs(indx)
indx =getindex(radjacnames,'v')
if(indx>0) ivs=radjacindxs(indx)
lwind=ius>0.and.ivs>0
indx=getindex(radjacnames,'sst')
if(indx>0) isst=radjacindxs(indx)
! Get indexes of variables for cloud jacobians
if (n_clouds_jac>0) then
allocate(icw(max(n_clouds_jac,1)))
icw=-1
icount=0
do ii=1,n_clouds_jac
indx=getindex(radjacnames,trim(cloud_names_jac(ii)))
if (indx>0) then
icount=icount+1
icw(icount)=radjacindxs(indx)
end if
end do
end if
! Get indexes of variables composing the jacobian_aero
if (n_actual_aerosols > 0) then
indx_p25 = getindex(aerosol_names,'p25')
indx_dust1 = getindex(aerosol_names,'dust1')
indx_dust2 = getindex(aerosol_names,'dust2')
if (n_aerosols_jac >0) then
allocate(iaero_jac(n_aerosols_jac))
iaero_jac=-1
icount=0
do ii=1,n_actual_aerosols
indx=getindex(aerosol_names_jac,trim(aerosol_names(ii)))
if(indx>0) then
icount=icount+1
iaero_jac(icount)=aerojacindxs(indx)
endif
end do
endif
endif
! When Cloud is available in MetGuess, defined Cloudy Radiance
mixed_use=.false.
if (radmod%lcloud_fwd) then
allocate(lcloud4crtm_wk(radmod%nchannel))
lcloud4crtm_wk(:) = radmod%lcloud4crtm(:)
do ii=1,radmod%nchannel
if (lcloud4crtm_wk(ii)<0) then
mixed_use=.true.
exit
end if
end do
allocate(cloud_cont(msig,n_clouds_fwd))
allocate(cloud_efr(msig,n_clouds_fwd))
allocate(jcloud(n_clouds_fwd))
allocate(cloud(nsig,n_clouds_fwd))
allocate(cloudefr(nsig,n_clouds_fwd))
allocate(icloud(n_actual_clouds))
allocate(cf(nsig))
allocate(ni(nsig))
allocate(nr(nsig))
allocate(hwp_guess(n_clouds_fwd))
cloud_cont=zero
cloud_efr =zero
cloud =zero
cloudefr =zero
cf =zero
ni =zero
nr =zero
hwp_guess =zero
call gsi_bundlegetpointer(gsi_metguess_bundle(1),cloud_names,icloud,ier)
iii=0
do ii=1,n_actual_clouds
call gsi_metguess_get ( 'i4crtm::'//trim(cloud_names(ii)), icloud4crtm, ier )
if (icloud4crtm>10) then
iii=iii+1
jcloud(iii)=ii
endif
end do
if(iii/=n_clouds_fwd) call die(myname_,'inconsistent cloud count',1)
n_actual_clouds_wk = n_actual_clouds
n_clouds_fwd_wk = n_clouds_fwd
n_clouds_jac_wk = n_clouds_jac
cld_sea_only_wk = radmod%cld_sea_only
Load_CloudCoeff = .true.
lprecip_wk = radmod%lprecip .or. fv3_full_hydro
else
n_actual_clouds_wk = 0
n_clouds_fwd_wk = 0
n_clouds_jac_wk = 0
cld_sea_only_wk = .false.
Load_CloudCoeff = .false.
endif
! Set up index for input satellite data array
isatid = 1 ! index of satellite id
itime = 2 ! index of analysis relative obs time
ilon = 3 ! index of grid relative obs location (x)
ilat = 4 ! index of grid relative obs location (y)
ilzen_ang = 5 ! index of local (satellite) zenith angle (radians)
ilazi_ang = 6 ! index of local (satellite) azimuth angle (radians)
iscan_ang = 7 ! index of scan (look) angle (radians)
iscan_pos = 8 ! index of integer scan position
iszen_ang = 9 ! index of solar zenith angle (degrees)
isazi_ang = 10 ! index of solar azimuth angle (degrees)
ifrac_sea = 11 ! index of ocean percentage
ifrac_lnd = 12 ! index of land percentage
ifrac_ice = 13 ! index of ice percentage
ifrac_sno = 14 ! index of snow percentage
its_sea = 15 ! index of ocean temperature
its_lnd = 16 ! index of land temperature
its_ice = 17 ! index of ice temperature
its_sno = 18 ! index of snow temperature
itsavg = 19 ! index of average temperature
ivty = 20 ! index of vegetation type
ivfr = 21 ! index of vegetation fraction
isty = 22 ! index of soil type
istp = 23 ! index of soil temperature
ism = 24 ! index of soil moisture
isn = 25 ! index of snow depth
izz = 26 ! index of surface height
idomsfc = 27 ! index of dominate surface type
isfcr = 28 ! index of surface roughness
iff10 = 29 ! index of ten meter wind factor
ilone = 30 ! index of earth relative longitude (degrees)
ilate = 31 ! index of earth relative latitude (degrees)
icount=ilate
if(dval_use) icount=icount+2
if ( obstype == 'avhrr_navy' .or. obstype == 'avhrr' ) then
icount=icount+2 ! when an independent SST analysis is read in
else if ( obstype == 'tmi' ) then
iedge_log = 32 ! index, if obs is to be obleted beause of locating near scan edges.
icount = iedge_log+2
else if ( obstype == 'gmi' ) then
iedge_log = 32 ! index, if obs is to be obleted beause of locating near scan edges.
ilzen_ang2= 33 ! index of local (satellite) zenith angle (radians)
ilazi_ang2= 34 ! index of local (satellite) azimuth angle (radians)
iscan_ang2= 35 ! index of scan (look) angle (radians)
iszen_ang2= 36 ! index of solar zenith angle (degrees)
isazi_ang2= 37 ! index of solar azimuth angle (degrees)
icount = isazi_ang2
if(dval_use) icount=icount+2
else if ( obstype == 'amsr2' ) then
icount=ilate+2
endif
itref = nreal-3 ! index of foundation temperature: Tr
idtw = nreal-2 ! index of diurnal warming: d(Tw) at depth zob
idtc = nreal-1 ! index of sub-layer cooling: d(Tc) at depth zob
itz_tr = nreal ! index of d(Tz)/d(Tr)
if (obstype == 'goes_img' .or. obstype == 'abi' &
.or. obstype == 'ahi' .or. obstype == 'seviri' ) then
iclr_sky = 7 ! index of clear sky amount
elseif (obstype == 'avhrr_navy') then
isst_navy = 7 ! index of navy sst (K) retrieval
idata_type = 32 ! index of data type (151=day, 152=night)
isst_hires = 33 ! index of interpolated hires sst (K)
elseif (obstype == 'avhrr') then
iclavr = 32 ! index CLAVR cloud flag with AVHRR data
isst_hires = 33 ! index of interpolated hires sst (K)
endif
! get the number of trace gases present in the chemguess bundle
n_ghg=0
if(size(gsi_chemguess_bundle)>0) then
call gsi_chemguess_get('ghg',n_ghg,ier)
if (n_ghg>0) then
allocate(ghg_names(n_ghg))
call gsi_chemguess_get('ghg',ghg_names,ier)
endif
endif
n_absorbers = min_n_absorbers + n_ghg
! Are there aerosols to affect CRTM?
if (radmod%laerosol_fwd) then
if(.not.allocated(aero)) allocate(aero(nsig,n_actual_aerosols))
if(.not.allocated(aero_conc)) allocate(aero_conc(msig,n_actual_aerosols),auxrh(msig))
n_actual_aerosols_wk=n_actual_aerosols
n_aerosols_fwd_wk=n_aerosols_fwd
n_aerosols_jac_wk=n_aerosols_jac
Load_AerosolCoeff=.true.
if (fv3_cmaq_regional) then
Aerosol_Model = trim(crtm_aerosol_model)
AerosolCoeff_File = trim(crtm_aerosolcoeff_file)
AerosolCoeff_Format = trim(crtm_aerosolcoeff_format)
end if
else
n_actual_aerosols_wk=0
n_aerosols_fwd_wk=0
n_aerosols_jac_wk=0
Load_AerosolCoeff=.false.
endif
! Initialize radiative transfer
sensorlist(1)=isis
quiet=.not. print_verbose
if( crtm_coeffs_path /= "" ) then
if(init_pass .and. mype==mype_diaghdr .and. print_verbose) &
write(6,*)myname_,': crtm_init() on path "'//trim(crtm_coeffs_path)//'"'
error_status = crtm_init(sensorlist,channelinfo,&
Process_ID=mype,Output_Process_ID=mype_diaghdr, &
! for crtm2.4.1
!<Aero need to comment out if CRTM doesn't support
! Aerosol_Model=Aerosol_Model,AerosolCoeff_File=AerosolCoeff_File, &
! AerosolCoeff_Format=AerosolCoeff_Format, &
!Aero>
Load_CloudCoeff=Load_CloudCoeff,Load_AerosolCoeff=Load_AerosolCoeff, &
File_Path = crtm_coeffs_path,quiet=quiet )
else
error_status = crtm_init(sensorlist,channelinfo,&
Process_ID=mype,Output_Process_ID=mype_diaghdr, &
! for crtm2.4.1
!Aero need to comment out if CRTM doesn't support
! Aerosol_Model=Aerosol_Model,AerosolCoeff_File=AerosolCoeff_File, &
! AerosolCoeff_Format=AerosolCoeff_Format, &
!Aero>
Load_CloudCoeff=Load_CloudCoeff,Load_AerosolCoeff=Load_AerosolCoeff,&
quiet=quiet)
endif
if (error_status /= success) then
write(6,*)myname_,': ***ERROR*** crtm_init error_status=',error_status,&
' TERMINATE PROGRAM EXECUTION'
call stop2(71)
endif
sensorindex = 0
if (channelinfo(1)%sensor_id == isis) then
sensorindex = 1
if (isis(1:4) == 'iasi' .or. &
trim(isis) == 'amsua_aqua' .or. &
isis(1:4) == 'airs' .or. &
isis(1:4) == 'cris' ) then
subset_start = 0
subset_end = 0
do k=1, jpch_rad
if (isis == nusis(k)) then
if (subset_start == 0) subset_start = k
subset_end = k
endif
end do
error_status = crtm_channelinfo_subset(channelinfo(1), &
channel_subset = nuchan(subset_start:subset_end))
endif
! This is to try to keep the CrIS naming conventions more flexible.
! The consistency of CRTM and BUFR files is checked in read_cris:
else if (channelinfo(1)%sensor_id(1:8) == 'cris-fsr' .AND. isis(1:8) == 'cris-fsr') then
sensorindex = 1
subset_start = 0
subset_end = 0
do k=1, jpch_rad
if (isis == nusis(k)) then
if (subset_start == 0) subset_start = k
subset_end = k
endif
end do
error_status = crtm_channelinfo_subset(channelinfo(1), &
channel_subset = nuchan(subset_start:subset_end))
else if (channelinfo(1)%sensor_id(1:4) == 'cris' .AND. isis(1:4) == 'cris') then
sensorindex = 1
subset_start = 0
subset_end = 0
do k=1, jpch_rad
if (isis == nusis(k)) then
if (subset_start == 0) subset_start = k
subset_end = k
endif
end do
error_status = crtm_channelinfo_subset(channelinfo(1), &
channel_subset = nuchan(subset_start:subset_end))
! TODO The CRTM spectral coefficient files have the instrument name in the beginning of the file. The current iasi-ng coefficient
! TODO file contains '999' instead of the instrument name. When the final coefficient file is built, it will have 'iasi-ng'.
! TODO else if (channelinfo(1)%sensor_id(1:7) == 'iasi-ng' .AND. isis(1:7) == 'iasi-ng') then
! TODO when this file exists, use the above line.
else if (channelinfo(1)%sensor_id(1:3) == '999' .AND. isis(1:7) == 'iasi-ng') then
! TODO and remove the above line.
sensorindex = 1
subset_start = 0
subset_end = 0
do k=1, jpch_rad
if (isis == nusis(k)) then
if (subset_start == 0) subset_start = k
subset_end = k
endif
end do
error_status = crtm_channelinfo_subset(channelinfo(1), &
channel_subset = nuchan(subset_start:subset_end))
else if (channelinfo(1)%sensor_id(1:4) == 'iasi' .AND. isis(1:4) == 'iasi') then
sensorindex = 1
subset_start = 0
subset_end = 0
do k=1, jpch_rad
if (isis == nusis(k)) then
if (subset_start == 0) subset_start = k
subset_end = k
endif
end do
error_status = crtm_channelinfo_subset(channelinfo(1), &
channel_subset = nuchan(subset_start:subset_end))
else if (channelinfo(1)%sensor_id(1:4) == 'airs' .AND. isis(1:4) == 'airs') then
sensorindex = 1
subset_start = 0
subset_end = 0
do k=1, jpch_rad
if (isis == nusis(k)) then
if (subset_start == 0) subset_start = k
subset_end = k
endif
end do
error_status = crtm_channelinfo_subset(channelinfo(1), &
channel_subset = nuchan(subset_start:subset_end))
endif
if (sensorindex == 0 ) then
write(6,*)myname_,': ***WARNING*** problem with sensorindex=',isis,&
' --> CAN NOT PROCESS isis=',isis,' TERMINATE PROGRAM EXECUTION found ',&
channelinfo(1)%sensor_id
call stop2(71)
endif
! Check for consistency between user specified number of channels (nchanl)
! and those defined by CRTM channelinfo structure. Return to calling
! routine if there is a mismatch.
if (nchanl /= crtm_channelinfo_n_channels(channelinfo(sensorindex))) then
write(6,*)myname_,': ***WARNING*** mismatch between nchanl=',&
nchanl,' and n_channels=',crtm_channelinfo_n_channels(channelinfo(sensorindex)),&
' --> CAN NOT PROCESS isis=',isis,' TERMINATE PROGRAM EXECUTION'
call stop2(71)
endif
! Allocate structures for radiative transfer
if (radmod%lcloud_fwd .and. (.not. mixed_use) .and. (.not. allocated(rtsolution0)) ) &
allocate(rtsolution0(channelinfo(sensorindex)%n_channels,1))
allocate(&
rtsolution (channelinfo(sensorindex)%n_channels,1),&
rtsolution_k(channelinfo(sensorindex)%n_channels,1),&
atmosphere_k(channelinfo(sensorindex)%n_channels,1),&
surface_k (channelinfo(sensorindex)%n_channels,1))
if (mixed_use) allocate(&
rtsolution_clr (channelinfo(sensorindex)%n_channels,1),&
rtsolution_k_clr(channelinfo(sensorindex)%n_channels,1),&
atmosphere_k_clr(channelinfo(sensorindex)%n_channels,1),&
surface_k_clr (channelinfo(sensorindex)%n_channels,1))
! Check to ensure that number of levels requested does not exceed crtm max
if(msig > max_n_layers)then
write(6,*) myname_,': msig > max_n_layers - increase crtm max_n_layers ',&
msig,max_n_layers
call stop2(36)
end if
! Create structures for radiative transfer
call crtm_atmosphere_create(atmosphere(1),msig,n_absorbers,n_clouds_fwd_wk,n_aerosols_fwd_wk)
!_RTod-NOTE if(r_kind==r_single .and. crtm_kind/=r_kind) then ! take care of case: GSI(single); CRTM(double)
!_RTod-NOTE call crtm_surface_create(surface(1),channelinfo(sensorindex)%n_channels,tolerance=1.0e-5_crtm_kind)
!_RTod-NOTE else
!_RTod-NOTE: the following will work in single precision but issue lots of msg and remove more obs than needed
if ( channelinfo(sensorindex)%sensor_type == crtm_microwave_sensor ) then
call crtm_surface_create(surface(1),channelinfo(sensorindex)%n_channels)
if (.NOT.(crtm_surface_associated(surface(1)))) then
write(6,*)myname_,' ***ERROR** creating surface.'
else
surface(1)%sensordata%sensor_id = channelinfo(sensorindex)%sensor_id
surface(1)%sensordata%wmo_sensor_id = channelinfo(sensorindex)%wmo_sensor_id
surface(1)%sensordata%wmo_satellite_id = channelinfo(sensorindex)%wmo_satellite_id
surface(1)%sensordata%sensor_channel = channelinfo(sensorindex)%sensor_channel
end if
end if
!_RTod-NOTE endif
if (radmod%lcloud_fwd .and. (.not. mixed_use)) &
call crtm_rtsolution_create(rtsolution0,msig)
call crtm_rtsolution_create(rtsolution,msig)
call crtm_rtsolution_create(rtsolution_k,msig)
call crtm_options_create(options,nchanl)
if (mixed_use) then
call crtm_rtsolution_create(rtsolution_clr,msig)
call crtm_rtsolution_create(rtsolution_k_clr,msig)
end if
if (.NOT.(crtm_atmosphere_associated(atmosphere(1)))) &
write(6,*)myname_,' ***ERROR** creating atmosphere.'
if (.NOT.(ANY(crtm_rtsolution_associated(rtsolution)))) &
write(6,*)myname_,' ***ERROR** creating rtsolution.'
if (radmod%lcloud_fwd .and. (.not. mixed_use)) then
if (.NOT.(ANY(crtm_rtsolution_associated(rtsolution0)))) &
write(6,*)' ***ERROR** creating rtsolution0.'
endif
if (.NOT.(ANY(crtm_rtsolution_associated(rtsolution_k)))) &
write(6,*)myname_,' ***ERROR** creating rtsolution_k.'
if (.NOT.(ANY(crtm_options_associated(options)))) &
write(6,*)myname_,' ***ERROR** creating options.'
! Turn off antenna correction
options(1)%use_antenna_correction = .false.
! Load surface sensor data structure
surface(1)%sensordata%n_channels = channelinfo(sensorindex)%n_channels
!! REL-1.2 CRTM
!! surface(1)%sensordata%select_wmo_sensor_id = channelinfo(1)%wmo_sensor_id
!! RB-1.1.rev1855 CRTM
atmosphere(1)%n_layers = msig
atmosphere(1)%absorber_id(1) = H2O_ID
atmosphere(1)%absorber_id(2) = O3_ID
atmosphere(1)%absorber_units(1) = MASS_MIXING_RATIO_UNITS
atmosphere(1)%absorber_units(2) = VOLUME_MIXING_RATIO_UNITS
atmosphere(1)%level_pressure(0) = TOA_PRESSURE
! Currently all considered trace gases affect CRTM. Load trace gases into CRTM atmosphere
ico2=-1
if (n_ghg>0) then
do ig=1,n_ghg
j = min_n_absorbers + ig
select case(trim(ghg_names(ig)))
case('co2'); atmosphere(1)%absorber_id(j) = CO2_ID
case('ch4'); atmosphere(1)%absorber_id(j) = CH4_ID
case('n2o'); atmosphere(1)%absorber_id(j) = N2O_ID
case('co') ; atmosphere(1)%absorber_id(j) = CO_ID
case default
call die(myname_,': invalid absorber TERMINATE PROGRAM'//trim(ghg_names(ig)),71)
end select
atmosphere(1)%absorber_units(j) = VOLUME_MIXING_RATIO_UNITS
if (trim(ghg_names(ig))=='co2') ico2=j
enddo
endif
ico24crtm=-1
if (ico2>0) call gsi_chemguess_get ( 'i4crtm::co2', ico24crtm, ier )
! Allocate structure for _k arrays (jacobians)
do ii=1,nchanl
atmosphere_k(ii,1) = atmosphere(1)
surface_k(ii,1) = surface(1)
end do
if (mixed_use) then
do ii=1,nchanl
atmosphere_k_clr(ii,1) = atmosphere(1)
surface_k_clr(ii,1) = surface(1)
end do
end if
! Mapping land surface type to CRTM surface fields
if (regional .or. nvege_type==IGBP_N_TYPES) then
allocate(map_to_crtm_ir(nvege_type))
allocate(map_to_crtm_mwave(nvege_type))
if(nvege_type==USGS_N_TYPES)then
! Assign mapping for CRTM microwave calculations
map_to_crtm_mwave=usgs_to_gfs
! map usgs to CRTM
select case ( TRIM(CRTM_IRlandCoeff_Classification()) )
case('NPOESS'); map_to_crtm_ir=usgs_to_npoess
case('USGS') ; map_to_crtm_ir=usgs_to_usgs
end select
else if(nvege_type==IGBP_N_TYPES)then
! Assign mapping for CRTM microwave calculations
map_to_crtm_mwave=igbp_to_gfs
! nmm igbp to CRTM
select case ( TRIM(CRTM_IRlandCoeff_Classification()) )
case('NPOESS'); map_to_crtm_ir=igbp_to_npoess
case('IGBP') ; map_to_crtm_ir=igbp_to_igbp
end select
else
write(6,*)myname_,': ***ERROR*** invalid vegetation types' &
//' for the CRTM IRland EmisCoeff file used.', &
' (only 20 and 24 are setup) nvege_type=',nvege_type, &
' ***STOP IN SETUPRAD***'
call stop2(71)
endif ! nvege_type
endif ! regional or IGBP
! Initial GFDL saturation water vapor pressure tables
if (use_gfdl_qsat) then
if (n_actual_aerosols_wk>0 .or. n_clouds_fwd_wk>0 .and. imp_physics==11) then
if (mype==0) write(6,*)myname_,':initial and load GFDL saturation water vapor pressure tables'
allocate(table (length))
allocate(table2(length))
allocate(tablew(length))
allocate(des2 (length))
allocate(desw (length))
call qs_table (length)
call qs_table2(length)
call qs_tablew(length)
do ii = 1, length - 1
des2 (ii) = max (zero, table2 (ii + 1) - table2 (ii))
desw (ii) = max (zero, tablew (ii + 1) - tablew (ii))
enddo
des2 (length) = des2 (length - 1)
desw (length) = desw (length - 1)
endif
endif
return
end subroutine init_crtm
subroutine destroy_crtm
!$$$ subprogram documentation block
! . . . .
! subprogram: destroy_crtm deallocates crtm arrays
! prgmmr: parrish org: np22 date: 2005-01-22
!
! abstract: deallocates crtm arrays
!
! program history log:
! 2010-08-17 derber
!
! input argument list:
!
! output argument list:
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$
implicit none
character(len=*),parameter::myname_ = myname//'*destroy_crtm'
integer(i_kind) error_status
error_status = crtm_destroy(channelinfo)
if (error_status /= success) &
write(6,*)myname_,': ***ERROR*** error_status=',error_status
if (use_gfdl_qsat) then
deallocate(table)
deallocate(table2)
deallocate(tablew)
deallocate(des2)
deallocate(desw)
endif
call crtm_atmosphere_destroy(atmosphere(1))
call crtm_surface_destroy(surface(1))
if (n_clouds_fwd_wk>0 .and. (.not. mixed_use)) &
call crtm_rtsolution_destroy(rtsolution0)
call crtm_rtsolution_destroy(rtsolution)
call crtm_rtsolution_destroy(rtsolution_k)
if (mixed_use) then
call crtm_rtsolution_destroy(rtsolution_clr)
call crtm_rtsolution_destroy(rtsolution_k_clr)
end if
call crtm_options_destroy(options)
if (crtm_atmosphere_associated(atmosphere(1))) &
write(6,*)myname_,' ***ERROR** destroying atmosphere.'
if (crtm_surface_associated(surface(1))) &
write(6,*)myname_,' ***ERROR** destroying surface.'
if (ANY(crtm_rtsolution_associated(rtsolution))) &
write(6,*)myname_,' ***ERROR** destroying rtsolution.'
if (n_clouds_fwd_wk>0 .and. (.not. mixed_use)) then
if (ANY(crtm_rtsolution_associated(rtsolution0))) &
write(6,*)' ***ERROR** destroying rtsolution0.'
endif
if (ANY(crtm_rtsolution_associated(rtsolution_k))) &
write(6,*)myname_,' ***ERROR** destroying rtsolution_k.'
if (ANY(crtm_options_associated(options))) &
write(6,*)myname_,' ***ERROR** destroying options.'
deallocate(rtsolution,atmosphere_k,surface_k,rtsolution_k)
if (mixed_use) deallocate(rtsolution_clr,atmosphere_k_clr, &
surface_k_clr,rtsolution_k_clr)
if (n_clouds_fwd_wk>0 .and. (.not. mixed_use)) &
deallocate(rtsolution0)
if(n_actual_aerosols_wk>0)then
deallocate(aero,aero_conc,auxrh)
if(n_aerosols_jac>0) deallocate(iaero_jac)
endif
if (n_ghg>0) then
deallocate(ghg_names)
endif
if(allocated(icloud)) deallocate(icloud)
if(allocated(cloud)) deallocate(cloud)
if(allocated(cloudefr)) deallocate(cloudefr)
if(allocated(jcloud)) deallocate(jcloud)
if(allocated(cloud_cont)) deallocate(cloud_cont)
if(allocated(cloud_efr)) deallocate(cloud_efr)
if(allocated(cf)) deallocate(cf)
if(allocated(ni)) deallocate(ni)
if(allocated(nr)) deallocate(nr)
if(allocated(hwp_guess)) deallocate(hwp_guess)
if(allocated(icw)) deallocate(icw)
if(allocated(lcloud4crtm_wk)) deallocate(lcloud4crtm_wk)
if(regional .or. nvege_type==IGBP_N_TYPES)deallocate(map_to_crtm_ir)
if(regional .or. nvege_type==IGBP_N_TYPES)deallocate(map_to_crtm_mwave)
return