-
Notifications
You must be signed in to change notification settings - Fork 156
/
planeflight_mod.F90
2826 lines (2445 loc) · 100 KB
/
planeflight_mod.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!------------------------------------------------------------------------------
! GEOS-Chem Global Chemical Transport Model !
!------------------------------------------------------------------------------
!BOP
!
! !MODULE: planeflight_mod.F90
!
! !DESCRIPTION: Module PLANEFLIGHT\_MOD contains variables and routines which
! are used to "fly" a plane through the GEOS-Chem model simulation. This is
! useful for comparing model results with aircraft observations.
!\\
!\\
! !INTERFACE:
!
MODULE PLANEFLIGHT_MOD
!
! !USES:
!
USE inquireMod, ONLY : findFreeLUN
USE PRECISION_MOD ! For GEOS-Chem Precision (fp)
IMPLICIT NONE
PRIVATE
!
! !PUBLIC MEMBER FUNCTIONS:
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! Prior to 5/12/16:
! This routine does not work with the FlexChem implementation. We need to
! rewrite this code to get the necessary information from KPP (mps, 5/12/16)
! PUBLIC :: ARCHIVE_RXNS_FOR_PF
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PUBLIC :: CLEANUP_PLANEFLIGHT
PUBLIC :: PLANEFLIGHT
PUBLIC :: SETUP_PLANEFLIGHT
PUBLIC :: SET_PLANEFLIGHT
!
! !PRIVATE MEMBER FUNCTIONS:
!
PRIVATE :: AN_SETUP
PRIVATE :: INIT_PLANEFLIGHT
PRIVATE :: NOY_SETUP
PRIVATE :: READ_VARIABLES
PRIVATE :: READ_POINTS
PRIVATE :: RO2_SETUP
PRIVATE :: TEST_VALID
PRIVATE :: WRITE_VARS_TO_FILE
!
! !REMARKS:
! The quantities that are saved to disk by the planeflight diagnostic were
! requested by GEOS-Chem users. If you would like to save out a new quantity,
! then you will have to make your own modifications in this module.
!
! !REVISION HISTORY:
! See https://github.com/geoschem/geos-chem for complete history
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !PRIVATE TYPES:
!
!=================================================================
! MODULE VARIABLES:
!
! DO_PF : Turn on the planeflight diagnostic? (T/F)
! MAXVARS : Maximum # of variables allowed
! MAXPOINTS : Maximum # of flight track points allowed
! MAXREAC : Maximum # of reactions allowed
! MAXRO2 : Maximum # of RO2 constituents allowed
! NPOINTS : Number of flight track points
! PPOINT : Pointer to last measured output
! PDATE : Array of dates at each flight point
! PTIME : Array of times at each flight point
! PTAU : Array of TAU's at each flight point
! PLATTD : Array of latitude at each flight point
! PLONGTD : Array of longitude at each flight point
! PPRESS : Array of pressure at each flight point
! PTYPE : Array of ID'#S at each flight point
! NPVAR : # of var's to be saved at each flight point
! PVAR : Array of variable indices
! PNAME : Array of variable names corresponding to PVAR
! NPREAC : # of variables that are really rxns
! PREAC : Array of rxn index numbers
! PRRATE : Array of rxn rates for each entry in PREAC
! JPREAC : Array of j-rate rxn index numbers
! NJPREAC : # of variables that are j-rate rxns
! NRO2 : # number of RO2 constituents
! PRO2 : Array of species that are RO2 const's
! INFILENAME : Name of input file defining the flight track
! OUTFILENAME : Name of output file
!=================================================================
! Logicals
LOGICAL :: DO_PF
! Parameters
INTEGER, PARAMETER :: MAXVARS = 800
INTEGER, PARAMETER :: MAXPOINTS = 100000
INTEGER, PARAMETER :: MAXREAC = 50
INTEGER, PARAMETER :: MAXRO2 = 56
INTEGER, PARAMETER :: MAXAN = 20
INTEGER, PARAMETER :: MAXNOY = 20
! For specifying flight track points
INTEGER :: NPOINTS
INTEGER :: PPOINT
! For specifying date/time
INTEGER, ALLOCATABLE :: PDATE(:)
INTEGER, ALLOCATABLE :: PTIME(:)
REAL(fp), ALLOCATABLE :: PTAU(:)
! For specifying lat/lon/alt and ID type
REAL*4, ALLOCATABLE :: PLATTD(:)
REAL*4, ALLOCATABLE :: PLONGTD(:)
REAL*4, ALLOCATABLE :: PPRESS(:)
REAL*4, ALLOCATABLE :: POBS(:)
REAL*4, ALLOCATABLE :: PTAMB(:)
REAL*4, ALLOCATABLE :: PH2OMR(:)
REAL*4, ALLOCATABLE :: PPOTTEMP(:)
REAL*4, ALLOCATABLE :: PRH(:)
REAL*4, ALLOCATABLE :: PGPSALT(:)
CHARACTER(LEN=7), ALLOCATABLE :: PTYPE(:)
! For specifying variables to save at each flight point
INTEGER :: NPVAR
INTEGER, ALLOCATABLE :: PVAR(:)
CHARACTER(LEN=10), ALLOCATABLE :: PNAME(:)
! For specifying rxns to save at each flight point
INTEGER :: NPREAC
INTEGER, ALLOCATABLE :: PREAC(:)
REAL(fp), ALLOCATABLE :: PRRATE(:,:,:,:)
! and for photolysis reactions (j-rates)
INTEGER, ALLOCATABLE :: JPREAC(:)
INTEGER :: NJPREAC
! For rate of production
INTEGER :: NPROD
INTEGER, ALLOCATABLE :: IPROD(:)
! For specifying RO2 constituents at each flight point
INTEGER :: NPRO2
INTEGER :: PRO2(MAXRO2)
! For specifying NOY constituents at each flight point
INTEGER :: NPNOY
INTEGER :: PNOY(MAXNOY)
! For specifying AN constituents at each flight point
INTEGER :: NPAN
INTEGER :: P_AN(MAXAN)
! Input/output file names
CHARACTER(LEN=255) :: INFILENAME, INF
CHARACTER(LEN=255) :: OUTFILENAME, OUTF
! Logical unit numbers
INTEGER :: IU_FILE
INTEGER :: IU_PLANE
CONTAINS
!EOC
!------------------------------------------------------------------------------
! GEOS-Chem Global Chemical Transport Model !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: setup_planeflight
!
! !DESCRIPTION: Subroutine SETUP\_PLANEFLIGHT reads information from the
! input file in order to initialize the planeflight diagnostic. Also
! calls INIT\_PLANEFLIGHT to allocate and zero module arrays.
!\\
!\\
! !INTERFACE:
!
SUBROUTINE SETUP_PLANEFLIGHT( Input_Opt, State_Chm, State_Grid, &
State_Met, RC )
!
! !USES:
!
USE ErrCode_Mod
USE FILE_MOD, ONLY : FILE_EXISTS
USE FILE_MOD, ONLY : IOERROR
USE Input_Opt_Mod, ONLY : OptInput
USE State_Chm_Mod, ONLY : ChmState
USE State_Grid_Mod, ONLY : GrdState
USE State_Met_Mod, ONLY : MetState
USE TIME_MOD, ONLY : EXPAND_DATE
USE TIME_MOD, ONLY : GET_NYMD
USE TIME_MOD, ONLY : GET_NHMS
!
! !INPUT PARAMETERS:
!
TYPE(OptInput), INTENT(IN) :: Input_Opt ! Input Options object
TYPE(ChmState), INTENT(IN) :: State_Chm ! Chemistry State object
TYPE(GrdState), INTENT(IN) :: State_Grid ! Grid State object
TYPE(MetState), INTENT(IN) :: State_Met ! Meteorology State object
!
! !OUTPUT PARAMETERS:
!
INTEGER, INTENT(OUT) :: RC ! Success or failure?
!
! !REMARKS:
!
! !REVISION HISTORY:
! 30 Jul 2002 - M. Evans - Initial version
! See https://github.com/geoschem/geos-chem for complete history
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
LOGICAL, SAVE :: FIRST = .TRUE.
LOGICAL :: IS_OPEN
INTEGER :: I, IP, N, TEMP, LENGTH
INTEGER :: RN, COUNTER, IOS, NYMD, NHMS
CHARACTER(LEN=6) :: TYPE
!=================================================================
! SETUP_PLANEFLIGHT begins here!
!=================================================================
! Assume that there is flight data for today
DO_PF = .TRUE.
! Find a free file LUN
IU_FILE = findFreeLun()
! Get date & time
NYMD = GET_NYMD()
NHMS = GET_NHMS()
! Copy file names to local variables
INF = INFILENAME
OUTF = OUTFILENAME
! Replace any date & time tokens in the file names
CALL EXPAND_DATE( INF, NYMD, NHMS )
CALL EXPAND_DATE( OUTF, NYMD, NHMS )
! If we can't find a flighttrack file for today's date, return
IF ( .not. FILE_EXISTS( INF ) ) THEN
DO_PF = .FALSE.
RETURN
ENDIF
! Echo info
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
WRITE( 6, 99 )
WRITE( 6, 100 ) TRIM( INF ), IU_FILE
99 FORMAT( 'P L A N E F L I G H T D I A G N O S T I C' )
100 FORMAT( /, 'SETUP_PLANEFLIGHT: Reading ',a, ' on unit ', i4 )
WRITE( 6, '(a)' )
ENDIF
! Compute # of species and # of points & allocate arrays
CALL INIT_PLANEFLIGHT( Input_Opt, State_Grid )
! Return if there are no flight track points for today
IF ( NPOINTS == 0 ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, '(a)' ) 'No flight track found for today!'
ENDIF
DO_PF = .FALSE.
RETURN
ENDIF
!=================================================================
! Open file and read info
!=================================================================
! Open input file
OPEN( IU_FILE, FILE=TRIM( INF ), IOSTAT=IOS )
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'setup_planeflight:1')
! Read variables to be output -- sort into PVAR array by type
CALL READ_VARIABLES( Input_Opt, State_Chm, IU_FILE, RC )
! Read information about each point (date/time/lon/lat/alt)
CALL READ_POINTS( Input_Opt, State_Grid, State_Met, IU_FILE, RC)
! Close the file
CLOSE( IU_FILE )
! Set the pointer to the first record
PPOINT = 1
!=================================================================
! Find the species # for all components of RO2 (fullchem only)
!=================================================================
CALL RO2_SETUP( Input_Opt, State_Chm, RC )
!=================================================================
! Find the species # for all components of NOY (fullchem only)
!=================================================================
CALL NOY_SETUP( Input_Opt, State_Chm, RC )
!=================================================================
! Find the species # for all components of AN (fullchem only)
!=================================================================
CALL AN_SETUP( Input_Opt, State_Chm, RC )
! Fancy output
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
!=================================================================
! Open today's plane.log file and write file header
!=================================================================
! Close previously opened plane.log file
INQUIRE( IU_PLANE, OPENED=IS_OPEN )
IF( IS_OPEN ) CLOSE( IU_PLANE )
! Close previously-opened file
CLOSE( IU_PLANE )
! Find a free file LUN
IU_PLANE = findFreeLUN()
! Open output file
OPEN( IU_PLANE, FILE=TRIM( OUTF ), STATUS='UNKNOWN', IOSTAT=IOS )
! Error check
IF ( IOS /= 0 ) THEN
CALL IOERROR( IOS, IU_PLANE, 'setup_planeflight:1' )
ENDIF
! Write header
IF ( Input_Opt%amIRoot ) THEN
WRITE( IU_PLANE, 110 ) 'POINT', 'TYPE', 'YYYYMMDD', 'HHMM', &
'LAT', 'LON', 'PRESS', 'OBS', &
'T-IND', 'P-IND', 'I-IND', 'J-IND', &
( PNAME(I), I=1,NPVAR )
ENDIF
! FORMAT string
#if defined( TOMAS )
110 FORMAT( A5,X,A7,X,A8,X,A4,X,A7,X,A7,X,A7,X,A10,X, &
A9,X,A3,X,A5,X,A5,X,250(a10,x) )
#else
110 FORMAT( A5,X,A7,X,A8,X,A4,X,A7,X,A7,X,A7,X,A10,X, &
A9,X,A3,X,A5,X,A5,X,250(a11,x) )
#endif
END SUBROUTINE SETUP_PLANEFLIGHT
!EOC
!------------------------------------------------------------------------------
! GEOS-Chem Global Chemical Transport Model !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: read_variables
!
! !DESCRIPTION: Subroutine READ\_VARIABLES reads the list of variables
! (chemical species, rxn rates, GMAO met fields, or GEOS-Chem species) to be
! printed out and sorts the information into the appropriate module variables.
!\\
!\\
! !INTERFACE:
!
SUBROUTINE READ_VARIABLES( Input_Opt, State_Chm, IU_FILE, RC )
!
! !USES:
!
USE ErrCode_Mod
USE ERROR_MOD, ONLY : GEOS_CHEM_STOP
USE FILE_MOD, ONLY : IOERROR
USE Input_Opt_Mod, ONLY : OptInput
USE Species_Mod, ONLY : Species
USE State_Chm_Mod, ONLY : ChmState
!
! !INPUT PARAMETERS:
!
TYPE(OptInput), INTENT(IN) :: Input_Opt ! Input Options object
TYPE(ChmState), INTENT(IN) :: State_Chm ! Chemistry State object
INTEGER, INTENT(IN) :: IU_FILE ! Logical unit # for ASCII read
!
! !OUTPUT PARAMETERS:
!
INTEGER, INTENT(OUT) :: RC ! Success or failure?
!
! !REVISION HISTORY:
! 30 Jul 2002 - M. Evans - Initial version
! See https://github.com/geoschem/geos-chem for complete history
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
LOGICAL :: IS_FULLCHEM
INTEGER :: M, N, NUM, R, IK, IOS, nAdvect, P
INTEGER :: PR, J, NF, FM
CHARACTER(LEN=255) :: LINE
CHARACTER(LEN=10) :: PRODNAME
! Objects
TYPE(Species), POINTER :: SpcInfo
!=================================================================
! READ_VARIABLES begins here!
!=================================================================
! Assume success
RC = GC_SUCCESS
! Get fields from Input_Opt
IS_FULLCHEM = Input_Opt%ITS_A_FULLCHEM_SIM
! Number of advected species
nAdvect = State_Chm%nAdvect
! Initialize pointer
SpcInfo => NULL()
! Read four lines of header
DO N = 1, 4
READ( IU_FILE, '(a)', IOSTAT=IOS )
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'read_variables:1')
ENDDO
! Read in the number of species to be output
! Read in as I4 now for the number of variables we save (skim, 7/24/13)
READ( IU_FILE, '(i4)', IOSTAT=IOS ) NPVAR
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'read_variables:2' )
! Read in a separation line
READ( IU_FILE, '(a)', IOSTAT=IOS )
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'read_variables:3' )
! Echo to stdout
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, '(a)' ) ' # Species PVAR'
WRITE( 6, '(a)' ) '-----------------------------'
ENDIF
!=================================================================
! Sort variables by type; assign indices to PVAR, PREAC arrays
! NOTE: Variables for which PVAR(N) = 0 will be skipped!
!=================================================================
! Zero reaction counter
R = 0
! Zero production counter
PR = 0
! Loop over all variables
DO N = 1, NPVAR
! Read each line
READ( IU_FILE, '(a)', IOSTAT=IOS ) LINE
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'read_variables:4')
! Save the name of each variable into the global PNAME array
PNAME(N) = LINE(1:10)
! We are searching for a ...
SELECT CASE ( LINE(1:4) )
!===========================================================
! GEOS-CHEM tracer: listed as "TRA_001", etc.
! PVAR offset: 100000
!===========================================================
CASE ( 'TRA_' )
! Extract tracer # from the string
READ( LINE(5:14), '(i10)' ) NUM
! Make sure the tracer # is valid!
IF ( NUM < 0 .or. NUM > nAdvect ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, 100 ) TRIM( LINE )
100 FORMAT( 'TRACER ', i4, ' is out of range!' )
WRITE( 6, '(a)' ) 'STOP in SETUP_PLANEFLIGHT!'
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
ENDIF
CALL GEOS_CHEM_STOP
ENDIF
! Save in PVAR -- add offset of 100000
PVAR(N) = 100000 + NUM
#ifdef TOMAS
! Add case matching for TOMAS microphysics rates (win, 7/28/09)
!===========================================================
! GEOS-CHEM tracer: listed as "TMS_001", etc.
! PVAR offset: 200000
!===========================================================
CASE ( 'TMS_' )
! Extract tracer # from the string
READ( LINE(5:14), '(i10)' ) NUM
! Make sure the tracer # is valid!
IF ( NUM < 0 .or. NUM > nAdvect ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, 100 ) TRIM( LINE )
WRITE( 6, '(a)' ) 'STOP in SETUP_PLANEFLIGHT!'
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
CALL GEOS_CHEM_STOP
ENDIF
ENDIF
! Save in PVAR -- add offset of 200000
PVAR(N) = 200000 + NUM
#endif
!===========================================================
! GMAO met field: listed as "GMAO_TEMP", etc.
! PVAR offset: 1000
!===========================================================
CASE ( 'GMAO' )
IF ( LINE == 'GMAO_TEMP' ) PVAR(N) = 1001
IF ( LINE == 'GMAO_ABSH' ) PVAR(N) = 1002
IF ( LINE == 'GMAO_SURF' ) PVAR(N) = 1003
IF ( LINE == 'GMAO_PSFC' ) PVAR(N) = 1004
IF ( LINE == 'GMAO_UWND' ) PVAR(N) = 1005
IF ( LINE == 'GMAO_VWND' ) PVAR(N) = 1006
IF ( LINE == 'GMAO_IIEV' ) PVAR(N) = 1007
IF ( LINE == 'GMAO_JJEV' ) PVAR(N) = 1008
IF ( LINE == 'GMAO_LLEV' ) PVAR(N) = 1009
IF ( LINE == 'GMAO_RELH' ) PVAR(N) = 1010
IF ( LINE == 'GMAO_PVRT' ) PVAR(N) = 1011
IF ( LINE == 'GMAO_PSLV' ) PVAR(N) = 1012
IF ( LINE == 'GMAO_AVGW' ) PVAR(N) = 1013
IF ( LINE == 'GMAO_THTA' ) PVAR(N) = 1014
IF ( LINE == 'GMAO_PRES' ) PVAR(N) = 1015
IF ( LINE == 'GMAO_ICE00' ) PVAR(N) = 1100
IF ( LINE == 'GMAO_ICE10' ) PVAR(N) = 1101
IF ( LINE == 'GMAO_ICE20' ) PVAR(N) = 1102
IF ( LINE == 'GMAO_ICE30' ) PVAR(N) = 1103
IF ( LINE == 'GMAO_ICE40' ) PVAR(N) = 1104
IF ( LINE == 'GMAO_ICE50' ) PVAR(N) = 1105
IF ( LINE == 'GMAO_ICE60' ) PVAR(N) = 1106
IF ( LINE == 'GMAO_ICE70' ) PVAR(N) = 1107
IF ( LINE == 'GMAO_ICE80' ) PVAR(N) = 1108
IF ( LINE == 'GMAO_ICE90' ) PVAR(N) = 1109
!===========================================================
! Column aerosol optical depths (same order as for FAST-J)
! PVAR offset: 2000
!===========================================================
CASE ( 'AODC' )
IF ( LINE == 'AODC_SULF' ) PVAR(N) = 2001
IF ( LINE == 'AODC_BLKC' ) PVAR(N) = 2002
IF ( LINE == 'AODC_ORGC' ) PVAR(N) = 2003
IF ( LINE == 'AODC_SALA' ) PVAR(N) = 2004
IF ( LINE == 'AODC_SALC' ) PVAR(N) = 2005
IF ( LINE == 'AODC_DUST' ) PVAR(N) = 2006
IF ( LINE == 'AODC_TOT' ) PVAR(N) = 2007
!===========================================================
! Aerosol optical depths below the plane
! (same order as for FAST-J) PVAR offset: 3000
!===========================================================
CASE ( 'AODB' )
IF ( LINE == 'AODB_SULF' ) PVAR(N) = 3001
IF ( LINE == 'AODB_BLKC' ) PVAR(N) = 3002
IF ( LINE == 'AODB_ORGC' ) PVAR(N) = 3003
IF ( LINE == 'AODB_SALA' ) PVAR(N) = 3004
IF ( LINE == 'AODB_SALC' ) PVAR(N) = 3005
IF ( LINE == 'AODB_DUST' ) PVAR(N) = 3006
IF ( LINE == 'AODB_TOT' ) PVAR(N) = 3007
!===========================================================
! Hg(II) Partitioning - eds 10/27/11 PVAR offset: 4000
!===========================================================
CASE ( 'HG2_' )
IF ( LINE == 'HG2_FRACG' ) PVAR(N) = 4001
IF ( LINE == 'HG2_FRACP' ) PVAR(N) = 4002
!===========================================================
! ISORROPIA/HETP H+, pH, water, and bisulfate (eam, 06/2015)
!===========================================================
CASE( 'ISOR' )
! ISORROPIA H+ (mol/L):
IF ( LINE == 'ISOR_HPLUS' ) PVAR(N) = 5001
! ISORROPIA pH (non-ideal system, so pH can be negative)
IF ( LINE == 'ISOR_PH' ) PVAR(N) = 5002
! ISORROPIA aerosol water (ug/m3 air)
IF ( LINE == 'ISOR_AH2O' ) PVAR(N) = 5003
! ISORROPIA bisulfate (mol/L):
IF ( LINE == 'ISOR_HSO4' ) PVAR(N) = 5004
!===========================================================
! Local time (eam, 06/2015)
!===========================================================
CASE( 'TIME' )
! Local time:
IF ( LINE == 'TIME_LT' ) PVAR(N) = 6001
!===========================================================
! Uptake coefficient for SOA formation (eam, 06/2015)
!===========================================================
CASE( 'GAMM' )
! Skip if not full-chemistry
IF ( IS_FULLCHEM ) THEN
! Increment reaction counter:
R = R + 1
IF ( LINE == 'GAMM_EPOX' ) THEN
PVAR(N) = 22001
PREAC(R) = 22001
ELSE IF ( LINE == 'GAMM_IMAE' ) THEN
PVAR(N) = 22002
PREAC(R) = 22002
ELSE IF ( LINE == 'GAMM_ISOPN' ) THEN
PVAR(N) = 22003
PREAC(R) = 22003
ELSE IF ( LINE == 'GAMM_DHDN' ) THEN
PVAR(N) = 22004
PREAC(R) = 22004
ELSE IF ( LINE == 'GAMM_GLYX' ) THEN
PVAR(N) = 22005
PREAC(R) = 22005
ENDIF
ENDIF
!===========================================================
! AQUEOUS AEROSOL properties (eam, 08/2015)
!===========================================================
CASE( 'AQAE' )
! Aqueous aerosol radius (cm):
IF ( LINE == 'AQAER_RAD' ) PVAR(N) = 7001
! Aqueous aerosol surface area (cm2/cm3):
IF ( LINE == 'AQAER_SURF' ) PVAR(N) = 7002
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! This code needs to be updated to work with FlexChem (mps, 6/13/17)
!!===========================================================
!! Production rate of CSPEC species (molec/cm3/s)
!! (eam, 08/2015):
!!===========================================================
!CASE( 'PROD' )
!
! ! Skip if not full chem:
! IF ( IS_FULLCHEM ) THEN
!
! ! Increment prod rate reaction counter:
! PR = PR + 1
!
! ! Initialize:
! PRODNAME = ''
!
! ! Extract species name:
! PRODNAME = LINE(6:15)
!
! ! Get family integer:
! DO NF = 1, NFAMILIES
! IF ( FAM_NAME(NF) == TRIM(PRODNAME) ) THEN
! ! Loop through family members:
! DO FM = 1, FAM_NMEM(NF)
! ! Loop through JSPEC species:
! DO J = 1, NSPEC(NCS)
! IF ( NAMEGAS(J) == FAM_MEMB(FM, NF) ) THEN
! IPROD(PR) = J
! ENDIF
! ENDDO ! CSPEC species
! ENDDO ! family members
! ENDIF
! ENDDO
!
! PVAR(N) = 8000 + PR
!
! ENDIF
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! Prior to 6/20/16:
! This diagnostic does not work with the FlexChem implementation. We need
! to rewrite it to get the necessary information from KPP (mps, 6/20/16)
!!===========================================================
!! Rxn rate: listed as "REA_001", etc.
!! PVAR offset: 10000
!!===========================================================
!CASE ( 'REA_' )
!
! ! Skip if not full-chemistry
! IF ( IS_FULLCHEM ) THEN
!
! ! Increment rxn counter
! R = R + 1
!
! IF ( TRIM( LINE ) == 'REA_O1D' ) THEN
!
! ! O1D is a special rxn, give it offset of 20000
! PVAR(N) = 20000
! PREAC(R) = 20000
!
! ELSE IF ( TRIM( LINE ) == 'REA_N2O5' ) THEN
!
! ! N2O5 hydrolysis is another special rxn
! ! give it an offset of 21000
! PVAR(N) = 21000
! PREAC(R) = 21000
!
! ELSE
! !==================================================
! ! NOTE: the reaction numbers listed in smv2.log
! ! aren't really used to index rxns. The
! ! rxns get reordered. Find the right rxn number,
! ! which is stored in NOLDFNEW. We assume only one
! ! chemistry scheme. (mje, bmy, 8/1/03)
! !==================================================
!
! ! Extract tracer # from the string
! READ( LINE(5:14), '(i10)' ) NUM
!
! ! Initialize
! PVAR(N) = -999
! PREAC(R) = -999
!
! ! Search for proper rxn number
! DO IK = 1, NMTRATE
!
! ! Offset other reaction rates by 10000
! IF ( NOLDFNEW(IK,1) == NUM ) THEN
! PVAR(N) = 10000 + IK
! PREAC(R) = 10000 + IK
! EXIT
! ENDIF
! ENDDO
!
! ! Stop w/ error
! IF ( PVAR(N) == -999 ) THEN
! IF ( Input_Opt%amIRoot ) THEN
! WRITE (6,*) 'Cant match up reaction number'
! WRITE (6,*) NUM
! WRITE (6,*) 'Is it the second line of the'
! WRITE (6,*) 'Three body reaction'
! WRITE (6,*) 'Stopping'
! ENDIF
! CALL GEOS_CHEM_STOP
! ENDIF
! ENDIF
! ENDIF
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! 21/12/20 - TMS: access J-rates already stored in State_Diag
!===========================================================
! J-rate Rxn rate: listed as "JVL_001", etc.
! PVAR offset: 30000
!===========================================================
CASE ( 'JVL_' )
! Skip if not full-chemistry
IF ( IS_FULLCHEM ) THEN
! Increment rxn counter
R = R + 1
!==================================================
! NOTE: JVL_??? is translated to indexes from FJX_j2j.dat
!==================================================
! Extract tracer # from the string
READ( LINE(5:14), '(i10)' ) NUM
! Initialize
PVAR(N) = -999
JPREAC(R) = -999
P = -999 ! GEOS-Chem photolyis species ID
! Loop the reaciton branches and find the correct "P" index
DO IK = 1, State_Chm%Phot%nMaxPhotRxns
! GC photolysis species index
P = State_Chm%Phot%GC_Photo_Id(NUM)
! If this FAST_JX photolysis species maps to a valid
! GEOS-Chem photolysis species (for this simulation)...
IF ( P > 0 ) THEN
! Archive the instantaneous photolysis rate
! (summing over all reaction branches)
IF ( IK == P ) THEN
PVAR(N) = 30000 + IK
JPREAC(R) = 30000 + IK
EXIT
ENDIF
ENDIF
ENDDO
! Stop w/ error
IF ( PVAR(N) == -999 ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE (6,*) 'Cant match up J-rate reaction number'
WRITE (6,*) NUM, P
WRITE (6,*) 'NOTE: Reactions indexs are from FJX_j2j.dat'
WRITE (6,*) 'Stopping'
ENDIF
CALL GEOS_CHEM_STOP
ENDIF
ENDIF
!===========================================================
! Species: listed as "O3", "C2H6", etc.
! PVAR offset: 0
!===========================================================
CASE DEFAULT
! Loop over all species
! match w/ species as read from disk
DO M = 1, State_Chm%nSpecies
! Get info about this species from the species database
SpcInfo => State_Chm%SpcData(M)%Info
IF ( TRIM( SpcInfo%Name ) == TRIM( LINE ) ) THEN
PVAR(N) = M
EXIT
ENDIF
! Free pointer
SpcInfo => NULL()
ENDDO
! Skip if not full-chemistry
IF ( IS_FULLCHEM ) THEN
! Special flag for RO2 species
IF ( TRIM( LINE ) == 'RO2' ) PVAR(N) = 999
! Special flag for AN species FP
IF ( TRIM( LINE ) == 'AN' ) PVAR(N) = 998
! Special flag for NOy species FP
IF ( TRIM( LINE ) == 'NOy' ) PVAR(N) = 997
ENDIF
! Error check
IF ( PVAR(N) == 0 ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, '(a)' ) 'ERROR: invalid species!'
WRITE( 6, 110 ) TRIM( LINE )
110 FORMAT( 'Species ', a, ' not found!' )
WRITE( 6, '(a)' ) 'STOP in PLANEFLIGHT!'
CALL GEOS_CHEM_STOP
ENDIF
ENDIF
END SELECT
! Echo species names/numbers to screen
WRITE( 6, 120 ) N, TRIM( LINE ), PVAR(N)
120 FORMAT( i4, 1x, a12, 1x, i10 )
ENDDO
END SUBROUTINE READ_VARIABLES
!EOC
!------------------------------------------------------------------------------
! GEOS-Chem Global Chemical Transport Model !
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE: read_points
!
! !DESCRIPTION: Subroutine READ\_POINTS reads the information (ID, date, time,
! lat, lon, pressure) for each measurement listed in the input file, and
! sorts these into the appropriate module variables.
!\\
!\\
! !INTERFACE:
!
SUBROUTINE READ_POINTS( Input_Opt, State_Grid, State_Met, IU_FILE, RC )
!
! !USES:
!
USE ErrCode_Mod
USE ERROR_MOD, ONLY : GEOS_CHEM_STOP
USE FILE_MOD, ONLY : IOERROR
USE GC_GRID_MOD, ONLY : GET_IJ
USE Input_Opt_Mod, ONLY : OptInput
USE Ncdf_Mod, ONLY : GET_TAU0
USE PhysConstants, ONLY : g0
USE State_Grid_Mod, ONLY : GrdState
USE State_Met_Mod, ONLY : MetState
!
! !INPUT PARAMETERS:
!
TYPE(OptInput), INTENT(IN) :: Input_Opt ! Input Options object
TYPE(GrdState), INTENT(IN) :: State_Grid ! Grid State object
TYPE(MetState), INTENT(IN) :: State_Met ! Meteorology State object
INTEGER, INTENT(IN) :: IU_FILE ! Logical unit # of file
!
! !OUTPUT PARAMETERS:
!
INTEGER, INTENT(OUT) :: RC ! Success or failure?
!
! !REVISION HISTORY:
! 30 Jul 2002 - M. Evans - Initial version
! See https://github.com/geoschem/geos-chem for complete history
!EOP
!------------------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
INTEGER :: N, IOS, QYY, QMM, QDD, QHH, QMN
REAL*4 :: LAT, LON, PRES, OBS
REAL*4 :: TAMB, H2OMR, POTTEMP, GPSALT
CHARACTER(LEN=7) :: TYPE
CHARACTER(LEN=7) :: NAME
! ajt for CCGG
INTEGER :: IJ(2), L, L_ALT
REAL(fp) :: MOD_ELEV
!=================================================================
! READ_POINTS begins here!
!=================================================================
! Assume success
RC = GC_SUCCESS
! Read 4 header lines
DO N = 1, 4
READ( IU_FILE, '(a)', IOSTAT=IOS )
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'read_points:1' )
ENDDO
!=================================================================
! Read plane track points -- plane, lat/lon/alt, date/time
! We have previously computed NPOINTS in INIT_PLANEFLIGHT
!=================================================================
DO N = 1, NPOINTS
! Read a line from the file
READ( IU_FILE, 100, IOSTAT=IOS ) &
TYPE, QDD, QMM, QYY, QHH, QMN, LAT, LON, PRES, OBS
100 FORMAT( 5x,a7,x,i2,x,i2,x,i4,x,i2,x,i2,x,f7.2,x,f7.2,x,f7.2,x,f10.3 )
! Error check
IF ( IOS /= 0 ) CALL IOERROR( IOS, IU_FILE, 'read_points:2' )
! Exit if the word END is found
IF ( INDEX( TYPE, 'END' ) > 0 ) EXIT
!==============================================================
! Read date and time coordinates -- also do error checks
!==============================================================
! Error check MONTH
IF ( QMM < 1 .or. QMM > 12 ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, 105 ) QMM
WRITE( 6, 106 )
105 FORMAT( 'ERROR: MONTH out of range: ', f8.3 )
106 FORMAT( 'STOP in READ_POINTS (planeflight_mod.F90)' )
ENDIF
CALL GEOS_CHEM_STOP
ENDIF
! Error check DAY
IF ( QDD < 1 .or. QDD > 31 ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, 110 ) QDD
111 WRITE( 6, 106 )
110 FORMAT( 'ERROR: DAY out of range: ', f8.3 )
ENDIF
CALL GEOS_CHEM_STOP
ENDIF
! Error check HOUR
IF ( QHH < 0 .or. QHH > 23 ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6, 115 ) QHH
WRITE( 6, 106 )
115 FORMAT( 'ERROR: HOUR out of range: ', f8.3 )
ENDIF
CALL GEOS_CHEM_STOP
ENDIF
! Error check MINUTES
IF ( QMN < 0 .or. QMN > 59 ) THEN
IF ( Input_Opt%amIRoot ) THEN