CCPP SciDoc v7.0.x  v7.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
radiation_gases.f
1
5
6! ========================================================== !!!!!
7! 'module_radiation_gases' description !!!!!
8! ========================================================== !!!!!
9! !
10! set up constant gas profiles, such as co2, ch4, n2o, o2, and those !
11! of cfc gases. All data are entered as mixing ratio by volume !
12! !
13! in the module, the externally callabe subroutines are : !
14! !
15! 'gas_init' -- initialization !
16! input: !
17! ( me ) !
18! output: !
19! ( errflg, errmsg ) !
20! !
21! 'gas_update' -- read in data and update with time !
22! input: !
23! ( iyear, imon, iday, ihour, ldoco2, me ) !
24! output: !
25! ( errflg, errmsg ) !
26! !
27! !
28! 'getgases' -- setup constant gas profiles for LW and SW !
29! input: !
30! ( plvl, xlon, xlat, !
31! IMAX, LMAX ) !
32! output: !
33! ( gasdat ) !
34! !
35! external modules referenced: !
36! 'module machine' in 'machine.f' !
37! 'module funcphys' in 'funcphys.f' !
38! 'module module_iounitdef' in 'iounitdef.f' !
39! !
40! unit used for radiative active gases: !
41! co2 : volume mixing ratio (p/p) !
42! n2o : volume mixing ratio (p/p) !
43! ch4 : volume mixing ratio (p/p) !
44! o2 : volume mixing ratio (p/p) !
45! co : volume mixing ratio (p/p) !
46! cfc11 : volume mixing ratio (p/p) !
47! cfc12 : volume mixing ratio (p/p) !
48! cfc22 : volume mixing ratio (p/p) !
49! ccl4 : volume mixing ratio (p/p) !
50! cfc113: volume mixing ratio (p/p) !
51! !
52! !
53! program history: !
54! may 2003 - y-t hou create rad_module.f that collectively !
55! combines several radiation computation supporting !
56! programs into fortran 90 module structure (gases !
57! and aerosols, etc.) !
58! apr 2004 - y-t hou modified to add astronomy and surface !
59! module components. !
60! feb 2005 - y-t hou rewrite the component modules into !
61! separate individule modules for thier corresponding !
62! tasks. here as radiation_gases.f !
63! mar 2006 - y-t hou add initialization subroutine to co2 and !
64! other gases. historical 2-d co2 data are added. !
65! sep 2008 - y-t hou add parameter ictm to control the input !
66! data time at the model initial condition. !
67! oct 2008 - y-t hou modify the initialization code to add the !
68! option of superimposing climatology seasonal cycle !
69! to the initial condition data (currently co2 only) !
70! nov 2008 - y-t hou fix bugs in superimposing climatology !
71! seasonal cycle calculations !
72! aug 2011 - y-t hou fix a bug in subr getgases doing vertical !
73! co2 mapping. (for top_at_1 case, not affact opr). !
74! nov 2012 - y-t hou modified control parameters thru module !
75! 'physparam'. !
76! jan 2013 - z. janjic/y. hou modified ilon (longitude index) !
77! computing formula in subroutine getgases to work !
78! properly for models with either of 0->360 or !
79! -180->180 zonal grid directions. !
80! !
81! !
82!!!!! ========================================================== !!!!!
83!!!!! end descriptions !!!!!
84!!!!! ========================================================== !!!!!
85
86
114
118 use machine, only : kind_phys, kind_io4
119 use funcphys, only : fpkapx
120 use module_iounitdef, only : nio3clm, nico2cn
121!
122 implicit none
123!
124 private
125
126! --- version tag and last revision date
127 character(40), parameter :: &
128 & VTAGGAS='NCEP-Radiation_gases v5.1 Nov 2012 '
129! & VTAGGAS='NCEP-Radiation_gases v5.0 Aug 2012 '
130
131 integer, parameter, public :: nf_vgas = 10 ! number of gas species
132 integer, parameter :: imxco2 = 24 ! input CO2 data longitude points
133 integer, parameter :: jmxco2 = 12 ! input CO2 data latitude points
134 integer, parameter :: minyear = 1957 ! earlist year 2D CO2 data available
135
136 real (kind=kind_phys), parameter :: resco2=15.0 ! horizontal resolution in degree
137 real (kind=kind_phys), parameter :: prsco2=788.0 ! pressure limitation for 2D CO2 (mb)
138 real (kind=kind_phys) :: raddeg ! rad->deg conversion
139 real (kind=kind_phys) :: hfpi ! half of pi
140
141 real (kind=kind_phys), parameter :: co2vmr_def = 350.0e-6 ! parameter constant for CO2 volume mixing ratio
142 real (kind=kind_phys), parameter :: n2ovmr_def = 0.31e-6 ! parameter constant for N2O volume mixing ratio
143 real (kind=kind_phys), parameter :: ch4vmr_def = 1.50e-6 ! parameter constant for CH4 volume mixing ratio
144 real (kind=kind_phys), parameter :: o2vmr_def = 0.209 ! parameter constant for O2 volume mixing ratio
145 real (kind=kind_phys), parameter :: covmr_def = 1.50e-8 ! parameter constant for CO colume mixing ratio
146! aer 2003 value
147 real (kind=kind_phys), parameter :: f11vmr_def = 3.520e-10
148! aer 2003 value
149 real (kind=kind_phys), parameter :: f12vmr_def = 6.358e-10
150! aer 2003 value
151 real (kind=kind_phys), parameter :: f22vmr_def = 1.500e-10
152! aer 2003 value
153 real (kind=kind_phys), parameter :: cl4vmr_def = 1.397e-10
154! gfdl 1999 value
155 real (kind=kind_phys), parameter :: f113vmr_def= 8.2000e-11
156
157! --- module variables to be set in subroutin gas_init and/or gas_update
158
159! arrays for co2 2-d monthly data and global mean values from observed data
160
161 real (kind=kind_phys), allocatable :: co2vmr_sav(:,:,:)
162 real (kind=kind_phys), allocatable :: co2cyc_sav(:,:,:)
163
164 real (kind=kind_phys) :: co2_glb = co2vmr_def
165 real (kind=kind_phys) :: gco2cyc(12)
166 data gco2cyc(:) / 12*0.0 /
167
168 integer :: kyrsav = 0
169 integer :: kmonsav = 1
170
171! --- public interfaces
172
174
175
176! =================
177 contains
178! =================
179
190!-----------------------------------
191 subroutine gas_init( me, co2usr_file, co2cyc_file, ico2flg, &
192 & ictmflg, con_pi, errflg, errmsg)
193
194! =================================================================== !
195! !
196! gas_init sets up co2, etc. parameters. !
197! !
198! inputs: !
199! me - print message control flag !
200! ico2flg - co2 data source control flag !
201! =0: use prescribed co2 global mean value !
202! =1: use input global mean co2 value (co2_glb) !
203! =2: use input 2-d monthly co2 value (co2vmr_sav) !
204! ictmflg - =yyyy#, data ic time/date control flag !
205! =-2: same as 0, but superimpose seasonal cycle !
206! from climatology data set. !
207! =-1: use user provided external data for the fcst !
208! time, no extrapolation. !
209! =0: use data at initial cond time, if not existed !
210! then use latest, without extrapolation. !
211! =1: use data at the forecast time, if not existed !
212! then use latest and extrapolate to fcst time. !
213! =yyyy0: use yyyy data for the forecast time, no !
214! further data extrapolation. !
215! =yyyy1: use yyyy data for the fcst. if needed, do !
216! extrapolation to match the fcst time. !
217! co2usr_file - external co2 user defined data table !
218! co2cyc_file - external co2 climotology monthly cycle data table !
219! con_pi - physical constant Pi !
220! !
221! outputs: (CCPP error handling) !
222! errflg - error flag !
223! errmsg - error message !
224! !
225! usage: call gas_init !
226! !
227! subprograms called: none !
228! !
229! =================================================================== !
230!
231 implicit none
232
233! --- inputs:
234 integer, intent(in) :: me, ictmflg, ico2flg
235 character(len=26),intent(in) :: co2usr_file,co2cyc_file
236 real(kind=kind_phys), intent(in) :: con_pi
237
238! --- output:
239 character(len=*), intent(out) :: errmsg
240 integer, intent(out) :: errflg
241
242! --- locals:
243 real (kind=kind_phys), dimension(IMXCO2,JMXCO2) :: co2dat
244 real (kind=kind_phys) :: co2g1, co2g2
245
246 integer :: i, j, k, iyr, imo
247 logical :: file_exist, lextpl
248 character :: cline*100, cform*8
249 data cform / '(24f7.2)' / !! data format in IMXCO2*f7.2
250!
251!===> ... begin here
252!
253
254! Initialize the CCPP error handling variables
255 errmsg = ''
256 errflg = 0
257
258! Initiailize module parameters
259 raddeg = 180.0/con_pi
260 hfpi = 0.5*con_pi
261
262 if ( me == 0 ) print *, vtaggas ! print out version tag
263
264 kyrsav = 0
265 kmonsav = 1
266
267! --- ... co2 data section
268
270
271 lab_ico2 : if ( ico2flg == 0 ) then
272
273 if ( me == 0 ) then
274 print *,' - Using prescribed co2 global mean value=', &
275 & co2vmr_def
276 endif
277
278 else lab_ico2
279
280 lab_ictm : if ( ictmflg == -1 ) then ! input user provided data
281
282 inquire (file=co2usr_file, exist=file_exist)
283 if ( .not. file_exist ) then
284 errflg = 1
285 errmsg = 'ERROR(gas_init): Cannot find user CO2 data file'//&
286 & ': '//co2usr_file
287 return
288 else
289 close (nico2cn)
290 open(nico2cn,file=co2usr_file,form='formatted',status='old')
291 rewind nico2cn
292 read (nico2cn, 25) iyr, cline, co2g1, co2g2
293 25 format(i4,a94,f7.2,16x,f5.2)
294 co2_glb = co2g1 * 1.0e-6
295
296 if ( ico2flg == 1 ) then
297 if ( me == 0 ) then
298 print *,' - Using co2 global annual mean value from', &
299 & ' user provided data set:',co2usr_file
300 print *, iyr,cline(1:94),co2g1,' GROWTH RATE =', co2g2
301 endif
302 elseif ( ico2flg == 2 ) then
303 allocate ( co2vmr_sav(imxco2,jmxco2,12) )
304
305 do imo = 1, 12
306 read (nico2cn,cform) co2dat
307!check print cform, co2dat
308
309 do j = 1, jmxco2
310 do i = 1, imxco2
311 co2vmr_sav(i,j,imo) = co2dat(i,j) * 1.0e-6
312 enddo
313 enddo
314 enddo
315
316 if ( me == 0 ) then
317 print *,' - Using co2 monthly 2-d data from user', &
318 & ' provided data set:',co2usr_file
319 print *, iyr,cline(1:94),co2g1,' GROWTH RATE =', co2g2
320
321 print *,' CHECK: Sample of selected months of CO2 data'
322 do imo = 1, 12, 3
323 print *,' Month =',imo
324 print *, (co2vmr_sav(1,j,imo),j=1,jmxco2)
325 enddo
326 endif
327 else
328 print *,' ICO2=',ico2flg,' is not a valid selection'
329 errflg = 1
330 errmsg = 'ERROR(gas_init): ICO2 is not a valid selection'
331 return
332 endif ! endif_ico2flg_block
333
334 close (nico2cn)
335 endif ! endif_file_exist_block
336
337 else lab_ictm ! input from observed data
338
339 if ( ico2flg == 1 ) then
340 if ( me == 0 ) then
341 print *,' - Using observed co2 global annual mean value'
342 endiF
343 elseif ( ico2flg == 2 ) then
344 allocate ( co2vmr_sav(imxco2,jmxco2,12) )
345
346 if ( me == 0 ) then
347 print *,' - Using observed co2 monthly 2-d data'
348 endif
349 else
350 print *,' ICO2=',ico2flg,' is not a valid selection'
351 errflg = 1
352 errmsg = 'ERROR(gas_init): ICO2 is not a valid selection'
353 return
354 endif
355
356 if ( ictmflg == -2 ) then
357 inquire (file=co2cyc_file, exist=file_exist)
358 if ( .not. file_exist ) then
359 errflg = 1
360 errmsg = 'ERROR(gas_init): Cannot find seasonal cycle '// &
361 & 'CO2 data file: '//co2cyc_file
362 return
363 else
364 allocate( co2cyc_sav(imxco2,jmxco2,12) )
365
366! --- ... read in co2 2-d seasonal cycle data
367 close (nico2cn)
368 open (nico2cn,file=co2cyc_file,form='formatted', &
369 & status='old')
370 rewind nico2cn
371 read (nico2cn, 35) cline, co2g1, co2g2
372 35 format(a98,f7.2,16x,f5.2)
373 read (nico2cn,cform) co2dat ! skip annual mean part
374
375 if ( me == 0 ) then
376 print *,' - Superimpose seasonal cycle to mean CO2 data'
377 print *,' Opened CO2 climatology seasonal cycle data',&
378 & ' file: ',co2cyc_file
379!check print *, cline(1:98), co2g1, co2g2
380 endif
381
382 do imo = 1, 12
383 read (nico2cn,45) cline, gco2cyc(imo)
384 45 format(a58,f7.2)
385!check print *, cline(1:58),gco2cyc(imo)
386 gco2cyc(imo) = gco2cyc(imo) * 1.0e-6
387
388 read (nico2cn,cform) co2dat
389!check print cform, co2dat
390 do j = 1, jmxco2
391 do i = 1, imxco2
392 co2cyc_sav(i,j,imo) = co2dat(i,j) * 1.0e-6
393 enddo
394 enddo
395 enddo
396
397 close (nico2cn)
398 endif ! endif_file_exist_block
399 endif
400
401 endif lab_ictm
402 endif lab_ico2
403!
404!...................................
405 end subroutine gas_init
406!-----------------------------------
407
423!-----------------------------------
424 subroutine gas_update(iyear, imon, iday, ihour, ldoco2, &
425 & me, co2dat_file, co2gbl_file, ictmflg, ico2flg, &
426 & errflg, errmsg )
427
428! =================================================================== !
429! !
430! gas_update reads in 2-d monthly co2 data set for a specified year. !
431! data are in a 15 degree lat/lon horizontal resolution. !
432! !
433! inputs: dimemsion !
434! iyear - year of the requested data for fcst 1 !
435! imon - month of the year 1 !
436! iday - day of the month 1 !
437! ihour - hour of the day 1 !
438! ldoco2 - co2 update control flag 1 !
439! me - print message control flag 1 !
440! ico2flg - co2 data source control flag !
441! =0: use prescribed co2 global mean value !
442! =1: use input global mean co2 value (co2_glb) !
443! =2: use input 2-d monthly co2 value (co2vmr_sav) !
444! ictmflg - =yyyy#, data ic time/date control flag !
445! =-2: same as 0, but superimpose seasonal cycle !
446! from climatology data set. !
447! =-1: use user provided external data for the fcst !
448! time, no extrapolation. !
449! =0: use data at initial cond time, if not existed !
450! then use latest, without extrapolation. !
451! =1: use data at the forecast time, if not existed !
452! then use latest and extrapolate to fcst time. !
453! =yyyy0: use yyyy data for the forecast time, no !
454! further data extrapolation. !
455! =yyyy1: use yyyy data for the fcst. if needed, do !
456! extrapolation to match the fcst time. !
457! ivflip - vertical profile indexing flag !
458! co2dat_file - external co2 2d monthly obsv data table !
459! co2gbl_file - external co2 global annual mean data table !
460! !
461! outputs: (CCPP error handling) !
462! errflg - error flag !
463! errmsg - error message !
464! !
465! internal module variables: !
466! co2vmr_sav - monthly co2 volume mixing ratio IMXCO2*JMXCO2*12 !
467! co2cyc_sav - monthly cycle co2 vol mixing ratio IMXCO2*JMXCO2*12 !
468! co2_glb - global annual mean co2 mixing ratio !
469! gco2cyc - global monthly mean co2 variation 12 !
470! !
471! usage: call gas_update !
472! !
473! subprograms called: none !
474! !
475! =================================================================== !
476!
477 implicit none
478
479! --- inputs:
480 integer, intent(in) :: iyear,imon,iday,ihour,me,ictmflg,ico2flg
481 character(len=26),intent(in) :: co2dat_file, co2gbl_file
482 logical, intent(in) :: ldoco2
483
484! --- output:
485 character(len=*), intent(out) :: errmsg
486 integer, intent(out) :: errflg
487
488! --- locals:
489 real (kind=kind_phys), dimension(IMXCO2,JMXCO2) :: co2dat, co2ann
490 real (kind=kind_phys) :: co2g1, co2g2, rate
491
492 integer :: i, id, j, l, iyr, imo, iyr1, iyr2, jyr, idyr
493 integer, save :: mdays(13), midmon=15, midm=15, midp=45
494! --- number of days in a month
495 data mdays / 31,28,31,30,31,30,31,31,30,31,30,31,30 /
496
497 logical :: file_exist, lextpl, change
498 character :: cline*100, cform*8, cfile1*26
499 data cform / '(24f7.2)' / !! data format in IMXCO2*f7.2
500!
501!===> ... begin here
502!
503! Initialize the CCPP error handling variables
504 errmsg = ''
505 errflg = 0
506
508
509 if ( ico2flg == 0 ) return ! use prescribed global mean co2 data
510 if ( ictmflg ==-1 ) return ! use user provided co2 data
511 if ( .not. ldoco2 ) return ! no need to update co2 data
512
513 if ( ictmflg < 0 ) then ! use user provided external data
514 lextpl = .false. ! no time extrapolation
515 idyr = iyear ! use the model year
516 else ! use historically observed data
517 lextpl = ( mod(ictmflg,10) == 1 ) ! flag for data extrapolation
518 idyr = ictmflg / 10 ! year of data source used
519 if ( idyr == 0 ) idyr = iyear ! not specified, use model year
520 endif
521
522! --- ... auto select co2 2-d data table for required year
523
524 kmonsav = imon
525 if ( kyrsav == iyear ) return
526 kyrsav = iyear
527 iyr = iyear
528
529! --- ... for data earlier than MINYEAR (1957), the data are in
530! the form of semi-yearly global mean values. otherwise,
531! data are monthly mean in horizontal 2-d map.
532
533 lab_if_idyr : if ( idyr < minyear .and. ictmflg > 0 ) then
534
535 if ( me == 0 ) then
536 print *,' Requested CO2 data year',iyear,' earlier than', &
537 & minyear
538 print *,' Which is the earliest monthly observation', &
539 & ' data available.'
540 print *,' Thus, historical global mean data is used'
541 endif
542
543! --- ... check to see if requested co2 data file existed
544
545 inquire (file=co2gbl_file, exist=file_exist)
546 if ( .not. file_exist ) then
547 errflg = 1
548 errmsg = 'ERROR(gas_update): Requested co2 data file not '// &
549 & 'found: '//co2gbl_file
550 return
551 else
552 close(nico2cn)
553 open (nico2cn,file=co2gbl_file,form='formatted',status='old')
554 rewind nico2cn
555
556 read (nico2cn, 24) iyr1, iyr2, cline
557 24 format(i4,4x,i4,a48)
558
559 if ( me == 0 ) then
560 print *,' Opened co2 data file: ',co2gbl_file
561!check print *, iyr1, iyr2, cline(1:48)
562 endif
563
564 if ( idyr < iyr1 ) then
565 iyr = iyr1
566!check if ( me == 0 ) then
567! print *,' Using earlist available co2 data, year=',iyr1
568!check endif
569 endif
570
571 i = iyr2
572 lab_dowhile1 : do while ( i >= iyr1 )
573! read (NICO2CN,26) jyr, co2g1, co2g2
574! 26 format(i4,4x,2f7.2)
575 read (nico2cn, *) jyr, co2g1, co2g2
576
577 if ( i == iyr .and. iyr == jyr ) then
578 co2_glb = (co2g1+co2g2) * 0.5e-6
579 if ( ico2flg == 2 ) then
580 do j = 1, jmxco2
581 do i = 1, imxco2
582 co2vmr_sav(i,j,1:6) = co2g1 * 1.0e-6
583 co2vmr_sav(i,j,7:12) = co2g2 * 1.0e-6
584 enddo
585 enddo
586 endif
587
588 if ( me == 0 ) print *,' Co2 data for year',iyear, &
589 & co2_glb
590 exit lab_dowhile1
591 else
592!check if ( me == 0 ) print *,' Skip co2 data for year',i
593 i = i - 1
594 endif
595 enddo lab_dowhile1
596
597 close ( nico2cn )
598 endif ! end if_file_exist_block
599
600 else lab_if_idyr
601
602! --- ... set up input data file name
603
604 cfile1 = co2dat_file
605 write(cfile1(19:22),34) idyr
606 34 format(i4.4)
607
608! --- ... check to see if requested co2 data file existed
609
610 inquire (file=cfile1, exist=file_exist)
611 if ( .not. file_exist ) then
612
613 lab_if_ictm : if ( ictmflg > 10 ) then ! specified year of data not found
614 if ( me == 0 ) then
615 print *,' Specified co2 data for year',idyr, &
616 & ' not found !! Need to change namelist ICTM !!'
617 endif
618 errflg = 1
619 errmsg = 'ERROR(gas_update): Specified co2 data for year '//&
620 & 'not found'
621 return
622 else lab_if_ictm ! looking for latest available data
623 if ( me == 0 ) then
624 print *,' Requested co2 data for year',idyr, &
625 & ' not found, check for other available data set'
626 endif
627
628 lab_dowhile2 : do while ( iyr >= minyear )
629 iyr = iyr - 1
630 write(cfile1(19:22),34) iyr
631
632 inquire (file=cfile1, exist=file_exist)
633 if ( me == 0 ) then
634 print *,' Looking for CO2 file ',cfile1
635 endif
636
637 if ( file_exist ) then
638 exit lab_dowhile2
639 endif
640 enddo lab_dowhile2
641
642 if ( .not. file_exist ) then
643 errflg = 1
644 errmsg = 'ERROR(gas_update): Cannot find co2 data '// &
645 & 'source file: '//co2dat_file
646 return
647 endif
648 endif lab_if_ictm
649 endif ! end if_file_exist_block
650
651! --- ... read in co2 2-d data for the requested month
652
653 close(nico2cn)
654 open (nico2cn,file=cfile1,form='formatted',status='old')
655 rewind nico2cn
656 read (nico2cn, 36) iyr, cline, co2g1, co2g2
657 36 format(i4,a94,f7.2,16x,f5.2)
658
659 if ( me == 0 ) then
660 print *,' Opened co2 data file: ',cfile1
661 print *, iyr, cline(1:94), co2g1,' GROWTH RATE =', co2g2
662 endif
663
664! --- ... add growth rate if needed
665 if ( lextpl ) then
666! rate = co2g2 * (iyear - iyr) ! rate from early year
667! rate = 1.60 * (iyear - iyr) ! avg rate over long period
668 rate = 2.00 * (iyear - iyr) ! avg rate for recent period
669 else
670 rate = 0.0
671 endif
672
673 co2_glb = (co2g1 + rate) * 1.0e-6
674 if ( me == 0 ) then
675 print *,' Global annual mean CO2 data for year', &
676 & iyear, co2_glb
677 endif
678
679 if ( ictmflg == -2 ) then ! need to calc ic time annual mean first
680
681 if ( ico2flg == 1 ) then
682 if ( me==0 ) then
683 print *,' CHECK: Monthly deviations of climatology ', &
684 & 'to be superimposed on global annual mean'
685 print *, gco2cyc
686 endif
687 elseif ( ico2flg == 2 ) then
688 co2ann(:,:) = 0.0
689
690 do imo = 1, 12
691 read (nico2cn,cform) co2dat
692!check print cform, co2dat
693
694 do j = 1, jmxco2
695 do i = 1, imxco2
696 co2ann(i,j) = co2ann(i,j) + co2dat(i,j)
697 enddo
698 enddo
699 enddo
700
701 do j = 1, jmxco2
702 do i = 1, imxco2
703 co2ann(i,j) = co2ann(i,j) * 1.0e-6 / float(12)
704 enddo
705 enddo
706
707 do imo = 1, 12
708 do j = 1, jmxco2
709 do i = 1, imxco2
710 co2vmr_sav(i,j,imo) = co2ann(i,j)+co2cyc_sav(i,j,imo)
711 enddo
712 enddo
713 enddo
714
715 if ( me==0 ) then
716 print *,' CHECK: Sample of 2-d annual mean of CO2 ', &
717 & 'data used for year:',iyear
718 print *, co2ann(1,:)
719 print *,' CHECK: AFTER adding seasonal cycle, Sample ', &
720 & 'of selected months of CO2 data for year:',iyear
721 do imo = 1, 12, 3
722 print *,' Month =',imo
723 print *, co2vmr_sav(1,:,imo)
724 enddo
725 endif
726 endif ! endif_icl2flg_block
727
728 else ! no need to calc ic time annual mean first
729
730 if ( ico2flg == 2 ) then ! directly save monthly data
731 do imo = 1, 12
732 read (nico2cn,cform) co2dat
733!check print cform, co2dat
734
735 do j = 1, jmxco2
736 do i = 1, imxco2
737 co2vmr_sav(i,j,imo) = (co2dat(i,j) + rate) * 1.0e-6
738 enddo
739 enddo
740 enddo
741
742 if ( me == 0 ) then
743 print *,' CHECK: Sample of selected months of CO2 ', &
744 & 'data used for year:',iyear
745 do imo = 1, 12, 3
746 print *,' Month =',imo
747 print *, co2vmr_sav(1,:,imo)
748 enddo
749 endif
750 endif ! endif_ico2flg_block
751
752 do imo = 1, 12
753 gco2cyc(imo) = 0.0
754 enddo
755 endif ! endif_ictmflg_block
756 close ( nico2cn )
757
758 endif lab_if_idyr
759!
760!...................................
761 end subroutine gas_update
762!-----------------------------------
763
796!-----------------------------------
797 subroutine getgases( plvl, xlon, xlat, IMAX, LMAX, ico2flg, &
798 & top_at_1, con_pi, gasdat)
799! =================================================================== !
800! !
801! getgases set up global distribution of radiation absorbing gases !
802! in volume mixing ratio. currently only co2 has the options from !
803! observed values, all other gases are asigned to the climatological !
804! values. !
805! !
806! inputs: !
807! plvl(IMAX,LMAX+1)- pressure at model layer interfaces (mb) !
808! xlon(IMAX) - grid longitude in radians, ok both 0->2pi or !
809! -pi -> +pi arrangements !
810! xlat(IMAX) - grid latitude in radians, default range to !
811! pi/2 -> -pi/2, otherwise see in-line comment !
812! IMAX, LMAX - horiz, vert dimensions for output data !
813! ico2flg - co2 data source control flag !
814! =0: use prescribed co2 global mean value !
815! =1: use input global mean co2 value (co2_glb) !
816! =2: use input 2-d monthly co2 value (co2vmr_sav)!
817! top_at_1 - vertical profile indexing flag !
818! con_pi - physical constant Pi !
819! !
820! outputs: !
821! gasdat(IMAX,LMAX,NF_VGAS) - gases volume mixing ratioes !
822! (:,:,1) - co2 !
823! (:,:,2) - n2o !
824! (:,:,3) - ch4 !
825! (:,:,4) - o2 !
826! (:,:,5) - co !
827! (:,:,6) - cfc11 !
828! (:,:,7) - cfc12 !
829! (:,:,8) - cfc22 !
830! (:,:,9) - ccl4 !
831! (:,:,10) - cfc113 !
832! !
833! note: for lower atmos co2vmr_sav may have clim monthly deviations !
834! superimposed on init-cond co2 value, while co2_glb only !
835! contains the global mean value, thus needs to add the !
836! monthly dglobal mean deviation gco2cyc at upper atmos. for !
837! ictmflg/=-2, this value will be zero. !
838! !
839! usage: call getgases !
840! !
841! subprograms called: none !
842! !
843! =================================================================== !
844!
845 implicit none
846
847! --- input:
848 integer, intent(in) :: imax, lmax, ico2flg
849 real (kind=kind_phys), intent(in) :: plvl(:,:), xlon(:), xlat(:)
850 logical, intent(in) :: top_at_1
851 real(kind=kind_phys), intent(in) :: con_pi
852
853! --- output:
854 real (kind=kind_phys), intent(out) :: gasdat(:,:,:)
855
856! --- local:
857 integer :: i, k, ilat, ilon
858
859 real (kind=kind_phys) :: xlon1, xlat1, tmp
860
861!===> ... begin here
862
863! --- ... assign default values
864
865 do k = 1, lmax
866 do i = 1, imax
867 gasdat(i,k,1) = co2vmr_def
868 gasdat(i,k,2) = n2ovmr_def
869 gasdat(i,k,3) = ch4vmr_def
870 gasdat(i,k,4) = o2vmr_def
871 gasdat(i,k,5) = covmr_def
872 gasdat(i,k,6) = f11vmr_def
873 gasdat(i,k,7) = f12vmr_def
874 gasdat(i,k,8) = f22vmr_def
875 gasdat(i,k,9) = cl4vmr_def
876 gasdat(i,k,10)= f113vmr_def
877 enddo
878 enddo
879
880! --- ... co2 section
881
882 if ( ico2flg == 1 ) then
883! --- use obs co2 global annual mean value only
884
885 do k = 1, lmax
886 do i = 1, imax
887 gasdat(i,k,1) = co2_glb + gco2cyc(kmonsav)
888 enddo
889 enddo
890
891 elseif ( ico2flg == 2 ) then
892! --- use obs co2 monthly data with 2-d variation at lower atmos
893! otherwise use global mean value
894
895 tmp = raddeg / resco2
896 do i = 1, imax
897 xlon1 = xlon(i)
898 if ( xlon1 < 0.0 ) xlon1 = xlon1 + con_pi ! if xlon in -pi->pi, convert to 0->2pi
899 xlat1 = hfpi - xlat(i) ! if xlat in pi/2 -> -pi/2 range
900!note xlat1 = xlat(i) ! if xlat in 0 -> pi range
901
902 ilon = min( imxco2, int( xlon1*tmp + 1 ))
903 ilat = min( jmxco2, int( xlat1*tmp + 1 ))
904
905 if (top_at_1) then ! index from toa to sfc
906 do k = 1, lmax
907 if ( plvl(i,k) >= prsco2 ) then
908 gasdat(i,k,1) = co2vmr_sav(ilon,ilat,kmonsav)
909 else
910 gasdat(i,k,1) = co2_glb + gco2cyc(kmonsav)
911 endif
912 enddo
913 else ! index from sfc to toa
914 do k = 1, lmax
915 if ( plvl(i,k+1) >= prsco2 ) then
916 gasdat(i,k,1) = co2vmr_sav(ilon,ilat,kmonsav)
917 else
918 gasdat(i,k,1) = co2_glb + gco2cyc(kmonsav)
919 endif
920 enddo
921 endif
922 enddo
923 endif
924!
925!...................................
926 end subroutine getgases
927!-----------------------------------
928
929!
930!........................................!
931 end module module_radiation_gases !
933!========================================!
real(kind=kind_phys), parameter cl4vmr_def
real(kind=kind_phys) co2_glb
real(kind=kind_phys) raddeg
real(kind=kind_phys), parameter f11vmr_def
real(kind=kind_phys), parameter covmr_def
real(kind=kind_phys), dimension(:,:,:), allocatable co2cyc_sav
integer, parameter minyear
integer, parameter imxco2
real(kind=kind_phys), dimension(:,:,:), allocatable co2vmr_sav
real(kind=kind_phys), parameter co2vmr_def
real(kind=kind_phys) hfpi
real(kind=kind_phys), parameter f113vmr_def
real(kind=kind_phys), parameter n2ovmr_def
real(kind=kind_phys), parameter o2vmr_def
real(kind=kind_phys), parameter f12vmr_def
subroutine, public getgases(plvl, xlon, xlat, imax, lmax, ico2flg, top_at_1, con_pi, gasdat)
This subroutine sets up global distribution of radiation absorbing gases in volume mixing ratio....
subroutine, public gas_init(me, co2usr_file, co2cyc_file, ico2flg, ictmflg, con_pi, errflg, errmsg)
This subroutine sets up co2, etc. parameters.
integer, parameter jmxco2
real(kind=kind_phys), parameter ch4vmr_def
real(kind=kind_phys), parameter prsco2
real(kind=kind_phys), dimension(12) gco2cyc
subroutine, public gas_update(iyear, imon, iday, ihour, ldoco2, me, co2dat_file, co2gbl_file, ictmflg, ico2flg, errflg, errmsg)
This subroutine reads in 2-d monthly co2 data set for a specified year. Data are in a 15 degree lat/l...
real(kind=kind_phys), parameter f22vmr_def
real(kind=kind_phys), parameter resco2
integer, parameter, public nf_vgas
this module defines fortran unit numbers for input/output data files for the ncep gfs model.
Definition iounitdef.f:53
This module sets up constant gas rofiles, such as co2, ch4, n2o, o2, and those of cfc gases.