photolysis.F90 179 KB

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