photolysis.F90 157 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033
  1. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  2. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  3. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  4. !
  5. #include "tm5.inc"
  6. !
  7. !----------------------------------------------------------------------------
  8. ! TM5 !
  9. !----------------------------------------------------------------------------
  10. !BOP
  11. !
  12. ! !MODULE: PHOTOLYSIS
  13. !
  14. ! !DESCRIPTION: <add description>
  15. !\\
  16. !\\
  17. ! !INTERFACE:
  18. !
  19. MODULE PHOTOLYSIS
  20. !
  21. ! !USES:
  22. !
  23. use GO, only : gol, goPr, goErr
  24. use tm5_distgrid, only : dgrid, Get_DistGrid, gather
  25. use photolysis_data
  26. #ifdef with_optics
  27. use optics, only : wavelendep
  28. #endif
  29. IMPLICIT NONE
  30. PRIVATE
  31. !
  32. ! !PUBLIC MEMBER FUNCTIONS:
  33. !
  34. public :: photolysis_init, photolysis_done ! life cycle
  35. public :: ozone_info_online ! calculate the overhead ozone
  36. public :: aerosol_info ! aerosol optical depths
  37. public :: slingo ! cloud optical properties
  38. public :: update_csqy ! update ...
  39. public :: daysim ! calculate solar zenith angles
  40. public :: get_sza ! return solar zenith angle (function)
  41. public :: photo_flux ! calculates radiation fields
  42. public :: photorates_tropo ! calculates photolysis and heating rates
  43. #ifdef with_optics
  44. public :: aerosol_info_m7 ! aerosol optical depths
  45. #endif
  46. !
  47. ! !PUBLIC DATA MEMBERS:
  48. !
  49. public :: phot_dat ! type defined in photolysis_data
  50. !
  51. ! !PRIVATE DATA MEMBERS:
  52. !
  53. character(len=*), parameter :: mname = 'photolysis'
  54. real, parameter :: todu = 3.767e-17 ! from #/cm2 --> du
  55. real, parameter :: to_m = 3.767e-22 ! from #/cm2 --> m (for o2)
  56. real, parameter :: sp = 6.022e23*1.e-4*0.2095/(28.964*1e-3*9.81) ! sp from pa ---> #o2/cm2
  57. logical :: with_o3du
  58. real,dimension(122,34) :: xs_o3_look
  59. real,dimension( 65,34) :: xs_hno3_look,xs_pan_look,qy_o3_look
  60. real,dimension( 45,34) :: xs_h2o2_look
  61. real,dimension( 55,34) :: xs_n2o5_look
  62. real,dimension( 89,34) :: xs_no2_look,qy_no2_look
  63. real,dimension( 62,34) :: xs_no3_look
  64. real,dimension(105,34) :: xs_ch2o_look ! local
  65. integer :: l
  66. real :: wl,x, ww
  67. #ifdef with_optics
  68. type(wavelendep),dimension(:),allocatable :: wdep
  69. #endif
  70. !
  71. ! !REVISION HISTORY:
  72. ! 16 Jun 2011 - P. Le Sager - new version from JEW
  73. ! 21 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  74. ! 3 Oct 2012 - P. Le Sager - separate Init into true init and monthly update
  75. ! 4 Mar 2013 - P. Le Sager - changes for optics feedback from NB
  76. !
  77. ! !REMARKS:
  78. !
  79. !EOP
  80. !--------------------------------------------------------------------------
  81. CONTAINS
  82. ! Trap overflow
  83. function safe_div(n,d,altv) result(q)
  84. real, intent(in) :: n, d, altv
  85. real :: q
  86. if ( exponent(n)-exponent(d) >= maxexponent(n) .OR. d==0) then
  87. q=altv
  88. else
  89. q=n/d
  90. end if
  91. end function safe_div
  92. !--------------------------------------------------------------------------
  93. ! TM5 !
  94. !--------------------------------------------------------------------------
  95. !BOP
  96. !
  97. ! !IROUTINE: INIT_PHOTOLYSIS
  98. !
  99. ! !DESCRIPTION: read reference tables for photolysis, allocate photolysis
  100. ! data. Called from sources_sinks/Trace0 at the run start and
  101. ! at beginning of every month.
  102. !\\
  103. !\\
  104. ! !INTERFACE:
  105. !
  106. SUBROUTINE PHOTOLYSIS_INIT( first, iunit, o3du )
  107. !
  108. ! !USES:
  109. !
  110. use dims, only : im, jm, lm, nregions, newsrun
  111. use ParTools, only : isRoot, par_broadcast
  112. use global_types, only : d23_data
  113. use global_data, only : rcfile
  114. use MeteoData, only : Set
  115. use MeteoData, only : sp_dat, temper_dat, lsmask_dat, phlb_dat
  116. use MeteoData, only : lwc_dat, iwc_dat, cc_dat, humid_dat, gph_dat
  117. use GO, only : TrcFile, Init, Done, ReadRc
  118. #ifdef with_optics
  119. use optics, only : Optics_Init
  120. #endif
  121. !
  122. ! !INPUT PARAMETERS:
  123. !
  124. logical, intent(in) :: first ! true init for a new run?
  125. integer, intent(in) :: iunit
  126. type(d23_data), dimension(nregions), optional, intent(in) :: o3du
  127. !
  128. ! !REVISION HISTORY:
  129. ! 21 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  130. !
  131. ! !REMARKS:
  132. !
  133. !EOP
  134. !------------------------------------------------------------------------
  135. !BOC
  136. integer :: i,j,l,m,n,region,imr,jmr,lmr,i1, i2, j1, j2
  137. real :: lat
  138. integer :: status, wav
  139. type(TrcFile) :: rcF
  140. character(len=256) :: photodir
  141. character(len=*), parameter :: rname = mname//'/photolysis_init'
  142. ! --- begin -------------------------
  143. with_o3du = present(o3du)
  144. !--------------------------------------------------
  145. ! ** TRUE INIT : only once
  146. !--------------------------------------------------
  147. if (first) then
  148. REG: do region = 1, nregions
  149. call Set( sp_dat(region), status, used=.true. )
  150. call Set( temper_dat(region), status, used=.true. )
  151. call Set( humid_dat(region), status, used=.true. )
  152. call Set( gph_dat(region), status, used=.true. )
  153. call Set( phlb_dat(region), status, used=.true. )
  154. call Set( lwc_dat(region), status, used=.true. )
  155. call Set( iwc_dat(region), status, used=.true. )
  156. call Set( cc_dat(region), status, used=.true. )
  157. call Set( lsmask_dat(region), status, used=.true. )
  158. ! allocate memory photolysis and initialise:
  159. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  160. lmr=lm(region)
  161. if (with_o3du) allocate( phot_dat(region)%o3klim_top(j1:j2) )
  162. allocate(phot_dat(region)%albedo (i1:i2, j1:j2)) ; phot_dat(region)%albedo = 0.05
  163. allocate(phot_dat(region)%ags_av (i1:i2, j1:j2)) ; phot_dat(region)%ags_av = 0.0
  164. allocate(phot_dat(region)%sza_av (i1:i2, j1:j2)) ; phot_dat(region)%sza_av = 0.0
  165. allocate(phot_dat(region)%lwp_av (i1:i2, j1:j2,lmr)) ; phot_dat(region)%lwp_av = 0.0
  166. allocate(phot_dat(region)%cfr_av (i1:i2, j1:j2,lmr)) ; phot_dat(region)%cfr_av = 0.0
  167. allocate(phot_dat(region)%reff_av (i1:i2, j1:j2,lmr)) ; phot_dat(region)%reff_av = 0.0
  168. allocate(phot_dat(region)%aero_surface_clim(i1:i2, j1:j2)) ; phot_dat(region)%aero_surface_clim = 0
  169. phot_dat(region)%nalb_av = 0.
  170. phot_dat(region)%ncloud_av = 0.
  171. phot_dat(region)%naer_av = 0.
  172. allocate(phot_dat(region)%cloud_reff(i1:i2, j1:j2, lmr )) ; phot_dat(region)%cloud_reff = 0.0
  173. allocate(phot_dat(region)%pmcld (i1:i2, j1:j2, lmr )) ; phot_dat(region)%pmcld = 0.0
  174. allocate(phot_dat(region)%taus_cld (i1:i2, j1:j2, lmr )) ; phot_dat(region)%taus_cld = 0.0
  175. allocate(phot_dat(region)%taua_cld (i1:i2, j1:j2, lmr )) ; phot_dat(region)%taua_cld = 0.0
  176. allocate(phot_dat(region)%pmaer (i1:i2, j1:j2, lmr, nbands_trop, ngrid )) ; phot_dat(region)%pmaer = 0.0
  177. allocate(phot_dat(region)%taus_aer (i1:i2, j1:j2, lmr, nbands_trop, ngrid )) ; phot_dat(region)%taus_aer = 0.0
  178. allocate(phot_dat(region)%taua_aer (i1:i2, j1:j2, lmr, nbands_trop, ngrid )) ; phot_dat(region)%taua_aer = 0.0
  179. allocate(phot_dat(region)%pmcld_av (i1:i2, j1:j2, lmr )) ; phot_dat(region)%pmcld_av = 0.0
  180. allocate(phot_dat(region)%taus_cld_av (i1:i2, j1:j2, lmr )) ; phot_dat(region)%taus_cld_av = 0.0
  181. allocate(phot_dat(region)%taua_cld_av (i1:i2, j1:j2, lmr )) ; phot_dat(region)%taua_cld_av = 0.0
  182. allocate(phot_dat(region)%pmaer_av (i1:i2, j1:j2, lmr, nbands_trop,ngrid )) ; phot_dat(region)%pmaer_av = 0.0
  183. allocate(phot_dat(region)%taus_aer_av (i1:i2, j1:j2, lmr, nbands_trop,ngrid )) ; phot_dat(region)%taus_aer_av = 0.0
  184. allocate(phot_dat(region)%taua_aer_av (i1:i2, j1:j2, lmr, nbands_trop,ngrid )) ; phot_dat(region)%taua_aer_av = 0.0
  185. allocate(phot_dat(region)%jo3 (i1:i2, j1:j2, lmr )) ; phot_dat(region)%jo3 = 0.0
  186. allocate(phot_dat(region)%jno2 (i1:i2, j1:j2, lmr )) ; phot_dat(region)%jno2 = 0.0
  187. allocate(phot_dat(region)%jo3_av (i1:i2, j1:j2, lmr )) ; phot_dat(region)%jo3_av = 0.0
  188. allocate(phot_dat(region)%jno2_av(i1:i2, j1:j2, lmr )) ; phot_dat(region)%jno2_av = 0.0
  189. phot_dat(region)%nj_av = 0
  190. ! absorption cross-sections
  191. allocate(phot_dat(region)%v2 (i1:i2, j1:j2, lmr+1 )) ; phot_dat(region)%v2 = 0.0
  192. allocate(phot_dat(region)%v3 (i1:i2, j1:j2, lmr+1 )) ; phot_dat(region)%v3 = 0.0
  193. allocate(phot_dat(region)%v3_surf (i1:i2, j1:j2 )) ; phot_dat(region)%v3_surf = 0.0
  194. allocate(phot_dat(region)%qy_ch3cocho(i1:i2, j1:j2, lmr, 52)) ; phot_dat(region)%qy_ch3cocho = 0.0
  195. ! SAD fields
  196. phot_dat(region)%nsad_av = 0
  197. allocate(phot_dat(region)%sad_cld (i1:i2, j1:j2, lmr)) ; phot_dat(region)%sad_cld = 0.0
  198. allocate(phot_dat(region)%sad_ice (i1:i2, j1:j2, lmr)) ; phot_dat(region)%sad_ice = 0.0
  199. allocate(phot_dat(region)%sad_aer (i1:i2, j1:j2, lmr)) ; phot_dat(region)%sad_aer = 0.0
  200. allocate(phot_dat(region)%sad_cld_av (i1:i2, j1:j2, lmr)) ; phot_dat(region)%sad_cld_av = 0.0
  201. allocate(phot_dat(region)%sad_ice_av (i1:i2, j1:j2, lmr)) ; phot_dat(region)%sad_ice_av = 0.0
  202. allocate(phot_dat(region)%sad_aer_av (i1:i2, j1:j2, lmr)) ; phot_dat(region)%sad_aer_av = 0.0
  203. end do REG
  204. ! read settings from rcfile:
  205. call Init( rcF, rcfile, status )
  206. call ReadRc( rcF, 'input.photo', photodir, status )
  207. !--------------------------------------------------------------------
  208. ! wavelengths in the middle of the intervals
  209. !--------------------------------------------------------------------
  210. ! see: C. Bruehl, P.J. Crutzen, Scenarios of possible changes in ...
  211. ! Climate Dynamics (1988)2: 173-203
  212. ! ONLINE TUNING : first 13 wavelength bins are now ignored. Grid also shortened above 690nm.
  213. do l=1,13
  214. wave_full(l)=1./(56250.-500.*l)
  215. end do
  216. do l=14,45
  217. wave_full(l)=1./(49750.-(l-13)*500.)
  218. end do
  219. do l=46,68
  220. wave_full(l)=(266.+(l-13))*1.e-7
  221. end do
  222. do l=69,71
  223. wave_full(l)=(320.5+2.*(l-68))*1.e-7
  224. end do
  225. do l=72,176
  226. wave_full(l)=(325.+5.*(l-71))*1.e-7
  227. end do
  228. do l=2,maxwav-1
  229. dwave_full(l)=0.5*(wave_full(l+1)-wave_full(l-1))
  230. end do
  231. dwave_full(1) = dwave_full(2)
  232. dwave_full(maxwav) = dwave_full(maxwav-1)
  233. ! select a subset from the full spctral grid to remove the first band
  234. wave=wave_full(14:135)
  235. dwave=dwave_full(14:135)
  236. !---------------------------------------------------------------------
  237. ! Rayleigh scattering cross sections
  238. ! emp. formula of Nicolet plan. space sci.32, 1467f (1984)
  239. !---------------------------------------------------------------------
  240. do l=1,maxwav
  241. wl=wave(l)*1.e4
  242. x=0.389*wl+0.09426/wl-0.3228
  243. cs_ray(l)=4.02e-28/wl**(4.+x)
  244. end do
  245. !--------------------------------------------------------------
  246. ! Read and store temperature dependent cross-section values
  247. !--------------------------------------------------------------
  248. open(unit=7, file=trim(photodir)//'/tropo_look_up_reduce_2009.dat', status='old')
  249. read(7,*)
  250. read(7,*)
  251. read(7,*)
  252. do i=1,34
  253. read(7,'(176(1Pe10.3))') (xs_o3_look(wav,i),wav=1,122)
  254. enddo
  255. read(7,*)
  256. do i=1,34
  257. read(7,*) (xs_no2_look(wav,i),wav=1,89)
  258. enddo
  259. read(7,*)
  260. do i=1,34
  261. read(7,*) (xs_hno3_look(wav,i),wav=1,65)
  262. enddo
  263. read(7,*)
  264. do i=1,34
  265. read(7,*) (xs_h2o2_look(wav,i),wav=1,45)
  266. enddo
  267. read(7,*)
  268. do i=1,34
  269. read(7,*) (xs_n2o5_look(wav,i),wav=1,55)
  270. enddo
  271. read(7,*)
  272. do i=1,34
  273. read(7,*) (xs_ch2o_look(wav,i),wav=1,90)
  274. enddo
  275. read(7,*)
  276. do i=1,34
  277. read(7,*) (xs_pan_look(wav,i),wav=1,65)
  278. enddo
  279. read(7,*)
  280. do i=1,34
  281. read(7,*) (xs_no3_look(wav,i),wav=1,62)
  282. enddo
  283. read(7,*)
  284. do i=1,34
  285. read(7,*) (qy_o3_look(wav,i),wav=1,65)
  286. enddo
  287. read(7,*)
  288. do i=1,34
  289. read(7,*)(qy_no2_look(wav,i),wav=1,89)
  290. enddo
  291. close(7)
  292. !--------------------------------------------------------------
  293. ! Read and store temperature dependent cross-section values
  294. !------------------ extraterrestrial flux from input file ------------------
  295. ! open(unit=7, file=trim(photodir)//'/OMI.data.reduce',status='old')
  296. ! read(7,*)
  297. ! read(7,'(1p7e10.2)') flux
  298. ! close(7)
  299. ! Cannot be read for some unknown reason on cca@ecmwf with cray compiler.
  300. ! Just set it here:
  301. flux=(/ 2.351E+12, 2.414E+12, 2.360E+12, 3.004E+12, 8.861E+12, 4.475E+12, 9.005E+12, &
  302. 1.607E+13, 1.556E+13, 1.221E+13, 2.061E+13, 2.070E+13, 1.047E+13, 7.497E+12, &
  303. 1.729E+13, 9.523E+12, 2.018E+13, 2.265E+13, 1.275E+13, 1.750E+13, 2.590E+13, &
  304. 8.777E+13, 2.193E+13, 5.449E+13, 1.074E+14, 6.856E+13, 7.875E+13, 2.275E+13, &
  305. 1.488E+14, 2.166E+14, 2.518E+14, 3.504E+14, 1.493E+14, 5.366E+13, 4.045E+13, &
  306. 2.054E+13, 6.274E+13, 9.589E+13, 1.326E+14, 1.307E+13, 1.332E+14, 1.729E+14, &
  307. 1.349E+14, 5.685E+13, 1.342E+14, 1.391E+14, 8.107E+13, 1.459E+14, 1.965E+14, &
  308. 5.681E+13, 1.349E+14, 6.819E+13, 2.137E+14, 1.564E+14, 1.334E+14, 3.559E+14, &
  309. 2.593E+14, 4.187E+14, 7.893E+14, 1.610E+14, 1.021E+15, 9.119E+14, 1.056E+15, &
  310. 8.424E+14, 6.622E+14, 9.387E+14, 1.463E+15, 3.382E+14, 1.076E+15, 9.586E+14, &
  311. 1.783E+15, 8.718E+14, 1.864E+15, 1.661E+15, 1.938E+15, 2.101E+15, 2.058E+15, &
  312. 1.738E+15, 9.227E+14, 2.404E+15, 2.176E+15, 2.625E+15, 2.167E+15, 1.741E+15, &
  313. 2.424E+15, 1.531E+15, 1.819E+15, 2.625E+15, 2.293E+15, 2.570E+15, 2.619E+15, &
  314. 2.663E+15, 2.705E+15, 2.542E+15, 1.331E+15, 2.633E+15, 2.575E+15, 2.744E+15, &
  315. 1.958E+15, 2.642E+15, 2.691E+15, 2.646E+15, 2.720E+15, 2.703E+15, 1.188E+15, &
  316. 2.720E+15, 2.271E+15, 2.405E+15, 2.723E+15, 2.690E+15, 2.550E+15, 2.670E+15, &
  317. 2.665E+15, 2.702E+15, 2.653E+15, 2.658E+15, 2.691E+15, 2.593E+15, 2.646E+15, &
  318. 2.653E+15, 2.636E+15, 2.648E+15 /)
  319. #ifdef with_optics
  320. ! define wavelengths for optics calculations
  321. nwdep = nbands_trop + count(lmid.ne.lmid_gridA)
  322. wav_grid = 0
  323. wav_gridA = 0
  324. allocate(photo_wavelengths(nwdep))
  325. l=1
  326. do i=1,nbands_trop
  327. if (lmid(i)==lmid_gridA(i)) then
  328. photo_wavelengths(l) = wave(lmid(i))*1.e4 ! cm to um
  329. wav_grid(i) = l
  330. wav_gridA(i) = l
  331. l=l+1
  332. else
  333. photo_wavelengths(l) = wave(lmid(i))*1.e4 ! cm to um
  334. photo_wavelengths(l+1) = wave(lmid_gridA(i))*1.e4 ! cm to um
  335. wav_grid(i) = l
  336. wav_gridA(i) = l+1
  337. l=l+2
  338. endif
  339. enddo
  340. allocate(wdep(nwdep))
  341. wdep(:)%wl = photo_wavelengths
  342. wdep(:)%split = .false.
  343. wdep(:)%insitu = .false.
  344. call Done( rcF, status )
  345. IF_NOTOK_RETURN(status=1)
  346. CALL OPTICS_INIT( nwdep, wdep, status )
  347. IF_NOTOK_RETURN(status=1)
  348. deallocate(photo_wavelengths)
  349. #else
  350. !**************************************************************************
  351. ! aerosol data from: "Models for Aerosols of the Lower Atmosphere
  352. ! and the Effects of Humidity Variations on their Optical Properties
  353. ! E. P. Shettle and R. W. Fenn (1979), Environmental Research Paper
  354. ! No. 676
  355. !**************************************************************************
  356. open(unit=7, file=trim(photodir)//'/aerosol_reduce.dat',status='old')
  357. do l = 1,4
  358. read(7,*)
  359. do i = 1,8
  360. read(7,*)
  361. read(7,20)(ext(wav,i,l),wav=1,maxwav)
  362. read(7,20)(abs_eff(wav,i,l),wav=1,maxwav)
  363. read(7,20)(g(wav,i,l),wav=1,maxwav)
  364. do wav=1,maxwav
  365. sca(wav,i,l) = ext(wav,i,l) - abs_eff(wav,i,l)
  366. enddo
  367. enddo
  368. enddo
  369. close(7)
  370. 20 format(6(1X,F7.5))
  371. do l=1,maxwav
  372. do i=1,8
  373. do j=1,4
  374. sca(l,i,j) = sca(l,i,j)/pn_ref(j)*1.E-5
  375. abs_eff(l,i,j) = abs_eff(l,i,j)/pn_ref(j)*1.E-5
  376. end do
  377. end do
  378. end do
  379. ! close rc file
  380. call Done( rcF, status )
  381. #endif
  382. ELSE ! NEWSRUN
  383. !--------------------------------------------------
  384. ! ** MONTHLY UPDATE
  385. !--------------------------------------------------
  386. if (with_o3du) then
  387. do region = 1, nregions
  388. call Get_DistGrid( dgrid(region), J_STRT=j1, J_STOP=j2 )
  389. phot_dat(region)%o3klim_top(:) = o3du(region)%d23(j1:j2,lm(region))
  390. end do
  391. end if
  392. ENDIF
  393. END SUBROUTINE PHOTOLYSIS_INIT
  394. !EOC
  395. !--------------------------------------------------------------------------
  396. ! TM5 !
  397. !--------------------------------------------------------------------------
  398. !BOP
  399. !
  400. ! !IROUTINE: DAYSIM
  401. !
  402. ! !DESCRIPTION: Get all solar zenith angles (THA) for a given Julian day
  403. ! (DAYNR) at 1/6, 3/6(=center), and 5/6 of each grid box.
  404. ! THA is three times oversampled.
  405. ! The longitudinal variation is equal to the simulation of
  406. ! one day, and covers the [-180,180] range for all regions.
  407. !\\
  408. !\\
  409. ! !INTERFACE:
  410. !
  411. SUBROUTINE DAYSIM(region, daynr, is, i1,i2,j1, j2, tha)
  412. !
  413. ! !USES:
  414. !
  415. use dims, only : im, jm, xbeg, xend
  416. use binas, only : pi
  417. use meteodata, only : lli
  418. !
  419. ! !INPUT PARAMETERS:
  420. !
  421. integer, intent(in) :: daynr, region, is, j1, j2,i1,i2
  422. !
  423. ! !OUTPUT PARAMETERS:
  424. !
  425. real, intent(out) :: tha( im(region)*3, j1:j2)
  426. !
  427. ! !REVISION HISTORY:
  428. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  429. !
  430. ! !REMARKS:
  431. ! (1) The regions are artificially expanded to cover all longitudes, in
  432. ! order to keep the correspondance b/w time and longitude.
  433. ! (2) Need to be called once a day only. Hence separated from GET_SZA,
  434. ! and the need to have 'im_alt' and 'shift' defined module wide.
  435. ! (3) Input 'is' is not i1=I_START from the distributed grid, but: (i1-1)*3+1
  436. ! It is not used yet. To delete?
  437. ! (4) Considering the cshift functions used on THA in GET_SZA, it is
  438. ! assumed that THA covers the entire longitude range.
  439. !EOP
  440. !------------------------------------------------------------------------
  441. !BOC
  442. real, dimension(j1:j2) :: lat
  443. real :: houra, rdecl, sinhh, eqr, ut
  444. real :: piby, lon, tz, sintz, costz
  445. real :: sin2tz, cos2tz, sin3tz, cos3tz
  446. integer :: i, j, k
  447. !
  448. !call Get_DistGrid( dgrid(region), I_STOP=i2, J_STOP=j2 )
  449. piby = pi/180.
  450. !
  451. ! latitude range in radian
  452. lat = lli(region)%lat
  453. !
  454. tz = 2.*pi*daynr/365.
  455. !
  456. ! Solar declination approximation
  457. !(p.97, Brasseur et al, Atmospheric Chemistry and Global Change, 1999)
  458. !
  459. rdecl = -0.4*cos(2.*pi*real(daynr+10)/365.)
  460. !
  461. sintz = sin(tz)
  462. costz = cos(tz)
  463. sin2tz = 2.*sintz*costz
  464. cos2tz = costz*costz-sintz*sintz
  465. eqr = 0.000075 + 0.001868*costz - 0.032077*sintz &
  466. - 0.014615*cos2tz - 0.040849*sin2tz
  467. !
  468. ! the sza variation over longitude [-180,180] at ut=12 equals
  469. ! a with variation of ut over [0,24] at longitude 0:
  470. ! houra = 15.*(ut-12. + eqr*24./(2.*pi) + lon*24./360)*piby
  471. !
  472. ! THA (sampled at 1/6, 3/6, and 5/6 of each box). As follow for 6 degree resolution:
  473. !
  474. ! -180---+---+---177---+---+---174---+---+---171---+---+---168 .......etc...
  475. ! | | |
  476. ! | box #1 | box #2 |
  477. ! | | |
  478. ! +---------------------------+---------------------------+ .......etc.....
  479. ! 0 1 2 3 4 5 0 1 2 3 4 5
  480. ! * * * * * * <---- samples (lon,THA)
  481. do j=j1,j2
  482. do i=1,im(region)*3
  483. lon = -180. + (real(i)-0.5)*360./real(im(region)*3)
  484. !lon = xbeg(region) + (real(i)-0.5)*(xend(region)-xbeg(region))/real(im(region)*3)
  485. houra = -pi + lon*piby + eqr
  486. sinhh = sin(rdecl)*sin(lat(j)) &
  487. + cos(rdecl)*cos(lat(j))*cos(houra)
  488. tha(i,j) = acos(sinhh)/piby
  489. enddo
  490. enddo
  491. END SUBROUTINE DAYSIM
  492. !EOC
  493. !--------------------------------------------------------------------------
  494. ! TM5 !
  495. !--------------------------------------------------------------------------
  496. !BOP
  497. !
  498. ! !IROUTINE: GET_SZA
  499. !
  500. ! !DESCRIPTION:
  501. !\\
  502. !\\
  503. ! !INTERFACE:
  504. !
  505. SUBROUTINE GET_SZA(region, i1, j1, i2, j2, tstart, deltat, tha, sza)
  506. !
  507. ! !USES:
  508. !
  509. use dims, only : im, jm
  510. !
  511. ! !INPUT PARAMETERS:
  512. !
  513. integer, intent(in) :: region, i1, j1, i2, j2
  514. real, intent(in) :: tstart ! start time of chemistry timestep
  515. real, intent(in) :: deltat ! chemistry timestep in hours
  516. real, intent(in) :: tha(im(region)*3,j1:j2) ! three times oversampled zenith angles
  517. !
  518. ! !OUTPUT PARAMETERS:
  519. !
  520. real, intent(out) :: sza(i1:i2,j1:j2) ! effective solar zenith angles for this timestep
  521. !
  522. ! !REVISION HISTORY:
  523. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  524. !
  525. ! !REMARKS:
  526. !
  527. !EOP
  528. !------------------------------------------------------------------------
  529. !BOC
  530. real, dimension(im(region)*3,j1:j2) :: mu3
  531. real :: dt
  532. integer :: it, i, ii
  533. !
  534. mu3 = 0.0
  535. !
  536. ! split chemistry timestep in intervals and calculate mu at 1/6, 3/6
  537. ! and 5/6 of timestep chemistry. Interpolate in time using the
  538. ! longitudinal dependence of tha and take the average.
  539. !
  540. do ii=1,5,2
  541. dt = ( tstart + ii*deltat/6. ) * (real(im(region)*3)/24.)
  542. it = int(dt)
  543. dt = dt-it
  544. mu3 = mu3 + (1-dt)*cshift(tha,it,1)+dt*cshift(tha,it+1,1)
  545. enddo
  546. !
  547. ! average over three angles at three times resolution
  548. !
  549. do i=i1,i2
  550. sza(i,:) = (mu3(i*3-2,:) + mu3(i*3-1,:) + mu3(i*3,:))/9.0
  551. enddo
  552. END SUBROUTINE GET_SZA
  553. !EOC
  554. !--------------------------------------------------------------------------
  555. ! TM5 !
  556. !--------------------------------------------------------------------------
  557. !BOP
  558. !
  559. ! !IROUTINE: PHOTO_FLUX
  560. !
  561. ! !DESCRIPTION:
  562. !\\
  563. !\\
  564. ! !INTERFACE:
  565. !
  566. SUBROUTINE PHOTO_FLUX( region, is, js, sza, rj_new)
  567. !**********************************************************************
  568. ! *
  569. ! contact: *
  570. ! *
  571. ! Jason Williams *
  572. ! Koninklijk Nederlands Meteorologisch instituut (KNMI) *
  573. ! Postbus 201 *
  574. ! 3730 AE De Bilt *
  575. ! tel +31 (0)30 2206748 *
  576. ! e-mail : williams@knmi.nl *
  577. ! *
  578. !**********************************************************************
  579. ! purpose:
  580. !
  581. ! The calculation of the radiation fields using input from TM5 and ECMWF meteo.
  582. !
  583. ! method:
  584. !
  585. ! Optical properties (optical thickness,cross sections, quantum yields)
  586. ! are calculated for lm(region) layers. Radiation fluxes are derived for 0:lm(region)
  587. ! levels, including the surface and top of atmosphere. Thus, level l overlays layer l.
  588. ! Photolysis rates in a layer are evaluated by taking the average of the
  589. ! photolysis rates evaluated at the upper and lower boundaries of the layer.
  590. !
  591. ! First, spectral calculations are performed for an atmosphere with absorption
  592. ! only, including gaseous absorption by O2 and O3 and aerosol absorption.
  593. ! Second, a correction is applied for scattering and surface reflection, per
  594. ! scattering band and using radiative transfer calculations at representative
  595. ! wavelengths
  596. !
  597. ! This photolysis module is based on:
  598. !
  599. ! Landgraf and Crutzen, 1998, J. Atmos. Sci, 55, 863-878.
  600. ! Williams et al., 2006, Atmos.Chem.Phys., 6, 4137-4161.
  601. !
  602. !------------------------------------------------------------------
  603. !
  604. ! Albedo field
  605. ! ------------
  606. !
  607. ! In older TM photolysis code, an adhoc uv-vis albedo was computed
  608. ! from land cover fields:
  609. !
  610. ! module dry_deposition
  611. ! dd_surface_fields
  612. ! if(root_k)then
  613. ! dd_calc_inisurf
  614. ! compute ags on glb1x1 from land cover, on root_k only
  615. ! dd_coarsen_vd
  616. ! coarsen ags to vd_temp, copy into phot_dat(region)%albedo
  617. ! endif
  618. ! broadcast phot_dat(region)%albedo to all other processors
  619. !
  620. ! In the first stratospheric codes, the same adhoc albedo computed in
  621. ! drydepos was written over the albedo meteo field, and then this one was used.
  622. ! To avoid this obscure destruction of ecmwf data, we use the phot_dat version here.
  623. ! In future, this should be replaced by ECMWF field:
  624. ! UV visible albedo for direct radiation ALUVP (0 - 1) 15 128
  625. !
  626. !------------------------------------------------------------------
  627. ! subroutine to calculate direct flux and actinic flux
  628. !*******************************************************************
  629. !
  630. ! !USES:
  631. !
  632. use dims, only : lm, idate, ndyn, ndyn_max
  633. use MeteoData, only : temper_dat, gph_dat, cc_dat
  634. !
  635. ! !INPUT PARAMETERS:
  636. !
  637. integer, intent(in) :: region
  638. integer, intent(in) :: is, js
  639. real, intent(in) :: sza(is:,js:)
  640. !
  641. ! !OUTPUT PARAMETERS:
  642. !
  643. ! photolysis rates for this time-step
  644. real, dimension(is:,js:,:,:), intent(out) :: rj_new ! (i1:i2,j1:j2,lm(region),nj)
  645. !
  646. ! !REVISION HISTORY:
  647. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  648. !
  649. !EOP
  650. !------------------------------------------------------------------------
  651. !BOC
  652. integer :: i, j, l, k, n, table_pos
  653. real :: zangle, alb, esrm2
  654. real, dimension(lm(region)+1) :: levels
  655. logical :: clear, cloudy, debug_flag
  656. ! temperature index array for the lookup table
  657. integer, parameter :: n_ind =34 ! number of increments in the look-up table
  658. integer, parameter :: jindex=9
  659. integer, parameter :: latindex=21
  660. real, parameter :: incr = 5. ! 5deg C intervals in look-up table (optimised value)
  661. real, dimension(n_ind) :: temp_ind
  662. real, dimension(:), allocatable :: v2_col, v3_col, dv2_col, dv3_col, t_lay, ly_a, column_cloud
  663. real, dimension(:,:), allocatable :: cst_o3_col
  664. real, dimension(:,:), allocatable :: cst_no2_col, qy_no2_col
  665. real, dimension(:,:), allocatable :: cst_hno3_col
  666. real, dimension(:,:), allocatable :: cst_h2o2_col
  667. real, dimension(:,:), allocatable :: cst_n2o5_col
  668. real, dimension(:,:), allocatable :: cst_ch2o_col
  669. real, dimension(:,:), allocatable :: cst_pan_col
  670. real, dimension(:,:), allocatable :: cst_no3_col
  671. real, dimension(:,:), allocatable :: qy_o1d_col
  672. real, dimension(:,:), allocatable :: qy_ch3cocho_col
  673. real, dimension(:,:), allocatable :: fdir, fact
  674. real, dimension(:), allocatable :: taua_cld_col, taus_cld_col
  675. real, dimension(:,:,:),allocatable :: taus_aer_col, taua_aer_col
  676. real, dimension(:,:), allocatable :: ts_pi_clr_col, ta_pi_clr_col, g_pi_clr_col, g_pi_cld_col
  677. real, dimension(:), allocatable :: ts_pi_cld, ta_pi_cld
  678. real, dimension(:,:,:),allocatable :: pm_aer_col
  679. real, dimension(:), allocatable :: pm_cld_col
  680. real, dimension(:,:), allocatable :: ds
  681. real, dimension(:,:), allocatable :: rj_column
  682. real, dimension(:,:,:),pointer :: temperature
  683. ! additional diagnostic array to compare old/new jvalue input
  684. real, dimension(:), allocatable :: vo3s_col
  685. integer :: i1, j1, i2, j2
  686. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  687. allocate( v2_col (lm(region)+1) )
  688. allocate( v3_col (lm(region)+1) )
  689. allocate( dv2_col (lm(region) ) )
  690. allocate( dv3_col (lm(region) ) )
  691. allocate( t_lay (lm(region) ) )
  692. allocate( cst_o3_col (lm(region),maxwav) )
  693. allocate( cst_no2_col (lm(region),89) )
  694. allocate( qy_no2_col (lm(region),89) )
  695. allocate( cst_hno3_col (lm(region),65) )
  696. allocate( cst_h2o2_col (lm(region),45) )
  697. allocate( cst_n2o5_col (lm(region),55) )
  698. allocate( cst_ch2o_col (lm(region),105) )
  699. allocate( cst_pan_col (lm(region),65) )
  700. allocate( cst_no3_col (lm(region),62) )
  701. allocate( qy_o1d_col (lm(region),65) )
  702. allocate( qy_ch3cocho_col(lm(region),52) )
  703. allocate( fdir (lm(region),maxw) ) ; fdir(:,:) = 0.
  704. allocate( taus_aer_col (lm(region),nbands_trop,ngrid))
  705. allocate( taua_aer_col (lm(region),nbands_trop,ngrid))
  706. allocate( taus_cld_col (lm(region)))
  707. allocate( taua_cld_col (lm(region)))
  708. allocate( ts_pi_clr_col (lm(region),nbands_trop))
  709. allocate( ta_pi_clr_col (lm(region),nbands_trop))
  710. allocate( g_pi_clr_col (lm(region),nbands_trop))
  711. allocate( g_pi_cld_col (lm(region),nbands_trop))
  712. allocate( pm_aer_col (lm(region),nbands_trop,ngrid))
  713. allocate( pm_cld_col (lm(region)))
  714. allocate( fact (lm(region),nbands_trop)) ; fact(:,:) = 0.
  715. allocate( column_cloud (lm(region)))
  716. allocate( ds (lm(region)+1,lm(region)))
  717. allocate( rj_column (lm(region),nj)) ; rj_column = 0.
  718. allocate(vo3s_col(lm(region)+1))
  719. temperature => temper_dat(region)%data
  720. clear = .false.
  721. cloudy = .true.
  722. debug_flag = .false.
  723. ! define temperature index array from the lookup table
  724. do i = 1, 34
  725. temp_ind(i) = 182.5 + (i-1) * 5.0
  726. enddo
  727. do j = j1, j2
  728. do i = i1, i2
  729. zangle = sza(i,j)
  730. t_lay = temperature(i,j,:)
  731. rj_new(i,j,:,:) = 0.
  732. if (zangle <= sza_limit ) then
  733. ! initialise
  734. fdir = 0. ; dv2_col = 0. ; dv3_col = 0. ; fact = 0.
  735. v2_col(:) = phot_dat(region)%v2(i,j,:)
  736. v3_col(:) = phot_dat(region)%v3(i,j,:)
  737. qy_ch3cocho_col(:,:) = phot_dat(region)%qy_ch3cocho(i,j,:,:)
  738. column_cloud(:) = cc_dat(region)%data(i,j,:)
  739. levels=gph_dat(region)%data(i,j,:)
  740. ! set optical depths parameters
  741. taus_cld_col = phot_dat(region)%taus_cld(i,j,:)
  742. taua_cld_col = phot_dat(region)%taua_cld(i,j,:)
  743. taus_aer_col = phot_dat(region)%taus_aer(i,j,:,:,:)
  744. taua_aer_col = phot_dat(region)%taua_aer(i,j,:,:,:)
  745. pm_cld_col = phot_dat(region)%pmcld(i,j,:)
  746. pm_aer_col = phot_dat(region)%pmaer(i,j,:,:,:)
  747. !
  748. ! assign the cross-sections here to avoid the exporting of large arrays
  749. !
  750. do k=1,lm(region)
  751. table_pos=int((t_lay(k) - (temp_ind(1)-0.5*5)) / 5) + 1
  752. table_pos=min(max(1,table_pos),34) ! bug fix for temperatures below 175.5
  753. cst_o3_col(k,:) = xs_o3_look(:,table_pos)
  754. cst_no2_col(k,:) = xs_no2_look(:,table_pos)
  755. cst_hno3_col(k,:) = xs_hno3_look(:,table_pos)
  756. cst_h2o2_col(k,:) = xs_h2o2_look(:,table_pos)
  757. cst_ch2o_col(k,:) = xs_ch2o_look(:,table_pos)
  758. cst_n2o5_col(k,:) = xs_n2o5_look(:,table_pos)
  759. cst_pan_col(k,:) = xs_pan_look(:,table_pos)
  760. cst_no3_col(k,:) = xs_no3_look(:,table_pos)
  761. qy_o1d_col(k,:) = qy_o3_look(:,table_pos)
  762. qy_no2_col(k,:) = qy_no2_look(:,table_pos)
  763. enddo
  764. ! slant column, lyman-alpha and direct flux ; all are zenith angle dependent
  765. call directflux(region,zangle,v2_col,v3_col,cst_o3_col,t_lay,fdir,dv2_col,dv3_col,taua_cld_col, &
  766. taua_aer_col,levels,ds,vo3s_col,debug_flag)
  767. ! now do radiative transfer calculation, calculate actinic flux
  768. ! set albedo
  769. alb = phot_dat(region)%albedo(i,j)
  770. ! Now call the PIFM RT solver for the online calculation ; both clear and cloudy conditions can be used
  771. if (clear) call pifm(region,zangle,alb,cst_o3_col,dv2_col,dv3_col, &
  772. taua_aer_col,taus_aer_col,pm_aer_col,fact)
  773. if (cloudy) call pifm_ran( region,zangle,alb,cst_o3_col,dv2_col,dv3_col, &
  774. taua_cld_col,taus_cld_col,pm_cld_col,taua_aer_col,taus_aer_col,pm_aer_col,fact,column_cloud)
  775. rj_column=0.
  776. call photorates_tropo(region,zangle,cst_o3_col,cst_no2_col,cst_hno3_col,cst_h2o2_col,cst_ch2o_col,&
  777. cst_n2o5_col,cst_pan_col,cst_no3_col,qy_no2_col,qy_o1d_col,qy_ch3cocho_col,fact,fdir,&
  778. rj_column,debug_flag)
  779. rj_new(i,j,:,:) = rj_column
  780. elseif(zangle > sza_limit) then
  781. vo3s_col = 0.
  782. do k=1,lm(region)
  783. table_pos=int((t_lay(k) - (temp_ind(1)-0.5*5)) / 5) + 1
  784. table_pos=min(max(1,table_pos),34) ! max(...) == temperatures below 175.5 used like 180.5
  785. cst_o3_col(k,:) = xs_o3_look(:,table_pos)
  786. enddo
  787. debug_flag=.false.
  788. endif ! sza_limit
  789. enddo ! i
  790. enddo ! j
  791. ! Correction photolysis for distance sun-earth
  792. esrm2 = sundis(idate(2),idate(3))
  793. rj_new = rj_new *esrm2
  794. ! Store
  795. phot_dat(region)%jo3 (:,:,:) = rj_new(:,:,:,jo3d)
  796. phot_dat(region)%jno2 (:,:,:) = rj_new(:,:,:,jno2)
  797. ! Averages
  798. phot_dat(region)%nj_av = phot_dat(region)%nj_av + float(ndyn)/float(ndyn_max)
  799. phot_dat(region)%nalb_av = phot_dat(region)%nalb_av + float(ndyn)/float(ndyn_max)
  800. phot_dat(region)%jo3_av = phot_dat(region)%jo3_av + float(ndyn)/float(ndyn_max) * rj_new(:,:,:,jo3d)
  801. phot_dat(region)%jno2_av = phot_dat(region)%jno2_av + float(ndyn)/float(ndyn_max) * rj_new(:,:,:,jno2)
  802. phot_dat(region)%ags_av = phot_dat(region)%ags_av + float(ndyn)/float(ndyn_max) * phot_dat(region)%albedo
  803. phot_dat(region)%sza_av = phot_dat(region)%sza_av + float(ndyn)/float(ndyn_max) * sza
  804. ! Done
  805. nullify(temperature)
  806. deallocate(v2_col)
  807. deallocate(v3_col)
  808. deallocate(dv2_col)
  809. deallocate(dv3_col)
  810. deallocate(cst_o3_col)
  811. deallocate(cst_no2_col)
  812. deallocate(qy_no2_col)
  813. deallocate(cst_hno3_col)
  814. deallocate(cst_h2o2_col)
  815. deallocate(cst_n2o5_col)
  816. deallocate(cst_ch2o_col)
  817. deallocate(cst_pan_col)
  818. deallocate(cst_no3_col)
  819. deallocate(qy_o1d_col)
  820. deallocate(qy_ch3cocho_col)
  821. deallocate(fdir)
  822. deallocate(t_lay)
  823. deallocate(taus_aer_col)
  824. deallocate(taua_aer_col)
  825. deallocate(pm_aer_col)
  826. deallocate(taus_cld_col)
  827. deallocate(taua_cld_col)
  828. deallocate(pm_cld_col)
  829. deallocate(ts_pi_clr_col)
  830. deallocate(ta_pi_clr_col)
  831. deallocate(g_pi_clr_col)
  832. deallocate(g_pi_cld_col)
  833. deallocate(fact)
  834. deallocate(column_cloud)
  835. deallocate(ds)
  836. deallocate(rj_column)
  837. deallocate(vo3s_col)
  838. END SUBROUTINE PHOTO_FLUX
  839. !EOC
  840. !--------------------------------------------------------------------------
  841. ! TM5 !
  842. !--------------------------------------------------------------------------
  843. !BOP
  844. !
  845. ! !IROUTINE: DIRECTFLUX
  846. !
  847. ! !DESCRIPTION:
  848. ! Schumann-Runge parameterization
  849. ! Koppers GAA, Murtagh DP, Ann. Geophysicae 14, 68-79
  850. !\\
  851. !\\
  852. ! !INTERFACE:
  853. !
  854. subroutine directflux(region,zangle,v2_col,v3_col,cst_o3_col,t_lay,&
  855. fdir,dv2_col,dv3_col,taua_cld_col,taua_aer_col,&
  856. levels,ds,vo3s_col,debug_flag)
  857. !
  858. ! !USES:
  859. !
  860. use dims, only : lm
  861. use binas, only : pi, avog, grav, xmair, ae
  862. !
  863. ! !INPUT PARAMETERS:
  864. !
  865. integer, intent(in) :: region
  866. real,intent(in) :: zangle
  867. ! oxygen and ozone column
  868. real,dimension(lm(region)+1),intent(in) :: v2_col,v3_col
  869. real,dimension(lm(region)),intent(in) :: taua_cld_col
  870. real,dimension(lm(region),nbands_trop,ngrid),intent(in) :: taua_aer_col
  871. !
  872. ! !OUTPUT PARAMETERS:
  873. !
  874. real,dimension(lm(region)+1),intent(out) :: vo3s_col
  875. ! temperature
  876. real,dimension(lm(region)),intent(in) :: t_lay
  877. ! temperature dependent cs of ozone
  878. real,dimension(lm(region),maxwav),intent(in) :: cst_o3_col
  879. ! flux through pure absorbing atmosphere
  880. real,dimension(lm(region),maxw),intent(out) :: fdir
  881. real,dimension(lm(region)),intent(out) :: dv2_col,dv3_col
  882. ! levels for ds calculation
  883. real,dimension(lm(region)+1) :: levels
  884. real,dimension(lm(region)+1,lm(region)),intent(out) :: ds
  885. logical,intent(in) :: debug_flag
  886. !
  887. ! !REVISION HISTORY:
  888. !
  889. !EOP
  890. !------------------------------------------------------------------------
  891. !BOC
  892. real,dimension(:),allocatable :: t_lev
  893. real,dimension(:),allocatable :: v2s,v3s,dv2s, dv3s
  894. integer :: l, li, i, j, k, k1, k2, id, n, h, bandno
  895. real :: dl_o2,u0
  896. real,dimension(20) :: coeff_a, coeff_b
  897. real :: a,b,c, gamma
  898. real,dimension(maxw) :: fdir_top
  899. real :: fdir_bot
  900. real :: ta_o2, ta_o3, tau
  901. real :: sp, const, press, alp, alv2, sln, ck, sf
  902. !-----------------------------------------------------------------
  903. ! declarations for the calculation of DS
  904. real,dimension(0:lm(region)) :: ze
  905. real,dimension(0:lm(region),lm(region)) :: ds_tmp
  906. real :: rpsinz,rj,rjp1,diffj,height1,height2
  907. real :: zenrad,sm,re,dsj,dummy
  908. allocate(t_lev(lm(region)+1)) ; t_lev=0.
  909. allocate(dv2s(lm(region))) ; dv2s = 0.
  910. allocate(dv3s(lm(region))) ; dv3s = 0.
  911. allocate(v2s(1:lm(region)+1)) ; v2s = 0.
  912. allocate(v3s(1:lm(region)+1)) ; v3s = 0.
  913. ! initialise all output
  914. fdir = 0. ; dv2_col = 0 ; dv3_col = 0. ; ds = 0. ; ds_tmp = 0.
  915. ! define temperature on grid levels. Note temperature on layers now has reversed vertical grid
  916. do k = 2,lm(region)
  917. t_lev(k) = (t_lay(k) + t_lay(k-1) ) * 0.5
  918. enddo
  919. ! boundaries
  920. t_lev(1) = t_lay(1)
  921. t_lev(lm(region)+1) = t_lay(lm(region))
  922. a = 0.50572 ; b = 6.07995 ; c = 1.63640
  923. dv2_col(lm(region)) = v2_col(lm(region))
  924. dv3_col(lm(region)) = v3_col(lm(region))
  925. do l=lm(region)-1,1,-1
  926. dv2_col(l) = v2_col(l)-v2_col(l+1)
  927. dv3_col(l) = v3_col(l)-v3_col(l+1)
  928. end do
  929. !-----correction of the air mass factor---------------------------------
  930. ! F. Kasten and T. Young, Revised optical air mass tabels and
  931. ! approximation formula (1989) Aplied Optics Vol 28, No. 22 P. 4735
  932. ! and J. Lenoble, atmospheric radiative transfer (1993), P. 236
  933. ! define air mass factor in mu
  934. gamma = 90. - zangle
  935. u0 = sin(gamma*pi/180.) + a *(gamma+b)**(-c)
  936. u0 = min(1.,u0)
  937. if(zangle <= 75.) then
  938. ds = 1/u0
  939. elseif(zangle >75. .and. zangle <=sza_limit) then
  940. levels(1:lm(region)+1)=levels(lm(region)+1:1:-1)
  941. re = (ae+levels(lm(region)+1))*1.e-3
  942. do k=lm(region)+1,1,-1
  943. ze(k-1) = (levels(k)/1.e3)-(levels(lm(region)+1)/1.e3)
  944. enddo
  945. zenrad=acos(u0)
  946. do k=0,lm(region)
  947. rpsinz = (re+ze(k))*sin(zenrad)
  948. id = k
  949. do n=1,id
  950. sm = 1.0
  951. rj = re + ze(n-1)
  952. rjp1 = re + ze(n)
  953. diffj = ze(n-1) - ze(n)
  954. height1 = rj**2 - rpsinz**2
  955. height2 = rjp1**2 - rpsinz**2
  956. height1=max(0.0,height1)
  957. height2=max(0.0,height2)
  958. if(id>k .and. n==id) then
  959. dsj=sqrt(height1)
  960. else
  961. dsj=sqrt(height1)-sm*sqrt(height2)
  962. endif
  963. ds_tmp(k,n) = dsj/diffj
  964. enddo ! n
  965. enddo !k
  966. ! invert matrix to be compatible with lm(region)+1 being tOA
  967. ds(1:lm(region)+1,1:lm(region))=ds_tmp(lm(region):0:-1,lm(region):1:-1)
  968. ENDIF ! sza_rad
  969. ! slant column : calculate in different way depending on zangle
  970. if(zangle <=75.) then
  971. v2s(lm(region)+1)=ds(lm(region),lm(region))*v2_col(lm(region)+1)
  972. v3s(lm(region)+1)=ds(lm(region),lm(region))*v3_col(lm(region)+1)
  973. do k1=lm(region)+1,1,-1
  974. v2s(k1) = v2s(lm(region)+1)
  975. v3s(k1) = v3s(lm(region)+1)
  976. do k2=lm(region),k1,-1
  977. v2s(k1) = v2s(k1) + ds(k1,k2)*dv2_col(k2)
  978. v3s(k1) = v3s(k1) + ds(k1,k2)*dv3_col(k2)
  979. end do
  980. end do
  981. elseif(zangle>75. .and. zangle<=85.) then
  982. v2s(lm(region)+1) = ds(lm(region),lm(region))*v2_col(lm(region)+1)
  983. v3s(lm(region)+1) = ds(lm(region),lm(region))*v3_col(lm(region)+1)
  984. do k1=lm(region)+1,1,-1
  985. v2s(k1) = v2s(lm(region)+1)
  986. v3s(k1) = v3s(lm(region)+1)
  987. do k2=lm(region),1,-1
  988. v2s(k1) = v2s(k1) + ds(k1,k2)*dv2_col(k2)
  989. v3s(k1) = v3s(k1) + ds(k1,k2)*dv3_col(k2)
  990. enddo
  991. enddo
  992. endif
  993. do k1=lm(region)+1,1,-1
  994. vo3s_col(k1)=v3s(k1)
  995. enddo
  996. ! differential slant column
  997. dv2s(lm(region)) = v2s(lm(region))-v2s(lm(region)+1)
  998. dv3s(lm(region)) = v3s(lm(region))-v3s(lm(region)+1)
  999. do k = lm(region)-1,1,-1
  1000. dv2s(k) = v2s(k)-v2s(k+1)
  1001. dv3s(k) = v3s(k)-v3s(k+1)
  1002. if(dv2s(k)<0.) dv2s(k)=-1.0*dv2s(k)
  1003. if(dv3s(k)<0.) dv3s(k)=-1.0*dv3s(k)
  1004. enddo
  1005. ! intialise direct flux
  1006. fdir_top(1:maxw) = flux(1:maxw)
  1007. ! direct flux = actinic flux for a purely abs. atmosphere
  1008. ! here, layer averaged quantity
  1009. bandno=1
  1010. if(zangle <=85.) then
  1011. do l = 1,maxw
  1012. do k = lm(region),1,-1
  1013. if(l<18) then
  1014. ta_o2 = cross_o2(l)*dv2s(k)
  1015. else
  1016. ta_o2 = 0.
  1017. endif
  1018. ta_o3 = cst_o3_col(k,l)*dv3s(k)
  1019. fdir_bot = fdir_top(l) * exp(-ta_o2-ta_o3-taua_cld_col(k)-taua_aer_col(k,bandno,1))
  1020. fdir(k,l) = (fdir_top(l) + fdir_bot)/2.
  1021. fdir_top(l) = fdir_bot
  1022. if(l>lfin(bandno)) bandno=bandno+1
  1023. enddo
  1024. enddo
  1025. endif
  1026. deallocate(t_lev)
  1027. deallocate(v2s)
  1028. deallocate(v3s)
  1029. deallocate(dv2s)
  1030. deallocate(dv3s)
  1031. END SUBROUTINE DIRECTFLUX
  1032. !EOC
  1033. #ifdef with_optics
  1034. ! only define when coupling with photolysis is turned on
  1035. !--------------------------------------------------------------------------
  1036. ! TM5 !
  1037. !--------------------------------------------------------------------------
  1038. !BOP
  1039. !
  1040. ! !IROUTINE: AEROSOL_INFO_M7
  1041. !
  1042. ! !DESCRIPTION: assignment of aerosol optical depths calculated in M7
  1043. !\\
  1044. !\\
  1045. ! !INTERFACE:
  1046. !
  1047. SUBROUTINE AEROSOL_INFO_M7(region, status)
  1048. !
  1049. ! !USES:
  1050. !
  1051. USE TM5_DISTGRID, ONLY : dgrid, Get_DistGrid
  1052. USE DIMS, ONLY : isr,ier,jsr,jer, ndyn_max, ndyn
  1053. USE METEODATA, ONLY : gph_dat
  1054. USE DIMS, ONLY : im, jm, lm
  1055. USE OPTICS, ONLY : optics_aop_get
  1056. !
  1057. ! !INPUT PARAMETERS:
  1058. !
  1059. integer, intent(in) :: region
  1060. !
  1061. ! !OUTPUT PARAMETERS:
  1062. !
  1063. integer, intent(out) :: status
  1064. !
  1065. ! !REVISION HISTORY:
  1066. ! Aug 2012 - NB
  1067. ! 5 Mar 2013 - Ph. Le Sager - TM5-MP version
  1068. !
  1069. ! !REMARKS:
  1070. !
  1071. !EOP
  1072. !------------------------------------------------------------------------
  1073. !BOC
  1074. character(len=*), parameter :: rname = mname//'/aerosol_info_m7'
  1075. integer :: i,j,l,lvec, nsend, igrid, i1, i2, j1, j2, lmr
  1076. real, dimension(:,:,:), pointer :: gph
  1077. real, dimension(:,:,:,:), allocatable :: taus_aer, taua_aer, pmaer
  1078. ! Optics output fields (to be used and allocated by methods using the optics)
  1079. real, dimension(:,:,:), allocatable :: aop_out_ext ! extinctions
  1080. real, dimension(:,:), allocatable :: aop_out_a ! single scattering albedo
  1081. real, dimension(:,:), allocatable :: aop_out_g ! assymetry factor
  1082. ! ------------ begin -----------------
  1083. ! count lvec, tile grid size
  1084. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1085. lmr=lm(region)
  1086. lvec = (i2-i1+1)*(j2-j1+1)*lmr
  1087. allocate( aop_out_ext(lvec, nwdep, 1))
  1088. allocate( aop_out_a (lvec, nwdep) )
  1089. allocate( aop_out_g (lvec, nwdep) )
  1090. CALL OPTICS_AOP_GET(lvec, region, nwdep, wdep, 1, aop_out_ext, aop_out_a, aop_out_g, status)
  1091. IF_NOTOK_RETURN(status=1)
  1092. gph => gph_dat(region)%data
  1093. allocate(taus_aer (i1:i2, j1:j2, lmr,nwdep)); taus_aer = 0.0
  1094. allocate(taua_aer (i1:i2, j1:j2, lmr,nwdep)); taua_aer = 0.0
  1095. allocate(pmaer (i1:i2, j1:j2, lmr,nwdep)); pmaer = 0.0
  1096. ! ---------------------------------
  1097. ! unpack results from calculate_aop
  1098. ! ---------------------------------
  1099. lvec = 0
  1100. do l = 1, lmr
  1101. do j = j1,j2
  1102. do i = i1,i2
  1103. lvec = lvec + 1
  1104. taus_aer(i,j,l,1:nwdep) = aop_out_ext(lvec,1:nwdep,1) * aop_out_a(lvec,1:nwdep) * (gph(i,j,l+1) - gph(i,j,l)) ! from 1/m to nondim
  1105. taua_aer(i,j,l,1:nwdep) = aop_out_ext(lvec,1:nwdep,1) * (1.-aop_out_a(lvec,1:nwdep)) * (gph(i,j,l+1) - gph(i,j,l))
  1106. pmaer (i,j,l,1:nwdep) = aop_out_g (lvec,1:nwdep)
  1107. enddo
  1108. enddo
  1109. enddo
  1110. nullify(gph)
  1111. do i=1, nbands_trop
  1112. phot_dat(region)%taus_aer(:,:,:,i,1) = taus_aer(:,:,:,wav_grid(i))
  1113. phot_dat(region)%taua_aer(:,:,:,i,1) = taua_aer(:,:,:,wav_grid(i))
  1114. phot_dat(region)%pmaer (:,:,:,i,1) = pmaer (:,:,:,wav_grid(i))
  1115. phot_dat(region)%taus_aer(:,:,:,i,2) = taus_aer(:,:,:,wav_gridA(i))
  1116. phot_dat(region)%taua_aer(:,:,:,i,2) = taua_aer(:,:,:,wav_gridA(i))
  1117. phot_dat(region)%pmaer (:,:,:,i,2) = pmaer (:,:,:,wav_gridA(i))
  1118. enddo
  1119. phot_dat(region)%naer_av = phot_dat(region)%naer_av + float(ndyn)/float(ndyn_max)
  1120. phot_dat(region)%pmaer_av = phot_dat(region)%pmaer_av + float(ndyn)/float(ndyn_max) * phot_dat(region)%pmaer
  1121. phot_dat(region)%taus_aer_av = phot_dat(region)%taus_aer_av + float(ndyn)/float(ndyn_max) * phot_dat(region)%taus_aer
  1122. phot_dat(region)%taua_aer_av = phot_dat(region)%taua_aer_av + float(ndyn)/float(ndyn_max) * phot_dat(region)%taua_aer
  1123. deallocate(taus_aer)
  1124. deallocate(taua_aer)
  1125. deallocate(pmaer)
  1126. Deallocate(aop_out_ext)
  1127. Deallocate(aop_out_a )
  1128. Deallocate(aop_out_g )
  1129. status = 0
  1130. END SUBROUTINE AEROSOL_INFO_M7
  1131. !EOC
  1132. #endif
  1133. !--------------------------------------------------------------------------
  1134. ! TM5 !
  1135. !--------------------------------------------------------------------------
  1136. !BOP
  1137. !
  1138. ! !IROUTINE: AEROSOL_INFO
  1139. !
  1140. ! !DESCRIPTION: assignment of aerosol optical depths
  1141. !
  1142. ! This is a crude method to provide some average values for the absorption and scattering
  1143. ! terms by background aerosol choice of values defined according to the relative humidity.
  1144. ! Absorption component can be set to zero throughout (M.van Weele, private comm.,2005).
  1145. ! Scattering component chosen to be representative of background aerosol
  1146. ! Moreover there is a choice as the whether the values defined by shettle and fenn are used
  1147. ! This will require a look up table on 1x1,60 layers with indexes 1->4 with respect to
  1148. ! location. At the moment background aerosol is chosen throughout
  1149. !\\
  1150. !\\
  1151. ! !INTERFACE:
  1152. !
  1153. SUBROUTINE AEROSOL_INFO( region )
  1154. !
  1155. ! !USES:
  1156. !
  1157. use dims, only : im, jm, lm, newsrun, ndyn, ndyn_max
  1158. use binas, only : xm_air, xm_h2o,grav
  1159. use global_data, only : mass_dat
  1160. use MeteoData, only : temper_dat, humid_dat, gph_dat, cc_dat, iwc_dat, lwc_dat, phlb_dat
  1161. use MeteoData, only : lsmask_dat
  1162. !
  1163. ! !INPUT PARAMETERS:
  1164. !
  1165. integer, intent(in) :: region
  1166. !
  1167. ! !REVISION HISTORY:
  1168. ! Jun 2005 - JEW -
  1169. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1170. !
  1171. !EOP
  1172. !------------------------------------------------------------------------
  1173. !BOC
  1174. real, dimension(:,:,:,:,:), allocatable :: taus_aer, taua_aer
  1175. real, dimension(:,:,:,:,:), allocatable :: pmaer
  1176. real, dimension(:,:,:), allocatable :: rhum, dens, part, dz, press_lay
  1177. real, dimension(:,:,:), pointer :: q, phlb, temp, gph, frac, xland
  1178. real :: a_sc, b_sc, a_ab, b_ab, a_g, b_g
  1179. real :: bsa, baa, ga
  1180. integer :: i_type
  1181. integer, dimension(:,:), pointer :: aero_clim
  1182. real :: wv, tr, scale_aero, lay1, lay2
  1183. integer :: i, j, l, k, kboun, i_ref, b, wav, ll, n
  1184. integer :: i1, j1, i2, j2, lmr
  1185. logical :: aerosol, shettle_and_fenn
  1186. real, dimension(8) :: rh_ref = (/0., 50., 70., 80., 90., 95., 98., 99./)
  1187. real, dimension(4) :: pn_ref = (/ 15000., 4000., 20000., 5000./)
  1188. !
  1189. ! different aerosol types:
  1190. ! 1 = rural aerosol
  1191. ! 2 = maritime aerosol
  1192. ! 3 = urban aerosol
  1193. ! 4 = free troposphere aerosol
  1194. !-----------------------------------------------------------------------
  1195. aerosol = .false.
  1196. shettle_and_fenn = .true.
  1197. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1198. lmr = lm(region)
  1199. allocate(taus_aer(i1:i2, j1:j2, lmr, nbands_trop, ngrid))
  1200. allocate(taua_aer(i1:i2, j1:j2, lmr, nbands_trop, ngrid))
  1201. allocate(pmaer (i1:i2, j1:j2, lmr, nbands_trop, ngrid))
  1202. allocate(rhum (i1:i2, j1:j2, lmr))
  1203. allocate(dens (i1:i2, j1:j2, lmr))
  1204. allocate(part (i1:i2, j1:j2, lmr))
  1205. allocate(dz (i1:i2, j1:j2, lmr))
  1206. allocate(press_lay(i1:i2, j1:j2, lmr))
  1207. ! Initialize values
  1208. taus_aer=0.
  1209. taua_aer=0.
  1210. pmaer =0.
  1211. ! read in met. data
  1212. temp => temper_dat(region)%data ! (i1:i2, j1:j2, 1:lmr)
  1213. q => humid_dat(region)%data ! (i1:i2, j1:j2, 1:lmr)
  1214. phlb => phlb_dat(region)%data !
  1215. gph => gph_dat(region)%data ! (i1:i2, j1:j2, 1:lmr+1)
  1216. frac => cc_dat(region)%data ! (i1:i2, j1:j2, 1:lmr)
  1217. xland => lsmask_dat(region)%data ! (i1:i2, j1:j2, 1)
  1218. aero_clim => phot_dat(region)%aero_surface_clim ! (i1:i2, j1:j2)
  1219. ! initialize values
  1220. scale_aero = 1.0
  1221. ! the land-sea mask is used to ascribe either marine or rural aerosol for the bottom layers
  1222. dz = 0. ; dens = 0. ; rhum = 0.
  1223. phot_dat(region)%taus_aer = 0.
  1224. phot_dat(region)%taua_aer = 0.
  1225. phot_dat(region)%pmaer = 0.
  1226. if (shettle_and_fenn) then
  1227. if(newsrun) then
  1228. do j=j1,j2
  1229. do i=i1,i2
  1230. if(j<=10 .or. j>=80) then
  1231. aero_clim(i,j)=4
  1232. else
  1233. if(xland(i,j,1) < 30.) aero_clim(i,j)=2
  1234. if(xland(i,j,1) >= 30.) aero_clim(i,j)=1
  1235. endif
  1236. enddo
  1237. enddo
  1238. endif
  1239. do l=1,lm(region)
  1240. do j=j1,j2
  1241. do i=i1,i2
  1242. dz(i,j,l) = (gph(i,j,l+1) - gph(i,j,l))
  1243. press_lay(i,j,l) = (phlb(i,j,l) + phlb(i,j,l+1)) * 0.01 * 0.5 ! hPa
  1244. dens(i,j,l) = 7.2427e18 * press_lay(i,j,l)/temp(i,j,l)
  1245. tr=1.-373.15/temp(i,j,l)
  1246. wv=exp((((-.1299*tr-.6445)*tr-1.976)*tr+13.3185)*tr)
  1247. if(frac(i,j,l)<0.95) rhum(i,j,l)=q(i,j,l)*dens(i,j,l)*xm_air/xm_h2o*temp(i,j,l)/(1013.25*wv*7.24e16)
  1248. ! JEW assume saturation when cloud fraction is very high.
  1249. if(frac(i,j,l)>=0.95) rhum(i,j,l)=98.0
  1250. rhum(i,j,l)=min(98.,rhum(i,j,l))
  1251. enddo
  1252. enddo
  1253. enddo
  1254. !
  1255. ! use land-sea mask to ascribe either marine or rural aerosol for different grid cells
  1256. ! in the lower few KM
  1257. !
  1258. do l=1,lm(region)
  1259. do j=j1,j2
  1260. do i=i1,i2
  1261. if(l<5) then
  1262. i_type=aero_clim(i,j)
  1263. elseif(l>=5) then
  1264. i_type=4
  1265. endif
  1266. kboun = 1
  1267. lay1 = (phlb(i,j,l)/phlb(i,j,kboun))**3
  1268. lay2 = (phlb(i,j,l+1)/phlb(i,j,kboun))**3
  1269. if(i_type<4) then
  1270. part(i,j,l) = scale_aero*pn_ref(i_type)*dz(i,j,l)*100.
  1271. kboun = l
  1272. else
  1273. part(i,j,l) = scale_aero*pn_ref(i_type)*0.5*(lay1+lay2)*dz(i,j,l)*100.
  1274. endif
  1275. i_ref = 8
  1276. do k = 1,8
  1277. if(rh_ref(k) < rhum(i,j,l)) i_ref = k
  1278. enddo
  1279. do n=1,ngrid
  1280. do b=1,nbands_trop
  1281. if (n==1) wav=lmid(b)
  1282. if (n==2) wav=lmid_gridA(b)
  1283. a_sc = (sca(wav,i_ref,i_type)-sca(wav,i_ref+1,i_type))/(rh_ref(i_ref)-rh_ref(i_ref+1))
  1284. b_sc = sca(wav,i_ref,i_type)- a_sc*rh_ref(i_ref)
  1285. a_ab = (abs_eff(wav,i_ref,i_type)-abs_eff(wav,i_ref+1,i_type))/(rh_ref(i_ref)-rh_ref(i_ref+1))
  1286. b_ab = abs_eff(wav,i_ref,i_type)- a_ab*rh_ref(i_ref)
  1287. a_g =(g(wav,i_ref,i_type)-g(wav,i_ref+1,i_type))/(rh_ref(i_ref)-rh_ref(i_ref+1))
  1288. b_g =g(wav,i_ref,i_type) - a_g*rh_ref(i_ref)
  1289. bsa = a_sc*rhum(i,j,l) + b_sc
  1290. baa = a_ab*rhum(i,j,l) + b_ab
  1291. ga = a_g*rhum(i,j,l) + b_g
  1292. taus_aer(i,j,l,b,n) = bsa*part(i,j,l)
  1293. taua_aer(i,j,l,b,n) = baa*part(i,j,l)
  1294. if(taus_aer(i,j,l,n,1)>0.) then
  1295. ! do k = 1,nmom
  1296. pmaer(i,j,l,b,n)=ga
  1297. ! enddo
  1298. else
  1299. pmaer(i,j,l,b,n) = 0.
  1300. endif
  1301. enddo !nbands_trop
  1302. enddo !ngrid
  1303. enddo ! l
  1304. enddo ! j
  1305. enddo ! i
  1306. phot_dat(region)%taus_aer = taus_aer
  1307. phot_dat(region)%taua_aer = taua_aer
  1308. phot_dat(region)%pmaer = pmaer
  1309. endif ! shettle and fenn switch
  1310. ! JEW switch for the aerosol absorption and scattering properties
  1311. if (aerosol) then
  1312. do l=1,lm(region)
  1313. do j=j1,j2
  1314. do i=i1,i2
  1315. dens(i,j,l) = 7.2427e18 * press_lay(i,j,l)/temp(i,j,l)
  1316. tr=1.-373.15/temp(i,j,l)
  1317. wv=exp((((-.1299*tr-.6445)*tr-1.976)*tr+13.3185)*tr)
  1318. rhum(i,j,l)=q(i,j,l)*dens(i,j,l)*xm_air/xm_h2o*temp(i,j,l)/(1013.25*wv*7.24e16)
  1319. if(rhum(i,j,l)>40. .and. rhum(i,j,l)<80.) pmaer(i,j,l,:,:) = 0.65
  1320. if(rhum(i,j,l)>=80.) pmaer(i,j,l,:,:) = 0.85
  1321. enddo
  1322. enddo
  1323. enddo
  1324. phot_dat(region)%taus_aer = 3.0e-3
  1325. phot_dat(region)%taua_aer = 1.5e-4
  1326. phot_dat(region)%pmaer = 0.7
  1327. endif
  1328. ! Averages
  1329. phot_dat(region)%naer_av = phot_dat(region)%naer_av + (float(ndyn)/float(ndyn_max))
  1330. phot_dat(region)%pmaer_av = phot_dat(region)%pmaer_av + (float(ndyn)/float(ndyn_max)) * phot_dat(region)%pmaer
  1331. phot_dat(region)%taus_aer_av = phot_dat(region)%taus_aer_av + (float(ndyn)/float(ndyn_max)) * phot_dat(region)%taus_aer
  1332. phot_dat(region)%taua_aer_av = phot_dat(region)%taua_aer_av + (float(ndyn)/float(ndyn_max)) * phot_dat(region)%taua_aer
  1333. ! Done
  1334. deallocate(taus_aer)
  1335. deallocate(taua_aer)
  1336. deallocate(pmaer)
  1337. deallocate(rhum)
  1338. deallocate(dens)
  1339. deallocate(part)
  1340. deallocate(dz)
  1341. deallocate(press_lay)
  1342. nullify(q)
  1343. nullify(temp)
  1344. nullify(phlb)
  1345. nullify(gph)
  1346. nullify(frac)
  1347. nullify(xland)
  1348. nullify(aero_clim)
  1349. END SUBROUTINE AEROSOL_INFO
  1350. !EOC
  1351. !--------------------------------------------------------------------------
  1352. ! TM5 !
  1353. !--------------------------------------------------------------------------
  1354. !BOP
  1355. !
  1356. ! !IROUTINE: SLINGO
  1357. !
  1358. ! !DESCRIPTION: A. Slingo's data for cloud particle radiative properties
  1359. ! (from 'A GCM Parameterization for the Shortwave Properties of Water Clouds'
  1360. ! JAS vol. 46 may 1989 pp 1419-1427)
  1361. !
  1362. ! Called everytime the meteo data is updated to calculate new
  1363. ! cloud optical properties
  1364. !\\
  1365. !\\
  1366. ! !INTERFACE:
  1367. !
  1368. SUBROUTINE SLINGO( region )
  1369. !
  1370. ! !USES:
  1371. !
  1372. use binas, only : xmair, Avog
  1373. use dims, only : im, jm, lm, lmax_conv
  1374. use global_data, only : mass_dat
  1375. use MeteoData, only : gph_dat, lwc_dat, iwc_dat, cc_dat, phlb_dat, temper_dat, lsmask_dat
  1376. !
  1377. ! !INPUT PARAMETERS:
  1378. !
  1379. integer, intent(in) :: region
  1380. !
  1381. ! !REVISION HISTORY:
  1382. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1383. !
  1384. !EOP
  1385. !------------------------------------------------------------------------
  1386. !BOC
  1387. real :: eff_rad ! effective radius no longer fixed but linked to LWP
  1388. real :: rhodz, tau_c, xsa, press, airn, D_ge
  1389. real :: rclf ! inverse cloud fraction
  1390. real :: clwc, ciwc ! [g/m3]
  1391. real :: lfrac, sfrac ! scaled components due to land and sea fraction
  1392. real,dimension(:,:,:),allocatable :: taua_cld
  1393. real,dimension(:,:,:),allocatable :: taus_cld
  1394. !total scattering optical depth for cloud layer (liquid+cirrus)
  1395. !total absorption optical depth for cloud layer (liquid_cirrus)
  1396. real,dimension(:,:,:),allocatable :: pmcld !phase function (HG)
  1397. !----------------------------Local------------------------------------------
  1398. real,dimension(:,:,:),allocatable :: lwp !cloud liquid water path [g/m^2]
  1399. real,dimension(:,:,:),pointer :: frac, lwc, iwc, gph, phlb, temp, xland
  1400. real, parameter :: factor = 7.24e16*1.e6*xmair*29.2605/avog
  1401. real,dimension(:,:,:), allocatable :: dz, totalwc, global_cloud_reff
  1402. real, dimension(4) :: abar, bbar, cbar, dbar, ebar, fbar
  1403. ! A coefficient for extinction optical depth
  1404. ! B coefficiant for extinction optical depth
  1405. ! C coefficiant for single particle scat albedo
  1406. ! D coefficiant for single particle scat albedo
  1407. ! E coefficiant for asymmetry parameter
  1408. ! F coefficiant for asymmetry parameter
  1409. data abar/ 2.817e-02, 2.682e-02,2.264e-02,1.281e-02/
  1410. data bbar/ 1.305 , 1.346 ,1.454 ,1.641 /
  1411. data cbar/-5.62e-08 ,-6.94e-06 ,4.64e-04 ,0.201 /
  1412. data dbar/ 1.63e-07 , 2.35e-05 ,1.24e-03 ,7.56e-03 /
  1413. data ebar/ 0.829 , 0.794 ,0.754 ,0.826 /
  1414. data fbar/ 2.482e-03, 4.226e-03,6.560e-03,4.353e-03/
  1415. real :: abari, bbari, cbari, dbari, ebari, fbari
  1416. ! A coefficiant for current spectral interval
  1417. ! B coefficiant for current spectral interval
  1418. ! C coefficiant for current spectral interval
  1419. ! D coefficiant for current spectral interval
  1420. ! E coefficiant for current spectral interval
  1421. ! F coefficiant for current spectral interval
  1422. real :: gc, wc, tot, tmp1 ,tmp2, tmp3
  1423. !asymmetry factor
  1424. !single scattering albedo
  1425. !total optical depth of cloud layer
  1426. ! constants for scattering parameterization of Fu (1996)
  1427. real, dimension(7) :: a0, a1
  1428. data a0/-.236447E-03,-.236447E-03,-.266955E-03,-.266955E-03,-.266955E-03,-.258858E-03,.982244E-04/
  1429. data a1/.253817E+01 ,.253817E+01 ,.254719E+01 ,.254719E+01 ,.254719E+01 ,.253815E+01,.250875E+01/
  1430. ! Parameters for computing cloud effective radius according to Martin et al. (JAS 1994)
  1431. real :: denom,numerator
  1432. real, parameter :: d_land=0.43
  1433. real, parameter :: d_sea=0.33
  1434. integer :: i,j,l,k, indxsl, n, i1, i2, j1, j2, lmr
  1435. !----------- START----------
  1436. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1437. lmr = lm(region)
  1438. !-------------------------------------------------------------------------
  1439. ! Set index for cloud particle properties based on the wavelength,
  1440. ! according to A. Slingo (1989) equations 1-3:
  1441. ! Use index 1 (0.25 to 0.69 micrometers) for visible
  1442. ! Use index 2 (0.69 - 1.19 micrometers) for near-infrared
  1443. ! Use index 3 (1.19 to 2.38 micrometers) for near-infrared
  1444. ! Use index 4 (2.38 to 4.00 micrometers) for near-infrared
  1445. indxsl = 1
  1446. ! Set cloud extinction optical depth, single scatter albedo,
  1447. ! asymmetry parameter, and forward scattered fraction:
  1448. abari = abar(indxsl)
  1449. bbari = bbar(indxsl)
  1450. cbari = cbar(indxsl)
  1451. dbari = dbar(indxsl)
  1452. ebari = ebar(indxsl)
  1453. fbari = fbar(indxsl)
  1454. !
  1455. !--------------------------------------------------------------------------
  1456. ! In the parameterization of Fu(1996) wavelength dependant extinction maybe
  1457. ! calculated using a set of pre-defined constants:
  1458. !
  1459. ! nm a0 a1
  1460. ! 250-300 -.236447E-03 .253817E+01
  1461. ! 300-330 -.266955E-03 .254719E+01
  1462. ! 330-360 -.293599E-03 .254540E+01
  1463. ! 360-400 -.258858E-03 .253815E+01
  1464. ! 400-440 -.106451E-03 .252684E+01
  1465. ! 440-480 .129121E-03 .250410E+01
  1466. ! 480-520 -.954458E-04 .252061E+01
  1467. ! 520-570 -.303108E-04 .251805E+01
  1468. ! 570-640 .982244E-04 .250875E+01
  1469. !
  1470. ! used in Beta=IWC(a0+a1/Dg)
  1471. !--------------------------------------------------------------------------
  1472. allocate(taua_cld(i1:i2, j1:j2, lm(region)))
  1473. allocate(taus_cld(i1:i2, j1:j2, lm(region)))
  1474. allocate(pmcld (i1:i2, j1:j2, lm(region)))
  1475. allocate(lwp (i1:i2, j1:j2, lm(region)))
  1476. allocate(dz (i1:i2, j1:j2, lm(region) ))
  1477. allocate(totalwc (i1:i2, j1:j2, lm(region) ))
  1478. allocate(global_cloud_reff(i1:i2, j1:j2, lm(region) ))
  1479. ! Initialize values
  1480. taua_cld = 0. ; taus_cld = 0. ; pmcld = 0. ; lwp = 0.
  1481. ! assume a baseline cloud radius, required for heterogeneous chemistry
  1482. global_cloud_reff = 6.
  1483. !JEW The ice and water particles are now treated seperately. For cloud the values are taken from slingo
  1484. !JEW the refractive index for ICE is very low below 750nm therefore T~T(scatt).
  1485. iwc => iwc_dat (region)%data ! (i1:i2, j1:j2, 1:lmr)
  1486. frac => cc_dat (region)%data ! (i1:i2, j1:j2, 1:lmr)
  1487. gph => gph_dat (region)%data ! (i1:i2, j1:j2, 1:lmr+1)
  1488. lwc => lwc_dat (region)%data ! (i1:i2, j1:j2, 1:lmr)
  1489. phlb => phlb_dat (region)%data !
  1490. temp => temper_dat(region)%data ! (i1:i2, j1:j2, 1:lmr)
  1491. xland => lsmask_dat(region)%data ! (i1:i2, j1:j2, 1)
  1492. ! No negative input
  1493. lwc=max(0.,lwc)
  1494. iwc=max(0.,iwc)
  1495. ! read in new cloud data to feed into the slingo routine. The values of lwc are zero in top levels so limit layer loop
  1496. do l=1,lmax_conv
  1497. do j=j1,j2
  1498. do i=i1,i2
  1499. press = (phlb(i,j,l) + phlb(i,j,l+1)) * 0.5 ! Pa
  1500. dz(i,j,l) = ( gph(i,j,l+1) - gph(i,j,l) )
  1501. ! We have replaced the parameterization of McFarlane et al. (1992) with that of Martin et al. (1994).
  1502. ! In the IFS a crude filter of 0.5 for the land fraction is used with the CNN(Marine) = 40.
  1503. ! and CNN(Land) = 900. Here we weight the final CCN with the actual land fraction so as to introduce
  1504. ! more variability.
  1505. ! JEW : there is a potential problem in that nonzero cloud fractions may occur with no associated lwc value
  1506. ! on TM5 vertical resolutions, therefore a filter w.r.t. both fraction and cloud liquid path are included.
  1507. if( lwc(i,j,l) > 1.e-10 .and. frac(i,j,l) > 0.02 ) then
  1508. ! JEW calculate total water path locally : convert to g/m(2) for slingo input
  1509. ! following the conversion procedure for LWC from ECMWF input from old cloud subroutine.
  1510. ! Included comments from old code to explain the prefactor in rhodz:
  1511. ! rho = airn*1e6*xmair/avo ! g/m3
  1512. ! dz = 29.2605*temp(i,j,l)* alog(phlb(i,j,l)/(1.0+phlb(i,j,l+1)))
  1513. rclf=1./frac(i,j,l)
  1514. rhodz = factor*press*alog(phlb(i,j,l)/(1.0+phlb(i,j,l+1)))
  1515. ! VH - scale lwc and lwp with cloud fraction, to compute cloud optical properties
  1516. ! and droplet radius representative for cloudy part only
  1517. lwp(i,j,l) = rhodz*lwc(i,j,l)*rclf
  1518. airn=7.24e16*press/temp(i,j,l) !#/cm3
  1519. clwc=lwc(i,j,l)*xmair*airn*1.e6/avog ! g/m3
  1520. ! Effective radius: Martin et al. (JAS 1994) parametrization
  1521. !if (xland(i,j,l) > 50.) then
  1522. ! Above land use ccn of ~900
  1523. ! D_land = 0.43
  1524. ! CCNLND = 900
  1525. ! NTOT=-2.10E-04*CCNLAND*CCNLAND+0.568*CCNLAND-27.9
  1526. ! DENOM=4.0*pi*rho_w*NTOT*(1.0+D_land*D_land)**3
  1527. ! with rho_w in g/m3.
  1528. denom = 6547.52*1.e6
  1529. numerator=3.0*clwc*rclf*(1.0+3.0*D_land*D_land)**2
  1530. lfrac=0.
  1531. if((numerator/denom) > 1.e-20) lfrac=1.e4*exp(0.333*LOG(numerator/denom))
  1532. !else
  1533. ! Maritime air mass
  1534. ! D_sea = 0.33
  1535. ! CCNSEA = 40
  1536. ! NTOT=-1.15E-03*CCNSEA*CCNSEA+0.963*CCNSEA+5.30
  1537. ! DENOM=4.0*pi*rho_w*NTOT*(1.0+D_sea*D_sea)**3
  1538. denom = 723.210*1.e6
  1539. numerator=3.0*clwc*rclf*(1.0+3.0*D_sea*D_sea)**2
  1540. sfrac=0.
  1541. if((numerator/denom) > 1.e-20) sfrac=1.e4*exp(0.333*LOG(numerator/denom))
  1542. !endif
  1543. ! TvN: Is this the best way to average land and sea?
  1544. eff_rad=(xland(i,j,1)/100.*lfrac)+(1.0-xland(i,j,1)/100.)*sfrac
  1545. ! prevent the radius of non-precipitation clouds being too big
  1546. ! these size limits are equal to those chosen in the IFS
  1547. eff_rad=min(16.0,max(eff_rad, 4.0))
  1548. tmp1 = abari + bbari/eff_rad
  1549. tmp2 = 1. - cbari - dbari*eff_rad
  1550. tmp3 = fbari*eff_rad
  1551. ! Do not let single scatter albedo be 1; delta-eddington solution
  1552. ! for non-conservative case:
  1553. wc = min(tmp2,.999999)
  1554. tot = lwp(i,j,l)*tmp1
  1555. gc = ebari + tmp3
  1556. ! JEW : no wavelength dependence for the absorption or scattering effects due to liquid clouds !!!!!
  1557. taua_cld(i,j,l) = (1.-wc)*tot
  1558. taus_cld(i,j,l) = wc*tot
  1559. ! avoid possible negatives due to input data
  1560. taua_cld(i,j,l)=max(0.0,taua_cld(i,j,l))
  1561. global_cloud_reff(i,j,l) = eff_rad
  1562. ! JEW : for calculating the scattering component due to ice
  1563. if(iwc(i,j,l) > 1.e-10) then
  1564. airn=7.24e16*press/temp(i,j,l)
  1565. ! iwc in g/m3 from TM5 definition
  1566. ciwc=iwc(i,j,l)*airn*xmair*1.e6/avog
  1567. ! Following Eq. (5) of Heymsfield and McFarquhar (JAS, 1996),
  1568. ! the cross-sectional surface area A (km^-1)
  1569. ! can be approximated by:
  1570. ! 10*IWC^0.9, where IWC in g/m3.
  1571. ! Thus, A in m^2/m^3 = m^-1 is given by 0.01 IWC^0.9,
  1572. ! which implies that xsa is in cm^-1.
  1573. xsa=1.0e-4*ciwc**0.9
  1574. !
  1575. ! calculate D_ge using the relationship in Fu (1996) where Beta=extinction co-efficient (m-1)
  1576. !
  1577. ! D_ge = 2(3)**0.5/(3 Rho)*(IWC/xsa)
  1578. !
  1579. ! The above relationship is for instance given in Table 1
  1580. ! in McFarquhar and Heymsfield (JAS, 1997).
  1581. ! Below an ice density in units g/cm^3 and
  1582. ! IWC in g/m^3 are used.
  1583. ! The conversion of IWC from g/m^3 to g/cm^3
  1584. ! gives a factor 10^6, which together with
  1585. ! the division by 100 converts from cm to um.
  1586. !
  1587. D_ge=(2.*1.73205/(3.*0.917))*(ciwc/xsa)
  1588. ! convert to uM
  1589. D_ge=D_ge/100.
  1590. !
  1591. ! Cirrus scattering has a wavelength dependancy
  1592. !
  1593. taus_cld(i,j,l)=taus_cld(i,j,l)+((ciwc*(a0(3)+(a1(3)/D_ge)))*dz(i,j,l))
  1594. endif
  1595. if (taus_cld(i,j,l) > 0.) then
  1596. pmcld(i,j,l)=gc
  1597. else
  1598. pmcld(i,j,l)=0.
  1599. end if
  1600. end if
  1601. enddo
  1602. enddo
  1603. enddo
  1604. ! Store optical depths and phase functions
  1605. phot_dat(region)%pmcld = pmcld
  1606. phot_dat(region)%taus_cld = taus_cld
  1607. phot_dat(region)%taua_cld = taua_cld
  1608. phot_dat(region)%cloud_reff = global_cloud_reff
  1609. ! Averages
  1610. phot_dat(region)%lwp_av = lwp
  1611. phot_dat(region)%cfr_av = phot_dat(region)%cfr_av + frac
  1612. phot_dat(region)%reff_av = global_cloud_reff
  1613. phot_dat(region)%ncloud_av = phot_dat(region)%ncloud_av + 1
  1614. phot_dat(region)%pmcld_av = phot_dat(region)%pmcld_av + pmcld
  1615. phot_dat(region)%taus_cld_av = phot_dat(region)%taus_cld_av + taus_cld
  1616. phot_dat(region)%taua_cld_av = phot_dat(region)%taua_cld_av + taua_cld
  1617. nullify(lwc)
  1618. nullify(frac)
  1619. nullify(iwc)
  1620. nullify(gph)
  1621. nullify(phlb)
  1622. nullify(temp,xland)
  1623. deallocate(taua_cld)
  1624. deallocate(taus_cld)
  1625. deallocate(pmcld)
  1626. deallocate(lwp)
  1627. deallocate(dz)
  1628. deallocate(totalwc)
  1629. deallocate(global_cloud_reff)
  1630. END SUBROUTINE SLINGO
  1631. !EOC
  1632. !--------------------------------------------------------------------------
  1633. ! TM5 !
  1634. !--------------------------------------------------------------------------
  1635. !BOP
  1636. !
  1637. ! !IROUTINE: UPDATE_CSQY
  1638. !
  1639. ! !DESCRIPTION:
  1640. !\\
  1641. !\\
  1642. ! !INTERFACE:
  1643. !
  1644. SUBROUTINE UPDATE_CSQY( region )
  1645. !
  1646. ! !USES:
  1647. !
  1648. use dims
  1649. use binas, only: Avog, xmair, grav
  1650. use global_data, only: mass_dat
  1651. use MeteoData, only: phlb_dat, temper_dat
  1652. use chem_param, only: xmo3, fscale
  1653. !
  1654. ! !INPUT PARAMETERS:
  1655. !
  1656. integer, intent(in) :: region
  1657. !
  1658. ! !REVISION HISTORY:
  1659. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1660. !
  1661. !EOP
  1662. !------------------------------------------------------------------------
  1663. !BOC
  1664. integer :: i,j,l
  1665. real,dimension(:,:,:),pointer :: temperature
  1666. real,dimension(:,:,:),pointer :: phlb
  1667. real,dimension(:,:,:),allocatable :: density
  1668. real,dimension(:,:,:),allocatable :: pressure
  1669. integer :: k, m, table_pos, i1, j1, i2, j2, lmr
  1670. real :: xa, xb, te, chix, ww, temper, ptorr
  1671. real :: phi, qy, tt, alpha, delta_t
  1672. real,dimension(maxwav) :: rd, phi0
  1673. real :: a0, b0, a1, b1, a2, b2, a3, b3, c3, a4, b4
  1674. real :: term,term1,term2,t_scale
  1675. phlb => phlb_dat(region)%data
  1676. temperature => temper_dat(region)%data
  1677. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1678. lmr = lm(region)
  1679. allocate(density (i1:i2, j1:j2, lmr))
  1680. allocate(pressure(i1:i2, j1:j2, lmr))
  1681. !---------------------------------------------------------------------------------
  1682. ! Only update the temperature sensitive regions of the spectral
  1683. ! grids. That is, initialize values values to either zero or cs_ values for selected
  1684. ! species.
  1685. !---------------------------------------------------------------------------------
  1686. do k = 1,lm(region)
  1687. do j = j1,j2
  1688. do i = i1,i2
  1689. ! define air pressure
  1690. pressure(i,j,k) = (phlb(i,j,k) + phlb(i,j,k+1))/2
  1691. enddo
  1692. enddo
  1693. enddo
  1694. ! define air density
  1695. density = 7.24e16*pressure/temperature(i1:i2, j1:j2, 1:lmr)
  1696. !---------------------------------------------------------------------
  1697. ! QUANTUM YIELD OF METHYGLYOXAL S. KOCH and G. K. MOORTGAT
  1698. ! J Phys Chem, 102, 9142-9153, 1998.
  1699. !
  1700. ! JEW: the qy_ch3cocho array has been reduced to 52 bins to represent the pressure.
  1701. ! dep. spectral bins ONLY !!
  1702. !---------------------------------------------------------------------
  1703. ! Calculate co-efficients for METHYGLYOXAL qy outside loop
  1704. phi0 = 1. ; rd = 0.
  1705. ! for wave < 380nm qy is essentially = 1.0.
  1706. do l = 1,39
  1707. if(l<32) then
  1708. phi0(l) = 1
  1709. elseif(l>=32) then
  1710. phi0(l) = 8.15e-9 * exp(7131./wave(l+37)*1.e-7)
  1711. endif
  1712. rd(l) = 7.34e-9 * exp(8793./wave(l+37)*1.e-7)
  1713. enddo
  1714. do l = 40,52
  1715. phi0(l) = 3.63e-7 * exp(5693./wave(l+37)*1.e-7)
  1716. rd(l) = 1.93e4*exp(-5639./wave(l+37)*1.e-7)
  1717. enddo
  1718. do k = 1,lm(region)
  1719. do j = j1,j2
  1720. do i = i1,i2
  1721. ! QUANTUM YIELD OF METHYGLYOXAL JPL 2006 P4-71
  1722. ! CH3COCHO -> CH3C(O)O2 + HO2 + CO (1)
  1723. ! -> CH4 + 2CO (2)
  1724. ! -> CH3CHO + CO (3)
  1725. ! the predominant products are from channel(1) for wav 240-480nm
  1726. ! hPa -> Torr
  1727. ptorr= (pressure(i,j,k)/100.)*760./1.013*1e-3
  1728. !second absorption band
  1729. do l = 1,39
  1730. qy = (phi0(l) * rd(l))/(rd(l) + ptorr*phi0(l))
  1731. phot_dat(region)%qy_ch3cocho(i,j,k,l) = min(1.0,qy)
  1732. end do
  1733. ! switch to the formulation by Chen et al, JPC, 104, 11126-11131, 2000 for wav > 420nm
  1734. do l = 40,52
  1735. qy = phi0(l)/(1.+(phi0(l)*rd(l)*ptorr))
  1736. phot_dat(region)%qy_ch3cocho(i,j,k,l) = min(1.0,qy)
  1737. enddo
  1738. end do ! longitude
  1739. end do ! latitude
  1740. end do ! level
  1741. deallocate(density)
  1742. deallocate(pressure)
  1743. nullify(temperature)
  1744. nullify(phlb)
  1745. END SUBROUTINE UPDATE_CSQY
  1746. !EOC
  1747. !--------------------------------------------------------------------------
  1748. ! TM5 !
  1749. !--------------------------------------------------------------------------
  1750. !BOP
  1751. !
  1752. ! !IROUTINE: PIFM
  1753. !
  1754. ! !DESCRIPTION:
  1755. ! *
  1756. ! PRACTICAL IMPROVED FLUX METHOD (PIFM) *
  1757. ! to calculate actinic fluxes *
  1758. ! Zdunkowski,Welch,Korb: Beitr. Phys. Atmosph. vol. 53, p. 147 ff *
  1759. ! *
  1760. ! This version is not suitable for calculation for conserving *
  1761. ! scattering (W0=1). W0 is limited to W0 <= 1. - 1.E-15. *
  1762. ! For W0 = 1, AL(4) and AL(5) has to be calculated differently. *
  1763. !\\
  1764. !\\
  1765. ! !INTERFACE:
  1766. !
  1767. SUBROUTINE PIFM(region, zangle, alb, cst_o3_col, dv2, dv3, taua_aer_col, taus_aer_col, paer_col, fact)
  1768. !
  1769. ! !USES:
  1770. !
  1771. use dims, only : lm
  1772. use binas, only : pi
  1773. !
  1774. ! !INPUT PARAMETERS:
  1775. !
  1776. integer, intent(in) :: region
  1777. real, intent(in) :: zangle ! zenith angle
  1778. real, intent(in) :: alb ! albedo
  1779. real, dimension(lm(region),maxwav) :: cst_o3_col ! temp dep o3 cross sections
  1780. real, dimension(lm(region)) :: dv2, dv3 ! differential column info
  1781. real, dimension(lm(region),nbands_trop,ngrid) :: taua_aer_col, taus_aer_col ! optical depth aerosols
  1782. real, dimension(lm(region),nbands_trop,ngrid) :: paer_col
  1783. real, dimension(lm(region),nbands_trop) :: fact !actinic flux
  1784. !
  1785. ! !REVISION HISTORY:
  1786. !
  1787. !EOP
  1788. !------------------------------------------------------------------------
  1789. !BOC
  1790. real, dimension(3*(lm(region)+1)) :: rw, & !flux array for cloudy sky
  1791. rf !flux array for clear sky
  1792. real, dimension(lm(region)) :: tu1, & !parallel solar flux
  1793. tu2 !matrix coefficient
  1794. real, dimension(lm(region),5) :: al
  1795. real, dimension(lm(region)+1,nbands_trop):: sd, fd, fu
  1796. real, dimension(0:nmom) :: pray ! phase functions
  1797. real :: taus, taua, tautot, g
  1798. real, dimension(lm(region),nbands_trop) :: taua_clr, taus_clr ! optical depth clear sky
  1799. ! diffusivity factor
  1800. real, parameter :: u = 2., delu0 = 1.e-3, resonc = 1.e-6
  1801. integer :: grid, l, k, n, nl, k3, maxlev, maxlay2, maxlev3
  1802. real :: p1, w0, f, b0, bu0
  1803. real :: eps, factor, ueps2, smooth1, smooth2
  1804. real :: alph1, alph2, alph3, alph4
  1805. real :: gam1, gam2, e, rm, tds1, td1, td2
  1806. real :: fact_bot, fact_top, arg
  1807. !downward diffuse flux
  1808. !upward diffuse flux
  1809. real :: a, b, c, gamma, u0
  1810. real :: cs_o2
  1811. ! internal integer variable
  1812. maxlev = lm(region) + 1
  1813. maxlay2 = 2 * lm(region)
  1814. maxlev3 = 3 * maxlev
  1815. ! intitialise arrays
  1816. al = 0. ; fd = 0. ; sd = 0. ; fu = 0. ; tu1 = 0. ; tu2 = 0. ; rw = 0. ; rf = 0.
  1817. !initialise output (actinic flux)
  1818. fact = 0.
  1819. !-----correction of the air mass factor---------------------------------
  1820. ! F. Kasten and T. Young, Revised optical air mass tabels and
  1821. ! approximation formula (1989) Aplied Optics Vol 28, No. 22 P. 4735
  1822. ! and J. Lenoble, atmospheric radiative transfer (1993), P. 236
  1823. a = 0.50572 ; b = 6.07995 ; c = 1.63640
  1824. ! define air mass factor in mu
  1825. gamma = 90. - zangle
  1826. u0 = sin(gamma*pi/180.) + a *(gamma+b)**(-c)
  1827. u0 = min(1.,u0)
  1828. !===================================================================
  1829. ! calculation of the matrix coefficients a1,...,a5
  1830. !===================================================================
  1831. ! determine phase functions
  1832. pray(0) = 1. ; pray(1) = 0. ; pray(2)=0.1 ; pray(3:nmom) = 0.
  1833. ! reverse order for input parameters
  1834. dv2(1:lm(region)) = dv2(lm(region):1:-1)
  1835. dv3(1:lm(region)) = dv3(lm(region):1:-1)
  1836. ! do not calculate for band #1
  1837. do l = 1,nbands_trop
  1838. if (zangle <= 71.) then
  1839. nl = lmid(l)
  1840. grid = 1
  1841. cs_o2 = 7.322e-24
  1842. elseif (zangle > 71. .and. zangle<=sza_limit) then
  1843. nl = lmid_gridA(l)
  1844. grid = 2
  1845. cs_o2 = 6.608e-24
  1846. endif
  1847. ! reverse order for input parameters
  1848. cst_o3_col(1:lm(region),nl) = cst_o3_col(lm(region):1:-1,nl)
  1849. taus_aer_col(1:lm(region),l,grid) = taus_aer_col(lm(region):1:-1,l,grid)
  1850. taua_aer_col(1:lm(region),l,grid) = taua_aer_col(lm(region):1:-1,l,grid)
  1851. paer_col(1:lm(region),l,grid) = paer_col(lm(region):1:-1,l,grid)
  1852. do k = 1,lm(region)
  1853. ! Calculate optical depth (clear-sky)
  1854. if(nl<18) then
  1855. taua_clr(k,l) = cs_o2*dv2(k) + cst_o3_col(k,nl)*dv3(k)
  1856. else
  1857. taua_clr(k,l) = cst_o3_col(k,nl)*dv3(k)
  1858. endif
  1859. taus_clr(k,l) = cs_ray(nl)*1./0.2095*dv2(k)
  1860. taus = taus_clr(k,l) + taus_aer_col(k,l,grid)
  1861. taua = taua_clr(k,l) + taua_aer_col(k,l,grid)
  1862. tautot = taus + taua
  1863. g = 0.
  1864. if (taus > 0.) &
  1865. g = (paer_col(k,l,grid)* taus_aer_col(k,l,grid) + pray(1)* taus_clr(k,l) )/taus
  1866. if (tautot .ne. 0.) then
  1867. w0=taus / tautot
  1868. else
  1869. w0=0.
  1870. end if
  1871. w0 = min(w0,1.-1.e-15)
  1872. ! P1: first expansion coefficient of the phase function
  1873. p1=3.*g
  1874. ! F: fraction of radiation contained in diffraction peak
  1875. f=g**2
  1876. ! B0: fractional mean backward scattering coefficient
  1877. ! of diffuse light
  1878. ! BU0: backward scattering coefficient of primary scattered
  1879. ! parallel solar light
  1880. ! for small P1 SMOOTH1,SMOOTH2 manage the smooth change of B0
  1881. ! BU0 to 0
  1882. if (p1 <= 0.1) then
  1883. smooth1=1.33333333-p1*3.3333333
  1884. smooth2=10.*p1
  1885. else
  1886. smooth1=1.
  1887. smooth2=1.
  1888. end if
  1889. b0=(3.-p1)/8. *smooth1
  1890. bu0=0.5-u0/4.*(p1-3.*f)/(1.-f) *smooth2
  1891. ! alpha coefficient
  1892. alph1=u*(1.-(1.-b0)*w0)
  1893. alph2=u*b0*w0
  1894. alph3=w0*bu0*(1-f)
  1895. alph4=w0*(1.-bu0)*(1-f)
  1896. ! epsilon and gamma coefficient
  1897. eps=sqrt(alph1**2-alph2**2)
  1898. factor=1.-w0*f
  1899. ! check for resonance condition in GAM1 and GAM2, if fulfil th
  1900. ! chance U0(J) and calculate UEPS2, BU0, ALPH3, ALPH4 again.
  1901. ueps2=(u0 *eps)**2
  1902. arg = ueps2-factor**2
  1903. if (arg < 0.) arg = -1. * arg
  1904. if (arg < resonc) then
  1905. if (ueps2.lt.factor**2) then
  1906. u0 = u0 - delu0
  1907. else
  1908. u0 = u0 + delu0
  1909. end if
  1910. ueps2=(u0 * eps)**2
  1911. bu0=0.5-u0/4.*(p1-3.*f)/(1.-f) *smooth2
  1912. alph3=w0*bu0*(1-f)
  1913. alph4=w0*(1.-bu0)*(1-f)
  1914. end if
  1915. gam1=( factor*alph3-u0 * (alph1*alph3+alph2*alph4) ) * &
  1916. 1/(factor**2-ueps2)
  1917. gam2=(-factor*alph4-u0 * (alph1*alph4+alph2*alph3) ) * &
  1918. 1/(factor**2-ueps2)
  1919. e=exp(-eps*tautot)
  1920. rm=alph2/(alph1+eps)
  1921. al(k,4)=e*(1.-rm**2.)/(1.-e**2. * rm**2.)
  1922. al(k,5)=rm*(1.-e**2.)/(1.-e**2. * rm**2.)
  1923. al(k,1)=exp(-factor*tautot/u0)
  1924. al(k,2)=-al(k,4)*gam2-al(k,5)*gam1*al(k,1) + gam2*al(k,1)
  1925. al(k,3)=-al(k,5)*gam2-al(k,4)*gam1*al(k,1) + gam1
  1926. enddo
  1927. !====================================================================
  1928. ! matrix inversion
  1929. !====================================================================
  1930. ! direct solution of the first four equations
  1931. rf(1) = u0 * flux(nl)
  1932. rf(2) = 0.
  1933. ! 5th to 10th equation: bring matrix elements on the left of the m
  1934. ! diagonal to the rhs: save elements on the right of the main
  1935. ! diagonal in array -tu(l,1)
  1936. rf(3) = al(1,3) * rf(1)
  1937. rf(4) = al(1,1) * rf(1)
  1938. rf(5) = al(1,2) * rf(1)
  1939. tu1(1) = al(1,4)
  1940. tu2(1) = al(1,5)
  1941. ! blocks of 6 equations: eliminate left matrix elements, save righ
  1942. ! matrix elements in array -tu(l,i),
  1943. ! calculate rhs.
  1944. do k=2,lm(region)
  1945. k3=3*k
  1946. td1 = 1./(1.-al(k,5)*tu2(k-1))
  1947. td2 = al(k,4)*tu2(k-1)
  1948. tu1(k) = td1*al(k,4)
  1949. tu2(k) = al(k,5) + td2*tu1(k)
  1950. rf(k3) = td1 * (al(k,3)*rf(k3-2) + al(k,5)*rf(k3-1))
  1951. rf(k3+1)= al(k,1)*rf(k3-2)
  1952. rf(k3+2)= al(k,2)*rf(k3-2) + al(k,4)*rf(k3-1)+td2*rf(k3)
  1953. end do
  1954. ! last two equations: the same as before
  1955. tds1 = 1. / (1.-alb*tu2(lm(region)))
  1956. rf(maxlev3) = tds1 * (alb * rf(maxlev3-2)+ &
  1957. alb * rf(maxlev3-1))
  1958. ! now we have created an upper triangular matrix the elements of
  1959. ! are -tu(l,i), 0, or 1 (in the main diagonal). the 0 and 1 eleme
  1960. ! are not stored in an array. let us solve the system now and sto
  1961. ! results in the arrays rf (fluxes clear sky) and rw (fluxes clou
  1962. do k=lm(region),1,-1
  1963. k3=3*k
  1964. rf(k3+2) = rf(k3+2) + tu2(k)*rf(k3+3)
  1965. rf(k3) = rf(k3) + tu1(k)*rf(k3+3)
  1966. sd(k+1,l) = rf(k3+1)
  1967. fd(k+1,l) = rf(k3+2)
  1968. fu(k+1,l) = rf(k3+3)
  1969. end do
  1970. sd(1,l) = rf(1)
  1971. fd(1,l) = rf(2)
  1972. fu(1,l) = rf(3)
  1973. ! calculate the actinic flux
  1974. fact_top = sd(1,l)/u0 + u * fd(1,l) + u * fu(1,l)
  1975. do k = 1,lm(region)
  1976. fact_bot = sd(k+1,l)/u0 + &
  1977. u * fd(k+1,l) + u * fu(k+1,l)
  1978. fact(k,l) = max(0. ,(fact_top + fact_bot)/2.)
  1979. fact_top = fact_bot
  1980. end do
  1981. ! swap vertical levels to the default order of the model
  1982. fact(1:lm(region),l) = fact(lm(region):1:-1,l)
  1983. cst_o3_col(1:lm(region),nl) = cst_o3_col(lm(region):1:-1,nl)
  1984. enddo ! spectral bands (nbands)
  1985. END SUBROUTINE PIFM
  1986. !EOC
  1987. !--------------------------------------------------------------------------
  1988. ! TM5 !
  1989. !--------------------------------------------------------------------------
  1990. !BOP
  1991. !
  1992. ! !IROUTINE: PIFM_RAN
  1993. !
  1994. ! !DESCRIPTION: Pifm method including random overlap method for clouds
  1995. !
  1996. !************************************************************************
  1997. !* PRACTICAL IMPROVED FLUX METHOD (PIFM) *
  1998. !* to calculate actinic fluxes *
  1999. !* Zdunkowski,Welch,Korb: Beitr. Phys. Atmosph. vol. 53, p. 147 ff *
  2000. !* *
  2001. !* Cloud effects added using the method of : *
  2002. !* Geleyn and Hollingworth, Contribs. Atms.Phys,52(1),1979 *
  2003. !* *
  2004. !************************************************************************
  2005. !* This version is not suitable for calculation for conserving *
  2006. !* scattering (W0=1). W0 is limited to W0 .le. 1. - 1.E-15. *
  2007. !* For W0 = 1, AL(4) and AL(5) has to be calculated differently. *
  2008. !************************************************************************
  2009. !\\
  2010. !\\
  2011. ! !INTERFACE:
  2012. !
  2013. SUBROUTINE PIFM_RAN(region, zangle, alb, cst_o3_col, dv2, dv3, &
  2014. taua_cld_col, taus_cld_col, pcld_col, &
  2015. taua_aer_col, taus_aer_col, paer_col, fact, frac )
  2016. !
  2017. ! !USES:
  2018. !
  2019. use dims, only : lm
  2020. use binas, only : pi
  2021. !
  2022. ! !INPUT PARAMETERS:
  2023. !
  2024. integer, intent(in) :: region
  2025. real, intent(in) :: zangle ! zenith angle
  2026. real, intent(in) :: alb ! albedo
  2027. real,dimension(lm(region)) :: frac ! cloud fraction per layer (0->1)
  2028. real,dimension(lm(region),maxwav) :: cst_o3_col ! o3 cross sections
  2029. real,dimension(lm(region)) :: dv2, dv3 ! differential column info
  2030. real,dimension(lm(region)) :: taua_cld_col, taus_cld_col ! optical depth clouds
  2031. real,dimension(lm(region),nbands_trop) :: taua_clr_col, taus_clr_col ! optical depth clear sky
  2032. real,dimension(lm(region),nbands_trop,ngrid) :: taua_aer_col, taus_aer_col ! optical depth aerosols
  2033. real,dimension(lm(region),nbands_trop) :: fact ! actinic flux
  2034. real,dimension(lm(region),nbands_trop,ngrid) :: paer_col ! aerosol phase functions
  2035. real,dimension(lm(region)) :: pcld_col ! cloud phase functions
  2036. real,dimension(0:nmom) :: pray ! rayleigh phase function
  2037. !
  2038. ! !REVISION HISTORY:
  2039. !
  2040. !EOP
  2041. !------------------------------------------------------------------------
  2042. !BOC
  2043. real,dimension(3*(lm(region)+1)) :: rw, & ! flux array for cloudy sky
  2044. rf ! flux array for clear sky
  2045. real,dimension(lm(region)) :: tu1, & ! parallel solar flux
  2046. tu2 ! matrix coefficient
  2047. real,dimension(lm(region),5) :: al
  2048. real,dimension(lm(region)+1,nbands_trop):: sd, fd, fu
  2049. real,dimension(lm(region),nbands_trop) :: TS_PI_CLR,TA_PI_CLR, G_PI_CLR, TS_PI_CLD
  2050. real,dimension(lm(region)) :: TA_PI_CLD, G_PI_CLD
  2051. real :: U,DELU0,RESONC,a,b,c,gamma,u0,cs_o2
  2052. integer :: grid,j,k,l,maxlev,maxlay2,maxlev3,nl,k3
  2053. real :: w0,p1,F,smooth1,smooth2,b0,bu0,alph1,alph2,alph3,alph4,tautot,eps,factor
  2054. real :: rm,gam1,gam2,e,tauscat,td1,td2,tds1,ueps2,g,arg,fact_bot, fact_top
  2055. ! diffusivity factor
  2056. DATA U / 2./
  2057. DATA DELU0 /1.E-3/
  2058. DATA RESONC /1.E-6/
  2059. real :: AL_CLR_1,AL_CLR_2,AL_CLR_3,AL_CLR_4,AL_CLR_5 !matrix coefficient for clear sky
  2060. real :: AL_CLD_1,AL_CLD_2,AL_CLD_3,AL_CLD_4,AL_CLD_5 !matrix coefficient for cloudy sky
  2061. !-----correction of the air mass factor---------------------------------
  2062. ! F. Kasten and T. Young, Revised optical air mass tables and
  2063. ! approximation formula (1989) Aplied Optics Vol 28, No. 22 P. 4735
  2064. ! and J. Lenoble, atmospheric radiative transfer (1993), P. 236
  2065. a = 0.50572 ; b = 6.07995 ; c = 1.63640
  2066. ! define air mass factor in mu
  2067. gamma = 90. - zangle
  2068. u0 = sin(gamma*pi/180.) + a *(gamma+b)**(-c)
  2069. u0 = min(1.,u0)
  2070. !---------------------------------------------------------------------
  2071. ! internal integer variable
  2072. MAXLEV = lm(region) + 1
  2073. MAXLAY2 = 2 * lm(region)
  2074. MAXLEV3 = 3 * MAXLEV
  2075. ! initialize
  2076. fact = 0. ; sd = 0 ; fd = 0. ; fu = 0. ; td1 = 0.
  2077. rf = 0. ; rw = 0. ; al = 0. ; tu1 = 0. ; tu2 = 0.
  2078. ! determine phase functions
  2079. pray(0) = 1. ; pray(1) = 0. ; pray(2)=0.1 ; pray(3:nmom) = 0.
  2080. dv2(1:lm(region)) = dv2(lm(region):1:-1)
  2081. dv3(1:lm(region)) = dv3(lm(region):1:-1)
  2082. frac(1:lm(region)) = frac(lm(region):1:-1)
  2083. taua_cld_col(1:lm(region)) = taua_cld_col(lm(region):1:-1)
  2084. taus_cld_col(1:lm(region)) = taus_cld_col(lm(region):1:-1)
  2085. pcld_col(1:lm(region)) = pcld_col(lm(region):1:-1)
  2086. do l = 1,nbands_trop
  2087. if (zangle <= 71.) then
  2088. nl = lmid(l)
  2089. grid = 1
  2090. cs_o2 = 7.322e-24
  2091. elseif (zangle > 71. .and. zangle<=sza_limit) then
  2092. nl = lmid_gridA(l)
  2093. grid = 2
  2094. cs_o2 = 6.608e-24
  2095. endif
  2096. ! reverse order for input parameters
  2097. cst_o3_col(1:lm(region),nl) = cst_o3_col(lm(region):1:-1,nl)
  2098. taus_aer_col(1:lm(region),l,grid) = taus_aer_col(lm(region):1:-1,l,grid)
  2099. taua_aer_col(1:lm(region),l,grid) = taua_aer_col(lm(region):1:-1,l,grid)
  2100. paer_col(1:lm(region),l,grid) = paer_col(lm(region):1:-1,l,grid)
  2101. ! fill array for absorption and scattering components before performing
  2102. ! calculations.
  2103. do K = 1,lm(region)
  2104. taus_clr_col(k,l) = cs_ray(nl)*1./0.2095*dv2(k)
  2105. if(nl<18) then
  2106. taua_clr_col(k,l) = cs_o2*dv2(k) + cst_o3_col(k,nl)*dv3(k)
  2107. else
  2108. taua_clr_col(k,l) = cst_o3_col(k,nl)*dv3(k)
  2109. endif
  2110. TS_PI_CLR(K,L) = TAUS_CLR_col(K,L)+TAUS_AER_col(K,L,grid)
  2111. TA_PI_CLR(K,L) = TAUA_CLR_col(K,L)+TAUA_AER_col(K,L,grid)
  2112. TS_PI_CLD(K,L) = TAUS_CLD_col(K)
  2113. TA_PI_CLD(K) = TAUA_CLD_col(K)
  2114. IF (TAUS_CLR_col(K,L)+TAUS_AER_col(K,L,grid)>0.) THEN
  2115. G_PI_CLR(K,L) = (PRAY(1)*TAUS_CLR_col(K,L) + &
  2116. PAER_col(k,l,grid)*TAUS_AER_col(K,L,grid))/ &
  2117. (TAUS_CLR_col(K,L)+TAUS_AER_col(K,L,grid))
  2118. ELSE
  2119. G_PI_CLR(K,L) = 0.
  2120. ENDIF
  2121. G_PI_CLD(K) = PCLD_col(k)
  2122. enddo
  2123. do K = 1,lm(region)
  2124. !***** first: clear sky *******************************************
  2125. TAUTOT = TS_PI_CLR(K,L)+TA_PI_CLR(K,L)
  2126. if (tautot /= 0.) then
  2127. W0=TS_PI_CLR(K,L) / TAUTOT
  2128. ELSE
  2129. W0=0.
  2130. ENDIF
  2131. W0 = MIN(W0,1.-1e-15)
  2132. ! P1: first expansion coefficient of the phase function
  2133. P1=3.*G_PI_CLR(K,L)
  2134. ! F: fraction of radiation contained in diffraction peak
  2135. F=G_PI_CLR(K,L)**2
  2136. ! B0: fractional mean backward scattering coefficient of diffuse light
  2137. ! BU0: backward scattering coefficient of primary scattered parallel solar light
  2138. ! for small P1 SMOOTH1,SMOOTH2 manage the smooth change of B0 and
  2139. ! BU0 to 0
  2140. IF (P1<=0.1) THEN
  2141. SMOOTH1=1.33333333-P1*3.3333333
  2142. SMOOTH2=10.*P1
  2143. ELSE
  2144. SMOOTH1=1
  2145. SMOOTH2=1
  2146. ENDIF
  2147. B0=(3.-P1)/8. *SMOOTH1
  2148. BU0=0.5-U0/4.*(P1-3.*F)/(1.-F) *SMOOTH2
  2149. ! alpha coefficient
  2150. ALPH1=U*(1.-(1.-B0)*W0)
  2151. ALPH2=U*B0*W0
  2152. ALPH3=W0*BU0*(1-F)
  2153. ALPH4=W0*(1.-BU0)*(1-F)
  2154. ! epsilon and gamma coefficient
  2155. EPS=SQRT(ALPH1**2-ALPH2**2)
  2156. FACTOR=1.-W0*F
  2157. ! check for resonance condition in GAM1 and GAM2, if fulfil then
  2158. ! chance U0 and calculate UEPS2, BU0, ALPH3, ALPH4 again.
  2159. UEPS2=(U0*EPS)**2
  2160. arg = ueps2-factor**2
  2161. if (arg < 0.) then
  2162. arg = -1. * arg
  2163. endif
  2164. if (arg < resonc) then
  2165. IF(UEPS2.LT.FACTOR**2) THEN
  2166. U0=U0-DELU0
  2167. ELSE
  2168. U0=U0+DELU0
  2169. ENDIF
  2170. UEPS2=(U0*EPS)**2
  2171. BU0=0.5-U0/4.*(P1-3.*F)/(1.-F) *SMOOTH2
  2172. ALPH3=W0*BU0*(1-F)
  2173. ALPH4=W0*(1.-BU0)*(1-F)
  2174. ENDIF
  2175. GAM1=( FACTOR*ALPH3-U0*(ALPH1*ALPH3+ALPH2*ALPH4) ) * &
  2176. & 1/(FACTOR**2-UEPS2)
  2177. GAM2=(-FACTOR*ALPH4-U0*(ALPH1*ALPH4+ALPH2*ALPH3) ) * &
  2178. & 1/(FACTOR**2-UEPS2)
  2179. E=EXP(-EPS*TAUTOT)
  2180. RM=ALPH2/(ALPH1+EPS)
  2181. AL_CLR_4= E*(1-RM**2)/(1-E**2 * RM**2)
  2182. AL_CLR_5= RM*(1-E**2)/(1-E**2 * RM**2)
  2183. AL_CLR_1= EXP(-FACTOR*TAUTOT/U0)
  2184. AL_CLR_2=-AL_CLR_4*GAM2-AL_CLR_5*GAM1* &
  2185. & AL_CLR_1+GAM2*AL_CLR_1
  2186. AL_CLR_3=-AL_CLR_5*GAM2-AL_CLR_4*GAM1* &
  2187. & AL_CLR_1+GAM1
  2188. !******************* second: cloudy sky *****************************
  2189. ! For ECMWF input there is the possibility that cloud fraction occurs without a
  2190. ! corresponding value for lwc
  2191. IF( FRAC(K) > 0.02 .and. TS_PI_CLD(K,L) > 1.e-5 ) THEN
  2192. TAUSCAT = TS_PI_CLR(K,L) + TAUS_CLD_col(K)
  2193. TAUTOT = TA_PI_CLR(K,L) + TAUA_CLD_col(K)+TAUSCAT
  2194. G = G_PI_CLD(K)*TAUS_CLD_col(K)/TAUSCAT
  2195. IF (TAUTOT > 0.) THEN
  2196. W0=TAUSCAT/TAUTOT
  2197. ELSE
  2198. W0=0.
  2199. ENDIF
  2200. W0 = MIN(W0,1.-1e-15)
  2201. P1=3.*G
  2202. F=G**2
  2203. IF (P1<0.1) THEN
  2204. SMOOTH1=1.33333333-P1*3.3333333
  2205. SMOOTH2=10.*P1
  2206. ELSE
  2207. SMOOTH1=1
  2208. SMOOTH2=1
  2209. ENDIF
  2210. B0=(3.-P1)/8. *SMOOTH1
  2211. BU0=0.5-U0/4.*(P1-3.*F)/(1.-F) *SMOOTH2
  2212. ALPH1=U*(1.-(1.-B0)*W0)
  2213. ALPH2=U*B0*W0
  2214. ALPH3=W0*BU0*(1-F)
  2215. ALPH4=W0*(1.-BU0)*(1-F)
  2216. EPS=SQRT(ALPH1**2-ALPH2**2)
  2217. FACTOR=1.-W0*F
  2218. UEPS2=(U0*EPS)**2
  2219. arg = ueps2-factor**2
  2220. if (arg < 0.) then
  2221. arg = -1. * arg
  2222. endif
  2223. if (arg < resonc) then
  2224. IF(UEPS2.LT.FACTOR**2) THEN
  2225. U0=U0-DELU0
  2226. ELSE
  2227. U0=U0+DELU0
  2228. ENDIF
  2229. UEPS2=(U0*EPS)**2
  2230. BU0=0.5-U0/4.*(P1-3.*F)/(1.-F) *SMOOTH2
  2231. ALPH3=W0*BU0*(1-F)
  2232. ALPH4=W0*(1.-BU0)*(1-F)
  2233. ENDIF
  2234. GAM1=( FACTOR*ALPH3-U0*(ALPH1*ALPH3+ALPH2*ALPH4) ) * 1/(FACTOR**2-UEPS2)
  2235. GAM2=(-FACTOR*ALPH4-U0*(ALPH1*ALPH4+ALPH2*ALPH3) ) * 1/(FACTOR**2-UEPS2)
  2236. E=EXP(-EPS*TAUTOT)
  2237. RM=ALPH2/(ALPH1+EPS)
  2238. AL_CLD_4=E*(1-RM**2)/(1-E**2 * RM**2)
  2239. AL_CLD_5=RM*(1-E**2)/(1-E**2 * RM**2)
  2240. AL_CLD_1=EXP(-FACTOR*TAUTOT/U0)
  2241. AL_CLD_2=-AL_CLD_4*GAM2-AL_CLD_5*GAM1*AL_CLD_1+GAM2*AL_CLD_1
  2242. AL_CLD_3=-AL_CLD_5*GAM2-AL_CLD_4*GAM1*AL_CLD_1+GAM1
  2243. AL(K,1) =(1-FRAC(K))*AL_CLR_1 + FRAC(K)*AL_CLD_1
  2244. AL(K,2) =(1-FRAC(K))*AL_CLR_2 + FRAC(K)*AL_CLD_2
  2245. AL(K,3) =(1-FRAC(K))*AL_CLR_3 + FRAC(K)*AL_CLD_3
  2246. AL(K,4) =(1-FRAC(K))*AL_CLR_4 + FRAC(K)*AL_CLD_4
  2247. AL(K,5) =(1-FRAC(K))*AL_CLR_5 + FRAC(K)*AL_CLD_5
  2248. ELSE
  2249. AL(K,1) = AL_CLR_1
  2250. AL(K,2) = AL_CLR_2
  2251. AL(K,3) = AL_CLR_3
  2252. AL(K,4) = AL_CLR_4
  2253. AL(K,5) = AL_CLR_5
  2254. ENDIF
  2255. enddo !k
  2256. !====================================================================
  2257. ! matrix inversion
  2258. !====================================================================
  2259. ! direct solution of the first four equations
  2260. RF(1) = U0*FLUX(NL)
  2261. RF(2) = 0.
  2262. ! 5th to 10th equation: bring matrix elements on the left of the main
  2263. ! diagonal to the rhs: save elements on the right of the main
  2264. ! diagonal in array -tu(l,1)
  2265. RF(3) = AL(1,3) * RF(1)
  2266. RF(4) = AL(1,1) * RF(1)
  2267. RF(5) = AL(1,2) * RF(1)
  2268. TU1(1) = AL(1,4)
  2269. TU2(1) = AL(1,5)
  2270. ! blocks of 6 equations: eliminate left matrix elements, save right
  2271. ! matrix elements in array -tu(l,i),
  2272. ! calculate rhs.
  2273. DO K=2,lm(region)
  2274. K3=3*K
  2275. TD1 = 1./(1.-AL(K,5)*TU2(K-1))
  2276. TD2 = AL(K,4)*TU2(K-1)
  2277. TU1(K) = TD1*AL(K,4)
  2278. TU2(K) = AL(K,5) + TD2*TU1(K)
  2279. RF(K3) = TD1 * (AL(K,3)*RF(K3-2) + AL(K,5)*RF(K3-1))
  2280. RF(K3+1)= AL(K,1)*RF(K3-2)
  2281. RF(K3+2)= AL(K,2)*RF(K3-2) + AL(K,4)*RF(K3-1)+TD2*RF(K3)
  2282. enddo
  2283. ! last two equations: the same as before
  2284. TDS1 = 1. / (1.-ALB*TU2(lm(region)))
  2285. rf(maxlev3) = tds1 * (alb * rf(maxlev3-2)+ &
  2286. alb * rf(maxlev3-1))
  2287. ! now we have created an upper triangular matrix the elements of which
  2288. ! are -tu(l,i), 0, or 1 (in the main diagonal). the 0 and 1 elements
  2289. ! are not stored in an array. let us solve the system now and store the
  2290. ! results in the arrays rf (fluxes clear sky) and rw (fluxes cloudy sky)
  2291. DO K=lm(region),1,-1
  2292. K3=3*K
  2293. RF(K3+2) = RF(K3+2) + TU2(K)*RF(K3+3)
  2294. RF(K3) = RF(K3) + TU1(K)*RF(K3+3)
  2295. SD(K+1,L) = RF(K3+1)
  2296. FD(K+1,L) = RF(K3+2)
  2297. FU(K+1,L) = RF(K3+3)
  2298. enddo ! K
  2299. SD(1,L) = RF(1)
  2300. FD(1,L) = RF(2)
  2301. FU(1,L) = RF(3)
  2302. ! calculate the actinic flux
  2303. fact_top = sd(1,l)/u0 + u * fd(1,l) + u * fu(1,l)
  2304. do k = 1,lm(region)
  2305. fact_bot = sd(k+1,l)/u0 + u * fd(k+1,l) + u * fu(k+1,l)
  2306. fact(k,l) = max(0. ,(fact_top + fact_bot)/2.)
  2307. fact_top = fact_bot
  2308. end do ! K
  2309. ! swap vertical levels to the default order of the model
  2310. fact(1:lm(region),l) = fact(lm(region):1:-1,l)
  2311. cst_o3_col(1:lm(region),nl) = cst_o3_col(lm(region):1:-1,nl)
  2312. enddo ! wavelength
  2313. return
  2314. END SUBROUTINE PIFM_RAN
  2315. !EOC
  2316. !------------------------------------------------------------------------------
  2317. ! TM5 !
  2318. !------------------------------------------------------------------------------
  2319. !BOP
  2320. !
  2321. ! !IROUTINE: SUNDIS
  2322. !
  2323. ! !DESCRIPTION:
  2324. !-----------------------------------------------------------------------------*
  2325. != purpose: =*
  2326. != calculate earth-sun distance variation for a given date. based on =*
  2327. != fourier coefficients originally from: spencer, j.w., 1971, fourier =*
  2328. != series representation of the position of the sun, search, 2:172 =*
  2329. !-----------------------------------------------------------------------------*
  2330. != parameters: =*
  2331. != idate - integer, specification of the date, from yymmdd (i)=*
  2332. != esrm2 - real, variation of the earth-sun distance (o)=*
  2333. != esrm2 = (average e/s dist)^2 / (e/s dist on day idate)^2 =*
  2334. !-----------------------------------------------------------------------------*
  2335. != edit history: =*
  2336. != 01/95 changed computation of trig function values =*
  2337. !-----------------------------------------------------------------------------*
  2338. != this program is free software; you can redistribute it and/or modify =*
  2339. != it under the terms of the gnu general public license as published by the =*
  2340. != free software foundation; either version 2 of the license, or (at your =*
  2341. != option) any later version. =*
  2342. != the tuv package is distributed in the hope that it will be useful, but =*
  2343. != without any warranty; without even the implied warranty of merchantibi- =*
  2344. != lity or fitness for a particular purpose. see the gnu general public =*
  2345. != license for more details. =*
  2346. != to obtain a copy of the gnu general public license, write to: =*
  2347. != free software foundation, inc., 675 mass ave, cambridge, ma 02139, usa. =*
  2348. !-----------------------------------------------------------------------------*
  2349. != to contact the authors, please mail to: =*
  2350. != sasha madronich, ncar/acd, p.o.box 3000, boulder, co, 80307-3000, usa or =*
  2351. != send email to: sasha@ucar.edu =*
  2352. !-----------------------------------------------------------------------------*
  2353. != copyright (c) 1994,95,96 university corporation for atmospheric research =*
  2354. !-----------------------------------------------------------------------------*
  2355. !\\
  2356. !\\
  2357. ! !INTERFACE:
  2358. !
  2359. REAL FUNCTION SUNDIS( imonth, iday)
  2360. !
  2361. ! !USES:
  2362. !
  2363. use binas, only : pi
  2364. !
  2365. ! !INPUT PARAMETERS:
  2366. !
  2367. integer, intent(in) :: iday, imonth
  2368. !
  2369. ! !REVISION HISTORY:
  2370. !
  2371. !EOP
  2372. !------------------------------------------------------------------------------
  2373. !BOC
  2374. ! internal:
  2375. integer mday, month, jday
  2376. real dayn, thet0
  2377. real sinth, costh, sin2th, cos2th
  2378. integer,dimension(12) ::imn=(/ 31,28,31,30,31,30,31,31,30,31,30,31 /)
  2379. ! start
  2380. ! parse date to find day number (julian day)
  2381. mday = 0
  2382. do month = 1, imonth-1
  2383. mday = mday + imn(month)
  2384. end do
  2385. jday = mday + iday
  2386. dayn = float(jday - 1) + 0.5
  2387. ! define angular day number and compute esrm2:
  2388. thet0 = 2.*pi*dayn/365.
  2389. ! calculate sin(2*thet0), cos(2*thet0) from
  2390. ! addition theoremes for trig functions for better
  2391. ! performance; the computation of sin2th, cos2th
  2392. ! is about 5-6 times faster than the evaluation
  2393. ! of the intrinsic functions sin and cos
  2394. !
  2395. sinth = sin(thet0)
  2396. costh = cos(thet0)
  2397. sin2th = 2.*sinth*costh
  2398. cos2th = costh*costh - sinth*sinth
  2399. sundis = 1.000110 + 0.034221*costh + 0.001280*sinth + &
  2400. 0.000719*cos2th + 0.000077*sin2th
  2401. !
  2402. END FUNCTION SUNDIS
  2403. !EOC
  2404. !--------------------------------------------------------------------------
  2405. ! TM5 !
  2406. !--------------------------------------------------------------------------
  2407. !BOP
  2408. !
  2409. ! !IROUTINE: OZONE_INFO_ONLINE
  2410. !
  2411. ! !DESCRIPTION: calculate, from an ozone field, the overhead ozone at all
  2412. ! grid points.
  2413. ! Optical depth clear sky conditions
  2414. ! upper values are given by the ozone climatology above the
  2415. ! highest model mid-level
  2416. !\\
  2417. !\\
  2418. ! !INTERFACE:
  2419. !
  2420. SUBROUTINE OZONE_INFO_ONLINE( region )
  2421. !
  2422. ! !USES:
  2423. !
  2424. use binas, only : Avog, xm_air, grav
  2425. use dims
  2426. ! use photolysis_data, only : phot_dat
  2427. use global_data, only : region_dat, mass_dat
  2428. use chem_param, only : xmo3, io3
  2429. use meteodata, only : phlb_dat
  2430. !
  2431. ! !INPUT PARAMETERS:
  2432. !
  2433. integer, intent(in) :: region
  2434. !
  2435. ! !REVISION HISTORY:
  2436. ! Jan 2003 - MK - adapted for new TM5 memory structure.
  2437. ! Jul 2008 - JEW - new ozone info unit coupled for online calculations
  2438. ! 26 Apr 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  2439. !
  2440. !EOP
  2441. !------------------------------------------------------------------------
  2442. !BOC
  2443. real, parameter :: conv = 0.1*Avog/xmo3 ! from kg/m2 --> #/cm2
  2444. real, parameter :: sp = Avog*1.e-4*0.2095/(xm_air*grav)
  2445. integer :: i, j, l, lmr, i1, i2, j1, j2
  2446. real,dimension(:,:,:),allocatable :: o3_overhead_online, o2_overhead ! #/cm2
  2447. real,dimension(:), pointer :: ozone_klimtop !in #cm-2
  2448. real,dimension(:,:), pointer :: v3_surf ! #/cm2
  2449. real,dimension(:,:,:),pointer :: v2, v3 ! #/cm2
  2450. real,dimension(:,:,:,:),pointer :: o3 ! #/cm2
  2451. real,dimension(:,:,:),pointer :: phlb
  2452. real,dimension(:), pointer :: area
  2453. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  2454. lmr = lm(region)
  2455. ! allocate on all prcessors so result maybe scattered
  2456. allocate(o3_overhead_online(i1:i2, j1:j2, lm(region))) ; o3_overhead_online = 0.0
  2457. allocate(o2_overhead (i1:i2, j1:j2, lm(region))) ; o2_overhead = 0.0
  2458. v2 => phot_dat(region)%v2
  2459. v3 => phot_dat(region)%v3
  2460. v3_surf => phot_dat(region)%v3_surf
  2461. area => region_dat(region)%dxyp
  2462. phlb => phlb_dat(region)%data
  2463. o3 => mass_dat(region)%rm ! (i1:i2, j1:j2, 1:lmr, io3)
  2464. ! CALCULATE COLUMNS
  2465. ! -----------------
  2466. ! (1) top
  2467. ! --------
  2468. ! o3du is not used anymore, except in cases where stratosphere is not resolved (EC-EARTH)
  2469. if (with_o3du) then ! use fortuin-kelder
  2470. ozone_klimtop => phot_dat(region)%o3klim_top
  2471. do j=j1,j2
  2472. do i=i1,i2
  2473. o3_overhead_online(i,j,lm(region)) = ozone_klimtop(j)
  2474. end do
  2475. end do
  2476. else ! from TM4-routine
  2477. do j=j1,j2
  2478. do i=i1,i2
  2479. o3_overhead_online(i,j,lm(region)) = 0.5*conv*o3(i,j,lm(region),io3)/area(j)
  2480. end do
  2481. end do
  2482. endif
  2483. ! (2) rest
  2484. ! --------
  2485. do l = lm(region)-1,1,-1
  2486. do j = j1,j2
  2487. do i = i1,i2
  2488. o3_overhead_online(i,j,l) = o3_overhead_online(i,j,l+1) + &
  2489. 0.5*conv*(o3(i,j,l,io3)+o3(i,j,l+1,io3))/area(j)
  2490. enddo
  2491. enddo
  2492. enddo
  2493. ! Define surface ozone column field for diagnostic purposes
  2494. do j=j1,j2
  2495. do i=i1,i2
  2496. v3_surf(i,j) = o3_overhead_online(i,j,1) + 0.5*conv*o3(i,j,1,io3)/area(j)
  2497. end do
  2498. end do
  2499. ! Boundaries
  2500. v3(:,:,1) = o3_overhead_online(:,:,1)
  2501. ! now transform o3 column from layers to levels
  2502. do l = 2,lm(region)
  2503. v3(:,:,l) = ( o3_overhead_online(:,:,l) + o3_overhead_online(:,:,l-1) ) * 0.5
  2504. enddo
  2505. ! TOA
  2506. do j=j1,j2
  2507. do i=i1,i2
  2508. v3(i,j,lm(region)+1) = 0.5*v3(i,j,lm(region))
  2509. enddo
  2510. enddo
  2511. ! determine oxygen columns (can directly be calculated on levels)
  2512. do l = 1,lm(region)
  2513. do j = j1,j2
  2514. do i = i1,i2
  2515. v2(i,j,l) = phlb(i,j,l)*sp
  2516. enddo
  2517. enddo
  2518. enddo
  2519. ! top boundary for v2
  2520. v2(:,:,lm(region)+1) = 0.5*v2(:,:,lm(region))
  2521. nullify(o3)
  2522. nullify(ozone_klimtop)
  2523. nullify(area)
  2524. nullify(phlb)
  2525. nullify(v2)
  2526. nullify(v3)
  2527. nullify(v3_surf)
  2528. deallocate(o3_overhead_online)
  2529. deallocate(o2_overhead)
  2530. END SUBROUTINE OZONE_INFO_ONLINE
  2531. !EOC
  2532. !--------------------------------------------------------------------------
  2533. ! TM5 !
  2534. !--------------------------------------------------------------------------
  2535. !BOP
  2536. !
  2537. ! !IROUTINE: PHOTORATES_TROPO
  2538. !
  2539. ! !DESCRIPTION: calculation of photolysis and heating rates
  2540. !
  2541. ! References:
  2542. ! J. Landgraf and P.J. Crutzen, 1998:
  2543. ! An Efficient Methode for Online Calculation of Photolysis and
  2544. ! Heating Rates, J. Atmos. Sci., 55, 863-878
  2545. !
  2546. ! Expanded for high angles and online:
  2547. ! J.E.Williams, J. Landgraf, B. Bregman and H. H. Walter, A modified band
  2548. ! approach for the accurate calculation of online photolysis rates in
  2549. ! stratospheric-tropospheric Chemistry Transport Models, Atms. Chem. Phys.,
  2550. ! 6, 4137-4161, 2006.
  2551. !\\
  2552. !\\
  2553. ! !INTERFACE:
  2554. !
  2555. SUBROUTINE PHOTORATES_TROPO(region, zangle, cst_o3_col, cst_no2_col, cst_hno3_col, cst_h2o2_col, &
  2556. cst_ch2o_col, cst_n2o5_col, cst_pan_col, cst_no3_col, qy_no2_col, qy_o1d_col, &
  2557. qy_ch3cocho_col, fact, fdir, rj, debug_flag)
  2558. !
  2559. ! !USES:
  2560. !
  2561. use Dims, only : im, jm, lm, idate
  2562. use global_data, only : mass_dat
  2563. !
  2564. ! !INPUT PARAMETERS:
  2565. !
  2566. integer, intent(in) :: region
  2567. real, intent(in) :: zangle
  2568. real,dimension(lm(region),nbands_trop), intent(in) :: fact !actinic flux
  2569. real,dimension(lm(region),maxw), intent(in) :: fdir !flux o2-o3 abs.
  2570. logical, intent(in) :: debug_flag
  2571. real,dimension(lm(region),maxwav), intent(in) :: cst_o3_col
  2572. real,dimension(lm(region),89), intent(in) :: cst_no2_col, qy_no2_col
  2573. real,dimension(lm(region),65), intent(in) :: cst_hno3_col, qy_o1d_col
  2574. real,dimension(lm(region),55), intent(in) :: cst_n2o5_col
  2575. real,dimension(lm(region),45), intent(in) :: cst_h2o2_col
  2576. real,dimension(lm(region),105), intent(in) :: cst_ch2o_col
  2577. real,dimension(lm(region),65), intent(in) :: cst_pan_col
  2578. real,dimension(lm(region),62), intent(in) :: cst_no3_col
  2579. real,dimension(lm(region),52), intent(in) :: qy_ch3cocho_col
  2580. !
  2581. ! !OUTPUT PARAMETERS:
  2582. !
  2583. real,dimension(lm(region),nj), intent(out) :: rj !photolysis rates
  2584. !
  2585. ! !REVISION HISTORY:
  2586. !
  2587. !EOP
  2588. !------------------------------------------------------------------------
  2589. !BOC
  2590. real,dimension(nbands_trop) :: bjo1d, bjno2, bjhno3, bjcoh2, bjchoh, bjn2o5, bjhno4, bjpan, &
  2591. bjno2o,bjnoo2, bjh2o2, bjch3ooh,bjald2,bjch3o2co,bjch3cocho,bjch3ono2,bjo2
  2592. !=================================================================================================
  2593. !First tropospheric band is temperature independent for H2O2.N2O5,HCHO and NO2 therefore remove from large temp dep. arrays.
  2594. real,dimension(17) :: cs_h2o2, cs_n2o5,cs_ch2o,cs_no2, cs_o2
  2595. data cs_h2o2 /4.34E-19, 4.07E-19, 3.85E-19, 3.63E-19, 3.41E-19, 3.18E-19, 2.95E-19, &
  2596. 2.72E-19, 2.50E-19, 2.30E-19, 2.10E-19, 1.92E-19, 1.74E-19, 1.57E-19, &
  2597. 1.41E-19, 1.26E-19, 1.13E-19/
  2598. data cs_n2o5 /8.049E-18, 7.208E-18, 6.212E-18, 4.853E-18, 3.925E-18, 3.248E-18, 2.619E-18, &
  2599. 2.087E-18, 1.661E-18, 1.349E-18, 1.131E-18, 9.549E-19, 8.353E-18, 7.427E-19, &
  2600. 6.762E-19, 6.095E-19, 5.229E-19/
  2601. data cs_ch2o /0.00E+00, 0.00E+00, 0.00E+00, 0.00E+00, 0.00E+00, 0.00E+00, 0.00E+00, &
  2602. 0.00E+00, 0.00E+00, 0.00E+00, 0.00E+00, 1.844E-22, 3.311E-22, 3.198E-22, &
  2603. 6.982E-22, 7.341E-22, 1.383E-21/
  2604. data cs_o2 /7.448E-24, 7.322E-24, 7.002E-24, 6.608E-24, 6.118E-24, 5.736E-24, 5.302E-24,&
  2605. 4.741E-24, 4.261E-24, 3.788E-24, 3.213E-24, 2.69E-24, 2.218E-24, 1.793E-24,&
  2606. 1.384E-24, 1.054E-24, 6.318E-25/
  2607. real,dimension(62) :: cs_hno4 !
  2608. ! Reference : JPL 2006, 4-40
  2609. data cs_hno4 /4.43E-18, 3.64E-18, 3.09E-18, 2.54E-18, 2.13E-18, 1.78E-18, 1.51E-18, &
  2610. 1.30E-18, 1.13E-18, 1.01E-18, 9.07E-19, 8.33E-19, 7.65E-19, 7.06E-19, &
  2611. 6.48E-19, 5.91E-19, 5.36E-19, 4.83E-19, 4.36E-19, 3.93E-19, 3.53E-19, &
  2612. 3.10E-19, 2.69E-19, 2.31E-19, 1.96E-19, 1.61E-19, 1.27E-19, 9.53E-20, &
  2613. 7.01E-20, 4.93E-20, 3.31E-20, 2.14E-20, 1.60E-20, 1.40E-20, 1.30E-20, &
  2614. 1.20E-20, 1.10E-20, 1.00E-20, 9.00E-21, 8.20E-21, 7.40E-21, 6.60E-21, &
  2615. 5.80E-21, 5.00E-21, 4.60E-21, 4.20E-21, 3.80E-21, 3.40E-21, 3.00E-21, &
  2616. 2.80E-21, 2.60E-21, 2.40E-21, 2.20E-21, 2.00E-21, 1.80E-21, 1.50E-21, &
  2617. 1.10E-21, 7.00E-22, 0.00E+00, 0.00E+00, 0.00E+00, 0.00E+00/
  2618. real, dimension(89) :: cs_ch3ooh
  2619. ! Reference : JPL 2011, D9
  2620. data cs_ch3ooh / 2.782E-19, 2.782E-19, 2.782E-19, 2.782E-19, 2.782E-19, 2.316E-19, 1.956E-19, &
  2621. 1.696E-19, 1.476E-19, 1.318E-19, 1.169E-19, 1.036E-19, 9.132E-20, 8.045E-20, &
  2622. 7.084E-20, 6.199E-20, 5.483E-20, 4.808E-20, 4.260E-20, 3.744E-20, 3.263E-20, &
  2623. 2.819E-20, 2.431E-20, 2.119E-20, 1.827E-20, 1.569E-20, 1.338E-20, 1.107E-20, &
  2624. 9.226E-21, 7.677E-21, 6.358E-21, 5.152E-21, 4.406E-21, 4.130E-21, 3.930E-21, &
  2625. 3.730E-21, 3.530E-21, 3.330E-21, 3.130E-21, 2.982E-21, 2.834E-21, 2.686E-21, &
  2626. 2.538E-21, 2.390E-21, 2.276E-21, 2.162E-21, 2.048E-21, 1.934E-21, 1.820E-21, &
  2627. 1.730E-21, 1.640E-21, 1.550E-21, 1.460E-21, 1.370E-21, 1.306E-21, 1.210E-21, &
  2628. 1.082E-21, 9.720E-22, 7.900E-22, 6.100E-22, 4.700E-22, 3.500E-22, 2.700E-22, &
  2629. 2.100E-22, 1.600E-22, 1.200E-22, 7.500E-23, 5.200E-23, 4.000E-23, 4.050E-23, &
  2630. 4.100E-23, 1.000E-23, 6.000E-24, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2631. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2632. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00/
  2633. real, dimension(120) :: cs_ch3cocho
  2634. ! Reference : JPL 2006, P 4-71
  2635. data cs_ch3cocho /2.280E-19, 1.489E-19, 9.624E-20, 6.968E-20, 5.036E-20, 3.627E-20, 2.581E-20, &
  2636. 1.729E-20, 1.440E-20, 1.435E-20, 1.460E-20, 1.521E-20, 1.619E-20, 1.743E-20, &
  2637. 1.908E-20, 2.036E-20, 2.207E-20, 2.312E-20, 2.509E-20, 2.697E-20, 2.807E-20, &
  2638. 3.175E-20, 3.343E-20, 3.580E-20, 4.070E-20, 4.234E-20, 4.473E-20, 4.906E-20, &
  2639. 4.782E-20, 4.712E-20, 4.813E-20, 4.120E-20, 3.760E-20, 3.690E-20, 3.700E-20, &
  2640. 3.740E-20, 3.740E-20, 3.620E-20, 3.380E-20, 3.150E-20, 2.920E-20, 2.710E-20, &
  2641. 2.520E-20, 2.340E-20, 2.180E-20, 2.060E-20, 1.970E-20, 1.900E-20, 1.860E-20, &
  2642. 1.860E-20, 1.870E-20, 1.820E-20, 1.680E-20, 1.500E-20, 1.340E-20, 1.180E-20, &
  2643. 9.670E-21, 8.110E-21, 6.470E-21, 4.950E-21, 3.220E-21, 2.950E-21, 3.850E-21, &
  2644. 5.560E-21, 7.650E-21, 1.080E-20, 1.470E-20, 1.900E-20, 2.420E-20, 3.200E-20, &
  2645. 4.030E-20, 4.670E-20, 5.620E-20, 6.920E-20, 8.520E-20, 9.690E-20, 1.020E-19, &
  2646. 1.030E-19, 1.040E-19, 1.080E-19, 9.940E-20, 9.620E-20, 8.680E-20, 3.690E-20, &
  2647. 9.140E-21, 2.680E-21, 1.080E-21, 6.270E-22, 3.920E-22, 2.430E-22, 1.740E-22, &
  2648. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2649. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2650. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2651. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2652. 0.000E+00/
  2653. real,dimension(62) :: cs_orgn
  2654. ! Reference : average 1-C4H9ONO2 & 2-C4H9ONO2 (IUPAC data sheet P18 and P19)
  2655. ! JEW: The absorption spectrum of 2-C4H9ONO2 is mirrored around the maxiumum.
  2656. data cs_orgn / 5.250E-018, 4.398E-018, 3.609E-018, 2.804E-018, 2.172E-018, 1.595E-018, 1.130E-018, &
  2657. 7.710E-019, 5.025E-019, 3.714E-019, 2.623E-019, 1.900E-019, 1.342E-019, 9.905E-020, &
  2658. 7.285E-020, 5.245E-020, 4.052E-020, 3.110E-020, 2.806E-020, 5.649E-020, 5.136E-020, &
  2659. 4.886E-020, 4.635E-020, 4.358E-020, 3.970E-020, 3.610E-020, 3.247E-020, 2.784E-020, &
  2660. 2.308E-020, 1.846E-020, 1.401E-020, 9.810E-021, 7.430E-021, 6.550E-021, 6.080E-021, &
  2661. 5.610E-021, 5.140E-021, 4.670E-021, 4.200E-021, 3.840E-021, 3.480E-021, 3.120E-021, &
  2662. 2.760E-021, 2.400E-021, 2.170E-021, 1.940E-021, 1.710E-021, 1.480E-021, 1.250E-021, &
  2663. 1.131E-021, 1.012E-021, 8.930E-022, 7.740E-022, 2.550E-022, 2.350E-022, 2.050E-022, &
  2664. 1.650E-022, 1.400E-022, 1.050E-022, 8.000E-023, 0.000E+000, 0.000E+000/
  2665. real, dimension(89) :: cs_ald2
  2666. ! Reference : average CH3CHO & C2H5CHO (JPL and IUPAC data sheet, respectively)
  2667. data cs_ald2 /5.211E-022, 5.133E-022, 5.163E-022, 5.272E-022, 5.526E-022, 5.837E-022, 6.266E-022, &
  2668. 6.774E-022, 7.498E-022, 8.806E-022, 1.054E-021, 1.387E-021, 1.849E-021, 2.472E-021, &
  2669. 3.444E-021, 4.679E-021, 6.217E-021, 8.229E-021, 1.074E-020, 1.376E-020, 1.729E-020, &
  2670. 2.131E-020, 2.584E-020, 3.082E-020, 3.565E-020, 4.055E-020, 4.482E-020, 4.809E-020, &
  2671. 5.184E-020, 5.155E-020, 5.245E-020, 4.795E-020, 4.640E-020, 4.600E-020, 4.540E-020, &
  2672. 4.465E-020, 4.330E-020, 4.085E-020, 3.870E-020, 3.730E-020, 3.585E-020, 3.490E-020, &
  2673. 3.380E-020, 3.265E-020, 3.145E-020, 3.015E-020, 2.895E-020, 2.750E-020, 2.485E-020, &
  2674. 2.235E-020, 2.125E-020, 1.990E-020, 1.869E-020, 1.777E-020, 1.631E-020, 1.471E-020, &
  2675. 1.254E-020, 1.014E-020, 6.315E-021, 3.375E-021, 1.525E-021, 2.300E-022, 9.000E-023, &
  2676. 3.000E-023, 1.500E-023, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, &
  2677. 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, &
  2678. 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, &
  2679. 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000, 0.000E+000/
  2680. !==========================================================================================================
  2681. ! Similar procedure for quantum yields for : HCHO and NO3. A quantum yield of 0.8 is adopted for JN2O5 below 305nm
  2682. ! as recommended in JPL 2006 - JEW 2009
  2683. real,dimension(90) :: qyh_hco,qyh2_co
  2684. real,dimension(62) :: qyno2_o,qyno_o2
  2685. data qyh_hco /0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2686. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2687. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 3.087E-01, 3.087E-01, 3.030E-01, &
  2688. 3.113E-01, 3.325E-01, 3.649E-01, 4.059E-01, 4.535E-01, 5.061E-01, 5.611E-01, &
  2689. 6.159E-01, 6.662E-01, 7.097E-01, 7.418E-01, 7.550E-01, 7.580E-01, 7.610E-01, &
  2690. 7.620E-01, 7.620E-01, 7.620E-01, 7.600E-01, 7.580E-01, 7.540E-01, 7.490E-01, &
  2691. 7.440E-01, 7.370E-01, 7.290E-01, 7.200E-01, 7.090E-01, 6.980E-01, 6.850E-01, &
  2692. 6.710E-01, 6.560E-01, 6.390E-01, 6.220E-01, 6.030E-01, 5.830E-01, 5.500E-01, &
  2693. 5.020E-01, 4.490E-01, 3.430E-01, 1.650E-01, 0.000E+00, 0.000E+00, 0.000E+00, &
  2694. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2695. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2696. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2697. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00/ !(JPL 2006, p4-47)
  2698. data qyh2_co /0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2699. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2700. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 4.913E-01, 4.913E-01, 4.970E-01, &
  2701. 4.887E-01, 4.697E-01, 4.546E-01, 4.313E-01, 4.020E-01, 3.682E-01, 3.440E-01, &
  2702. 3.152E-01, 2.922E-01, 2.662E-01, 2.547E-01, 2.450E-01, 2.420E-01, 2.390E-01, &
  2703. 2.380E-01, 2.380E-01, 2.380E-01, 2.400E-01, 2.420E-01, 2.460E-01, 2.510E-01, &
  2704. 2.560E-01, 2.630E-01, 2.710E-01, 2.800E-01, 2.910E-01, 3.020E-01, 3.150E-01, &
  2705. 3.290E-01, 3.440E-01, 3.610E-01, 3.780E-01, 3.970E-01, 4.170E-01, 4.500E-01, &
  2706. 4.980E-01, 5.510E-01, 6.570E-01, 7.350E-01, 6.500E-01, 5.000E-01, 3.800E-01, &
  2707. 2.200E-01, 4.000E-03, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2708. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2709. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, &
  2710. 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00, 0.000E+00/
  2711. data qyno2_o /0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, &
  2712. 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, &
  2713. 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 1.00, &
  2714. 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, &
  2715. 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, &
  2716. 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, &
  2717. 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, &
  2718. 1.00, 0.83, 0.65, 0.58, 0.51, 0.43, 0.36, &
  2719. 0.29, 0.22, 0.14, 0.07, 0.0, 0.0/
  2720. data qyno_o2 /0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2721. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2722. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2723. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2724. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2725. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2726. 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
  2727. 0.0, 0.18, 0.35, 0.31, 0.27, 0.23, 0.19, &
  2728. 0.16, 0.12, 0.08, 0.04, 0.0, 0.0/
  2729. !========================================================================================================
  2730. integer :: i, j, l, k, c
  2731. real :: delta1, delta2, delta3, delta4, delta5, delta6, delta7, delta1_spec, delta3_spec
  2732. integer, dimension(7) :: band_start, band_middle, band_end
  2733. logical :: daylight
  2734. ! ==============================================================
  2735. ! CALCULATION PHOTOLYSIS RATES FOR SCATTERING ATMOSPHERE
  2736. ! ==============================================================
  2737. ! the check for daylight is skipped as the calculation of rj is only called within the photo_flux loop
  2738. ! where a filter already applies
  2739. rj(:,:) = 0.
  2740. ! choose the grid settings dependent on the SZA for the column
  2741. if(zangle<=71.) then
  2742. band_start(:)=lini(:)
  2743. band_middle(:)=lmid(:)
  2744. band_end(:)=lfin(:)
  2745. elseif(zangle>71. .and. zangle<=sza_limit) then
  2746. band_start(:)=lini_gridA(:)
  2747. band_middle(:)=lmid_gridA(:)
  2748. band_end(:)=lfin_gridA(:)
  2749. endif
  2750. do k = 1,lm(region)
  2751. ! re-initialize bj values
  2752. do l = 1,nbands_trop
  2753. bjo1d(l) = 0.0
  2754. bjno2(l) = 0.0
  2755. bjhno3(l) = 0.0
  2756. bjcoh2(l) = 0.0
  2757. bjchoh(l) = 0.0
  2758. bjn2o5(l) = 0.0
  2759. bjhno4(l) = 0.0
  2760. bjno2o(l) = 0.0
  2761. bjnoo2(l) = 0.0
  2762. bjh2o2(l) = 0.0
  2763. bjch3ooh(l) = 0.0
  2764. bjpan(l) = 0.0
  2765. bjald2(l) = 0.0
  2766. bjch3cocho(l) = 0.0
  2767. bjch3ono2(l) = 0.0
  2768. bjo2(l) = 0.0
  2769. end do
  2770. !==============================================================================================
  2771. ! re-initialize the temporary arrays for the next layer
  2772. !===============================================================================================
  2773. delta1 = 0. ; delta2 = 0. ;delta3 = 0. ; delta4 = 0. ; delta5 = 0. ; delta6 = 0. ; delta7 = 0.
  2774. delta1_spec = 0. ; delta3_spec = 0.
  2775. ! =====================================================================================
  2776. ! Tropo band 1
  2777. ! =====================================================================================
  2778. ! temp indep species for this band: no2,h2o2,n2o5,hno4,ch2o,ch3ooh,ald2,orgntr
  2779. do l = band_start(1),band_end(1)
  2780. bjo1d(1) = bjo1d(1) + cst_o3_col(k,l)*qy_o1d_col(k,l)*fdir(k,l)
  2781. bjno2(1) = bjno2(1) + cst_no2_col(k,l)*qy_no2_col(k,l)*fdir(k,l)
  2782. bjh2o2(1) = bjh2o2(1) + cs_h2o2(l)*fdir(k,l)
  2783. bjhno3(1) = bjhno3(1) + cst_hno3_col(k,l)*fdir(k,l)
  2784. bjhno4(1) = bjhno4(1) + cs_hno4(l)*fdir(k,l)
  2785. bjn2o5(1) = bjn2o5(1) + 0.8*cs_n2o5(l)*fdir(k,l)
  2786. bjchoh(1) = bjchoh(1) + cs_ch2o(l)*qyh_hco(l)*fdir(k,l)
  2787. bjch3ooh(1) = bjch3ooh(1) + cs_ch3ooh(l)*fdir(k,l)
  2788. bjald2(1) = bjald2(1) + cs_ald2(l)*fdir(k,l)
  2789. bjpan(1) = bjpan(1) + cst_pan_col(k,l)*fdir(k,l)
  2790. bjch3ono2(1) = bjch3ono2(1) + cs_orgn(l) * fdir(k,l)
  2791. bjo2(1) = bjo2(1) + cs_o2(l) * fdir(k,l)
  2792. end do
  2793. ! =====================================================================================
  2794. ! Tropo band 2
  2795. ! =====================================================================================
  2796. ! temp indep species for this band: hno4,ch3ooh,ald2,orgntr
  2797. do l = band_start(2),band_end(2) ! temp indep for : no2,hno4,ch2o,ch3ooh,orgntr
  2798. bjo1d(2) = bjo1d(2) + cst_o3_col(k,l)*qy_o1d_col(k,l)*fdir(k,l)
  2799. bjno2(2) = bjno2(2) + cst_no2_col(k,l)*qy_no2_col(k,l)*fdir(k,l)
  2800. bjh2o2(2) = bjh2o2(2) + cst_h2o2_col(k,l-17)*fdir(k,l)
  2801. bjhno3(2) = bjhno3(2) + cst_hno3_col(k,l)*fdir(k,l)
  2802. bjhno4(2) = bjhno4(2) + cs_hno4(l)*fdir(k,l)
  2803. bjn2o5(2) = bjn2o5(2) + 0.8*cst_n2o5_col(k,l-17)*fdir(k,l)
  2804. bjcoh2(2) = bjcoh2(2) + cst_ch2o_col(k,l-17)*qyh2_co(l)*fdir(k,l)
  2805. bjchoh(2) = bjchoh(2) + cst_ch2o_col(k,l-17)*qyh_hco(l)*fdir(k,l)
  2806. bjch3ooh(2) = bjch3ooh(2) + cs_ch3ooh(l)*fdir(k,l)
  2807. bjpan(2) = bjpan(2) + cst_pan_col(k,l)*fdir(k,l)
  2808. bjald2(2) = bjald2(2) + cs_ald2(l)* fdir(k,l)
  2809. bjch3cocho(2) = bjch3cocho(2) + cs_ch3cocho(l)*fdir(k,l)
  2810. bjch3ono2(2) = bjch3ono2(2) + cs_orgn(l) * fdir(k,l)
  2811. end do
  2812. ! =======================================================================================
  2813. ! Tropo band 3
  2814. ! =======================================================================================
  2815. ! temp indep species for this band: hno4,ch3ooh,ald2,mgly,orgntr
  2816. do l = band_start(3),band_end(3)
  2817. bjo1d(3) = bjo1d(3) + cst_o3_col(k,l)*qy_o1d_col(k,l)*fdir(k,l)
  2818. bjno2(3) = bjno2(3) + cst_no2_col(k,l)*qy_no2_col(k,l)*fdir(k,l)
  2819. bjh2o2(3) = bjh2o2(3) + cst_h2o2_col(k,l-17)*fdir(k,l)
  2820. bjhno3(3) = bjhno3(3) + cst_hno3_col(k,l)*fdir(k,l)
  2821. bjhno4(3) = bjhno4(3) + cs_hno4(l)*fdir(k,l)
  2822. bjn2o5(3) = bjn2o5(3) + 0.8*cst_n2o5_col(k,l-17)*fdir(k,l)
  2823. bjcoh2(3) = bjcoh2(3) + cst_ch2o_col(k,l-17)*qyh2_co(l)*fdir(k,l)
  2824. bjchoh(3) = bjchoh(3) + cst_ch2o_col(k,l-17)*qyh_hco(l)*fdir(k,l)
  2825. bjch3ooh(3) = bjch3ooh(3) + cs_ch3ooh(l)*fdir(k,l)
  2826. bjpan(3) = bjpan(3) + cst_pan_col(k,l)*fdir(k,l)
  2827. bjald2(3) = bjald2(3) + cs_ald2(l)*fdir(k,l)
  2828. bjch3cocho(3) = bjch3cocho(3) + cs_ch3cocho(l)*fdir(k,l)
  2829. bjch3ono2(3) = bjch3ono2(3) + cs_orgn(l)*fdir(k,l)
  2830. end do
  2831. ! ================================================================================
  2832. ! Tropo band 4
  2833. ! ================================================================================
  2834. ! temp indep species for this band: hno4,ch3ooh,ald2,orgntr
  2835. do l = band_start(4),band_end(4)
  2836. bjo1d(4) = bjo1d(4)+cst_o3_col(k,l)*qy_o1d_col(k,l)*fdir(k,l)
  2837. bjno2(4) = bjno2(4) + cst_no2_col(k,l)*qy_no2_col(k,l)*fdir(k,l)
  2838. bjh2o2(4) = bjh2o2(4) + cst_h2o2_col(k,l-17)*fdir(k,l)
  2839. bjhno3(4) = bjhno3(4) + cst_hno3_col(k,l)*fdir(k,l)
  2840. bjhno4(4) = bjhno4(4) + cs_hno4(l)*fdir(k,l)
  2841. bjn2o5(4) = bjn2o5(4) + cst_n2o5_col(k,l-17)*fdir(k,l)
  2842. bjcoh2(4) = bjcoh2(4) + cst_ch2o_col(k,l-17)*qyh2_co(l)*fdir(k,l)
  2843. bjchoh(4) = bjchoh(4) + cst_ch2o_col(k,l-17)*qyh_hco(l)*fdir(k,l)
  2844. bjch3ooh(4) = bjch3ooh(4) + cs_ch3ooh(l)*fdir(k,l)
  2845. bjpan(4) = bjpan(4) + cst_pan_col(k,l)*fdir(k,l)
  2846. bjald2(4) = bjald2(4) + cs_ald2(l)*fdir(k,l)
  2847. bjch3cocho(4) = bjch3cocho(4) + cs_ch3cocho(l)*qy_ch3cocho_col(k,l-37)*fdir(k,l)
  2848. bjch3ono2(4) = bjch3ono2(4) + cs_orgn(l)*fdir(k,l)
  2849. end do
  2850. ! ========================================================================================
  2851. ! Tropo band 5
  2852. ! ========================================================================================
  2853. ! temp indep species for this band: hno4,ch3ooh,ald2,orgntr
  2854. do l = band_start(5),band_end(5)
  2855. bjo1d(5) = bjo1d(5)+cst_o3_col(k,l)*qy_o1d_col(k,l)*fdir(k,l)
  2856. bjno2(5) = bjno2(5)+cst_no2_col(k,l)*qy_no2_col(k,l)*fdir(k,l)
  2857. bjh2o2(5) = bjh2o2(5)+cst_h2o2_col(k,l-17)*fdir(k,l)
  2858. bjhno3(5) = bjhno3(5)+cst_hno3_col(k,l)*fdir(k,l)
  2859. bjhno4(5) = bjhno4(5)+cs_hno4(l)*fdir(k,l)
  2860. bjn2o5(5) = bjn2o5(5)+cst_n2o5_col(k,l-17)*fdir(k,l)
  2861. bjcoh2(5) = bjcoh2(5)+cst_ch2o_col(k,l-17)*qyh2_co(l)*fdir(k,l)
  2862. bjchoh(5) = bjchoh(5)+cst_ch2o_col(k,l-17)*qyh_hco(l)*fdir(k,l)
  2863. bjch3ooh(5) = bjch3ooh(5)+cs_ch3ooh(l)*fdir(k,l)
  2864. bjpan(5) = bjpan(5)+cst_pan_col(k,l)*fdir(k,l)
  2865. bjald2(5) = bjald2(5)+cs_ald2(l)* fdir(k,l)
  2866. bjch3cocho(5) = bjch3cocho(5)+cs_ch3cocho(l)*qy_ch3cocho_col(k,l-37)*fdir(k,l)
  2867. bjch3ono2(5) = bjch3ono2(5)+cs_orgn(l)*fdir(k,l)
  2868. end do
  2869. !=========================================================================================
  2870. ! Tropo band 6
  2871. !=========================================================================================
  2872. do l = band_start(6),band_end(6)
  2873. bjno2(6) = bjno2(6) +cst_no2_col(k,l)*qy_no2_col(k,l)*fdir(k,l)
  2874. bjcoh2(6) = bjcoh2(6)+cst_ch2o_col(k,l-17)*qyh2_co(l)*fdir(k,l)
  2875. bjch3ooh(6) = bjch3ooh(6)+cs_ch3ooh(l)*fdir(k,l)
  2876. bjno2o(6) = bjno2o(6)+cst_no3_col(k,l-60)*qyno2_o(l-60)*fdir(k,l)
  2877. bjch3cocho(6) = bjch3cocho(6)+cs_ch3cocho(l)*qy_ch3cocho_col(k,l-37)*fdir(k,l)
  2878. end do
  2879. ! Add the contribution from band 6 separately for H2O2, N2O5 and HNO3 for high angle grid to allow reducion in cst arrays
  2880. ! This has been tested using a box model to ensure that no errors are introduced compared to using main array
  2881. if(zangle>71.) then
  2882. bjh2o2(6) = bjh2o2(6)+cst_h2o2_col(k,44)*fdir(k,61)
  2883. bjh2o2(6) = bjh2o2(6)+cst_h2o2_col(k,45)*fdir(k,62)
  2884. do c=63,68
  2885. bjn2o5(6) = bjn2o5(6)+cst_n2o5_col(k,c-17)*fdir(k,c)
  2886. enddo
  2887. bjhno3(6) = bjhno3(6)+cst_hno3_col(k,63)*fdir(k,63)
  2888. bjpan(6) = 0.
  2889. elseif(zangle<=71.) then
  2890. do c=61,63
  2891. bjhno3(6) = bjhno3(6)+cst_hno3_col(k,c)*fdir(k,c)
  2892. enddo
  2893. do c=61,69
  2894. bjn2o5(6) = bjn2o5(6)+cst_n2o5_col(k,c-17)*fdir(k,c)
  2895. enddo
  2896. do c=61,62
  2897. bjpan(6) = bjpan(6)+cst_pan_col(k,c)*fdir(k,c)
  2898. enddo
  2899. endif
  2900. !========================================================================================
  2901. ! Tropo band 7
  2902. !=========================================================================================
  2903. do l = band_start(7),band_end(7)-2
  2904. bjno2o(7) = bjno2o(7)+cst_no3_col(k,l-60)*qyno2_o(l-60)*fdir(k,l)
  2905. bjnoo2(7) = bjnoo2(7)+cst_no3_col(k,l-60)*qyno_o2(l-60)*fdir(k,l)
  2906. end do
  2907. ! only set a scaling ratio for the first band once the sza > 71.
  2908. ! only calculate limits to bands 2 and 4 for high sza
  2909. if(zangle<=71.) then
  2910. delta1 = fact(k,1)/fdir(k,band_middle(1))
  2911. delta2 = fact(k,2)/fdir(k,band_middle(2))
  2912. delta3 = fact(k,3)/fdir(k,band_middle(3))
  2913. delta4 = fact(k,4)/fdir(k,band_middle(4))
  2914. delta5 = fact(k,5)/fdir(k,band_middle(5))
  2915. delta6 = fact(k,6)/fdir(k,band_middle(6))
  2916. delta7 = fact(k,7)/fdir(k,band_middle(7))
  2917. elseif(zangle>71. .and. zangle<=sza_limit) then
  2918. delta1 = safe_div( fact(k,1), fdir(k,band_middle(1)), huge(1.))
  2919. delta2 = safe_div( fact(k,2), fdir(k,band_middle(2)), huge(1.))
  2920. delta3 = safe_div( fact(k,3), fdir(k,band_middle(3)), huge(1.))
  2921. delta4 = safe_div( fact(k,4), fdir(k,band_middle(4)), huge(1.))
  2922. delta5 = safe_div( fact(k,5), fdir(k,band_middle(5)), huge(1.))
  2923. delta6 = safe_div( fact(k,6), fdir(k,band_middle(6)), huge(1.))
  2924. delta7 = safe_div( fact(k,7), fdir(k,band_middle(7)), huge(1.))
  2925. if(fdir(k,band_middle(1))>5.e9) delta1_spec = fact(k,1)/fdir(k,band_middle(1))
  2926. if(fdir(k,band_middle(3))>1.e9) delta3_spec = fact(k,3)/fdir(k,band_middle(3))
  2927. endif
  2928. ! ============================================================
  2929. ! CALCULATION PHOTOLYSIS RATES FOR SCATTERING ATMOSPHERE
  2930. ! ============================================================
  2931. ! O2 -> O3P
  2932. rj(k,jo2) = bjo2(1)*delta1
  2933. ! O3 -> 2OH
  2934. rj(k,jo3d) = bjo1d(1)*delta1 + bjo1d(2)*delta2 &
  2935. + bjo1d(3)*delta3 + bjo1d(4)*delta4 &
  2936. + bjo1d(5)*delta5
  2937. ! NO2 -> O3
  2938. rj(k,jno2) = bjno2(1)*delta1 + bjno2(2)*delta2 + &
  2939. bjno2(3)*delta3 + bjno2(4)*delta4 + &
  2940. bjno2(5)*delta5 + bjno2(6)*delta6
  2941. ! HNO3 -> OH + NO2
  2942. rj(k,jhno3) = bjhno3(1)*delta1 + bjhno3(2)*delta2 + &
  2943. bjhno3(3)*delta3 + bjhno3(4)*delta4 + &
  2944. bjhno3(5)*delta5 + bjhno3(6)*delta6
  2945. ! HNO4 -> HO2 + NO2
  2946. rj(k,jhno4) = bjhno4(1)*delta1 + bjhno4(2)*delta2 + &
  2947. bjhno4(3)*delta3 + bjhno4(4)*delta4 + &
  2948. bjhno4(5)*delta5
  2949. ! N2O5 -> NO2 + NO2
  2950. rj(k,jn2o5) = bjn2o5(1)*delta1 + bjn2o5(2)*delta2 + &
  2951. bjn2o5(3)*delta3 + bjn2o5(4)*delta4 + &
  2952. bjn2o5(5)*delta5 + bjn2o5(6)*delta6
  2953. ! PAN (QY = 1) -> NO2 + C2O3
  2954. rj(k,jpan) = bjpan(1)*delta1 + bjpan(2)*delta2 + &
  2955. bjpan(3)*delta3 + bjpan(4)*delta4 + &
  2956. bjpan(5)*delta5 + bjpan(6)*delta6
  2957. ! CH2O -> CO
  2958. rj(k,jach2o) = bjcoh2(2)*delta2 + bjcoh2(3)*delta3 &
  2959. + bjcoh2(4)*delta4 + bjcoh2(5)*delta5 &
  2960. + bjcoh2(6)*delta6
  2961. ! CH2O -> COH + H
  2962. rj(k,jbch2o) = bjchoh(1)*delta1 + bjchoh(2)*delta2 &
  2963. + bjchoh(3)*delta3 + bjchoh(4)*delta4 &
  2964. + bjchoh(5)*delta5 + bjchoh(6)*delta6
  2965. ! H2O2 -> 2OH
  2966. rj(k,jh2o2) = bjh2o2(1)*delta1 + bjh2o2(2)*delta2 &
  2967. + bjh2o2(3)*delta3 + bjh2o2(4)*delta4 &
  2968. + bjh2o2(5)*delta5 + bjh2o2(6)*delta6
  2969. ! NO3 -> NO2 + O
  2970. rj(k,jano3) = bjno2o(6)*delta6 + bjno2o(7)*delta7
  2971. ! NO3 -> NO
  2972. rj(k,jbno3) = bjnoo2(7)*delta7
  2973. ! CH3OOH -> HCHO + HO2 + OH
  2974. rj(k,jmepe) = bjch3ooh(1)*delta1 + bjch3ooh(2)*delta2 + &
  2975. bjch3ooh(3)*delta3 + bjch3ooh(4)*delta4 + &
  2976. bjch3ooh(5)*delta5 + bjch3ooh(6)*delta6
  2977. ! ALD2 -> HCHO + XO2 + CO + 2HO2
  2978. rj(k,j45) = bjald2(1)*delta1 + bjald2(2)*delta2 &
  2979. + bjald2(3)*delta3 + bjald2(4)*delta4 &
  2980. + bjald2(5)*delta5
  2981. ! CH3ONO2 -> HO2 + NO2
  2982. rj(k,jorgn) = bjch3ono2(1)*delta1 + bjch3ono2(2)*delta2 + &
  2983. bjch3ono2(3)*delta3 + bjch3ono2(4)*delta4 + &
  2984. bjch3ono2(5)*delta5
  2985. ! CH3COCHO -> C2O3 + HO2 + CO
  2986. rj(k,j74) = bjch3cocho(2)*delta2 + bjch3cocho(3)*delta3 + &
  2987. bjch3cocho(4)*delta4 + bjch3cocho(5)*delta5 + &
  2988. bjch3cocho(6)*delta6 + bjch3cocho(7)*delta7
  2989. if(zangle>80. .and. zangle<=85.) then
  2990. rj(k,jo3d) = 0. ; rj(k,jhno3) = 0. ; rj(k,jhno4) = 0. ; rj(k,jn2o5) = 0.
  2991. rj(k,jh2o2) = 0. ; rj(k,jach2o) = 0. ; rj(k,jbch2o) = 0.
  2992. rj(k,jpan) = 0. ; rj(k,j45) = 0. ; rj(k,jorgn) = 0. ; rj(k,j74) = 0. ; rj(k,jo2) = 0.
  2993. ! O2 -> 2O3P
  2994. rj(k,jo2) = bjo2(1)*delta1_spec
  2995. ! O3 -> O(1D) + O2
  2996. rj(k,jo3d) = bjo1d(1)*delta1_spec + bjo1d(2)*delta2 + &
  2997. bjo1d(3)*delta3_spec + bjo1d(4)*delta4 + &
  2998. bjo1d(5)*delta5
  2999. ! HNO3 -> OH + NO2
  3000. rj(k,jhno3) = bjhno3(1)*delta1_spec + bjhno3(2)*delta2 + &
  3001. bjhno3(3)*delta3_spec + bjhno3(4)*delta4 + &
  3002. bjhno3(5)*delta5 + bjhno3(6)*delta6
  3003. ! N2O5 -> NO2 + NO2
  3004. rj(k,jn2o5) = bjn2o5(1)*delta1_spec + bjn2o5(2)*delta2 + &
  3005. bjn2o5(3)*delta3_spec + bjn2o5(4)*delta4 + &
  3006. bjn2o5(5)*delta5 + bjn2o5(6)*delta6
  3007. ! PAN (QY = 1)
  3008. rj(k,jpan) = bjpan(1)*delta1_spec + bjpan(2)*delta2 + &
  3009. bjpan(3)*delta3_spec + bjpan(4)*delta4 + &
  3010. bjpan(5)*delta5 + bjpan(6)*delta6
  3011. ! ORGNTR -> HO2 + NO2
  3012. rj(k,jorgn) = bjch3ono2(1)*delta1_spec + bjch3ono2(2)*delta2 + &
  3013. bjch3ono2(3)*delta3_spec + bjch3ono2(4)*delta4 + &
  3014. bjch3ono2(5)*delta5
  3015. ! ALD2 -> HCHO + XO2 + CO + 2HO2
  3016. rj(k,j45) = bjald2(1)*delta1_spec + bjald2(2)*delta2 + &
  3017. bjald2(3)*delta3_spec + bjald2(4)*delta4 + &
  3018. bjald2(5)*delta5
  3019. ! NO2 -> O3
  3020. rj(k,jno2) = bjno2(1)*delta1_spec + bjno2(2)*delta2 + &
  3021. bjno2(3)*delta3_spec + bjno2(4)*delta4 + &
  3022. bjno2(5)*delta5 + bjno2(6)*delta6
  3023. ! CH2O -> CO
  3024. rj(k,jach2o) = bjcoh2(2)*delta2 + bjcoh2(3)*delta3_spec + &
  3025. bjcoh2(4)*delta4 + bjcoh2(5)*delta5 + &
  3026. bjcoh2(6)*delta6
  3027. ! CH2O -> COH + H
  3028. rj(k,jbch2o) = bjchoh(1)*delta1_spec + bjchoh(2)*delta2 + &
  3029. bjchoh(3)*delta3_spec + bjchoh(4)*delta4 + &
  3030. bjchoh(5)*delta5 + bjchoh(6)*delta6
  3031. rj(k,jhno4) = bjhno4(1)*delta1_spec + bjhno4(2)*delta2 + &
  3032. bjhno4(3)*delta3_spec + bjhno4(4)*delta4 + &
  3033. bjhno4(5)*delta5
  3034. ! H2O2 -> 2OH
  3035. rj(k,jh2o2) = bjh2o2(1)*delta1_spec + bjh2o2(2)*delta2 + &
  3036. bjh2o2(3)*delta3_spec + bjh2o2(4)*delta4 + &
  3037. bjh2o2(5)*delta5 + bjh2o2(6)*delta6
  3038. ! CH3OOH -> HCHO + HO2 + OH
  3039. rj(k,jmepe) = bjch3ooh(1)*delta1_spec + bjch3ooh(2)*delta2 + &
  3040. bjch3ooh(3)*delta3_spec + bjch3ooh(4)*delta4 + &
  3041. bjch3ooh(5)*delta5 + bjch3ooh(6)*delta6
  3042. ! CH3COCHO -> C2O3 + HO2 + CO
  3043. rj(k,j74) = bjch3cocho(2)*delta2 + bjch3cocho(3)*delta3_spec + &
  3044. bjch3cocho(4)*delta4 + bjch3cocho(5)*delta5 + &
  3045. bjch3cocho(6)*delta6 + bjch3cocho(7)*delta7
  3046. endif ! sza > 80.
  3047. rj(k,jrooh) = rj(k,jmepe)
  3048. enddo ! layers
  3049. END SUBROUTINE PHOTORATES_TROPO
  3050. !EOC
  3051. !------------------------------------------------------------------------------
  3052. ! TM5 !
  3053. !------------------------------------------------------------------------------
  3054. !BOP
  3055. !
  3056. ! !IROUTINE: PHOTOLYSIS_DONE
  3057. !
  3058. ! !DESCRIPTION: Deallocates photolysis data, and writes photolysis statistics:
  3059. ! output (e.g. monthly) averaged photolysis jo3, jno2 and
  3060. ! surface data of: albedo, cloud-cover, cloud optical thickness
  3061. ! total ozone
  3062. !\\
  3063. !\\
  3064. ! !INTERFACE:
  3065. !
  3066. SUBROUTINE PHOTOLYSIS_DONE( status )
  3067. !
  3068. ! !USES:
  3069. !
  3070. use dims, only : region_name, im, jm, lm
  3071. use dims, only : idatei, idatee
  3072. use global_data, only : outdir
  3073. use file_hdf, only : THdfFile, TSds
  3074. use file_hdf, only : Init, Done, WriteAttribute, Init, Done, WriteData
  3075. use partools, only : isRoot
  3076. !
  3077. ! !OUTPUT PARAMETERS:
  3078. !
  3079. integer, intent(out) :: status
  3080. !
  3081. ! !REVISION HISTORY:
  3082. ! 21 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  3083. !
  3084. ! !REMARKS:
  3085. ! (1) Called from SOURCES_SINKS/TRACE_END
  3086. !
  3087. !EOP
  3088. !------------------------------------------------------------------------------
  3089. !BOC
  3090. character(len=*), parameter :: rname = mname//'/end_photolysis'
  3091. integer :: n
  3092. integer :: k,iret,imr,jmr,lmr
  3093. integer :: region
  3094. real, allocatable :: average_field(:,:,:), average_field_2d(:,:), average_field_5d(:,:,:,:,:)
  3095. type(THdfFile) :: io
  3096. type(TSds) :: sds
  3097. character(len=256) :: fname
  3098. ! --- begin --------------------------------
  3099. if (isRoot) then
  3100. write (fname,'(a,"/j_statistics_",i4.4,3i2.2,"_",i4.4,3i2.2,".hdf")') &
  3101. trim(outdir), idatei(1:4), idatee(1:4)
  3102. call Init(io,fname,'create',status)
  3103. IF_ERROR_RETURN(status=1)
  3104. end if
  3105. REG: do region=1,nregions
  3106. if(isRoot) then
  3107. imr=im(region)
  3108. jmr=jm(region)
  3109. lmr=lm(region)
  3110. else
  3111. imr=1; jmr=1; lmr=1
  3112. end if
  3113. allocate(average_field(imr,jmr,lmr))
  3114. ! Assume that the nav is the same on all proc
  3115. write (gol,*) 'end_photolysis: j_statistics ', &
  3116. '(region, nj_av, nvo3s_av, ncloud_av)', region, &
  3117. phot_dat(region)%nj_av, phot_dat(region)%nvo3s_av; call goPr
  3118. !---- 3D fields
  3119. if ( phot_dat(region)%nj_av > 0 ) then
  3120. call gather(dgrid(region), phot_dat(region)%jo3_av, average_field, 0, status)
  3121. if ( isRoot ) then
  3122. average_field = average_field/phot_dat(region)%nj_av
  3123. call Init(Sds,io,'jo3_av',(/imr,jmr,lmr/),'real(4)',status)
  3124. IF_ERROR_RETURN(status=1)
  3125. call WriteAttribute(Sds,'Unit','1/s',status)
  3126. IF_ERROR_RETURN(status=1)
  3127. call WriteData(Sds,average_field,status)
  3128. IF_ERROR_RETURN(status=1)
  3129. call Done(Sds,status)
  3130. IF_ERROR_RETURN(status=1)
  3131. end if
  3132. call gather(dgrid(region), phot_dat(region)%jno2_av, average_field, 0, status)
  3133. if ( isRoot ) then
  3134. average_field = average_field/phot_dat(region)%nj_av
  3135. call Init(Sds,io,'jno2_av',(/imr,jmr,lmr/),'real(4)',status)
  3136. IF_ERROR_RETURN(status=1)
  3137. call WriteAttribute(Sds,'Unit','1/s',status)
  3138. IF_ERROR_RETURN(status=1)
  3139. call WriteData(Sds,average_field,status)
  3140. IF_ERROR_RETURN(status=1)
  3141. call Done(Sds,status)
  3142. IF_ERROR_RETURN(status=1)
  3143. end if
  3144. call gather(dgrid(region), phot_dat(region)%reff_av, average_field, 0, status)
  3145. if ( isRoot ) then
  3146. call Init(Sds,io,'reff_av',(/imr,jmr,lmr/),'real(4)',status)
  3147. IF_ERROR_RETURN(status=1)
  3148. call WriteAttribute(Sds,'Unit','um',status)
  3149. IF_ERROR_RETURN(status=1)
  3150. call WriteData(Sds,average_field,status)
  3151. IF_ERROR_RETURN(status=1)
  3152. call Done(Sds,status)
  3153. IF_ERROR_RETURN(status=1)
  3154. end if
  3155. call gather(dgrid(region), phot_dat(region)%lwp_av, average_field, 0, status)
  3156. if ( isRoot ) then
  3157. call Init(Sds,io,'lwp_av',(/imr,jmr,lmr/),'real(4)',status)
  3158. IF_ERROR_RETURN(status=1)
  3159. call WriteAttribute(Sds,'Unit','g/m2',status)
  3160. IF_ERROR_RETURN(status=1)
  3161. call WriteData(Sds,average_field,status)
  3162. IF_ERROR_RETURN(status=1)
  3163. call Done(Sds,status)
  3164. IF_ERROR_RETURN(status=1)
  3165. end if
  3166. end if
  3167. ! ---- 2D fields
  3168. if ( phot_dat(region)%nalb_av > 0 ) then
  3169. allocate(average_field_2d(imr,jmr))
  3170. call gather(dgrid(region), phot_dat(region)%ags_av, average_field_2d, 0, status)
  3171. if(isRoot) then
  3172. average_field_2d = average_field_2d / phot_dat(region)%nalb_av
  3173. call Init(Sds,io,'ags_av',(/imr,jmr/),'real(4)',status)
  3174. IF_ERROR_RETURN(status=1)
  3175. call WriteAttribute(Sds,'Unit','Fraction',status)
  3176. IF_ERROR_RETURN(status=1)
  3177. call WriteData(Sds,average_field_2d,status)
  3178. IF_ERROR_RETURN(status=1)
  3179. call Done(Sds,status)
  3180. IF_ERROR_RETURN(status=1)
  3181. end if
  3182. call gather(dgrid(region), phot_dat(region)%sza_av, average_field_2d, 0, status)
  3183. if ( isRoot ) then
  3184. average_field_2d = average_field_2d / phot_dat(region)%nalb_av
  3185. call Init(Sds,io,'sza_av',(/imr,jmr/),'real(4)',status)
  3186. IF_ERROR_RETURN(status=1)
  3187. call WriteAttribute(Sds,'Unit','Zenith Angle',status)
  3188. IF_ERROR_RETURN(status=1)
  3189. call WriteData(Sds,average_field_2d,status)
  3190. IF_ERROR_RETURN(status=1)
  3191. call Done(Sds,status)
  3192. IF_ERROR_RETURN(status=1)
  3193. end if
  3194. deallocate(average_field_2d)
  3195. end if ! any 2D field
  3196. ! Clouds data (3D)
  3197. if ( phot_dat(region)%ncloud_av > 0 ) then
  3198. call gather(dgrid(region), phot_dat(region)%pmcld_av, average_field, 0, status)
  3199. if ( isRoot ) then
  3200. average_field = average_field/phot_dat(region)%ncloud_av
  3201. call Init(Sds,io,'pmcld_av',(/imr,jmr,lmr/),'real(4)',status)
  3202. IF_ERROR_RETURN(status=1)
  3203. call WriteAttribute(Sds,'Unit',' ',status)
  3204. IF_ERROR_RETURN(status=1)
  3205. call WriteData(Sds,average_field,status)
  3206. IF_ERROR_RETURN(status=1)
  3207. call Done(Sds,status)
  3208. IF_ERROR_RETURN(status=1)
  3209. endif
  3210. call gather(dgrid(region), phot_dat(region)%taus_cld_av, average_field, 0, status)
  3211. if ( isRoot ) then
  3212. average_field = average_field/phot_dat(region)%ncloud_av
  3213. call Init(Sds,io,'taus_cld_av',(/imr,jmr,lmr/),'real(4)',status)
  3214. IF_ERROR_RETURN(status=1)
  3215. call WriteAttribute(Sds,'Unit',' ',status)
  3216. IF_ERROR_RETURN(status=1)
  3217. call WriteData(Sds,average_field,status)
  3218. IF_ERROR_RETURN(status=1)
  3219. call Done(Sds,status)
  3220. IF_ERROR_RETURN(status=1)
  3221. end if
  3222. call gather(dgrid(region), phot_dat(region)%taua_cld_av, average_field, 0, status)
  3223. if ( isRoot ) then
  3224. average_field = average_field/phot_dat(region)%ncloud_av
  3225. call Init(Sds,io,'taua_cld_av',(/imr,jmr,lmr/),'real(4)',status)
  3226. IF_ERROR_RETURN(status=1)
  3227. call WriteAttribute(Sds,'Unit',' ',status)
  3228. IF_ERROR_RETURN(status=1)
  3229. call WriteData(Sds,average_field,status)
  3230. IF_ERROR_RETURN(status=1)
  3231. call Done(Sds,status)
  3232. IF_ERROR_RETURN(status=1)
  3233. end if
  3234. end if
  3235. ! Aerosols info (5D)
  3236. if ( phot_dat(region)%naer_av > 0 ) then
  3237. allocate(average_field_5d(imr,jmr,lmr,nbands_trop,ngrid))
  3238. call gather(dgrid(region), phot_dat(region)%pmaer_av, average_field_5d, 0, status)
  3239. if ( isRoot ) then
  3240. average_field_5d = average_field_5d/phot_dat(region)%naer_av
  3241. call Init(Sds,io,'pmaer_av',(/imr,jmr,lmr,nbands_trop,ngrid/),'real(4)',status)
  3242. IF_ERROR_RETURN(status=1)
  3243. call WriteAttribute(Sds,'Unit',' ',status)
  3244. IF_ERROR_RETURN(status=1)
  3245. call WriteData(Sds,average_field_5d,status)
  3246. IF_ERROR_RETURN(status=1)
  3247. call Done(Sds,status)
  3248. IF_ERROR_RETURN(status=1)
  3249. end if
  3250. call gather(dgrid(region), phot_dat(region)%taus_aer_av, average_field_5d, 0, status)
  3251. if ( isRoot ) then
  3252. average_field_5d = average_field_5d/phot_dat(region)%naer_av
  3253. call Init(Sds,io,'taus_aer_av',(/imr,jmr,lmr,nbands_trop,ngrid/),'real(4)',status)
  3254. IF_ERROR_RETURN(status=1)
  3255. call WriteAttribute(Sds,'Unit',' ',status)
  3256. IF_ERROR_RETURN(status=1)
  3257. call WriteData(Sds,average_field_5d,status)
  3258. IF_ERROR_RETURN(status=1)
  3259. call Done(Sds,status)
  3260. IF_ERROR_RETURN(status=1)
  3261. end if
  3262. call gather(dgrid(region), phot_dat(region)%taua_aer_av, average_field_5d, 0, status)
  3263. if ( isRoot ) then
  3264. average_field_5d = average_field_5d/phot_dat(region)%naer_av
  3265. call Init(Sds,io,'taua_aer_av',(/imr,jmr,lmr,nbands_trop,ngrid/),'real(4)',status)
  3266. IF_ERROR_RETURN(status=1)
  3267. call WriteAttribute(Sds,'Unit',' ',status)
  3268. IF_ERROR_RETURN(status=1)
  3269. call WriteData(Sds,average_field_5d,status)
  3270. IF_ERROR_RETURN(status=1)
  3271. call Done(Sds,status)
  3272. IF_ERROR_RETURN(status=1)
  3273. end if
  3274. deallocate(average_field_5d)
  3275. end if
  3276. if ( phot_dat(region)%nsad_av >0 ) then
  3277. call gather(dgrid(region), phot_dat(region)%sad_cld_av, average_field, 0, status)
  3278. if ( isRoot ) then
  3279. average_field = average_field/phot_dat(region)%nsad_av
  3280. call Init(Sds,io,'sad_cld',(/imr,jmr,lmr/),'real(4)',status)
  3281. IF_ERROR_RETURN(status=1)
  3282. call WriteAttribute(Sds,'Unit','cm^2/cm^3 ',status)
  3283. call WriteAttribute(Sds,'long_name','average water cloud surface area density',status)
  3284. IF_ERROR_RETURN(status=1)
  3285. call WriteData(Sds,average_field,status)
  3286. IF_ERROR_RETURN(status=1)
  3287. call Done(Sds,status)
  3288. IF_ERROR_RETURN(status=1)
  3289. endif
  3290. call gather(dgrid(region), phot_dat(region)%sad_ice_av, average_field, 0, status)
  3291. if ( isRoot ) then
  3292. average_field = average_field/phot_dat(region)%nsad_av
  3293. call Init(Sds,io,'sad_ice',(/imr,jmr,lmr/),'real(4)',status)
  3294. IF_ERROR_RETURN(status=1)
  3295. call WriteAttribute(Sds,'Unit','cm^2/cm^3 ',status)
  3296. call WriteAttribute(Sds,'long_name','average ice cloud surface area density',status)
  3297. IF_ERROR_RETURN(status=1)
  3298. call WriteData(Sds,average_field,status)
  3299. IF_ERROR_RETURN(status=1)
  3300. call Done(Sds,status)
  3301. IF_ERROR_RETURN(status=1)
  3302. endif
  3303. call gather(dgrid(region), phot_dat(region)%sad_aer_av, average_field, 0, status)
  3304. if ( isRoot ) then
  3305. average_field = average_field/phot_dat(region)%nsad_av
  3306. call Init(Sds,io,'sad_aer',(/imr,jmr,lmr/),'real(4)',status)
  3307. IF_ERROR_RETURN(status=1)
  3308. call WriteAttribute(Sds,'Unit','cm^2/cm^3 ',status)
  3309. call WriteAttribute(Sds,'long_name','average aerosol surface area density',status)
  3310. IF_ERROR_RETURN(status=1)
  3311. call WriteData(Sds,average_field,status)
  3312. IF_ERROR_RETURN(status=1)
  3313. call Done(Sds,status)
  3314. IF_ERROR_RETURN(status=1)
  3315. endif
  3316. end if
  3317. deallocate(average_field)
  3318. end do REG
  3319. if ( isRoot ) then
  3320. call Done(io, status)
  3321. IF_ERROR_RETURN(status=1)
  3322. endif
  3323. do region = 1,nregions
  3324. if (associated( phot_dat(region)%o3klim_top)) deallocate(phot_dat(region)%o3klim_top )
  3325. deallocate(phot_dat(region)%albedo )
  3326. deallocate(phot_dat(region)%ags_av )
  3327. deallocate(phot_dat(region)%sza_av )
  3328. deallocate(phot_dat(region)%lwp_av )
  3329. deallocate(phot_dat(region)%cfr_av )
  3330. deallocate(phot_dat(region)%reff_av )
  3331. deallocate(phot_dat(region)%aero_surface_clim)
  3332. deallocate(phot_dat(region)%cloud_reff )
  3333. deallocate(phot_dat(region)%pmcld )
  3334. deallocate(phot_dat(region)%taus_cld )
  3335. deallocate(phot_dat(region)%taua_cld )
  3336. deallocate(phot_dat(region)%pmaer )
  3337. deallocate(phot_dat(region)%taus_aer )
  3338. deallocate(phot_dat(region)%taua_aer )
  3339. deallocate(phot_dat(region)%pmcld_av )
  3340. deallocate(phot_dat(region)%taus_cld_av)
  3341. deallocate(phot_dat(region)%taua_cld_av)
  3342. deallocate(phot_dat(region)%pmaer_av )
  3343. deallocate(phot_dat(region)%taus_aer_av)
  3344. deallocate(phot_dat(region)%taua_aer_av)
  3345. deallocate(phot_dat(region)%jo3 )
  3346. deallocate(phot_dat(region)%jno2 )
  3347. deallocate(phot_dat(region)%jo3_av )
  3348. deallocate(phot_dat(region)%jno2_av )
  3349. deallocate(phot_dat(region)%v2 )
  3350. deallocate(phot_dat(region)%v3 )
  3351. deallocate(phot_dat(region)%v3_surf )
  3352. deallocate(phot_dat(region)%qy_ch3cocho)
  3353. deallocate(phot_dat(region)%sad_cld )
  3354. deallocate(phot_dat(region)%sad_ice )
  3355. deallocate(phot_dat(region)%sad_aer )
  3356. deallocate(phot_dat(region)%sad_cld_av )
  3357. deallocate(phot_dat(region)%sad_ice_av )
  3358. deallocate(phot_dat(region)%sad_aer_av )
  3359. end do
  3360. #ifdef with_optics
  3361. deallocate( wdep ) !NB optics_done
  3362. #endif
  3363. ! ok
  3364. status = 0
  3365. END SUBROUTINE PHOTOLYSIS_DONE
  3366. !EOC
  3367. END MODULE PHOTOLYSIS