← Back to Documentation Home
CCPP SciDoc v8.0.0  v8.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
120
124 use mpi_f08
125 use mpiutil, only: ccpp_bcast
126 use machine, only : kind_phys, kind_io4
127 use funcphys, only : fpkapx
128 use module_iounitdef, only : nio3clm, nico2cn
129!
130 implicit none
131!
132 private
133
134! --- version tag and last revision date
135 character(40), parameter ::
136 & vtaggas='NCEP-Radiation_gases v5.1 Nov 2012 '
137! & VTAGGAS='NCEP-Radiation_gases v5.0 Aug 2012 '
138
139 ! number of gas species
140 integer, parameter, public :: NF_VGAS = 10
141 ! input CO2 data longitude points
142 integer, parameter :: IMXCO2 = 24
143 ! input CO2 data latitude points
144 integer, parameter :: JMXCO2 = 12
145 ! earlist year 2D CO2 data available
146 integer, parameter :: MINYEAR = 1957
147
148 ! horizontal resolution in degree
149 real (kind=kind_phys), parameter :: resco2=15.0
150 ! pressure limitation for 2D CO2 (mb)
151 real (kind=kind_phys), parameter :: prsco2=788.0
152 real (kind=kind_phys) :: raddeg ! rad->deg conversion
153 real (kind=kind_phys) :: hfpi ! half of pi
154
155 ! parameter constant for CO2 volume mixing ratio
156 real (kind=kind_phys), parameter :: co2vmr_def = 350.0e-6
157 ! parameter constant for N2O volume mixing ratio
158 real (kind=kind_phys), parameter :: n2ovmr_def = 0.31e-6
159 ! parameter constant for CH4 volume mixing ratio
160 real (kind=kind_phys), parameter :: ch4vmr_def = 1.50e-6
161 ! parameter constant for O2 volume mixing ratio
162 real (kind=kind_phys), parameter :: o2vmr_def = 0.209
163 ! parameter constant for CO colume mixing ratio
164 real (kind=kind_phys), parameter :: covmr_def = 1.50e-8
165 ! aer 2003 value
166 real (kind=kind_phys), parameter :: f11vmr_def = 3.520e-10
167 ! aer 2003 value
168 real (kind=kind_phys), parameter :: f12vmr_def = 6.358e-10
169 ! aer 2003 value
170 real (kind=kind_phys), parameter :: f22vmr_def = 1.500e-10
171 ! aer 2003 value
172 real (kind=kind_phys), parameter :: cl4vmr_def = 1.397e-10
173 ! gfdl 1999 value
174 real (kind=kind_phys), parameter :: f113vmr_def= 8.2000e-11
175
176! - module variables to be set in subroutine gas_init and/or gas_update
177
178! arrays for co2 2-d mon. data and global mean values from observed data
179
180 real (kind=kind_phys), allocatable :: co2vmr_sav(:,:,:)
181 real (kind=kind_phys), allocatable :: co2cyc_sav(:,:,:)
182
183 real (kind=kind_phys) :: co2_glb = co2vmr_def
184 real (kind=kind_phys) :: gco2cyc(12)
185 data gco2cyc(:) / 12*0.0 /
186
187 integer :: kyrsav = 0
188 integer :: kmonsav = 1
189
190! --- public interfaces
191
193
194
195! =================
196 contains
197! =================
198
209!-----------------------------------
210 subroutine gas_init( mpicomm, mpirank, mpiroot, co2usr_file,
211 & co2cyc_file, ico2flg,
212 & ictmflg, con_pi, errflg, errmsg)
213
214! =================================================================== !
215! !
216! gas_init sets up co2, etc. parameters. !
217! !
218! inputs: !
219! me - print message control flag !
220! ico2flg - co2 data source control flag !
221! =0: use prescribed co2 global mean value !
222! =1: use input global mean co2 value (co2_glb) !
223! =2: use input 2-d monthly co2 value (co2vmr_sav) !
224! ictmflg - =yyyy#, data ic time/date control flag !
225! =-2: same as 0, but superimpose seasonal cycle !
226! from climatology data set. !
227! =-1: use user provided external data for the fcst !
228! time, no extrapolation. !
229! =0: use data at initial cond time, if not existed !
230! then use latest, without extrapolation. !
231! =1: use data at the forecast time, if not existed !
232! then use latest and extrapolate to fcst time. !
233! =yyyy0: use yyyy data for the forecast time, no !
234! further data extrapolation. !
235! =yyyy1: use yyyy data for the fcst. if needed, do !
236! extrapolation to match the fcst time. !
237! co2usr_file - external co2 user defined data table !
238! co2cyc_file - external co2 climotology monthly cycle data table !
239! con_pi - physical constant Pi !
240! !
241! outputs: (CCPP error handling) !
242! errflg - error flag !
243! errmsg - error message !
244! !
245! usage: call gas_init !
246! !
247! subprograms called: none !
248! !
249! =================================================================== !
250!
251 implicit none
252
253! --- inputs:
254 type(mpi_comm), intent(in) :: mpicomm
255 integer, intent(in) :: mpirank, mpiroot
256 integer, intent(in) :: ictmflg, ico2flg
257 character(len=26),intent(in) :: co2usr_file,co2cyc_file
258 real(kind=kind_phys), intent(in) :: con_pi
259
260! --- output:
261 character(len=*), intent(out) :: errmsg
262 integer, intent(out) :: errflg
263
264! --- locals:
265 real (kind=kind_phys), dimension(IMXCO2,JMXCO2) :: co2dat
266 real (kind=kind_phys) :: co2g1, co2g2
267
268 integer :: i, j, k, iyr, imo
269 logical :: file_exist, lextpl
270 character :: cline*100, cform*8
271 data cform / '(24f7.2)' / !! data format in IMXCO2*f7.2
272 integer :: ierr
273!
274!===> ... begin here
275!
276
277! Initialize the CCPP error handling variables
278 errmsg = ''
279 errflg = 0
280
281! Initiailize module parameters
282 raddeg = 180.0/con_pi
283 hfpi = 0.5*con_pi
284
285 if ( mpirank==mpiroot ) print *, vtaggas ! print out version tag
286
287 kyrsav = 0
288 kmonsav = 1
289
290! --- ... co2 data section
291
292 co2_glb = co2vmr_def
293
294 lab_ico2 : if ( ico2flg == 0 ) then
295
296 if ( mpirank==mpiroot ) then
297 print *,' - Using prescribed co2 global mean value=',
298 & co2vmr_def
299 endif
300
301 else lab_ico2
302
303 lab_ictm : if ( ictmflg == -1 ) then ! input user provided data
304
305 read_and_broadcast_co2_v1: if ( mpirank==mpiroot ) then
306 inquire (file=co2usr_file, exist=file_exist)
307 if ( .not. file_exist ) then
308 print *,' Can not find user CO2 data file: ',co2usr_file
309 errflg = 1
310 errmsg = 'ERROR(gas_init): Cannot find user CO2 data file'
311 return
312 else
313 close (nico2cn)
314 open(nico2cn,file=co2usr_file,form='formatted',
315 & status='old')
316 rewind nico2cn
317 read (nico2cn, 25) iyr, cline, co2g1, co2g2
318 25 format(i4,a94,f7.2,16x,f5.2)
319 co2_glb = co2g1 * 1.0e-6
320
321 if ( ico2flg == 1 ) then
322 print *,' - Using co2 global annual mean value from',
323 & ' user provided data set:',co2usr_file
324 print *, iyr,cline(1:94),co2g1,' GROWTH RATE =', co2g2
325 elseif ( ico2flg == 2 ) then
326 allocate ( co2vmr_sav(imxco2,jmxco2,12) )
327
328 do imo = 1, 12
329 read (nico2cn,cform) co2dat
330!check print cform, co2dat
331
332 do j = 1, jmxco2
333 do i = 1, imxco2
334 co2vmr_sav(i,j,imo) = co2dat(i,j) * 1.0e-6
335 enddo
336 enddo
337 enddo
338
339 print *,' - Using co2 monthly 2-d data from user',
340 & ' provided data set:',co2usr_file
341 print *, iyr,cline(1:94),co2g1,' GROWTH RATE =', co2g2
342
343 print *,' CHECK: Sample of selected months of CO2 data'
344 do imo = 1, 12, 3
345 print *,' Month =',imo
346 print *, (co2vmr_sav(1,j,imo),j=1,jmxco2)
347 enddo
348 else
349 print *,' ICO2=',ico2flg,' is not a valid selection'
350 errflg = 1
351 errmsg = 'ERROR(gas_init): ICO2 is not valid'
352 return
353 endif ! endif_ico2flg_block
354
355 close (nico2cn)
356 endif ! endif_file_exist_block
357 else
358 if ( ico2flg == 2 ) then
359 allocate ( co2vmr_sav(imxco2,jmxco2,12) )
360 endif
361 endif read_and_broadcast_co2_v1
362
363 else lab_ictm ! input from observed data
364
365 if ( ico2flg == 1 ) then
366 if ( mpirank==mpiroot ) then
367 print *,' - Using observed co2 global annual mean value'
368 endif
369 elseif ( ico2flg == 2 ) then
370 allocate ( co2vmr_sav(imxco2,jmxco2,12) )
371 if ( mpirank==mpiroot ) then
372 print *,' - Using observed co2 monthly 2-d data'
373 endif
374 else
375 print *,' ICO2=',ico2flg,' is not a valid selection'
376 errflg = 1
377 errmsg = 'ERROR(gas_init): ICO2 is not a valid selection'
378 return
379 endif
380
381 if ( ictmflg == -2 ) then
382 read_and_broadcast_co2_v2: if ( mpirank==mpiroot ) then
383 inquire (file=co2cyc_file, exist=file_exist)
384 if ( .not. file_exist ) then
385 print *,' Can not find seasonal cycle CO2 data: ',
386 & co2cyc_file
387 errflg = 1
388 errmsg = 'ERROR(gas_init): Can not find seasonal cycle '
389 & // 'CO2 data'
390 return
391 else
392 allocate( co2cyc_sav(imxco2,jmxco2,12) )
393
394! --- ... read in co2 2-d seasonal cycle data
395 close (nico2cn)
396 open (nico2cn,file=co2cyc_file,form='formatted',
397 & status='old')
398 rewind nico2cn
399 read (nico2cn, 35) cline, co2g1, co2g2
400 35 format(a98,f7.2,16x,f5.2)
401 read (nico2cn,cform) co2dat ! skip annual mean part
402
403 print *,' - Superimpose seasonal cycle to mean CO2 data'
404 print *,' Opened CO2 climatology seasonal cycle data',
405 & ' file: ',co2cyc_file
406!check print *, cline(1:98), co2g1, co2g2
407
408 do imo = 1, 12
409 read (nico2cn,45) cline, gco2cyc(imo)
410 45 format(a58,f7.2)
411!check print *, cline(1:58),gco2cyc(imo)
412 gco2cyc(imo) = gco2cyc(imo) * 1.0e-6
413
414 read (nico2cn,cform) co2dat
415!check print cform, co2dat
416 do j = 1, jmxco2
417 do i = 1, imxco2
418 co2cyc_sav(i,j,imo) = co2dat(i,j) * 1.0e-6
419 enddo
420 enddo
421 enddo
422
423 close (nico2cn)
424 endif ! endif_file_exist_block
425 else
426 allocate( co2cyc_sav(imxco2,jmxco2,12) )
427 endif read_and_broadcast_co2_v2
428 endif
429
430 endif lab_ictm
431 endif lab_ico2
432
433 ! Broadcast all necessary fields
434 call ccpp_bcast(co2_glb, mpiroot, mpicomm, ierr)
435 call ccpp_bcast(gco2cyc, mpiroot, mpicomm, ierr)
436 if (allocated(co2vmr_sav)) then
437 call ccpp_bcast(co2vmr_sav, mpiroot, mpicomm, ierr)
438 endif
439 if (allocated(co2cyc_sav)) then
440 call ccpp_bcast(co2cyc_sav, mpiroot, mpicomm, ierr)
441 endif
442!
443!...................................
444 end subroutine gas_init
445!-----------------------------------
446
462!-----------------------------------
463 subroutine gas_update(iyear, imon, iday, ihour, ldoco2,
464 & mpicomm, mpirank, mpiroot, co2dat_file, co2gbl_file,
465 & ictmflg, ico2flg, errflg, errmsg )
466
467! =================================================================== !
468! !
469! gas_update reads in 2-d monthly co2 data set for a specified year. !
470! data are in a 15 degree lat/lon horizontal resolution. !
471! !
472! inputs: dimemsion !
473! iyear - year of the requested data for fcst 1 !
474! imon - month of the year 1 !
475! iday - day of the month 1 !
476! ihour - hour of the day 1 !
477! ldoco2 - co2 update control flag 1 !
478! me - print message control flag 1 !
479! ico2flg - co2 data source control flag !
480! =0: use prescribed co2 global mean value !
481! =1: use input global mean co2 value (co2_glb) !
482! =2: use input 2-d monthly co2 value (co2vmr_sav) !
483! ictmflg - =yyyy#, data ic time/date control flag !
484! =-2: same as 0, but superimpose seasonal cycle !
485! from climatology data set. !
486! =-1: use user provided external data for the fcst !
487! time, no extrapolation. !
488! =0: use data at initial cond time, if not existed !
489! then use latest, without extrapolation. !
490! =1: use data at the forecast time, if not existed !
491! then use latest and extrapolate to fcst time. !
492! =yyyy0: use yyyy data for the forecast time, no !
493! further data extrapolation. !
494! =yyyy1: use yyyy data for the fcst. if needed, do !
495! extrapolation to match the fcst time. !
496! ivflip - vertical profile indexing flag !
497! co2dat_file - external co2 2d monthly obsv data table !
498! co2gbl_file - external co2 global annual mean data table !
499! !
500! outputs: (CCPP error handling) !
501! errflg - error flag !
502! errmsg - error message !
503! !
504! internal module variables: !
505! co2vmr_sav - monthly co2 volume mixing ratio IMXCO2*JMXCO2*12!
506! co2cyc_sav - monthly cycle co2 vol mixing ratio IMXCO2*JMXCO2*12!
507! co2_glb - global annual mean co2 mixing ratio !
508! gco2cyc - global monthly mean co2 variation 12 !
509! !
510! usage: call gas_update !
511! !
512! subprograms called: none !
513! !
514! =================================================================== !
515!
516 implicit none
517
518! --- inputs:
519 integer, intent(in) :: iyear, imon, iday, ihour
520 type(mpi_comm), intent(in) :: mpicomm
521 integer, intent(in) :: mpirank, mpiroot
522 integer, intent(in) :: ictmflg,ico2flg
523 character(len=26),intent(in) :: co2dat_file, co2gbl_file
524 logical, intent(in) :: ldoco2
525
526! --- output:
527 character(len=*), intent(out) :: errmsg
528 integer, intent(out) :: errflg
529
530! --- locals:
531 real (kind=kind_phys), dimension(IMXCO2,JMXCO2) :: co2dat, co2ann
532 real (kind=kind_phys) :: co2g1, co2g2, rate
533
534 integer :: i, id, j, l, iyr, imo, iyr1, iyr2, jyr, idyr
535 integer, save :: mdays(13), midmon=15, midm=15, midp=45
536! --- number of days in a month
537 data mdays / 31,28,31,30,31,30,31,31,30,31,30,31,30 /
538
539 logical :: file_exist, lextpl, change
540 character :: cline*100, cform*8, cfile1*26
541 data cform / '(24f7.2)' / !! data format in IMXCO2*f7.2
542 integer :: ierr
543!
544!===> ... begin here
545!
546! Initialize the CCPP error handling variables
547 errmsg = ''
548 errflg = 0
549
551
552 if ( ico2flg == 0 ) return ! use prescribed global mean co2 data
553 if ( ictmflg ==-1 ) return ! use user provided co2 data
554 if ( .not. ldoco2 ) return ! no need to update co2 data
555
556 if ( ictmflg < 0 ) then ! use user provided external data
557 lextpl = .false. ! no time extrapolation
558 idyr = iyear ! use the model year
559 else ! use historically observed data
560 lextpl = ( mod(ictmflg,10) == 1 )! flag for data extrapolation
561 idyr = ictmflg / 10 ! year of data source used
562 if ( idyr == 0 ) idyr = iyear ! not specified, use model year
563 endif
564
565! --- ... auto select co2 2-d data table for required year
566
567 kmonsav = imon
568 if ( kyrsav == iyear ) return
569 kyrsav = iyear
570 iyr = iyear
571
572! --- ... for data earlier than MINYEAR (1957), the data are in
573! the form of semi-yearly global mean values. otherwise,
574! data are monthly mean in horizontal 2-d map.
575
576 lab_if_idyr : if ( idyr < minyear .and. ictmflg > 0 ) then
577
578 read_and_broadcast_co2_v1: if ( mpirank==mpiroot ) then
579 print *,' Requested CO2 data year',iyear,' earlier than',
580 & minyear
581 print *,' Which is the earliest monthly observation',
582 & ' data available.'
583 print *,' Thus, historical global mean data is used'
584
585! --- ... check to see if requested co2 data file existed
586
587 inquire (file=co2gbl_file, exist=file_exist)
588 if ( .not. file_exist ) then
589 print *,' Requested co2 data file "',co2gbl_file,
590 & '" not found'
591 errflg = 1
592 errmsg = 'ERROR(gas_update): Requested co2 data file not '//
593 & 'found'
594 return
595 else
596 close(nico2cn)
597 open(nico2cn,file=co2gbl_file,form='formatted',status='old')
598 rewind nico2cn
599
600 read (nico2cn, 24) iyr1, iyr2, cline
601 24 format(i4,4x,i4,a48)
602
603 print *,' Opened co2 data file: ',co2gbl_file
604!check print *, iyr1, iyr2, cline(1:48)
605
606 if ( idyr < iyr1 ) then
607 iyr = iyr1
608!check if ( me == 0 ) then
609! print *,' Using earlist available co2 data, year=',iyr1
610!check endif
611 endif
612
613 i = iyr2
614 lab_dowhile1 : do while ( i >= iyr1 )
615! read (NICO2CN,26) jyr, co2g1, co2g2
616! 26 format(i4,4x,2f7.2)
617 read (nico2cn, *) jyr, co2g1, co2g2
618
619 if ( i == iyr .and. iyr == jyr ) then
620 co2_glb = (co2g1+co2g2) * 0.5e-6
621 if ( ico2flg == 2 ) then
622 do j = 1, jmxco2
623 do i = 1, imxco2
624 co2vmr_sav(i,j,1:6) = co2g1 * 1.0e-6
625 co2vmr_sav(i,j,7:12) = co2g2 * 1.0e-6
626 enddo
627 enddo
628 endif
629
630 print *,' Co2 data for year',iyear, co2_glb
631 exit lab_dowhile1
632 else
633!check if ( me == 0 ) print *,' Skip co2 data for year',i
634 i = i - 1
635 endif
636 enddo lab_dowhile1
637
638 close ( nico2cn )
639 endif ! end if_file_exist_block
640 endif read_and_broadcast_co2_v1
641
642 else lab_if_idyr
643
644! --- ... set up input data file name
645
646 cfile1 = co2dat_file
647 write(cfile1(19:22),34) idyr
648 34 format(i4.4)
649
650! --- ... check to see if requested co2 data file existed
651 read_and_broadcast_co2_v2: if ( mpirank==mpiroot ) then
652 inquire (file=cfile1, exist=file_exist)
653 if ( .not. file_exist ) then
654 ! specified year of data not found
655 lab_if_ictm : if ( ictmflg > 10 ) then
656 print *,' Specified co2 data for year',idyr,
657 & ' not found !! Need to change namelist ICTM !!'
658 errflg = 1
659 errmsg = 'ERROR(gas_update): Specified co2 data for year '
660 & // 'not found'
661 return
662 else lab_if_ictm ! looking for latest available data
663 print *,' Requested co2 data for year',idyr,
664 & ' not found, check for other available data set'
665
666 lab_dowhile2 : do while ( iyr >= minyear )
667 iyr = iyr - 1
668 write(cfile1(19:22),34) iyr
669
670 inquire (file=cfile1, exist=file_exist)
671 print *,' Looking for CO2 file ',cfile1
672
673 if ( file_exist ) then
674 exit lab_dowhile2
675 endif
676 enddo lab_dowhile2
677
678 if ( .not. file_exist ) then
679 print *,' Can not find co2 data source file'
680 errflg = 1
681 errmsg = 'ERROR(gas_update): Can not find co2 data '//
682 & 'source file'
683 return
684 endif
685 endif lab_if_ictm
686 endif ! end if_file_exist_block
687
688! --- ... read in co2 2-d data for the requested month
689
690 close(nico2cn)
691 open (nico2cn,file=cfile1,form='formatted',status='old')
692 rewind nico2cn
693 read (nico2cn, 36) iyr, cline, co2g1, co2g2
694 36 format(i4,a94,f7.2,16x,f5.2)
695
696 print *,' Opened co2 data file: ',cfile1
697 print *, iyr, cline(1:94), co2g1,' GROWTH RATE =', co2g2
698
699! --- ... add growth rate if needed
700 if ( lextpl ) then
701! rate = co2g2 * (iyear - iyr) ! rate from early year
702! rate = 1.60 * (iyear - iyr) ! avg rate over long period
703 rate = 2.00 * (iyear - iyr) ! avg rate for recent period
704 else
705 rate = 0.0
706 endif
707
708 co2_glb = (co2g1 + rate) * 1.0e-6
709 print *,' Global annual mean CO2 data for year',
710 & iyear, co2_glb
711 ! need to calc ic time annual mean first
712 if ( ictmflg == -2 ) then
713
714 if ( ico2flg == 1 ) then
715 print *,' CHECK: Monthly deviations of climatology ',
716 & 'to be superimposed on global annual mean'
717 print *, gco2cyc
718 elseif ( ico2flg == 2 ) then
719 co2ann(:,:) = 0.0
720
721 do imo = 1, 12
722 read (nico2cn,cform) co2dat
723!check print cform, co2dat
724
725 do j = 1, jmxco2
726 do i = 1, imxco2
727 co2ann(i,j) = co2ann(i,j) + co2dat(i,j)
728 enddo
729 enddo
730 enddo
731
732 do j = 1, jmxco2
733 do i = 1, imxco2
734 co2ann(i,j) = co2ann(i,j) * 1.0e-6 / float(12)
735 enddo
736 enddo
737
738 do imo = 1, 12
739 do j = 1, jmxco2
740 do i = 1, imxco2
741 co2vmr_sav(i,j,imo) = co2ann(i,j)+co2cyc_sav(i,j,imo)
742 enddo
743 enddo
744 enddo
745
746 print *,' CHECK: Sample of 2-d annual mean of CO2 ',
747 & 'data used for year:',iyear
748 print *, co2ann(1,:)
749 print *,' CHECK: AFTER adding seasonal cycle, Sample ',
750 & 'of selected months of CO2 data for year:',iyear
751 do imo = 1, 12, 3
752 print *,' Month =',imo
753 print *, co2vmr_sav(1,:,imo)
754 enddo
755 endif ! endif_icl2flg_block
756
757 else ! no need to calc ic time annual mean first
758
759 if ( ico2flg == 2 ) then ! directly save monthly data
760 do imo = 1, 12
761 read (nico2cn,cform) co2dat
762!check print cform, co2dat
763
764 do j = 1, jmxco2
765 do i = 1, imxco2
766 co2vmr_sav(i,j,imo) = (co2dat(i,j) + rate) * 1.0e-6
767 enddo
768 enddo
769 enddo
770
771 print *,' CHECK: Sample of selected months of CO2 ',
772 & 'data used for year:',iyear
773 do imo = 1, 12, 3
774 print *,' Month =',imo
775 print *, co2vmr_sav(1,:,imo)
776 enddo
777 endif ! endif_ico2flg_block
778
779 do imo = 1, 12
780 gco2cyc(imo) = 0.0
781 enddo
782 endif ! endif_ictmflg_block
783 close ( nico2cn )
784 endif read_and_broadcast_co2_v2
785 endif lab_if_idyr
786
787 ! Broadcast all necessary fields
788 call ccpp_bcast(co2_glb, mpiroot, mpicomm, ierr)
789 call ccpp_bcast(gco2cyc, mpiroot, mpicomm, ierr)
790 if (allocated(co2vmr_sav)) then
791 call ccpp_bcast(co2vmr_sav, mpiroot, mpicomm, ierr)
792 endif
793 if (allocated(co2cyc_sav)) then
794 call ccpp_bcast(co2cyc_sav, mpiroot, mpicomm, ierr)
795 endif
796
797!...................................
798 end subroutine gas_update
799!-----------------------------------
800
833!-----------------------------------
834 subroutine getgases( plvl, xlon, xlat, IMAX, LMAX, ico2flg,
835 & top_at_1, con_pi, gasdat)
836! =================================================================== !
837! !
838! getgases set up global distribution of radiation absorbing gases !
839! in volume mixing ratio. currently only co2 has the options from !
840! observed values, all other gases are asigned to the climatological !
841! values. !
842! !
843! inputs: !
844! plvl(IMAX,LMAX+1)- pressure at model layer interfaces (mb) !
845! xlon(IMAX) - grid longitude in radians, ok both 0->2pi or !
846! -pi -> +pi arrangements !
847! xlat(IMAX) - grid latitude in radians, default range to !
848! pi/2 -> -pi/2, otherwise see in-line comment !
849! IMAX, LMAX - horiz, vert dimensions for output data !
850! ico2flg - co2 data source control flag !
851! =0: use prescribed co2 global mean value !
852! =1: use input global mean co2 value (co2_glb) !
853! =2: use input 2-d monthly co2 value (co2vmr_sav)!
854! top_at_1 - vertical profile indexing flag !
855! con_pi - physical constant Pi !
856! !
857! outputs: !
858! gasdat(IMAX,LMAX,NF_VGAS) - gases volume mixing ratioes !
859! (:,:,1) - co2 !
860! (:,:,2) - n2o !
861! (:,:,3) - ch4 !
862! (:,:,4) - o2 !
863! (:,:,5) - co !
864! (:,:,6) - cfc11 !
865! (:,:,7) - cfc12 !
866! (:,:,8) - cfc22 !
867! (:,:,9) - ccl4 !
868! (:,:,10) - cfc113 !
869! !
870! note: for lower atmos co2vmr_sav may have clim monthly deviations!
871! superimposed on init-cond co2 value, while co2_glb only !
872! contains the global mean value, thus needs to add the !
873! monthly dglobal mean deviation gco2cyc at upper atmos. for !
874! ictmflg/=-2, this value will be zero. !
875! !
876! usage: call getgases !
877! !
878! subprograms called: none !
879! !
880! =================================================================== !
881
882 implicit none
883
884! --- input:
885 integer, intent(in) :: imax, lmax, ico2flg
886 real (kind=kind_phys), intent(in) :: plvl(:,:), xlon(:), xlat(:)
887 logical, intent(in) :: top_at_1
888 real(kind=kind_phys), intent(in) :: con_pi
889
890! --- output:
891 real (kind=kind_phys), intent(out) :: gasdat(:,:,:)
892
893! --- local:
894 integer :: i, k, ilat, ilon
895
896 real (kind=kind_phys) :: xlon1, xlat1, tmp
897
898!===> ... begin here
899
900! --- ... assign default values
901
902 do k = 1, lmax
903 do i = 1, imax
904 gasdat(i,k,1) = co2vmr_def
905 gasdat(i,k,2) = n2ovmr_def
906 gasdat(i,k,3) = ch4vmr_def
907 gasdat(i,k,4) = o2vmr_def
908 gasdat(i,k,5) = covmr_def
909 gasdat(i,k,6) = f11vmr_def
910 gasdat(i,k,7) = f12vmr_def
911 gasdat(i,k,8) = f22vmr_def
912 gasdat(i,k,9) = cl4vmr_def
913 gasdat(i,k,10)= f113vmr_def
914 enddo
915 enddo
916
917! --- ... co2 section
918
919 if ( ico2flg == 1 ) then
920! --- use obs co2 global annual mean value only
921
922 do k = 1, lmax
923 do i = 1, imax
924 gasdat(i,k,1) = co2_glb + gco2cyc(kmonsav)
925 enddo
926 enddo
927
928 elseif ( ico2flg == 2 ) then
929! --- use obs co2 monthly data with 2-d variation at lower atmos
930! otherwise use global mean value
931
932 tmp = raddeg / resco2
933 do i = 1, imax
934 xlon1 = xlon(i)
935 ! if xlon in -pi->pi, convert to 0->2pi
936 if ( xlon1 < 0.0 ) xlon1 = xlon1 + con_pi
937 xlat1 = hfpi - xlat(i) ! if xlat in pi/2 -> -pi/2 range
938!note xlat1 = xlat(i) ! if xlat in 0 -> pi range
939
940 ilon = min( imxco2, int( xlon1*tmp + 1 ))
941 ilat = min( jmxco2, int( xlat1*tmp + 1 ))
942
943 if (top_at_1) then ! index from toa to sfc
944 do k = 1, lmax
945 if ( plvl(i,k) >= prsco2 ) then
946 gasdat(i,k,1) = co2vmr_sav(ilon,ilat,kmonsav)
947 else
948 gasdat(i,k,1) = co2_glb + gco2cyc(kmonsav)
949 endif
950 enddo
951 else ! index from sfc to toa
952 do k = 1, lmax
953 if ( plvl(i,k+1) >= prsco2 ) then
954 gasdat(i,k,1) = co2vmr_sav(ilon,ilat,kmonsav)
955 else
956 gasdat(i,k,1) = co2_glb + gco2cyc(kmonsav)
957 endif
958 enddo
959 endif
960 enddo
961 endif
962!
963!...................................
964 end subroutine getgases
965!-----------------------------------
966
967!
968!........................................!
969 end module module_radiation_gases !
971!========================================!
subroutine, public gas_init(mpicomm, mpirank, mpiroot, co2usr_file,
This subroutine sets up co2, etc. parameters.
subroutine, public getgases(plvl, xlon, xlat, imax, lmax, ico2flg,
This subroutine sets up global distribution of radiation absorbing gases in volume mixing ratio....
subroutine, public gas_update(iyear, imon, iday, ihour, ldoco2,
This subroutine reads in 2-d monthly co2 data set for a specified year. Data are in a 15 degree lat/l...
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.