-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupbend.f90
1495 lines (1345 loc) · 62.7 KB
/
setupbend.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 gpsbend_setup
implicit none
private
public:: setup
interface setup; module procedure setupbend; end interface
contains
subroutine setupbend(obsLL,odiagLL, &
lunin,mype,awork,nele,nobs,toss_gps_sub,is,init_pass,last_pass,conv_diagsave)
!$$$ subprogram documentation block
! . . . .
! subprogram: setupbend compute rhs of oi for gps bending angle
! prgmmr: cucurull, l. org: JCSDA/NCEP date: 2005-12-01
!
! abstract: For gps bending angle observations, this routine
! a) reads obs assigned to given mpi task (geographic region),
! b) simulates obs from guess,
! c) apply some quality control to obs,
! d) load weight and innovation arrays used in minimization
! e) collects statistics for runtime diagnostic output
! f) writes additional diagnostic information to output file
!
! program history log:
! 2005-12-01 cucurull - original code
! 2005-12-09 derber - remove psfcg and use ges_lnps instead
! 2005-12-21 treadon - add super_gps, move some diagnostics statistics
! to genstat_gps
! 2006-01-04 treadon - correct inconsistency when using qcfail
! 2006-02-02 treadon - rename lnprsl as ges_lnprsl
! 2006-02-24 derber - modify to take advantage of convinfo module
! 2006-02-24 cucurull - update QC parameters and compute representativeness error
! - fix bug when counting obs that fail gross qc check
! - fix bug when rejecting obs that fail sats QC
! 2006-04-14 middlecoff - changed IF test to avoid out-of-bounds-reference on DATA
! 2006-07-28 derber - modify to use new inner loop obs data structure
! 2006-07-31 kleist - change to use ges_ps instead of lnps
! 2006-09-20 cucurull - use geopotential heights at intermediate levels instead
! of midpoint,levels,remove psges, generalize minimization terms
! to hybrid coordinate,penalize high level obs,new QC checks,
! remove obs above 30 km,add b_tkges, remove dtime,
! improve obs pressure calculation for diagnostic purposes,
! increase the extended atmosphere from 6 to 10 levels
! 2006-10-20 cucurull - update QC statistical checks and representativeness error with
! COSMIC data
! - add information to diagnostic file
! 2007-01-29 cucurull - remove observations below 6 km
! 2007-03-01 derber - add toss_gps_sub; simplify profile qc loop
! 2007-03-19 tremolet - binning of observations
! 2007-06-05 tremolet - add observation diagnostics structure
! 2007-04-18 su - add nchar and cdiagbuf to diagnostic file
! 2007-06-22 cucurull - generalize qc structure to enable regional GSI;
! reduce gpswork2;remove conv_diagsave from argument list;
! consistent data counts for qc checks;
! update diagnostic information to be consistent with other obs;
! modify diagnostic structure;
! fix bug for jprof in stats qc
! 2007-07-26 cucurull - update code to generalized vertical coordinate (3d pressure)
! 2007-09-21 cucurull - remove obs above 40km from qc checks
! 2008-04-14 treadon - remove super_gps (moved to genstats_gps)
! 2008-05-23 safford - rm unused vars and uses
! 2008-12-03 todling - revisited Tremolet modifications in light of newer GSI
! - changed handle of tail%time
! 2009-08-19 guo - changed for multi-pass setup with dtime_check().
! 2010-04-16 cucurull - substantial clean up, bugs fixes, and update according to ref
! 2010-04-23 cucurull - simplify loops and define repe_gps here
! 2010-05-26 cucurull - modify ds
! 2010-06-11 cucurull - update Statistics QC
! 2010-05-24 guo - remerged/reimplmented multi-pass setup in observer mode;
! 2010-08-09 lueken - removed n_5km variable from code.
! 2010-08-10 treadon - remove last check for gpshead allocate; clean up use statements,
! replace (izero,ione) with (0,1), remove _i_kind suffix from integer
! constants
! 2010-08-11 lcucurull - replace tpdpres with tpdpres(nobs) to fix bug in TL code
! 2010-08-18 hu - add tell to mpeu_util declaration
! 2010-10-25 cucurull - add quality control options for C/NOFS satellite
! 2010-11-8 cucurull - tune observational errors
! 2010-12-12 cucurull - generalize number of layers above model top to nsig_ext
! 2011-01-05 cucurull - add gpstop to reject anything above this value
! 2011-01-07 cucurull - reject observation if outside new integration grid and compute
! the nsig_ext value the user needs to use
! 2011-01-13 lueken - corrected init_pass and last_pass indentation
! 2011-01-18 cucurull - increase the size of mreal by one element to add gps_dtype information
! 2011-06-17 treadon - remove call tell at end of routine
! 2011-08-16 cucurull - fix bug in statistics qc
! 2011-08-17 cucurull - add Oceansat-2, METOP-B GRAS, SAC-D, and M-T assimilation capabilities
! 2012-10-16 cucurull - add preliminary super-refraction QC, compute and include qrefqes in diagnostic file
! different meaning for toss_gps_sub, add Tandem-X assimilation capability
! 2013-01-26 parrish - change from grdcrd to grdcrd1, tintrp2a to tintrp2a1, tintrp2a11,
! tintrp3 to tintrp31 (to allow successful debug compile on WCOSS)
! 2013-10-19 todling - metguess now holds background
! 2014-04-10 todling - 4dvar fix: obs must be in current time bin
! 2014-12-30 derber - Modify for possibility of not using obsdiag
! 2015-10-01 guo - full res obvsr: index to allow redistribution of obsdiags
! 2016-05-18 guo - replaced ob_type with polymorphic obsNode through type casting
! 2016-06-24 guo - fixed the default value of obsdiags(:,:)%tail%luse to luse(i)
! . removed (%dlat,%dlon) debris.
! 2016-11-29 shlyaeva - save linearized H(x) for EnKF
! 2017-02-09 guo - Remove m_alloc, n_alloc.
! . Remove my_node with corrected typecast().
! 2019-08-21 Shao - add COSMIC-2, metop-c and Paz
! 2020-03-18 Shao - update observation error for COSMIC-2
! 2020-04-13 Shao - update the statistis QC for COSMIC-2
! 2020-05-21 Shao - add comments to include commercial data ID information
! 2020-08-26 Shao/Bathmann - add Jacobian QC
! 2021-07-29 cucurull - revert gross error check to default values
! 2021-07-29 cucurull - fix forward operator issues identified with L127
! 2021-11-04 cucurull - turn off Jacbian QC
! 2021-11-05 cucurull - update QCs and optimize/improve forward operator; bug fixes
! 2022-01-28 cucurull - add Sentinel-6, PAZ
! 2022-04-06 collard - reintroduce Jacbian QC as an option (default off)
!
! input argument list:
! lunin - unit from which to read observations
! mype - mpi task id
! nele - number of data elements per observation
! nobs - number of observations
!
! output argument list:
! awork - array containing information for data counts and gross checks
!
! attributes:
! language: f90
! machine: ibm RS/6000 SP
!
!$$$
use mpeu_util, only: die,perr,tell,getindex
use kinds, only: r_kind,i_kind
use m_gpsStats, only: gps_allhead,gps_alltail
use obsmod , only: nprof_gps,lobsdiag_allocated,&
lobsdiagsave,nobskeep,&
time_offset,lobsdiag_forenkf
use qcmod, only: gps_jacqc
use m_obsNode, only: obsNode
use m_gpsNode , only: gpsNode
use m_gpsNode , only: gpsNode_appendto
use m_obsLList, only: obsLList
use obsmod, only: luse_obsdiag
use m_obsdiagNode, only: obs_diag
use m_obsdiagNode, only: obs_diags
use m_obsdiagNode, only: obsdiagLList_appendNode
use m_obsdiagNode, only: obsdiagLList_nextNode
use m_obsdiagNode, only: obsdiagNode_init
use m_obsdiagNode, only: obsdiagNode_set
use m_obsdiagNode, only: obsdiagNode_get
use m_obsdiagNode, only: obsdiagNode_assert
use gsi_4dvar, only: nobs_bins,hr_obsbin
use guess_grids, only: ges_lnprsi,hrdifsig,geop_hgti,nfldsig
use guess_grids, only: ges_lnprsl,ges_prsi,geop_hgtl
use guess_grids, only: nsig_ext,gpstop,commgpstop,commgpserrinf
!> xuanli
use guess_grids, only: ges_tsen
!< xuanli
use gridmod, only: nsig
use gridmod, only: get_ij,latlon11
use constants, only: fv,n_a,n_b,n_c,deg2rad,tiny_r_kind,r0_01,r18,r61,r63,r10000
use constants, only: zero,half,one,two,eccentricity,semi_major_axis,&
grav_equator,somigliana,flattening,grav_ratio,grav,rd,eps,three,four,five,&
r100,r400,r1000
use lagmod, only: setq, setq_TL
use lagmod, only: slagdw, slagdw_TL
use jfunc, only: jiter,miter,jiterstart
use convinfo, only: cermin,cermax,cgross,cvar_b,cvar_pg,ictype
use m_dtime, only: dtime_setup, dtime_check
use m_gpsrhs, only: muse
use m_gpsrhs, only: dbend_loc,xj
use m_gpsrhs, only: n_t,n_q,n_p,nrefges
use m_gpsrhs, only: rges,gp2gm,prsltmp_o,tges_o
use m_gpsrhs, only: error,error_adjst
use m_gpsrhs, only: ratio_errors
use m_gpsrhs, only: rdiagbuf,cdiagbuf
use m_gpsrhs, only: qcfail
use m_gpsrhs, only: qcfail_loc,qcfail_high,qcfail_gross,qcfail_jac
use m_gpsrhs, only: data_ier,data_igps,data_ihgt
use m_gpsrhs, only: gpsrhs_alloc
use m_gpsrhs, only: gpsrhs_dealloc
use m_gpsrhs, only: gpsrhs_aliases
use m_gpsrhs, only: gpsrhs_unaliases
use state_vectors, only: levels, svars3d
use gsi_bundlemod, only : gsi_bundlegetpointer
use gsi_metguess_mod, only : gsi_metguess_get,gsi_metguess_bundle
use sparsearr, only: sparr2, new, size, writearray
implicit none
! Declare passed variables
type(obsLList ),target,dimension(:),intent(in):: obsLL
type(obs_diags),target,dimension(:),intent(in):: odiagLL
integer(i_kind) ,intent(in ) :: lunin,mype,nele,nobs
real(r_kind),dimension(100+7*nsig) ,intent(inout) :: awork
real(r_kind),dimension(max(1,nprof_gps)),intent(inout) :: toss_gps_sub
integer, intent(in):: is ! index to GPSbend buffer variables
logical, intent(in):: init_pass ! flag the pass for the first background bin
logical, intent(in):: last_pass ! flag the pass for the last background bin
logical, intent(in):: conv_diagsave ! save diagnostics file
! Declare local parameters
real(r_kind),parameter:: r240 = 240.0_r_kind
real(r_kind),parameter:: six = 6.0_r_kind
real(r_kind),parameter:: ten = 10.0_r_kind
real(r_kind),parameter:: eight = 8.0_r_kind
real(r_kind),parameter:: nine = 9.0_r_kind
real(r_kind),parameter:: eleven = 11.0_r_kind
real(r_kind),parameter:: r12=12.0_r_kind
real(r_kind),parameter:: r20=20.0_r_kind
real(r_kind),parameter:: r40=40.0_r_kind
real(r_kind),parameter:: r80=80.0_r_kind
real(r_kind),parameter:: r1em3 = 1.0e-3_r_kind
real(r_kind),parameter:: r1em6 = 1.0e-6_r_kind
character(len=*),parameter :: myname='setupbend'
real(r_kind),parameter:: crit_grad = 157.0_r_kind
real(r_kind),parameter:: r790000=790000.0_r_kind
! Declare local variables
integer(i_kind):: grids_dim
real(r_kind) cutoff,cutoff1,cutoff2,cutoff3,cutoff4,cutoff12,cutoff23,cutoff34
real(r_kind) sin2,zsges,ds,ns
real(r_kind),dimension(:),allocatable:: ddnj,grid_s,ref_rad_s
real(r_kind) rsig,rsig_up,ddbend,tmean,qmean
real(r_kind) termg,termr,termrg,hob,dbend,grad_mod
real(r_kind) fact,pw,nrefges1,nrefges2,nrefges3,k4,delz
real(r_kind) ratio,residual,obserror,obserrlm,cermaxuse,cerminuse,cgrossuse
real(r_kind) errinv_input,errinv_adjst,errinv_final,err_final,repe_gps
real(r_kind),dimension(nele,nobs):: data
real(r_kind),dimension(nsig):: dbenddn,dbenddxi
real(r_kind) pressure,hob_s,d_ref_rad,d_ref_rad_TL,hob_s_top
real(r_kind) hobb
real(r_kind),dimension(4) :: w4,dw4,dw4_TL
!> xuanli
integer(i_kind) ier,ilon,ilat,ihgt,igps,itime,ikx,iuse, &
iprof,ipctc,iroc,isatid,iptid,ilate,ilone,ioff,igeoid,iqfro
integer(i_kind) iascd, iazm, iconstid, isiid, iogce, iref
!< xuanli
integer(i_kind) i,j,k,kk,mreal,nreal,jj,ikxx,ibin
integer(i_kind) mm1,nsig_up,ihob,istatus,nsigstart
integer(i_kind) kprof,istat,k1,k2,nobs_out,top_layer_SR,bot_layer_SR,count_SR
integer(i_kind),dimension(4) :: gps_ij
integer(i_kind):: satellite_id,transmitter_id
type(sparr2) :: dhx_dx
integer(i_kind) :: iz, t_ind, q_ind, p_ind, nnz, nind
real(r_kind),dimension(3,nsig+nsig_ext) :: q_w,q_w_tl
! xuanli correct the dimension of hges
! real(r_kind),dimension(nsig) :: hges,irefges,zges,dhdt,dhdp
real(r_kind),dimension(nsig) :: irefges,zges,dhdt,dhdp
real(r_kind),dimension(nsig+1) :: hges
real(r_kind),dimension(nsig+1) :: prsltmp
real(r_kind),dimension(nsig,nsig)::dndp,dxidp
real(r_kind),dimension(nsig,nsig)::dndt,dxidt,dndq,dxidq
real(r_kind),dimension(nsig+nsig_ext) :: n_TL
real(r_kind),dimension(0:nsig+nsig_ext+1) :: ref_rad,xi_TL
real(r_kind),dimension(nsig+nsig_ext+20) :: ref_rad_out
real(r_kind) :: dlat,dlon,rocprof,unprof,dtime,dpressure,trefges,qrefges
real(r_kind) :: dbetan,dbetaxi,rdog,alt
real(r_kind),dimension(nsig):: tges,qges,qges_o
real(r_kind),dimension(nobs):: tpdpres
logical,dimension(nobs):: luse
integer(i_kind),dimension(nobs):: ioid ! initial (pre-distribution) obs ID
logical proceed
logical:: in_curbin, in_anybin, obs_check,qc_layer_SR, save_jacobian
type(gpsNode),pointer:: my_head
type(obs_diag),pointer:: my_diag
type(obs_diags),pointer:: my_diagLL
real(r_kind),allocatable,dimension(:,:,: ) :: ges_z
real(r_kind),allocatable,dimension(:,:,:,:) :: ges_tv
real(r_kind),allocatable,dimension(:,:,:,:) :: ges_q
!> xuanli
real(r_kind),dimension(nsig, nobs) :: Tsen,Tvir,sphm,hgtl,prslnl
real(r_kind),dimension(nsig+1,nobs) :: hgti,prslni
integer(i_kind),dimension(nobs) :: qc_superr, qc_layer, qc_ddnj
integer(i_kind),dimension(nobs) :: qc_stat,qc_largeBA,qc_metop
!< xuanli
type(obsLList),pointer,dimension(:):: gpshead
logical:: commdat
gpshead => obsLL(:)
save_jacobian = conv_diagsave .and. jiter==jiterstart .and. lobsdiag_forenkf
!*******************************************************************************
! List of GPS RO satellites and corresponding BUFR id
!740 => COSMIC FM1
!741 => COSMIC FM2
!742 => COSMIC FM3
!743 => COSMIC FM4
!744 => COSMIC FM5
!745 => COSMIC FM6
!4 => MetOpA
!41 => Champ
!722 => GRACE A
!723 => GRACE B
!820 => SACC
!42 => TerraSAR-X
!43 => Tandem-X
!786 => C/NOFS
!421 => OCEANSAT-2
!3 => MetOpB
!440 => Megha-Tropiques
!821 => SACD
!44 => PAZ
!750-755 => COSMIC-2 Equatorial
!724-729 => COSMIC-2 Polar
!825 => KOMPSAT-5
!5 => MetOpC
!265 => GeoOptics CICERO OP1
!266 => GeoOptics CICERO OP2
!267 => PlanetiQ GNOMES-A
!268 => PlanetiQ GNOMES-B
!269 => Spire Lemur 3U CubeSat
!66 => Sentinel-6
! Check to see if required guess fields are available
call check_vars_(proceed)
if(.not.proceed) return ! not all vars available, simply return
! If require guess vars available, extract from bundle ...
call init_vars_
! Read and reformat observations in work arrays.
read(lunin)data,luse,ioid
ier=1 ! index of obs error in data array (now 1/(original obs error))
ilon=2 ! index of grid relative obs location (x)
ilat=3 ! index of grid relative obs location (y)
ihgt=4 ! index of obs vertical coordinate in data array - impact parameter
igps=5 ! index of gps data (or residual) in data array
itime=6 ! index of obs time in data array
ikxx=7 ! index of observation type
iprof=8 ! index of profile
ipctc=9 ! index of percent confidence
iroc=10 ! index of local radius of curvature (m)
isatid=11 ! index of satellite identifier
iptid=12 ! index of platform transmitter id number
iuse=13 ! index of use parameter
ilone=14 ! index of earth relative longitude (degrees)
ilate=15 ! index of earth relative latitude (degrees)
igeoid=16 ! index of geoid undulation (a value per profile, m)
!> xuanli
iqfro=17 ! index of qfro (integer)
iascd=18 ! index of ascending flag (integer)
iazm=19 ! index of azimuth angle
iconstid=20 ! index of classification ID (integer)
isiid=21 ! index of occulting sat (integer)
iogce=22 ! index of identification of originating (integer)
iref=23 ! index of refractivity
qc_superr(:) = 0
qc_stat(:) = 0
qc_largeBA(:) = 0
qc_metop(:) = 0
qc_layer(:) = 0
qc_ddnj(:) = 0
!< xuanli
! Intialize variables
nsig_up=nsig+nsig_ext ! extend nsig_ext levels above interface level nsig
rsig=float(nsig)
rdog=rd/grav
rsig_up=float(nsig_up)
nobs_out=0
hob_s_top=one
mm1=mype+1
ns=nsig/two
nsigstart=nint(ns)
ns=r80
grids_dim=nint(ns) ! grid points for integration of GPS bend
ds=r10000
allocate(ddnj(grids_dim),grid_s(grids_dim),ref_rad_s(grids_dim))
! Allocate arrays for output to diagnostic file
! mreal=22 ! xuanli
mreal=34 ! xuanli
nreal=mreal
if (lobsdiagsave) nreal=nreal+4*miter+1
if (save_jacobian) then
nnz = nsig * 3 ! number of non-zero elements in dH(x)/dx profile
nind = 3 ! number of dense subarrays
call new(dhx_dx, nnz, nind)
nreal = nreal + size(dhx_dx)
! jacobian sparse array indices are the same for all obs and can be filled
! in once here:
t_ind = getindex(svars3d, 'tv')
if (t_ind < 0) then
print *, 'Error: no variable tv in state vector. Exiting.'
call stop2(1300)
endif
q_ind = getindex(svars3d, 'q')
if (q_ind < 0) then
print *, 'Error: no variable q in state vector. Exiting.'
call stop2(1300)
endif
p_ind = getindex(svars3d, 'prse')
if (p_ind < 0) then
print *, 'Error: no variable prse in state vector. Exiting.'
call stop2(1300)
endif
dhx_dx%st_ind(1) = sum(levels(1:t_ind-1)) + 1
dhx_dx%end_ind(1) = sum(levels(1:t_ind-1)) + nsig
dhx_dx%st_ind(2) = sum(levels(1:q_ind-1)) + 1
dhx_dx%end_ind(2) = sum(levels(1:q_ind-1)) + nsig
dhx_dx%st_ind(3) = sum(levels(1:p_ind-1)) + 1
dhx_dx%end_ind(3) = sum(levels(1:p_ind-1)) + nsig
endif
if(init_pass) call gpsrhs_alloc(is,'bend',nobs,nsig,nreal,grids_dim,nsig_ext)
call gpsrhs_aliases(is)
if(nreal/=size(rdiagbuf,1)) then
call perr(myname,'unexpected dimension')
call perr(myname,'nreal =',nreal)
call perr(myname,'size(rdiagbuf,1) =',size(rdiagbuf,1))
call die(myname)
endif
if(init_pass) then
! initialize explicitly workspace variables,
! although they have been initialized during the
! buffer_alloc() call.
data_ier (:)=data(ier ,:)
data_ihgt(:)=data(ihgt,:)
data_igps(:)=data(igps,:)
muse(:)=.false.
qcfail=.false.
qcfail_loc=zero;qcfail_gross=zero
qcfail_high=zero
qcfail_jac=zero
toss_gps_sub=zero
dbend_loc=zero
else ! (init_pass)
! Restore those arrays saved from the previous pass
data(ier ,:)=data_ier (:)
data(ihgt,:)=data_ihgt(:)
data(igps,:)=data_igps(:)
endif ! (init_pass)
! define new equally spaced grid s
do j=0,grids_dim-1
grid_s(j+1)=j*ds
enddo
k4=n_c-n_a
! A loop over all obs.
call dtime_setup()
loopoverobs1: &
do i=1,nobs ! loop over obs
dtime=data(itime,i)
obs_check=.false.
call dtime_check(dtime, in_curbin, in_anybin)
if(.not.in_anybin) cycle ! not interested, not even for ibin
if(.not.in_curbin) cycle ! skip rest of lookp
muse(i)=nint(data(iuse,i)) <= jiter
sin2 = sin(data(ilate,i)*deg2rad)**2
dlat=data(ilat,i)
dlon=data(ilon,i)
rocprof=data(iroc,i)
unprof=data(igeoid,i)
tpdpres(i)=data(ihgt,i)
ikx=nint(data(ikxx,i))
! Interpolate log(pres),temperature,specific humidity,
! corrected geopotential heights and topography to obs location
call tintrp2a1(ges_lnprsi,prsltmp,dlat,dlon,dtime,hrdifsig,&
nsig+1,mype,nfldsig)
call tintrp2a1(ges_tv,tges,dlat,dlon,dtime,hrdifsig,&
nsig,mype,nfldsig)
call tintrp2a1(ges_q,qges,dlat,dlon,dtime,hrdifsig,&
nsig,mype,nfldsig)
call tintrp2a1(geop_hgti,hges,dlat,dlon,dtime,hrdifsig,&
nsig+1,mype,nfldsig)
call tintrp2a11(ges_z,zsges,dlat,dlon,dtime,hrdifsig,&
mype,nfldsig)
prsltmp_o(1:nsig,i)=prsltmp(1:nsig) ! needed in minimization
call tintrp2a1(ges_tsen, Tsen(1:nsig,i), dlat,dlon,dtime,hrdifsig, &
nsig, mype,nfldsig)
call tintrp2a1(geop_hgtl, hgtl(1:nsig,i), dlat,dlon,dtime,hrdifsig, &
nsig, mype,nfldsig)
call tintrp2a1(ges_lnprsl,prslnl(1:nsig,i),dlat,dlon,dtime,hrdifsig, &
nsig, mype,nfldsig)
Tvir(1:nsig,i) = tges(1:nsig) ! virtual temperature
sphm(1:nsig,i) = qges(1:nsig) ! specific humidity
hgtl(1:nsig,i) = hgtl(1:nsig,i) + zsges ! mid level geopotential height
hgti(1:nsig+1,i) = hges(1:nsig+1) + zsges ! interface level geopotential height
prslni(1:nsig+1,i) = prsltmp(1:nsig+1) ! interface level log(pressure)
! Compute refractivity index-radius product at interface
!
! Convert geopotential height at layer midpoints to geometric height using
! equations (17, 20, 23) in MJ Mahoney's note "A discussion of various
! measures of altitude" (2001). Available on the web at
! http://mtp.jpl.nasa.gov/notes/altitude/altitude.html
!
! termg = equation 17
! termr = equation 21
! termrg = first term in the denominator of equation 23
! zges = equation 23
termg = grav_equator * &
((one+somigliana*sin2)/sqrt(one-eccentricity*eccentricity*sin2))
termr = semi_major_axis / (one + flattening + grav_ratio - two*flattening*sin2)
termrg = (termg/grav)*termr
qc_layer_SR=.false.
count_SR=0
top_layer_SR=0
bot_layer_SR=0
!$omp parallel do schedule(dynamic,1) private(k,qmean,tmean,fact,pw,pressure,nrefges1,nrefges2,nrefges3)
do k=1,nsig
zges(k) = (termr*hges(k)) / (termrg-hges(k)) ! eq (23) at interface (topo corrected)
gp2gm(k,i)= termr/(termrg-hges(k))+((termr*hges(k))/(termrg-hges(k))**2)
rges(k,i) = zges(k) + zsges + unprof + rocprof ! radius r_i
if(k>1) then
qmean=(qges(k)+qges(k-1))/two
tmean=(tges(k)+tges(k-1))/two
else
qmean=qges(1)
tmean=tges(1)
endif
tges_o(k,i)=tmean ! needed in minimization
qges_o(k)=qmean
fact=(one+fv*qmean)
pw=eps+qmean*(one-eps)
pressure=ten*exp(prsltmp(k)) ! pressure of interface level in mb
nrefges1=n_a*(pressure/tmean)*fact
nrefges2=n_b*qmean*pressure*fact**2/(tmean**2*pw)
nrefges3=k4*fact*qmean*pressure/(tmean*pw)
nrefges(k,i)=nrefges1+nrefges2+nrefges3 ! refractivity N_i
irefges(k)= one+(r1em6*nrefges(k,i)) ! index of refractivity n_i
ref_rad(k)=irefges(k)*rges(k,i) ! refractivity index-radius product x_i
! Terms for the minimization
n_q(k,i)= &
n_a*(pressure/tmean)*fv+&
(n_b/(tmean**2*pw))*pressure*fact*(fact+qmean*two*fv)-&
(n_b/(tmean**2*pw**2))*pressure*qmean*fact**2*(one-eps)+&
(k4*pressure/(tmean*pw))*(fv*qmean+fact)-&
(k4/(tmean*pw**2))*fact*qmean*pressure*(one-eps)
n_p(k,i)= &
ten*((n_a/tmean)*fact+&
(n_b/(tmean**2*pw))*qmean*fact**2+&
(k4/(tmean*pw))*qmean*fact)
n_t(k,i)= &
-n_a*fact*(pressure/tmean**2)-n_b*qmean*fact**2*two*&
(pressure/(tmean**3*pw))-&
(k4/(tmean**2*pw))*fact*qmean*pressure
end do
alt=(tpdpres(i)-rocprof-zsges-unprof)*r1em3
if (alt<= five) then
do k=nsigstart,1,-1
! check for model SR layer at obs location
grad_mod=1000.0_r_kind*(nrefges(k+1,i)-nrefges(k,i))/(rges(k+1,i)-rges(k,i))
if (abs(grad_mod)>= half*crit_grad) then ! SR - likely, to be used in obs SR qc
qc_layer_SR=.true. !SR-likely layer detected
endif
if (abs(grad_mod) >= 0.75_r_kind*crit_grad) then !relax to close-to-SR conditions
count_SR=count_SR+1 ! layers of SR
if (count_SR > 1 ) then
bot_layer_SR=k
else
top_layer_SR=k
bot_layer_SR=top_layer_SR
endif
endif
end do
endif
! locate observation in model vertical grid
hob=tpdpres(i)
call grdcrd1(hob,ref_rad(1),nsig,1)
data(ihgt,i)=hob
! initialize error, error_adjst, and err_final
error(i)=tiny_r_kind
error_adjst(i)=tiny_r_kind
if (hob<three .or. hob>rsig) then
data(ier,i) = zero
ratio_errors(i) = zero
muse(i)=.false.
qcfail_loc(i)=one
endif
! Increment obs counter along with low and high obs counters
if (luse(i))then
awork(1)=awork(1)+one
if(hob > rsig) awork(3)=awork(3)+one
if(hob < one) awork(2)=awork(2)+one
endif
! Save some diagnostic information
! occultation identification
satellite_id = data(isatid,i) ! receiver occ id
transmitter_id = data(iptid,i) ! transmitter occ id
write(cdiagbuf(i),'(2(i4.4))') satellite_id,transmitter_id
rdiagbuf(:,i) = zero
rdiagbuf(1,i) = ictype(ikx) ! observation type
rdiagbuf(20,i) = one ! uses gps_ref (one = use of bending angle)
rdiagbuf(2,i) = data(iprof,i) ! profile identifier
rdiagbuf(3,i) = data(ilate,i) ! lat in degrees
rdiagbuf(4,i) = data(ilone,i) ! lon in degrees
!> xuanli: modified imph in the diag file. In jedi: imph=impp-roc-geoid
rdiagbuf(7,i) = tpdpres(i)-rocprof ! impact height in meters
! rdiagbuf(7,i) = tpdpres(i)-rocprof-unprof ! impact height in meters -- defination in JEDI
!< xuanli
! rdiagbuf(7,i) = tpdpres(i) ! impact parameter in meters
rdiagbuf(8,i) = dtime-time_offset ! obs time (hours relative to analysis time)
! rdiagbuf(9,i) = data(ipctc,i) ! input bufr qc - index of per cent confidence
rdiagbuf(9,i) = zsges ! model terrain (m)
rdiagbuf(11,i) = data(iuse,i) ! data usage flag
rdiagbuf(17,i) = data(igps,i) ! bending angle observation (radians)
rdiagbuf(19,i) = hob ! model vertical grid (interface) if monotone grid
rdiagbuf(22,i) = 1.e+10_r_kind ! spread (filled in by EnKF)
!> xuanli
rdiagbuf(23,i) = tpdpres(i) ! impact parameter in meters
rdiagbuf(24,i) = data(ipctc,i) ! input bufr qc - index of per cent confidence
rdiagbuf(25,i) = data(iptid,i) ! transmitter occ id
rdiagbuf(26,i) = rocprof ! local radius of curvature (m)
rdiagbuf(27,i) = unprof ! geoid undulation (m)
rdiagbuf(28,i) = data(iqfro,i) ! qfro
rdiagbuf(29,i) = data(iascd,i) ! ascending flag
rdiagbuf(30,i) = data(iazm,i) ! azimuth angle
rdiagbuf(31,i) = data(iconstid,i) ! satellite classification
rdiagbuf(32,i) = data(isiid,i) ! occulting satellite
rdiagbuf(33,i) = data(iogce,i) ! Identification of processing center
rdiagbuf(34,i) = data(iref,i) ! refractivity
!< xuanli -
if(ratio_errors(i) > tiny_r_kind) then ! obs inside model grid
if (alt <= five) then
if (top_layer_SR >= 1) then ! SR exists for at least one layer. Check if obs is inside
if ((tpdpres(i)<ref_rad(top_layer_SR+1)) .and. &
(tpdpres(i)<ref_rad(bot_layer_SR))) then !obs below model SR/close-to-SR layer
qcfail(i)=.true.
qc_superr(i)=1
elseif (tpdpres(i)>ref_rad(top_layer_SR+5)) then ! obs above SR/close-to-SR layer
qcfail(i)=.false.
if(hob < top_layer_SR+1) then !location might be aliased to the lower section of the non-monotonicity
hob = tpdpres(i)
call grdcrd1(hob,ref_rad(top_layer_SR+1),nsig-top_layer_SR-1,1) ! only non-monotonic section above SR layer
data(ihgt,i) = hob+top_layer_SR
hob = hob+top_layer_SR
rdiagbuf(19,i) = hob
endif
else ! obs inside model SR/shadow or close-to-SR layer
qcfail(i)=.true.
qc_superr(i)=1
endif
endif
! check for SR in obs, will be updated in genstats.
if ( data(igps,i) >= 0.03_r_kind .and. qc_layer_SR) then
kprof = data(iprof,i)
toss_gps_sub(kprof) = max (toss_gps_sub(kprof),data(igps,i))
qc_layer(i)=1
endif
endif
alt=(tpdpres(i)-rocprof)*r1em3
! get pressure (in mb), temperature and moisture at obs location
call tintrp31(ges_lnprsi(:,:,1:nsig,:),dpressure,dlat,dlon,hob,&
dtime,hrdifsig,mype,nfldsig)
ihob=hob
k1=min(max(1,ihob),nsig)
k2=max(1,min(ihob+1,nsig))
delz=hob-float(k1)
delz=max(zero,min(delz,one))
trefges=tges_o(k1,i)*(one-delz)+tges_o(k2,i)*delz
qrefges=qges_o(k1)*(one-delz)+qges_o(k2)*delz !Lidia
rdiagbuf( 6,i) = ten*exp(dpressure) ! pressure at obs location (hPa) if monotone grid
! atmosphere_pressure_coordinate
rdiagbuf(18,i) = trefges ! temperature at obs location (Kelvin) if monotone grid
rdiagbuf(21,i) = qrefges ! specific humidity at obs location (kg/kg) if monotone grid
commdat=.false.
if (data(isatid,i)>=265 .and. data(isatid,i)<=269) commdat=.true.
if (.not. qcfail(i)) then ! not SR
! Modify error to account for representativeness error.
repe_gps=one
! UKMET-type processing
if((data(isatid,i)==41) .or.(data(isatid,i)==722).or. &
(data(isatid,i)==723).or.(data(isatid,i)==4) .or. &
(data(isatid,i)==42) .or.(data(isatid,i)==3) .or. &
(data(isatid,i)==821).or.(data(isatid,i)==421).or. &
(data(isatid,i)==440).or.(data(isatid,i)==43) .or. &
(data(isatid,i)==5).or.(data(isatid,i)==66)) then
if((data(ilate,i)> r40).or.(data(ilate,i)< -r40)) then
if(alt>r12) then
repe_gps=0.19032_r_kind+0.287535_r_kind*alt-0.00260813_r_kind*alt**2
else
repe_gps=-3.20978_r_kind+1.26964_r_kind*alt-0.0622538_r_kind*alt**2
endif
else
if(alt>r18) then
repe_gps=-1.87788_r_kind+0.354718_r_kind*alt-0.00313189_r_kind*alt**2
else
repe_gps=-2.41024_r_kind+0.806594_r_kind*alt-0.027257_r_kind*alt**2
endif
endif
else
! CDAAC-type processing
if (((data(isatid,i) > 749).and.(data(isatid,i) < 756)).or.commdat) then
if ((data(ilate,i)> r40).or.(data(ilate,i)< -r40)) then
if (alt <= 8.0_r_kind) then
repe_gps=-1.0304261_r_kind+0.3203316_r_kind*alt+0.0141337_r_kind*alt**2
elseif (alt > 8.0_r_kind.and.alt <= r12) then
repe_gps=2.1750271_r_kind+0.0431177_r_kind*alt-0.0008567_r_kind*alt**2
else
repe_gps=-0.3447429_r_kind+0.2829981_r_kind*alt-0.0028545_r_kind*alt**2
endif
else
if (alt <= 4.0_r_kind) then
repe_gps=0.7285212_r_kind-1.1138755_r_kind*alt+0.2311123_r_kind*alt**2
elseif (alt <= r18.and.alt > 4.0_r_kind) then
repe_gps=-3.3878629_r_kind+0.8691249_r_kind*alt-0.0297196_r_kind*alt**2
else
repe_gps=-2.3875749_r_kind+0.3667211_r_kind*alt-0.0037542_r_kind*alt**2
endif
endif
else
if((data(ilate,i)> r40).or.(data(ilate,i)< -r40)) then
if(alt>r12) then
repe_gps=-0.685627_r_kind+0.377174_r_kind*alt-0.00421934_r_kind*alt**2
else
repe_gps=-3.27737_r_kind+1.20003_r_kind*alt-0.0558024_r_kind*alt**2
endif
else
if(alt>r18) then
repe_gps=-2.73867_r_kind+0.447663_r_kind*alt-0.00475603_r_kind*alt**2
else
repe_gps=-3.45303_r_kind+0.908216_r_kind*alt-0.0293331_r_kind*alt**2
endif
endif
endif
endif
repe_gps=exp(repe_gps) ! one/modified error in (rad-1*1E3)
repe_gps= r1em3*(one/abs(repe_gps)) ! modified error in rad
if (commdat) repe_gps=commgpserrinf*repe_gps ! Inflate error for commercial data
ratio_errors(i) = data(ier,i)/abs(repe_gps)
error(i)=one/data(ier,i) ! one/original error
data(ier,i)=one/data(ier,i) ! one/original error
error_adjst(i)= ratio_errors(i)* data(ier,i) !one/adjusted error
! Extending atmosphere above interface level nsig
d_ref_rad=ref_rad(nsig)-ref_rad(nsig-1)
do k=1,nsig_ext
ref_rad(nsig+k)=ref_rad(nsig)+ k*d_ref_rad ! extended x_i
nrefges(nsig+k,i)=nrefges(nsig+k-1,i)**2/nrefges(nsig+k-2,i) ! exended N_i
end do
! Lagrange coefficients
ref_rad(0)=ref_rad(3)
ref_rad(nsig_up+1)=ref_rad(nsig_up-2)
do k=1,nsig_up
call setq(q_w(:,k),ref_rad(k-1:k+1),3)
enddo
muse(i)=nint(data(iuse,i)) <= jiter
! Get refractivity index-radius and [d(ln(n))/dx] in new grid.
intloop: do j=1,grids_dim
ref_rad_s(j)=sqrt(grid_s(j)*grid_s(j)+tpdpres(i)*tpdpres(i)) !x_j
xj(j,i)=ref_rad_s(j)
hob_s=ref_rad_s(j)
call grdcrd1(hob_s,ref_rad(1),nsig_up,1)
if(top_layer_SR >=1) then
if(hob_s < top_layer_SR+1) then !correct if wrong location
hob_s = ref_rad_s(j)
call grdcrd1(hob_s,ref_rad(top_layer_SR+1),nsig_up-top_layer_SR-1,1)
hob_s = hob_s+top_layer_SR
endif
endif
dbend_loc(j,i)=hob_s !location of x_j with respect to extended x_i
if (hob_s < rsig_up) then !obs inside the new grid
ihob=hob_s
! Compute refractivity and derivative at target points
! using Lagrange interpolators
call slagdw(ref_rad(ihob-1:ihob+2),ref_rad_s(j),&
q_w(:,ihob),q_w(:,ihob+1),&
w4,dw4,4)
if(ihob==1) then
w4(4)=w4(4)+w4(1); w4(1:3)=w4(2:4);w4(4)=zero
dw4(4)=dw4(4)+dw4(1);dw4(1:3)=dw4(2:4);dw4(4)=zero
ihob=ihob+1
endif
if(ihob==nsig_up-1) then
w4(1)=w4(1)+w4(4); w4(2:4)=w4(1:3);w4(1)=zero
dw4(1)=dw4(1)+dw4(4); dw4(2:4)=dw4(1:3);dw4(1)=zero
ihob=ihob-1
endif
ddnj(j)=dot_product(dw4,nrefges(ihob-1:ihob+2,i))!derivative (dN/dx)_j
if(ddnj(j)>zero) then
!> xuanli -- set dbend, rdiagbuf(5), rdiagbuf(17) as JEDI missing
dbend=-3.368795e+38
rdiagbuf( 5,i) = -3.368795e+38
rdiagbuf( 17,i) = -3.368795e+38
!< xuanli
qcfail(i)=.true.
qc_ddnj(i)=1
data(ier,i) = zero
ratio_errors(i) = zero
muse(i)=.false.
cycle loopoverobs1 ! reject observation
endif
else
obs_check=.true.
if (obs_check) then ! only once per obs here
nobs_out=nobs_out+1
d_ref_rad=ref_rad(nsig)-ref_rad(nsig-1)
do kk=1,20
ref_rad_out(nsig_up+kk)=ref_rad(nsig_up)+ kk*d_ref_rad ! extended x_i
end do
do kk=1,nsig_up
ref_rad_out(kk)=ref_rad(kk)
enddo
endif
hob_s=ref_rad_s(j)
call grdcrd1(hob_s,ref_rad_out,nsig_up+20,1)
hob_s_top=max(hob_s,hob_s_top)
endif !obs in new grid
end do intloop
if (obs_check) then ! reject observation
!> xuanli -- set dbend, rdiagbuf(5), rdiagbuf(17) as JEDI missing
rdiagbuf( 5,i) = -3.368795e+38
rdiagbuf( 17,i) = -3.368795e+38
dbend = -3.368795e+38
!< xuanli
qcfail(i)=.true.
data(ier,i) = zero
ratio_errors(i) = zero
muse(i)=.false.
cycle loopoverobs1
endif
! bending angle (radians)
dbend=ds*ddnj(1)/ref_rad_s(1)
do j=2,grids_dim
ddbend=ds*ddnj(j)/ref_rad_s(j)
dbend=dbend+two*ddbend
end do
dbend=-r1em6*tpdpres(i)*dbend
! Accumulate diagnostic information
rdiagbuf( 5,i) = (data(igps,i)-dbend)/data(igps,i) ! incremental bending angle (x100 %)
data(igps,i)=data(igps,i)-dbend !innovation vector
! Remove very large simulated values
if(dbend > 0.05_r_kind) then
!> xuanli -- set dbend, rdiagbuf(5), rdiagbuf(17) as JEDI missing
rdiagbuf( 5,i) = -3.368795e+38
rdiagbuf( 17,i) = -3.368795e+38
dbend = -3.368795e+38
!< xuanli
data(ier,i) = zero
ratio_errors(i) = zero
qcfail(i)=.true.
qc_largeBA(i)=1
muse(i)=.false.
endif
if (alt <= gpstop) then ! go into qc checks
if ((alt <= commgpstop) .or. (.not.commdat)) then
cgrossuse=cgross(ikx)
cermaxuse=cermax(ikx)
cerminuse=cermin(ikx)
! Gross error check
obserror = one/max(ratio_errors(i)*data(ier,i),tiny_r_kind)
obserrlm = max(cerminuse,min(cermaxuse,obserror))
residual = abs(data(igps,i))
ratio = residual/obserrlm
if (ratio > cgrossuse) then
if (luse(i)) then
awork(4) = awork(4)+one
endif
qcfail_gross(i)=one
data(ier,i) = zero
ratio_errors(i) = zero
muse(i)=.false.
else
! Statistics QC check if obs passed gross error check
cutoff=zero
if (((data(isatid,i) > 749).and.(data(isatid,i) < 756)).or.commdat) then
cutoff1=(-4.725_r_kind+0.045_r_kind*alt+0.005_r_kind*alt**2)*one/two
else
cutoff1=(-4.725_r_kind+0.045_r_kind*alt+0.005_r_kind*alt**2)*two/three
end if
cutoff2=1.5_r_kind+one*cos(data(ilate,i)*deg2rad)
if(trefges<=r240) then
cutoff3=two
else
cutoff3=0.005_r_kind*trefges**2-2.3_r_kind*trefges+266_r_kind
endif
if (((data(isatid,i) > 749).and.(data(isatid,i) < 756)).or.commdat) then
cutoff3=cutoff3*one/two
else
cutoff3=cutoff3*two/three
end if
if (((data(isatid,i) > 749).and.(data(isatid,i) < 756)).or.commdat) then
cutoff4=(four+eight*cos(data(ilate,i)*deg2rad))*one/two
else
cutoff4=(four+eight*cos(data(ilate,i)*deg2rad))*two/three
end if
cutoff12=((36_r_kind-alt)/two)*cutoff2+&
((alt-34_r_kind)/two)*cutoff1
cutoff23=((eleven-alt)/two)*cutoff3+&
((alt-nine)/two)*cutoff2
cutoff34=((six-alt)/two)*cutoff4+&
((alt-four)/two)*cutoff3
if(alt>36_r_kind) cutoff=cutoff1
if((alt<=36_r_kind).and.(alt>34_r_kind)) cutoff=cutoff12
if((alt<=34_r_kind).and.(alt>eleven)) cutoff=cutoff2
if((alt<=eleven).and.(alt>nine)) cutoff=cutoff23
if((alt<=nine).and.(alt>six)) cutoff=cutoff3
if((alt<=six).and.(alt>four)) cutoff=cutoff34
if(alt<=four) cutoff=cutoff4
if (((data(isatid,i) > 749).and.(data(isatid,i) < 756)).or.commdat) then
cutoff=two*cutoff*r0_01
else
cutoff=three*cutoff*r0_01
end if
if(abs(rdiagbuf(5,i)) > cutoff) then
qcfail(i)=.true.
qc_stat(i)=1
data(ier,i) = zero
ratio_errors(i) = zero
muse(i) = .false.
end if
end if !gross qc check
end if ! commdat < commgpstop
end if ! qc checks (only below 50km)
! Remove obs above 50 km
if((alt > gpstop) .or. (commdat .and. (alt > commgpstop))) then
data(ier,i) = zero
ratio_errors(i) = zero
qcfail_high(i)=one
muse(i)=.false.
endif
! Remove MetOP/GRAS data below 8 km
if( (alt <= eight) .and. &
((data(isatid,i)==4).or.(data(isatid,i)==3).or.(data(isatid,i)==5))) then
qcfail(i)=.true.
qc_metop(i)=1
data(ier,i) = zero
ratio_errors(i) = zero
muse(i)=.false.
endif
end if ! obs above super-refraction and shadow layers
end if ! obs inside the vertical grid
end do loopoverobs1 ! end of loop over observations
if (nobs_out>=1) then
write(6,*)'WARNING GPSRO:',nobs_out,'obs outside integration grid. Increase nsig_ext to',&
int(hob_s_top)-nsig+1
endif
! Loop over observation profiles. Compute penalty
! terms, and accumulate statistics.
if(last_pass) then