XIOS_user_guide.lyx 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449
  1. #LyX 2.1 created this file. For more info see http://www.lyx.org/
  2. \lyxformat 474
  3. \begin_document
  4. \begin_header
  5. \textclass book
  6. \begin_preamble
  7. \usepackage{MnSymbol}
  8. \end_preamble
  9. \use_default_options true
  10. \begin_modules
  11. logicalmkup
  12. \end_modules
  13. \maintain_unincluded_children false
  14. \language english
  15. \language_package default
  16. \inputencoding auto
  17. \fontencoding global
  18. \font_roman default
  19. \font_sans default
  20. \font_typewriter default
  21. \font_math auto
  22. \font_default_family default
  23. \use_non_tex_fonts false
  24. \font_sc false
  25. \font_osf false
  26. \font_sf_scale 100
  27. \font_tt_scale 100
  28. \graphics default
  29. \default_output_format default
  30. \output_sync 0
  31. \bibtex_command default
  32. \index_command default
  33. \paperfontsize default
  34. \spacing single
  35. \use_hyperref false
  36. \papersize a4paper
  37. \use_geometry false
  38. \use_package amsmath 1
  39. \use_package amssymb 1
  40. \use_package cancel 1
  41. \use_package esint 1
  42. \use_package mathdots 1
  43. \use_package mathtools 1
  44. \use_package mhchem 1
  45. \use_package stackrel 1
  46. \use_package stmaryrd 1
  47. \use_package undertilde 1
  48. \cite_engine basic
  49. \cite_engine_type default
  50. \biblio_style plain
  51. \use_bibtopic false
  52. \use_indices false
  53. \paperorientation portrait
  54. \suppress_date false
  55. \justification true
  56. \use_refstyle 0
  57. \index Index
  58. \shortcut idx
  59. \color #008000
  60. \end_index
  61. \secnumdepth 3
  62. \tocdepth 3
  63. \paragraph_separation indent
  64. \paragraph_indentation default
  65. \quotes_language english
  66. \papercolumns 1
  67. \papersides 1
  68. \paperpagestyle default
  69. \tracking_changes false
  70. \output_changes false
  71. \html_math_output 0
  72. \html_css_as_file 0
  73. \html_be_strict false
  74. \end_header
  75. \begin_body
  76. \begin_layout Title
  77. XIOS User Guide
  78. \end_layout
  79. \begin_layout Author
  80. Draft
  81. \end_layout
  82. \begin_layout Chapter
  83. Calendar
  84. \end_layout
  85. \begin_layout Section
  86. How to define a calendar
  87. \end_layout
  88. \begin_layout Standard
  89. XIOS has an embedded calendar module which needs to be configured before
  90. you can run your simulation.
  91. \begin_inset Newline newline
  92. \end_inset
  93. \begin_inset Newline newline
  94. \end_inset
  95. Only the calendar type and the time step used by your simulation are mandatory
  96. to have a well defined calendar.
  97. For example, a minimal calendar definition could be:
  98. \end_layout
  99. \begin_layout Itemize
  100. from the XML configuration file:
  101. \begin_inset Newline newline
  102. \end_inset
  103. \begin_inset listings
  104. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  105. inline false
  106. status open
  107. \begin_layout Plain Layout
  108. <?xml version="1.0"?>
  109. \end_layout
  110. \begin_layout Plain Layout
  111. <simulation>
  112. \end_layout
  113. \begin_layout Plain Layout
  114. <context id="test">
  115. \end_layout
  116. \begin_layout Plain Layout
  117. <calendar type="Gregorian" timestep="1.5h" />
  118. \end_layout
  119. \begin_layout Plain Layout
  120. </context>
  121. \end_layout
  122. \begin_layout Plain Layout
  123. </simulation>
  124. \end_layout
  125. \end_inset
  126. \end_layout
  127. \begin_layout Itemize
  128. from the Fortran interface:
  129. \begin_inset Newline newline
  130. \end_inset
  131. \begin_inset listings
  132. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  133. inline false
  134. status open
  135. \begin_layout Plain Layout
  136. ! ...
  137. \end_layout
  138. \begin_layout Plain Layout
  139. TYPE(xios_context) :: ctx_hdl
  140. \end_layout
  141. \begin_layout Plain Layout
  142. ! ...
  143. \end_layout
  144. \begin_layout Plain Layout
  145. ! Context initialization ommited, see the corresponding section of this
  146. user manual and of the reference manual
  147. \end_layout
  148. \begin_layout Plain Layout
  149. CALL xios_get_handle("test",ctx_hdl)
  150. \end_layout
  151. \begin_layout Plain Layout
  152. CALL xios_set_current_context(ctx_hdl)
  153. \end_layout
  154. \begin_layout Plain Layout
  155. CALL xios_define_calendar(type="Gregorian", timestep=1.5*xios_hour)
  156. \end_layout
  157. \end_inset
  158. \end_layout
  159. \begin_layout Standard
  160. The calendar type definition is done once and for all, either from the XML
  161. configuration file or the Fortran interface, and cannot be modified.
  162. However there is no such restriction regarding the time step which can
  163. be defined at a different time than the calendar type and even redefined
  164. multiple times.
  165. \begin_inset Newline newline
  166. \end_inset
  167. \begin_inset Newline newline
  168. \end_inset
  169. For example, it is possible to the achieve the same minimal configuration
  170. as above by using both the XML configuration file:
  171. \end_layout
  172. \begin_layout Standard
  173. \begin_inset listings
  174. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  175. inline false
  176. status open
  177. \begin_layout Plain Layout
  178. <?xml version="1.0"?>
  179. \end_layout
  180. \begin_layout Plain Layout
  181. <simulation>
  182. \end_layout
  183. \begin_layout Plain Layout
  184. <context id="test">
  185. \end_layout
  186. \begin_layout Plain Layout
  187. <calendar type="Gregorian" />
  188. \end_layout
  189. \begin_layout Plain Layout
  190. </context>
  191. \end_layout
  192. \begin_layout Plain Layout
  193. </simulation>
  194. \end_layout
  195. \end_inset
  196. and the Fortran interface:
  197. \end_layout
  198. \begin_layout Standard
  199. \begin_inset listings
  200. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  201. inline false
  202. status open
  203. \begin_layout Plain Layout
  204. ! ...
  205. \end_layout
  206. \begin_layout Plain Layout
  207. TYPE(xios_context) :: ctx_hdl
  208. \end_layout
  209. \begin_layout Plain Layout
  210. ! ...
  211. \end_layout
  212. \begin_layout Plain Layout
  213. ! Context initialization ommited, see the corresponding section of this
  214. user manual and of the reference manual
  215. \end_layout
  216. \begin_layout Plain Layout
  217. CALL xios_get_handle("test",ctx_hdl)
  218. \end_layout
  219. \begin_layout Plain Layout
  220. CALL xios_set_current_context(ctx_hdl)
  221. \end_layout
  222. \begin_layout Plain Layout
  223. ! xios_define_calendar cannot be used here because the type was already
  224. defined in the configuration file.
  225. \end_layout
  226. \begin_layout Plain Layout
  227. ! Ommiting the following line would lead to an error because the timestep
  228. would be undefined.
  229. \end_layout
  230. \begin_layout Plain Layout
  231. CALL xios_set_timestep(timestep=1.5*xios_hour)
  232. \end_layout
  233. \end_inset
  234. The calendar also has two optional date parameters:
  235. \end_layout
  236. \begin_layout Itemize
  237. the start date which corresponds to the beginning of the simulation
  238. \end_layout
  239. \begin_layout Itemize
  240. the time origin which corresponds to the origin of the time axis.
  241. \end_layout
  242. \begin_layout Standard
  243. If they are undefined, those parameters are set by default to
  244. \begin_inset Quotes eld
  245. \end_inset
  246. \series bold
  247. \emph on
  248. 0000-01-01 00:00:00
  249. \series default
  250. \emph default
  251. \begin_inset Quotes erd
  252. \end_inset
  253. .
  254. If you are not interested in specific dates, you can ignore those parameters
  255. completely.
  256. However if you wish to set them, please note that they must not be set
  257. before the calendar is defined.
  258. Thus the following XML configuration file would be for example invalid:
  259. \end_layout
  260. \begin_layout Standard
  261. \begin_inset listings
  262. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  263. inline false
  264. status open
  265. \begin_layout Plain Layout
  266. <?xml version="1.0"?>
  267. \end_layout
  268. \begin_layout Plain Layout
  269. <simulation>
  270. \end_layout
  271. \begin_layout Plain Layout
  272. <context id="test">
  273. \end_layout
  274. \begin_layout Plain Layout
  275. <!-- Invalid because the calendar type cannot be known at that point -->
  276. \end_layout
  277. \begin_layout Plain Layout
  278. <calendar start_date="2011-11-11 13:37:42" />
  279. \end_layout
  280. \begin_layout Plain Layout
  281. </context>
  282. \end_layout
  283. \begin_layout Plain Layout
  284. </simulation>
  285. \end_layout
  286. \end_inset
  287. while the following configuration file would be valid:
  288. \end_layout
  289. \begin_layout Standard
  290. \begin_inset listings
  291. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  292. inline false
  293. status open
  294. \begin_layout Plain Layout
  295. <?xml version="1.0"?>
  296. \end_layout
  297. \begin_layout Plain Layout
  298. <simulation>
  299. \end_layout
  300. \begin_layout Plain Layout
  301. <context id="test">
  302. \end_layout
  303. \begin_layout Plain Layout
  304. <!-- The order of the arguments does not matter so this is valid -->
  305. \end_layout
  306. \begin_layout Plain Layout
  307. <calendar time_origin="2011-11-11 13:37:42" type="Gregorian" />
  308. \end_layout
  309. \begin_layout Plain Layout
  310. </context>
  311. \end_layout
  312. \begin_layout Plain Layout
  313. </simulation>
  314. \end_layout
  315. \end_inset
  316. Of course, it is always possible to define or redefine those parameters
  317. from the Fortran interface, directly when defining the calendar:
  318. \end_layout
  319. \begin_layout Standard
  320. \begin_inset listings
  321. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  322. inline false
  323. status open
  324. \begin_layout Plain Layout
  325. ! ...
  326. \end_layout
  327. \begin_layout Plain Layout
  328. TYPE(xios_context) :: ctx_hdl
  329. \end_layout
  330. \begin_layout Plain Layout
  331. ! ...
  332. \end_layout
  333. \begin_layout Plain Layout
  334. ! Context initialization ommited, see the corresponding section of this
  335. user manual and of the reference manual
  336. \end_layout
  337. \begin_layout Plain Layout
  338. CALL xios_get_handle("test",ctx_hdl)
  339. \end_layout
  340. \begin_layout Plain Layout
  341. CALL xios_set_current_context(ctx_hdl)
  342. \end_layout
  343. \begin_layout Plain Layout
  344. CALL xios_define_calendar(type="Gregorian", time_origin=xios_date(1977,
  345. 10, 19, 00, 00, 00), start_date=xios_date(2011, 11, 11, 13, 37, 42))
  346. \end_layout
  347. \end_inset
  348. or at a later time:
  349. \end_layout
  350. \begin_layout Standard
  351. \begin_inset listings
  352. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  353. inline false
  354. status open
  355. \begin_layout Plain Layout
  356. ! ...
  357. \end_layout
  358. \begin_layout Plain Layout
  359. TYPE(xios_context) :: ctx_hdl
  360. \end_layout
  361. \begin_layout Plain Layout
  362. ! ...
  363. \end_layout
  364. \begin_layout Plain Layout
  365. ! Context initialization ommited, see the corresponding section of this
  366. user manual and of the reference manual
  367. \end_layout
  368. \begin_layout Plain Layout
  369. CALL xios_get_handle("test",ctx_hdl)
  370. \end_layout
  371. \begin_layout Plain Layout
  372. CALL xios_set_current_context(ctx_hdl)
  373. \end_layout
  374. \begin_layout Plain Layout
  375. CALL xios_define_calendar(type="Gregorian")
  376. \end_layout
  377. \begin_layout Plain Layout
  378. CALL xios_set_time_origin(time_origin=xios_date(1977, 10, 19, 00, 00, 00))
  379. \end_layout
  380. \begin_layout Plain Layout
  381. CALL xios_set_start_date(start_date=xios_date(2011, 11, 11, 13, 37, 42))
  382. \end_layout
  383. \end_inset
  384. To simplify the use of dates in the XML configuration files, it is possible
  385. to partially define a date as long as the omitted parts are the rightmost.
  386. In this case the remainder of the date is initialized as in the default
  387. date.
  388. For example, it would be valid to write:
  389. \begin_inset Flex Code
  390. status open
  391. \begin_layout Plain Layout
  392. start_date="1977-10-19"
  393. \end_layout
  394. \end_inset
  395. instead of
  396. \begin_inset Flex Code
  397. status open
  398. \begin_layout Plain Layout
  399. start_date="1977-10-19 00:00:00"
  400. \end_layout
  401. \end_inset
  402. or even
  403. \begin_inset Flex Code
  404. status open
  405. \begin_layout Plain Layout
  406. time_origin="1789"
  407. \end_layout
  408. \end_inset
  409. instead of
  410. \begin_inset Flex Code
  411. status open
  412. \begin_layout Plain Layout
  413. time_origin="1789-01-01 00:00:00"
  414. \end_layout
  415. \end_inset
  416. .
  417. Similarly, it is possible to express a date with an optional duration offset
  418. in the configuration file by using the
  419. \begin_inset Flex Code
  420. status open
  421. \begin_layout Plain Layout
  422. date + duration
  423. \end_layout
  424. \end_inset
  425. notation, with
  426. \begin_inset Flex Code
  427. status open
  428. \begin_layout Plain Layout
  429. date
  430. \end_layout
  431. \end_inset
  432. potentially partially defined or even completely omitted.
  433. Consequently the following examples are all valid in the XML configuration
  434. file:
  435. \end_layout
  436. \begin_layout Itemize
  437. \begin_inset Flex Code
  438. status open
  439. \begin_layout Plain Layout
  440. time_origin="2011-11-11 13:37:00 + 42s"
  441. \end_layout
  442. \end_inset
  443. \end_layout
  444. \begin_layout Itemize
  445. \begin_inset Flex Code
  446. status open
  447. \begin_layout Plain Layout
  448. time_origin="2014 + 1y 2d"
  449. \end_layout
  450. \end_inset
  451. \end_layout
  452. \begin_layout Itemize
  453. \begin_inset Flex Code
  454. status open
  455. \begin_layout Plain Layout
  456. start_date="+ 36h"
  457. \end_layout
  458. \end_inset
  459. .
  460. \end_layout
  461. \begin_layout Section
  462. How to define a user defined calendar
  463. \end_layout
  464. \begin_layout Standard
  465. Predefined calendars might not be enough for your needs if you simulate
  466. phenomenons on another planet than the Earth.
  467. For this reason, XIOS can let you configure a completely user defined calendar
  468. by setting the
  469. \series bold
  470. type
  471. \series default
  472. attribute to
  473. \begin_inset Quotes eld
  474. \end_inset
  475. \series bold
  476. \emph on
  477. user_defined
  478. \series default
  479. \emph default
  480. \begin_inset Quotes erd
  481. \end_inset
  482. .
  483. In that case, the calendar type alone is not sufficient to define the calendar
  484. and other parameters should be provided since the duration of a day or
  485. a year are not known in advance.
  486. \begin_inset Newline newline
  487. \end_inset
  488. \begin_inset Newline newline
  489. \end_inset
  490. Two approaches are possible depending on whether you want that your custom
  491. calendar to have months or not: either use the
  492. \series bold
  493. month_lengths
  494. \series default
  495. attribute to define the duration of each months in days or use the
  496. \series bold
  497. year_length
  498. \series default
  499. attribute to define the duration of the year in seconds.
  500. In both cases, you have to define
  501. \series bold
  502. day_length
  503. \series default
  504. , the duration of a day in seconds.
  505. Those attributes have to be defined at the same time than the calendar
  506. type, either from the XML configuration file or the Fortran interface,
  507. for example:
  508. \begin_inset Newline newline
  509. \end_inset
  510. \begin_inset listings
  511. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  512. inline false
  513. status open
  514. \begin_layout Plain Layout
  515. <?xml version="1.0"?>
  516. \end_layout
  517. \begin_layout Plain Layout
  518. <simulation>
  519. \end_layout
  520. \begin_layout Plain Layout
  521. <context id="test">
  522. \end_layout
  523. \begin_layout Plain Layout
  524. <calendar type="user_defined" day_length="86400" month_lengths="(1, 12)
  525. [31 28 31 30 31 30 31 31 30 31 30 31]" />
  526. \end_layout
  527. \begin_layout Plain Layout
  528. </context>
  529. \end_layout
  530. \begin_layout Plain Layout
  531. </simulation>
  532. \end_layout
  533. \end_inset
  534. or
  535. \end_layout
  536. \begin_layout Standard
  537. \begin_inset listings
  538. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  539. inline false
  540. status open
  541. \begin_layout Plain Layout
  542. ! ...
  543. \end_layout
  544. \begin_layout Plain Layout
  545. TYPE(xios_context) :: ctx_hdl
  546. \end_layout
  547. \begin_layout Plain Layout
  548. ! ...
  549. \end_layout
  550. \begin_layout Plain Layout
  551. ! Context initialization ommited, see the corresponding section of this
  552. user manual and of the reference manual
  553. \end_layout
  554. \begin_layout Plain Layout
  555. CALL xios_get_handle("test",ctx_hdl)
  556. \end_layout
  557. \begin_layout Plain Layout
  558. CALL xios_set_current_context(ctx_hdl)
  559. \end_layout
  560. \begin_layout Plain Layout
  561. CALL xios_define_calendar(type="Gregorian", day_length=86400, year_length=315576
  562. 00)
  563. \end_layout
  564. \end_inset
  565. Note that if no months are defined, the format of the dates is modified
  566. in the XML configuration file since the month must be omitted.
  567. For example,
  568. \begin_inset Flex Code
  569. status open
  570. \begin_layout Plain Layout
  571. "2015-71 13:37:42"
  572. \end_layout
  573. \end_inset
  574. would be the correct way to refer to the 71st day of the year 2015 at 13:37:42.
  575. If you use the Fortran interface, the month cannot be omitted but you have
  576. to make sure to always set it to
  577. \begin_inset Flex Code
  578. status open
  579. \begin_layout Plain Layout
  580. 1
  581. \end_layout
  582. \end_inset
  583. in that case.
  584. For example, use
  585. \begin_inset Flex Code
  586. status open
  587. \begin_layout Plain Layout
  588. xios_date(2015, 01, 71, 13, 37, 42)
  589. \end_layout
  590. \end_inset
  591. for
  592. \begin_inset Flex Code
  593. status open
  594. \begin_layout Plain Layout
  595. "2015-71 13:37:42"
  596. \end_layout
  597. \end_inset
  598. .
  599. Moreover, it is possible that the duration of the day is greater than the
  600. duration of the year on some planets.
  601. In this case, it obviously not possible to define months so you have to
  602. use the
  603. \series bold
  604. year_length
  605. \series default
  606. attribute.
  607. Additionally the day must also be omitted from the dates in the configuration
  608. file (for example
  609. \begin_inset Flex Code
  610. status open
  611. \begin_layout Plain Layout
  612. "2015 13:37:42"
  613. \end_layout
  614. \end_inset
  615. ) and must always be set to
  616. \begin_inset Flex Code
  617. status open
  618. \begin_layout Plain Layout
  619. 1
  620. \end_layout
  621. \end_inset
  622. when using the Fortran interface (for example
  623. \begin_inset Flex Code
  624. status open
  625. \begin_layout Plain Layout
  626. xios_date(2015, 01, 01, 13, 37, 42)
  627. \end_layout
  628. \end_inset
  629. ).
  630. \begin_inset Newline newline
  631. \end_inset
  632. \begin_inset Newline newline
  633. \end_inset
  634. If months have been defined, you might want to have leap years to correct
  635. the drift between the calendar year and the astronomical year.
  636. This can be achieved by using the
  637. \series bold
  638. leap_year_drift
  639. \series default
  640. and
  641. \series bold
  642. leap_year_month
  643. \series default
  644. attributes and optionally the
  645. \series bold
  646. leap_year_drift_offset
  647. \series default
  648. attribute.
  649. The idea is to define
  650. \series bold
  651. leap_year_drift
  652. \series default
  653. , the yearly drift between the calendar year and the astronomical year as
  654. a fraction of a day.
  655. This yearly drift is summed each year to know the current drift and each
  656. time the current drift is greater or equal to one day, the year is considered
  657. a leap year.
  658. In that case, an extra day is added to the month defined by
  659. \series bold
  660. leap_year_month
  661. \series default
  662. and one day is subtracted to the current drift.
  663. The initial drift is null by default but it can be fixed by the
  664. \series bold
  665. leap_year_drift_offset
  666. \series default
  667. attribute.
  668. \begin_inset Newline newline
  669. \end_inset
  670. \begin_inset Newline newline
  671. \end_inset
  672. The following configuration file defines a simplified Gregorian calendar
  673. using the user calendar feature:
  674. \end_layout
  675. \begin_layout Standard
  676. \begin_inset listings
  677. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  678. inline false
  679. status open
  680. \begin_layout Plain Layout
  681. <?xml version="1.0"?>
  682. \end_layout
  683. \begin_layout Plain Layout
  684. <simulation>
  685. \end_layout
  686. \begin_layout Plain Layout
  687. <context id="test">
  688. \end_layout
  689. \begin_layout Plain Layout
  690. <calendar type="user_defined"
  691. \end_layout
  692. \begin_layout Plain Layout
  693. day_length="86400"
  694. \end_layout
  695. \begin_layout Plain Layout
  696. month_lengths="(1, 12) [31 28 31 30 31 30 31 31 30 31 30 31]"
  697. \end_layout
  698. \begin_layout Plain Layout
  699. leap_year_month="2"
  700. \end_layout
  701. \begin_layout Plain Layout
  702. leap_year_drift="0.25"
  703. \end_layout
  704. \begin_layout Plain Layout
  705. leap_year_drift_offset="0.75"
  706. \end_layout
  707. \begin_layout Plain Layout
  708. time_origin="2012-02-29 15:00:00"
  709. \end_layout
  710. \begin_layout Plain Layout
  711. start_date="2012-03-01 15:00:00" />
  712. \end_layout
  713. \begin_layout Plain Layout
  714. </context>
  715. \end_layout
  716. \begin_layout Plain Layout
  717. </simulation>
  718. \end_layout
  719. \end_inset
  720. As you know, the astronomical year on Earth is approximately a quarter of
  721. day longer than the Gregorian calendar year so we have to define the yearly
  722. drift as 0.25 day.
  723. In case of a leap year, an extra day is added at the end of February which
  724. is the second month of the year so
  725. \series bold
  726. leap_year_month
  727. \series default
  728. should be set to 2.
  729. We start our time axis in 2012 which was a leap year in the Gregorian calendar.
  730. This means there was previously three non-leap years in a row so the current
  731. drift was (approximately)
  732. \begin_inset Formula $3\times0.25$
  733. \end_inset
  734. days, hence
  735. \series bold
  736. leap_year_drift_offset
  737. \series default
  738. should be set to 0.75.
  739. At the beginning of 2013, the drift would have been
  740. \begin_inset Formula $0.75+0.25=1$
  741. \end_inset
  742. day so 2012 will be a leap year as expected.
  743. \end_layout
  744. \begin_layout Section
  745. How to use the calendar
  746. \end_layout
  747. \begin_layout Standard
  748. The calendar is created immediately after the calendar type has been defined
  749. and thus can be used even before the context definition has been closed.
  750. \begin_inset Newline newline
  751. \end_inset
  752. \begin_inset Newline newline
  753. \end_inset
  754. Once the calendar is created, you have to keep it updated so that it is
  755. in sync with your simulation.
  756. To do that, you have to call the
  757. \series bold
  758. xios_update_calendar
  759. \series default
  760. subroutine for each iteration of your code:
  761. \end_layout
  762. \begin_layout Standard
  763. \begin_inset listings
  764. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  765. inline false
  766. status open
  767. \begin_layout Plain Layout
  768. ! ...
  769. \end_layout
  770. \begin_layout Plain Layout
  771. INTEGER :: ts
  772. \end_layout
  773. \begin_layout Plain Layout
  774. ! ...
  775. \end_layout
  776. \begin_layout Plain Layout
  777. DO ts=1,end
  778. \end_layout
  779. \begin_layout Plain Layout
  780. CALL xios_update_calendar(ts)
  781. \end_layout
  782. \begin_layout Plain Layout
  783. ! Do useful stuff
  784. \end_layout
  785. \begin_layout Plain Layout
  786. ENDDO
  787. \end_layout
  788. \end_inset
  789. The current date is updated to
  790. \begin_inset Formula $start\_date+ts\times timestep$
  791. \end_inset
  792. after each call.
  793. \begin_inset Newline newline
  794. \end_inset
  795. \begin_inset Newline newline
  796. \end_inset
  797. Many other calendar operations are available, including:
  798. \end_layout
  799. \begin_layout Itemize
  800. accessing various calendar related information like the time step, the time
  801. origin, the start date, the duration of a day or a year, the current date,
  802. etc.
  803. \end_layout
  804. \begin_layout Itemize
  805. doing arithmetic and comparison operations on date:
  806. \begin_inset Newline newline
  807. \end_inset
  808. \begin_inset listings
  809. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  810. inline false
  811. status open
  812. \begin_layout Plain Layout
  813. TYPE(xios_date) :: date1, date2
  814. \end_layout
  815. \begin_layout Plain Layout
  816. TYPE(xios_duration) :: duration
  817. \end_layout
  818. \begin_layout Plain Layout
  819. LOGICAL :: res
  820. \end_layout
  821. \begin_layout Plain Layout
  822. ! we suppose a calendar is defined
  823. \end_layout
  824. \begin_layout Plain Layout
  825. CALL xios_get_current_date(date1)
  826. \end_layout
  827. \begin_layout Plain Layout
  828. duration = xios_duration(0, 0, 1, 0, 0, 0, 0, 0) + 12 * xios_hour
  829. \end_layout
  830. \begin_layout Plain Layout
  831. date2 = date1 + duration + 0.5 * xios_hour
  832. \end_layout
  833. \begin_layout Plain Layout
  834. res = date2 > date1
  835. \end_layout
  836. \begin_layout Plain Layout
  837. duration = date2 - date1
  838. \end_layout
  839. \end_inset
  840. \end_layout
  841. \begin_layout Itemize
  842. converting dates to
  843. \end_layout
  844. \begin_deeper
  845. \begin_layout Itemize
  846. the number of seconds since the time origin, the beginning of the year or
  847. the beginning of the day,
  848. \end_layout
  849. \begin_layout Itemize
  850. the number of days since the beginning of the year,
  851. \end_layout
  852. \begin_layout Itemize
  853. the fraction of the day or the year.
  854. \end_layout
  855. \end_deeper
  856. \begin_layout Standard
  857. For more detailed about the calendar attributes and operations, see the
  858. XIOS reference guide.
  859. \end_layout
  860. \begin_layout Chapter
  861. Files
  862. \end_layout
  863. \begin_layout Standard
  864. Since files are central to an I/O server, the configuration of XIOS is built
  865. around file objects.
  866. Those objects correspond directly to files on the computer file system
  867. which are either to be written or to be read.
  868. Although, XIOS currently only supports the NetCDF format, XIOS files are
  869. a generic abstraction.
  870. Each file can contain one or more fields (each field being defined on a
  871. grid) and optionally variables.
  872. In the NetCDF nomenclature, fields defined in XIOS correspond to NetCDF
  873. variables and XIOS variables are NetCDF attributes.
  874. As fields, variables and grids are complex objects, they have their own
  875. chapters and we will focus only on files in this section.
  876. \end_layout
  877. \begin_layout Section
  878. How to define your first file
  879. \end_layout
  880. \begin_layout Standard
  881. If you wish to input or to output data using XIOS, you will need to define
  882. at least one file.
  883. This can be done from both the XML configuration file and the Fortran interface.
  884. Files are usually defined in the configuration file, although their definitions
  885. are sometimes amended using the API.
  886. \begin_inset Newline newline
  887. \end_inset
  888. \begin_inset Newline newline
  889. \end_inset
  890. File objects are defined with the
  891. \begin_inset Flex Code
  892. status open
  893. \begin_layout Plain Layout
  894. <file>
  895. \end_layout
  896. \end_inset
  897. tag and should always be inside the
  898. \begin_inset Flex Code
  899. status open
  900. \begin_layout Plain Layout
  901. <file_definition>
  902. \end_layout
  903. \end_inset
  904. section.
  905. Only the output frequency is mandatory to have a well defined file but
  906. it is generally a good idea to give it a name.
  907. The following example shows a minimal configuration file which defines
  908. one file.
  909. \end_layout
  910. \begin_layout Standard
  911. \begin_inset listings
  912. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  913. inline false
  914. status open
  915. \begin_layout Plain Layout
  916. <?xml version="1.0"?>
  917. \end_layout
  918. \begin_layout Plain Layout
  919. <simulation>
  920. \end_layout
  921. \begin_layout Plain Layout
  922. <context id="test">
  923. \end_layout
  924. \begin_layout Plain Layout
  925. <calendar type="Gregorian" timestep="1h" />
  926. \end_layout
  927. \begin_layout Plain Layout
  928. \end_layout
  929. \begin_layout Plain Layout
  930. <file_definition>
  931. \end_layout
  932. \begin_layout Plain Layout
  933. <file name="output" output_freq="1ts">
  934. \end_layout
  935. \begin_layout Plain Layout
  936. <!-- Content of the file ommited for now -->
  937. \end_layout
  938. \begin_layout Plain Layout
  939. </file>
  940. \end_layout
  941. \begin_layout Plain Layout
  942. </file_definition>
  943. \end_layout
  944. \begin_layout Plain Layout
  945. </context>
  946. \end_layout
  947. \begin_layout Plain Layout
  948. </simulation>
  949. \end_layout
  950. \end_inset
  951. Note that the file extension could depend of the format so it is automatically
  952. added to the chosen name by XIOS.
  953. Since XIOS only support NetCDF formats for now, the extension is always
  954. \begin_inset Quotes eld
  955. \end_inset
  956. .nc
  957. \begin_inset Quotes erd
  958. \end_inset
  959. .
  960. If the name is not set, XIOS will use the id of the file object instead.
  961. This id is generated automatically by XIOS if it was not set by the user.
  962. \begin_inset Newline newline
  963. \end_inset
  964. \begin_inset Newline newline
  965. \end_inset
  966. The output frequency is particularly important since it defines the interval
  967. of time between two consecutive outputs, that is in NetCDF nomenclature
  968. the interval between two records.
  969. In the example, the data would be written for every timestep (independently
  970. of the timestep duration).
  971. It is possible to use any duration as the output frequency but be careful
  972. if you are not using a duration which is a multiple of the timestep duration
  973. since XIOS might not be doing what you want.
  974. \begin_inset Newline newline
  975. \end_inset
  976. \begin_inset Newline newline
  977. \end_inset
  978. The same configuration could be obtained from the Fortran interface as well:
  979. \begin_inset Newline newline
  980. \end_inset
  981. \begin_inset listings
  982. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  983. inline false
  984. status open
  985. \begin_layout Plain Layout
  986. ! ...
  987. \end_layout
  988. \begin_layout Plain Layout
  989. TYPE(xios_context) :: ctx_hdl
  990. \end_layout
  991. \begin_layout Plain Layout
  992. TYPE(xios_file) :: file_hdl
  993. \end_layout
  994. \begin_layout Plain Layout
  995. TYPE(xios_filegroup) :: filegroup_hdl
  996. \end_layout
  997. \begin_layout Plain Layout
  998. ! ...
  999. \end_layout
  1000. \begin_layout Plain Layout
  1001. ! Context and calendar initializations ommited, see the corresponding section
  1002. of this user manual and of the reference manual
  1003. \end_layout
  1004. \begin_layout Plain Layout
  1005. CALL xios_get_handle("test", ctx_hdl)
  1006. \end_layout
  1007. \begin_layout Plain Layout
  1008. CALL xios_set_current_context(ctx_hdl)
  1009. \end_layout
  1010. \begin_layout Plain Layout
  1011. CALL xios_get_filegroup_handle("file_definition", filegroup_hdl)
  1012. \end_layout
  1013. \begin_layout Plain Layout
  1014. CALL xios_add_file(filegroup_hdl, file_hdl)
  1015. \end_layout
  1016. \begin_layout Plain Layout
  1017. CALL xios_set_attr(file_hdl, name="output", output_freq=xios_timestep)
  1018. \end_layout
  1019. \end_inset
  1020. Another important parameter for file is the
  1021. \series bold
  1022. mode
  1023. \series default
  1024. attribute which is set by default to
  1025. \begin_inset Quotes eld
  1026. \end_inset
  1027. \series bold
  1028. \emph on
  1029. write
  1030. \series default
  1031. \emph default
  1032. \begin_inset Quotes erd
  1033. \end_inset
  1034. .
  1035. You need to set it to
  1036. \begin_inset Quotes eld
  1037. \end_inset
  1038. \series bold
  1039. \emph on
  1040. read
  1041. \series default
  1042. \emph default
  1043. \begin_inset Quotes erd
  1044. \end_inset
  1045. if you want to use XIOS to handle inputs.
  1046. Note that in this case the
  1047. \series bold
  1048. output_freq
  1049. \series default
  1050. attribute must correspond to the output frequency used to create the input
  1051. file.
  1052. \begin_inset Newline newline
  1053. \end_inset
  1054. \begin_inset Newline newline
  1055. \end_inset
  1056. When using the
  1057. \begin_inset Quotes eld
  1058. \end_inset
  1059. \series bold
  1060. \emph on
  1061. write
  1062. \series default
  1063. \emph default
  1064. \begin_inset Quotes erd
  1065. \end_inset
  1066. mode, it is possible to append the data to an existing file instead of
  1067. overwriting it by setting the
  1068. \series bold
  1069. append
  1070. \series default
  1071. attribute to
  1072. \begin_inset Quotes eld
  1073. \end_inset
  1074. \series bold
  1075. \emph on
  1076. true
  1077. \series default
  1078. \emph default
  1079. \begin_inset Quotes erd
  1080. \end_inset
  1081. .
  1082. In this case, you must be careful not to modify the structure of the file,
  1083. in particular no fields should be added, modified nor removed, or XIOS
  1084. will throw an error.
  1085. \begin_inset Newline newline
  1086. \end_inset
  1087. \begin_inset Newline newline
  1088. \end_inset
  1089. If you wish to disable a file without having to remove its definition from
  1090. the configuration file, you can set the
  1091. \series bold
  1092. enabled
  1093. \series default
  1094. attribute to
  1095. \begin_inset Quotes eld
  1096. \end_inset
  1097. \series bold
  1098. \emph on
  1099. false
  1100. \series default
  1101. \emph default
  1102. \begin_inset Quotes erd
  1103. \end_inset
  1104. .
  1105. \end_layout
  1106. \begin_layout Section
  1107. How to use parallel I/O
  1108. \end_layout
  1109. \begin_layout Standard
  1110. By default XIOS will create one file by server, each file being suffixed
  1111. with the rank of the server.
  1112. For example, if the sample configuration used in the previous section was
  1113. used with two servers, two files named
  1114. \begin_inset Quotes eld
  1115. \end_inset
  1116. output_0.nc
  1117. \begin_inset Quotes erd
  1118. \end_inset
  1119. and
  1120. \begin_inset Quotes eld
  1121. \end_inset
  1122. output_1.nc
  1123. \begin_inset Quotes erd
  1124. \end_inset
  1125. would be created.
  1126. Each file would contain only the portion of the fields affected to the
  1127. corresponding server.
  1128. This default mode can also be explicitly configured by setting the
  1129. \series bold
  1130. type
  1131. \series default
  1132. attribute to
  1133. \begin_inset Quotes eld
  1134. \end_inset
  1135. \series bold
  1136. \emph on
  1137. multiple_file
  1138. \series default
  1139. \emph default
  1140. \begin_inset Quotes erd
  1141. \end_inset
  1142. .
  1143. \begin_inset Newline newline
  1144. \end_inset
  1145. \begin_inset Newline newline
  1146. \end_inset
  1147. Using the
  1148. \begin_inset Quotes eld
  1149. \end_inset
  1150. \series bold
  1151. \emph on
  1152. multiple_file
  1153. \series default
  1154. \emph default
  1155. \begin_inset Quotes erd
  1156. \end_inset
  1157. mode is often a reliable way to achieve good performances, particularly
  1158. if you only have a few servers.
  1159. However having multiple files also increases the complexity of the post-process
  1160. ing chains and it is often much easier to always get one file regardless
  1161. of how many servers are used.
  1162. \begin_inset Newline newline
  1163. \end_inset
  1164. \begin_inset Newline newline
  1165. \end_inset
  1166. It is possible to achieve such behavior in XIOS by setting the
  1167. \series bold
  1168. type
  1169. \series default
  1170. attribute to
  1171. \begin_inset Quotes eld
  1172. \end_inset
  1173. \series bold
  1174. \emph on
  1175. one_file
  1176. \series default
  1177. \emph default
  1178. \begin_inset Quotes erd
  1179. \end_inset
  1180. .
  1181. This feature depends directly on the NetCDF library capabilities so you
  1182. need to make sure that XIOS was properly linked with a parallel version
  1183. of NetCDF.
  1184. If the library was not compiled with parallel input/output support, XIOS
  1185. will issue a warning and revert to the
  1186. \begin_inset Quotes eld
  1187. \end_inset
  1188. \series bold
  1189. \emph on
  1190. multiple_file
  1191. \series default
  1192. \emph default
  1193. \begin_inset Quotes erd
  1194. \end_inset
  1195. mode.
  1196. \end_layout
  1197. \begin_layout Section
  1198. Supported NetCDF formats
  1199. \end_layout
  1200. \begin_layout Standard
  1201. XIOS supports only the version 4 or later of NetCDF library.
  1202. It uses by default the new NetCDF-4 format which relies on HDF5 format
  1203. as a back-end.
  1204. This format can also be selected explicitly by setting the
  1205. \series bold
  1206. format
  1207. \series default
  1208. attribute to
  1209. \begin_inset Quotes eld
  1210. \end_inset
  1211. \series bold
  1212. \emph on
  1213. netcdf4
  1214. \series default
  1215. \emph default
  1216. \begin_inset Quotes erd
  1217. \end_inset
  1218. .
  1219. \begin_inset Newline newline
  1220. \end_inset
  1221. \begin_inset Newline newline
  1222. \end_inset
  1223. Alternatively, it also possible to force NetCDF-4 to use the classic NetCDF-3
  1224. binary format by setting the
  1225. \series bold
  1226. format
  1227. \series default
  1228. attribute to
  1229. \begin_inset Quotes eld
  1230. \end_inset
  1231. \series bold
  1232. \emph on
  1233. netcdf4_classic
  1234. \series default
  1235. \emph default
  1236. \begin_inset Quotes erd
  1237. \end_inset
  1238. .
  1239. When using this older format, some features might be unavailable but current
  1240. version of XIOS should not be affected much.
  1241. \begin_inset Newline newline
  1242. \end_inset
  1243. \begin_inset Newline newline
  1244. \end_inset
  1245. Depending on the format, there are some specific requirements on how the
  1246. NetCDF library should have been compiled:
  1247. \end_layout
  1248. \begin_layout Itemize
  1249. \begin_inset Quotes eld
  1250. \end_inset
  1251. \series bold
  1252. \emph on
  1253. netcdf4
  1254. \series default
  1255. \emph default
  1256. \begin_inset Quotes erd
  1257. \end_inset
  1258. format requires that HDF5 support has been enabled in NetCDF using the
  1259. configuration option
  1260. \begin_inset Flex Code
  1261. status open
  1262. \begin_layout Plain Layout
  1263. -\SpecialChar \nobreakdash-
  1264. -enable-netcdf4
  1265. \end_layout
  1266. \end_inset
  1267. and that the HDF5 library has been properly linked.
  1268. \end_layout
  1269. \begin_layout Itemize
  1270. \begin_inset Quotes eld
  1271. \end_inset
  1272. \series bold
  1273. \emph on
  1274. netcdf4
  1275. \series default
  1276. \emph default
  1277. \begin_inset Quotes erd
  1278. \end_inset
  1279. format used in
  1280. \begin_inset Quotes eld
  1281. \end_inset
  1282. \series bold
  1283. \emph on
  1284. one_file
  1285. \series default
  1286. \emph default
  1287. \begin_inset Quotes erd
  1288. \end_inset
  1289. mode requires that the HDF5 library has been compiled with parallel support
  1290. using the configuration option
  1291. \begin_inset Flex Code
  1292. status open
  1293. \begin_layout Plain Layout
  1294. -\SpecialChar \nobreakdash-
  1295. -enable-parallel
  1296. \end_layout
  1297. \end_inset
  1298. .
  1299. \end_layout
  1300. \begin_layout Itemize
  1301. \begin_inset Quotes eld
  1302. \end_inset
  1303. \series bold
  1304. \emph on
  1305. netcdf4_classic
  1306. \series default
  1307. \emph default
  1308. \begin_inset Quotes erd
  1309. \end_inset
  1310. format used in
  1311. \begin_inset Quotes eld
  1312. \end_inset
  1313. \series bold
  1314. \emph on
  1315. one_file
  1316. \series default
  1317. \emph default
  1318. \begin_inset Quotes erd
  1319. \end_inset
  1320. mode requires that Parallel NetCDF support has been enabled in NetCDF using
  1321. the configuration option
  1322. \begin_inset Flex Code
  1323. status open
  1324. \begin_layout Plain Layout
  1325. -\SpecialChar \nobreakdash-
  1326. -enable-pnetcdf
  1327. \end_layout
  1328. \end_inset
  1329. and that the Parallel NetCDF library has been properly linked.
  1330. \end_layout
  1331. \begin_layout Section
  1332. UGRID
  1333. \end_layout
  1334. \begin_layout Standard
  1335. In addition to the CF conventions, it is also possible to output data using
  1336. \begin_inset CommandInset href
  1337. LatexCommand href
  1338. name "UGRID"
  1339. target "https://ugrid-conventions.github.io/ugrid-conventions/"
  1340. \end_inset
  1341. metadata conventions developed for unstructured meshes.
  1342. It allows users to store the topology of an underlying unstructured mesh.
  1343. Currently XIOS supports 2D unstructured meshes of any shape (triangular,
  1344. quadrilateral, etc) and their mixture.
  1345. \end_layout
  1346. \begin_layout Standard
  1347. A 2D mesh can be described by a set of nodes, edges and/or faces.
  1348. XIOS allows one to define data on any of these three types of elements.
  1349. XIOS will generate a full list of connectivity attributes proposed by the
  1350. UGRID conventions.
  1351. For example in case of a mesh comprised of faces the following connectivity
  1352. parameters will be the calculated:
  1353. \end_layout
  1354. \begin_layout Standard
  1355. \family typewriter
  1356. edge_node_connectivity
  1357. \end_layout
  1358. \begin_layout Standard
  1359. \family typewriter
  1360. face_node_connectivity
  1361. \end_layout
  1362. \begin_layout Standard
  1363. \family typewriter
  1364. edge_nodes_connectivity
  1365. \end_layout
  1366. \begin_layout Standard
  1367. \family typewriter
  1368. face_nodes_connectivity
  1369. \end_layout
  1370. \begin_layout Standard
  1371. \family typewriter
  1372. face_edges_connectivity
  1373. \end_layout
  1374. \begin_layout Standard
  1375. \family typewriter
  1376. edge_face_connectivity
  1377. \end_layout
  1378. \begin_layout Standard
  1379. \family typewriter
  1380. face_face_connectivity
  1381. \end_layout
  1382. \begin_layout Standard
  1383. In order to select UGRID output format, one has to set file attribute
  1384. \series bold
  1385. convention
  1386. \series default
  1387. to
  1388. \series bold
  1389. \shape italic
  1390. "UGRID"
  1391. \series default
  1392. \shape default
  1393. (its default value is
  1394. \series bold
  1395. \shape italic
  1396. \begin_inset Quotes eld
  1397. \end_inset
  1398. CF
  1399. \begin_inset Quotes erd
  1400. \end_inset
  1401. \series default
  1402. \shape default
  1403. ).
  1404. Domain attribute
  1405. \series bold
  1406. nvertex
  1407. \series default
  1408. is mandatory for UGRID.
  1409. It servers for identifying one of three types of mesh elements on which
  1410. data can be defined: nodes (nvertex=1), edges (nvertex=2), and faces (nvertex
  1411. \begin_inset Formula $\geq$
  1412. \end_inset
  1413. 3).
  1414. In order to write fields on the same mesh but on its different elements,
  1415. one has to assign the same domain name to each of the domains.
  1416. Example given below illustrates this point for three fields defined on
  1417. the same mesh but on its different elements: nodes, edges, and faces.
  1418. \end_layout
  1419. \begin_layout Standard
  1420. \begin_inset listings
  1421. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  1422. inline false
  1423. status open
  1424. \begin_layout Plain Layout
  1425. <file_definition>
  1426. \end_layout
  1427. \begin_layout Plain Layout
  1428. <file id="output_UGRID" convention="UGRID">
  1429. \end_layout
  1430. \begin_layout Plain Layout
  1431. <field id="varOnNodes" ...
  1432. domain_ref="node"/>
  1433. \end_layout
  1434. \begin_layout Plain Layout
  1435. <field id="varOnEdges" ...
  1436. domain_ref="edge"/>
  1437. \end_layout
  1438. \begin_layout Plain Layout
  1439. <field id="varOnFaces" ...
  1440. domain_ref="face"/>
  1441. \end_layout
  1442. \begin_layout Plain Layout
  1443. </file>
  1444. \end_layout
  1445. \begin_layout Plain Layout
  1446. </file_definition>
  1447. \end_layout
  1448. \begin_layout Plain Layout
  1449. \end_layout
  1450. \begin_layout Plain Layout
  1451. <domain_definition>
  1452. \end_layout
  1453. \begin_layout Plain Layout
  1454. <domain id="node" name="mesh2D" nvertex="1"/>
  1455. \end_layout
  1456. \begin_layout Plain Layout
  1457. <domain id="edge" name="mesh2D" nvertex="2"/>
  1458. \end_layout
  1459. \begin_layout Plain Layout
  1460. <domain id="face" name="mesh2D" nvertex="4"/>
  1461. \end_layout
  1462. \begin_layout Plain Layout
  1463. </domain_definition>
  1464. \end_layout
  1465. \end_inset
  1466. \end_layout
  1467. \begin_layout Section
  1468. How to use file splitting
  1469. \end_layout
  1470. \begin_layout Standard
  1471. Output files can often be quite huge, particularly if the
  1472. \begin_inset Quotes eld
  1473. \end_inset
  1474. \series bold
  1475. \emph on
  1476. one_file
  1477. \series default
  1478. \emph default
  1479. \begin_inset Quotes erd
  1480. \end_inset
  1481. mode is used.
  1482. In this case, it can be interesting to periodically split the file in order
  1483. to have a few smaller files containing contiguous temporal portions of
  1484. the output data.
  1485. \begin_inset Newline newline
  1486. \end_inset
  1487. \begin_inset Newline newline
  1488. \end_inset
  1489. This behavior can be achieved in XIOS by setting the
  1490. \series bold
  1491. split_freq
  1492. \series default
  1493. attribute to the duration you want, as illustrated in the following example:
  1494. \begin_inset Newline newline
  1495. \end_inset
  1496. \begin_inset listings
  1497. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  1498. inline false
  1499. status open
  1500. \begin_layout Plain Layout
  1501. <?xml version="1.0"?>
  1502. \end_layout
  1503. \begin_layout Plain Layout
  1504. <simulation>
  1505. \end_layout
  1506. \begin_layout Plain Layout
  1507. <context id="test">
  1508. \end_layout
  1509. \begin_layout Plain Layout
  1510. <calendar type="Gregorian" timestep="1h" />
  1511. \end_layout
  1512. \begin_layout Plain Layout
  1513. \end_layout
  1514. \begin_layout Plain Layout
  1515. <file_definition>
  1516. \end_layout
  1517. \begin_layout Plain Layout
  1518. <file name="output" output_freq="1d" split_freq="1y">
  1519. \end_layout
  1520. \begin_layout Plain Layout
  1521. <!-- Content of the file ommited for now -->
  1522. \end_layout
  1523. \begin_layout Plain Layout
  1524. </file>
  1525. \end_layout
  1526. \begin_layout Plain Layout
  1527. </file_definition>
  1528. \end_layout
  1529. \begin_layout Plain Layout
  1530. </context>
  1531. \end_layout
  1532. \begin_layout Plain Layout
  1533. </simulation>
  1534. \end_layout
  1535. \end_inset
  1536. With this configuration, some data will be outputted every day and a new
  1537. file will be created every year.
  1538. \begin_inset Newline newline
  1539. \end_inset
  1540. \begin_inset Newline newline
  1541. \end_inset
  1542. Note that the split frequency is the duration after which a new file will
  1543. be created, it does not mean that a new file will be created at the beginning
  1544. of each period.
  1545. For example, if you start your simulation the first of June 2014 and run
  1546. it for two years with a split frequency of one year:
  1547. \end_layout
  1548. \begin_layout Itemize
  1549. you will get two files containing respectively the period from June 1st,
  1550. 2014 to May 31th, 2015 and from June 1st, 2015 to May 31th, 2016.
  1551. \end_layout
  1552. \begin_layout Itemize
  1553. you will NOT get three files containing respectively the last six months
  1554. of 2014, the full year of 2015 and the first six months of 2016.
  1555. \end_layout
  1556. \begin_layout Standard
  1557. XIOS automatically suffixes the file names with the start and end dates
  1558. when using file splitting.
  1559. By default, it will try to use the shortest date that still enables to
  1560. distinguish the files.
  1561. Thus in the above example, the files would be named
  1562. \begin_inset Quotes eld
  1563. \end_inset
  1564. output_2014-2015.nc
  1565. \begin_inset Quotes erd
  1566. \end_inset
  1567. and
  1568. \begin_inset Quotes eld
  1569. \end_inset
  1570. output_2015-2016.nc
  1571. \begin_inset Quotes erd
  1572. \end_inset
  1573. .
  1574. If you wish to force the date format used to prefix the files, you can
  1575. define the
  1576. \series bold
  1577. split_freq_format
  1578. \series default
  1579. attribute to override the default behavior.
  1580. \end_layout
  1581. \begin_layout Section
  1582. A word about file synchronization
  1583. \end_layout
  1584. \begin_layout Standard
  1585. File synchronization is usually not something you should worry about.
  1586. However, it is important to understand that data written by XIOS might
  1587. not be immediately written on the disk in practice.
  1588. Input/output libraries like NetCDF and HDF5 and parallel file systems generally
  1589. use complex caching policies for performance reasons.
  1590. This means that your data might still be stored in memory after it was
  1591. supposedly written.
  1592. \begin_inset Newline newline
  1593. \end_inset
  1594. \begin_inset Newline newline
  1595. \end_inset
  1596. It might become critical to control this behavior for two main reasons:
  1597. \end_layout
  1598. \begin_layout Itemize
  1599. if you want to mitigate the impact of a crash, as all buffered data would
  1600. be lost ;
  1601. \end_layout
  1602. \begin_layout Itemize
  1603. if you want to be able to access the data from the output file immediately
  1604. after writing it.
  1605. \end_layout
  1606. \begin_layout Standard
  1607. By default, XIOS will never force file synchronization but you can require
  1608. it to do so by setting the
  1609. \series bold
  1610. sync_freq
  1611. \series default
  1612. attribute to the wanted duration.
  1613. In this case, XIOS will regularly instruct NetCDF to synchronize the file
  1614. on disk by flushing its internal buffers.
  1615. \begin_inset Newline newline
  1616. \end_inset
  1617. \begin_inset Newline newline
  1618. \end_inset
  1619. Note file synchronization must be used sparingly as it can have a disastrous
  1620. impact on performance.
  1621. Make sure to use a reasonably high synchronization frequency to avoid any
  1622. issue.
  1623. \end_layout
  1624. \begin_layout Chapter
  1625. Fields and variables
  1626. \end_layout
  1627. \begin_layout Standard
  1628. XIOS outsources the input/output definitions in its XML configuration file.
  1629. In the last chapter we presented some general points about file objects.
  1630. This chapter focuses on how to use fields and variables (that is variables
  1631. and attributes in NetCDF nomenclature) to populate files.
  1632. \begin_inset Newline newline
  1633. \end_inset
  1634. \end_layout
  1635. \begin_layout Section
  1636. How to define your first field
  1637. \end_layout
  1638. \begin_layout Standard
  1639. If you wish to input or to output data using XIOS, you will need to define
  1640. at least one file with one field.
  1641. This can be done from both the XML configuration file and the Fortran interface.
  1642. Fields are often defined in the configuration file, although their definitions
  1643. are sometimes amended using the API.
  1644. \begin_inset Newline newline
  1645. \end_inset
  1646. \begin_inset Newline newline
  1647. \end_inset
  1648. Field objects are defined with the
  1649. \begin_inset Flex Code
  1650. status open
  1651. \begin_layout Plain Layout
  1652. <field>
  1653. \end_layout
  1654. \end_inset
  1655. tag and should always be inside a
  1656. \begin_inset Flex Code
  1657. status open
  1658. \begin_layout Plain Layout
  1659. <field_definition>
  1660. \end_layout
  1661. \end_inset
  1662. or a
  1663. \begin_inset Flex Code
  1664. status open
  1665. \begin_layout Plain Layout
  1666. <file>
  1667. \end_layout
  1668. \end_inset
  1669. section.
  1670. Only the grid and the operation attached to the field are mandatory to
  1671. have a well defined field but it is generally a good idea to give it an
  1672. identifier.
  1673. The following example shows a minimal configuration file which defines
  1674. one file with one field.
  1675. \end_layout
  1676. \begin_layout Standard
  1677. \begin_inset listings
  1678. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  1679. inline false
  1680. status open
  1681. \begin_layout Plain Layout
  1682. <?xml version="1.0"?>
  1683. \end_layout
  1684. \begin_layout Plain Layout
  1685. <simulation>
  1686. \end_layout
  1687. \begin_layout Plain Layout
  1688. <context id="test">
  1689. \end_layout
  1690. \begin_layout Plain Layout
  1691. <calendar type="Gregorian" timestep="1h" />
  1692. \end_layout
  1693. \begin_layout Plain Layout
  1694. \end_layout
  1695. \begin_layout Plain Layout
  1696. <grid_definition>
  1697. \end_layout
  1698. \begin_layout Plain Layout
  1699. <grid id="grid_A"><!-- Definition ommited --></grid>
  1700. \end_layout
  1701. \begin_layout Plain Layout
  1702. </grid_definition>
  1703. \end_layout
  1704. \begin_layout Plain Layout
  1705. \end_layout
  1706. \begin_layout Plain Layout
  1707. <file_definition>
  1708. \end_layout
  1709. \begin_layout Plain Layout
  1710. <file name="output" type="one_file" output_freq="1ts">
  1711. \end_layout
  1712. \begin_layout Plain Layout
  1713. <field id="field_A" grid_ref="grid_A" operation="instant" />
  1714. \end_layout
  1715. \begin_layout Plain Layout
  1716. </file>
  1717. \end_layout
  1718. \begin_layout Plain Layout
  1719. </file_definition>
  1720. \end_layout
  1721. \begin_layout Plain Layout
  1722. </context>
  1723. \end_layout
  1724. \begin_layout Plain Layout
  1725. </simulation>
  1726. \end_layout
  1727. \end_inset
  1728. It defines one file named
  1729. \begin_inset Quotes eld
  1730. \end_inset
  1731. \emph on
  1732. output
  1733. \emph default
  1734. \begin_inset Quotes erd
  1735. \end_inset
  1736. which contains one field
  1737. \begin_inset Quotes eld
  1738. \end_inset
  1739. \emph on
  1740. field_A
  1741. \emph default
  1742. \begin_inset Quotes erd
  1743. \end_inset
  1744. defined on a grid
  1745. \begin_inset Quotes eld
  1746. \end_inset
  1747. \emph on
  1748. grid_A
  1749. \emph default
  1750. \begin_inset Quotes erd
  1751. \end_inset
  1752. .
  1753. The file and the field are configured so that the data is written in the
  1754. file at every timestep (using the
  1755. \series bold
  1756. output_freq
  1757. \series default
  1758. file attribute) without any transformation (using the
  1759. \series bold
  1760. operation
  1761. \series default
  1762. field attribute set to
  1763. \begin_inset Quotes eld
  1764. \end_inset
  1765. \series bold
  1766. \emph on
  1767. instant
  1768. \series default
  1769. \emph default
  1770. \begin_inset Quotes erd
  1771. \end_inset
  1772. ).
  1773. \begin_inset Newline newline
  1774. \end_inset
  1775. \begin_inset Newline newline
  1776. \end_inset
  1777. The corresponding Fortran simulation loop could be:
  1778. \end_layout
  1779. \begin_layout Standard
  1780. \begin_inset listings
  1781. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  1782. inline false
  1783. status open
  1784. \begin_layout Plain Layout
  1785. DO ts=1,numberOfTimestep
  1786. \end_layout
  1787. \begin_layout Plain Layout
  1788. ! Inform XIOS of the current timestep
  1789. \end_layout
  1790. \begin_layout Plain Layout
  1791. CALL xios_update_calendar(ts)
  1792. \end_layout
  1793. \begin_layout Plain Layout
  1794. ! Compute field_A for current timestep
  1795. \end_layout
  1796. \begin_layout Plain Layout
  1797. ! ...
  1798. \end_layout
  1799. \begin_layout Plain Layout
  1800. ! Output the data
  1801. \end_layout
  1802. \begin_layout Plain Layout
  1803. CALL xios_send_field("field_A", field_A)
  1804. \end_layout
  1805. \begin_layout Plain Layout
  1806. ENDDO
  1807. \end_layout
  1808. \end_inset
  1809. As you can see, the
  1810. \series bold
  1811. id
  1812. \series default
  1813. of the field is used in the model to select the field for which data is
  1814. being provided which makes this attribute extremely important.
  1815. Note that it must be unique for all fields even if they are defined in
  1816. different files.
  1817. By default, the
  1818. \series bold
  1819. id
  1820. \series default
  1821. of a field is also used as the name of the corresponding NetCDF variable.
  1822. It is however possible to override this default name using the field attribute
  1823. \series bold
  1824. name
  1825. \series default
  1826. .
  1827. Two fields can share the same
  1828. \series bold
  1829. name
  1830. \series default
  1831. as long as they are not used in the same file.
  1832. \begin_inset Newline newline
  1833. \end_inset
  1834. \begin_inset Newline newline
  1835. \end_inset
  1836. The second argument of the
  1837. \begin_inset Flex Code
  1838. status open
  1839. \begin_layout Plain Layout
  1840. xios_send_field
  1841. \end_layout
  1842. \end_inset
  1843. function is an array containing the data.
  1844. Its shape and content are not described here as they depend directly on
  1845. the grid.
  1846. For more information on the data layout, refer to the chapters focusing
  1847. on grids, domains and axis.
  1848. \begin_inset Newline newline
  1849. \end_inset
  1850. \begin_inset Newline newline
  1851. \end_inset
  1852. The same configuration could also be obtained using the Fortran interface:
  1853. \end_layout
  1854. \begin_layout Standard
  1855. \begin_inset listings
  1856. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  1857. inline false
  1858. status open
  1859. \begin_layout Plain Layout
  1860. ! ...
  1861. \end_layout
  1862. \begin_layout Plain Layout
  1863. TYPE(xios_context) :: ctx_hdl
  1864. \end_layout
  1865. \begin_layout Plain Layout
  1866. TYPE(xios_file) :: file_hdl
  1867. \end_layout
  1868. \begin_layout Plain Layout
  1869. TYPE(xios_filegroup) :: filegroup_hdl
  1870. \end_layout
  1871. \begin_layout Plain Layout
  1872. TYPE(xios_field) :: field_hdl
  1873. \end_layout
  1874. \begin_layout Plain Layout
  1875. ! ...
  1876. \end_layout
  1877. \begin_layout Plain Layout
  1878. ! Context, calendar and grid initializations ommited, see the corresponding
  1879. section of this user manual and of the reference manual
  1880. \end_layout
  1881. \begin_layout Plain Layout
  1882. CALL xios_get_handle("test", ctx_hdl)
  1883. \end_layout
  1884. \begin_layout Plain Layout
  1885. CALL xios_set_current_context(ctx_hdl)
  1886. \end_layout
  1887. \begin_layout Plain Layout
  1888. CALL xios_get_filegroup_handle("file_definition", filegroup_hdl)
  1889. \end_layout
  1890. \begin_layout Plain Layout
  1891. CALL xios_add_file(filegroup_hdl, file_hdl)
  1892. \end_layout
  1893. \begin_layout Plain Layout
  1894. CALL xios_set_attr(file_hdl, name="output", output_freq=xios_timestep)
  1895. \end_layout
  1896. \begin_layout Plain Layout
  1897. CALL xios_add_field(file_hdl, field_hdl, "field_A")
  1898. \end_layout
  1899. \begin_layout Plain Layout
  1900. CALL xios_set_attr(field_hdl, grid_ref="grid_A", operation="instant")
  1901. \end_layout
  1902. \end_inset
  1903. Note that if you want to define a field on a grid with only one domain and/or
  1904. one axis, it is possible to use the
  1905. \series bold
  1906. domain_ref
  1907. \series default
  1908. and
  1909. \series bold
  1910. axis_ref
  1911. \series default
  1912. attributes instead of the
  1913. \series bold
  1914. grid_ref
  1915. \series default
  1916. attribute.
  1917. A temporary grid will be created based on the domain and/or axis defined
  1918. this way.
  1919. \begin_inset Newline newline
  1920. \end_inset
  1921. \begin_inset Newline newline
  1922. \end_inset
  1923. If you are using a grid with some masked points (see the relevant sections
  1924. of this manual), you must set the
  1925. \series bold
  1926. default_value
  1927. \series default
  1928. attribute to define the default value that will replace the missing values
  1929. in the output file.
  1930. \begin_inset Newline newline
  1931. \end_inset
  1932. \begin_inset Newline newline
  1933. \end_inset
  1934. If you wish to disable a field without having to remove its definition from
  1935. the configuration file, you can set the
  1936. \series bold
  1937. enabled
  1938. \series default
  1939. attribute to
  1940. \begin_inset Quotes eld
  1941. \end_inset
  1942. \series bold
  1943. \emph on
  1944. false
  1945. \series default
  1946. \emph default
  1947. \begin_inset Quotes erd
  1948. \end_inset
  1949. .
  1950. \end_layout
  1951. \begin_layout Section
  1952. How to use temporal operations
  1953. \end_layout
  1954. \begin_layout Standard
  1955. The last section showed a very basic example where the data was outputted
  1956. at every timestep using the
  1957. \begin_inset Quotes eld
  1958. \end_inset
  1959. \series bold
  1960. \emph on
  1961. instant
  1962. \series default
  1963. \emph default
  1964. \begin_inset Quotes erd
  1965. \end_inset
  1966. \series bold
  1967. operation
  1968. \series default
  1969. .
  1970. However in many use cases, it might be more interesting to output only
  1971. the mean value on a certain period of time for example.
  1972. This section describes the use of temporal operations available in XIOS.
  1973. \begin_inset Newline newline
  1974. \end_inset
  1975. \begin_inset Newline newline
  1976. \end_inset
  1977. The field attribute
  1978. \series bold
  1979. operation
  1980. \series default
  1981. currently supports six modes:
  1982. \end_layout
  1983. \begin_layout Itemize
  1984. \series bold
  1985. \emph on
  1986. instant
  1987. \series default
  1988. \emph default
  1989. : no temporal operation is applied which means the new data always overrides
  1990. the previous one even if it was not outputted,
  1991. \end_layout
  1992. \begin_layout Itemize
  1993. \series bold
  1994. \emph on
  1995. average
  1996. \series default
  1997. \emph default
  1998. : compute and output the mean value,
  1999. \end_layout
  2000. \begin_layout Itemize
  2001. \series bold
  2002. \emph on
  2003. accumulate
  2004. \series default
  2005. \emph default
  2006. : compute and output the sum,
  2007. \end_layout
  2008. \begin_layout Itemize
  2009. \series bold
  2010. \emph on
  2011. minimum
  2012. \series default
  2013. \emph default
  2014. : compute and output the minimum value,
  2015. \end_layout
  2016. \begin_layout Itemize
  2017. \series bold
  2018. \emph on
  2019. maximum
  2020. \series default
  2021. \emph default
  2022. : compute and output the maximum value,
  2023. \end_layout
  2024. \begin_layout Itemize
  2025. \series bold
  2026. \emph on
  2027. once
  2028. \series default
  2029. \emph default
  2030. : the data is written to the file only the first time it is received from
  2031. the model, any subsequent data is ignored.
  2032. The corresponding NetCDF variable does not have a time dimension.
  2033. \end_layout
  2034. \begin_layout Standard
  2035. The output frequency of the file defined by the
  2036. \series bold
  2037. output_freq
  2038. \series default
  2039. attribute is used as the temporal operation period (except for the
  2040. \begin_inset Quotes eld
  2041. \end_inset
  2042. \series bold
  2043. \emph on
  2044. once
  2045. \series default
  2046. \emph default
  2047. \begin_inset Quotes erd
  2048. \end_inset
  2049. \series bold
  2050. operation
  2051. \series default
  2052. for which there is no period).
  2053. This means it is for example not possible to output a daily average and
  2054. a weekly average in the same file.
  2055. \begin_inset Newline newline
  2056. \end_inset
  2057. \begin_inset Newline newline
  2058. \end_inset
  2059. This updated example shows how to output the daily average instead of the
  2060. instant data for all timesteps:
  2061. \end_layout
  2062. \begin_layout Standard
  2063. \begin_inset listings
  2064. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2065. inline false
  2066. status open
  2067. \begin_layout Plain Layout
  2068. <?xml version="1.0"?>
  2069. \end_layout
  2070. \begin_layout Plain Layout
  2071. <simulation>
  2072. \end_layout
  2073. \begin_layout Plain Layout
  2074. <context id="test">
  2075. \end_layout
  2076. \begin_layout Plain Layout
  2077. <calendar type="Gregorian" timestep="1h" />
  2078. \end_layout
  2079. \begin_layout Plain Layout
  2080. \end_layout
  2081. \begin_layout Plain Layout
  2082. <grid_definition>
  2083. \end_layout
  2084. \begin_layout Plain Layout
  2085. <grid id="grid_A"><!-- Definition ommited --></grid>
  2086. \end_layout
  2087. \begin_layout Plain Layout
  2088. </grid_definition>
  2089. \end_layout
  2090. \begin_layout Plain Layout
  2091. \end_layout
  2092. \begin_layout Plain Layout
  2093. <file_definition>
  2094. \end_layout
  2095. \begin_layout Plain Layout
  2096. <file name="output" type="one_file" output_freq="1d">
  2097. \end_layout
  2098. \begin_layout Plain Layout
  2099. <field id="field_A" grid_ref="grid_A" operation="average" />
  2100. \end_layout
  2101. \begin_layout Plain Layout
  2102. </file>
  2103. \end_layout
  2104. \begin_layout Plain Layout
  2105. </file_definition>
  2106. \end_layout
  2107. \begin_layout Plain Layout
  2108. </context>
  2109. \end_layout
  2110. \begin_layout Plain Layout
  2111. </simulation>
  2112. \end_layout
  2113. \end_inset
  2114. Compared to the previous example, only the file attribute
  2115. \series bold
  2116. output_freq
  2117. \series default
  2118. and the field attribute
  2119. \series bold
  2120. operation
  2121. \series default
  2122. have been modified.
  2123. Computing the weekly minimum instead of the daily average would be as simple
  2124. as using
  2125. \begin_inset Flex Code
  2126. status open
  2127. \begin_layout Plain Layout
  2128. output_freq="7d"
  2129. \end_layout
  2130. \end_inset
  2131. and
  2132. \begin_inset Flex Code
  2133. status open
  2134. \begin_layout Plain Layout
  2135. operation="minimum"
  2136. \end_layout
  2137. \end_inset
  2138. .
  2139. \begin_inset Newline newline
  2140. \end_inset
  2141. \begin_inset Newline newline
  2142. \end_inset
  2143. Note that if you use a temporal operation and have
  2144. \series bold
  2145. default_value
  2146. \series default
  2147. defined, it might be useful to set the attribute
  2148. \series bold
  2149. detect_missing_value
  2150. \series default
  2151. to
  2152. \begin_inset Quotes eld
  2153. \end_inset
  2154. \series bold
  2155. \emph on
  2156. true
  2157. \series default
  2158. \emph default
  2159. \begin_inset Quotes erd
  2160. \end_inset
  2161. .
  2162. This way temporal operations will not be applied when a default value is
  2163. detected.
  2164. \begin_inset Newline newline
  2165. \end_inset
  2166. \begin_inset Newline newline
  2167. \end_inset
  2168. For example, we consider the values of a 2x2 domain for three timesteps:
  2169. \begin_inset Formula
  2170. \[
  2171. \begin{bmatrix}3 & -1\\
  2172. 7 & 1
  2173. \end{bmatrix},\qquad\begin{bmatrix}5 & 6\\
  2174. -1 & 2
  2175. \end{bmatrix},\qquad\begin{bmatrix}-1 & 8\\
  2176. 3 & 4
  2177. \end{bmatrix}.
  2178. \]
  2179. \end_inset
  2180. If we suppose that the field is configured to compute the average on three
  2181. timesteps, the resulting field would be:
  2182. \begin_inset Formula
  2183. \[
  2184. \begin{bmatrix}\nicefrac{7}{3} & \nicefrac{13}{3}\\
  2185. 3 & \nicefrac{7}{3}
  2186. \end{bmatrix}.
  2187. \]
  2188. \end_inset
  2189. If
  2190. \series bold
  2191. default_value
  2192. \series default
  2193. is set to
  2194. \emph on
  2195. \begin_inset Quotes eld
  2196. \end_inset
  2197. -1
  2198. \begin_inset Quotes erd
  2199. \end_inset
  2200. \emph default
  2201. and
  2202. \series bold
  2203. detect_missing_value
  2204. \series default
  2205. is set to
  2206. \begin_inset Quotes eld
  2207. \end_inset
  2208. \series bold
  2209. \emph on
  2210. true
  2211. \series default
  2212. \emph default
  2213. \begin_inset Quotes erd
  2214. \end_inset
  2215. , the resulting field would be:
  2216. \begin_inset Formula
  2217. \[
  2218. \begin{bmatrix}4 & 7\\
  2219. 5 & \nicefrac{7}{3}
  2220. \end{bmatrix}.
  2221. \]
  2222. \end_inset
  2223. \end_layout
  2224. \begin_layout Section
  2225. How to use a specific data sampling
  2226. \end_layout
  2227. \begin_layout Standard
  2228. It is sometimes useful to have more control on the data sampling.
  2229. By default, the input data is used at every timestep but sometimes it is
  2230. not what you want.
  2231. The following examples illustrate such cases:
  2232. \end_layout
  2233. \begin_layout Enumerate
  2234. the model is not computing updated values at the same frequency for all
  2235. fields (for example, a field is updated every two timesteps).
  2236. \end_layout
  2237. \begin_layout Enumerate
  2238. you want to output a specific instant value in the interval between two
  2239. outputs.
  2240. \end_layout
  2241. \begin_layout Enumerate
  2242. you want to compute an average without taking into account all instant values
  2243. in the interval between two outputs.
  2244. \end_layout
  2245. \begin_layout Standard
  2246. Data sampling can be controlled in XIOS using the
  2247. \series bold
  2248. freq_op
  2249. \series default
  2250. (one timestep by default) and
  2251. \series bold
  2252. freq_offset
  2253. \series default
  2254. (null by default) attributes.
  2255. Those attributes define respectively how often data from the model must
  2256. be used and the amount of time before starting to use it.
  2257. \begin_inset Newline newline
  2258. \end_inset
  2259. \begin_inset Newline newline
  2260. \end_inset
  2261. For following excerpts of configuration files show you to use those attributes
  2262. to handle the motivating examples.
  2263. \end_layout
  2264. \begin_layout Enumerate
  2265. In this example, we suppose that we get two fields from the model:
  2266. \begin_inset Quotes eld
  2267. \end_inset
  2268. field_A
  2269. \begin_inset Quotes erd
  2270. \end_inset
  2271. which is computed for each timestep and
  2272. \begin_inset Quotes eld
  2273. \end_inset
  2274. field_B
  2275. \begin_inset Quotes erd
  2276. \end_inset
  2277. which is only computed every two timesteps.
  2278. For both fields, we show how to compute and output the sum of all values
  2279. received during 6 timesteps:
  2280. \begin_inset Newline newline
  2281. \end_inset
  2282. \begin_inset listings
  2283. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2284. inline false
  2285. status open
  2286. \begin_layout Plain Layout
  2287. <file_definition>
  2288. \end_layout
  2289. \begin_layout Plain Layout
  2290. <file name="output" output_freq="6ts">
  2291. \end_layout
  2292. \begin_layout Plain Layout
  2293. <field id="field_A" grid_ref="grid_A" operation="accumulate" />
  2294. \end_layout
  2295. \begin_layout Plain Layout
  2296. <field id="field_B" grid_ref="grid_B" operation="accumulate" freq_op="2ts"
  2297. />
  2298. \end_layout
  2299. \begin_layout Plain Layout
  2300. </file>
  2301. \end_layout
  2302. \begin_layout Plain Layout
  2303. </file_definition>
  2304. \end_layout
  2305. \end_inset
  2306. \end_layout
  2307. \begin_layout Enumerate
  2308. In this example, we show how to output the 11th instant value every 12 timesteps
  2309. :
  2310. \begin_inset Newline newline
  2311. \end_inset
  2312. \begin_inset listings
  2313. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2314. inline false
  2315. status open
  2316. \begin_layout Plain Layout
  2317. <file_definition>
  2318. \end_layout
  2319. \begin_layout Plain Layout
  2320. <file name="output" output_freq="12ts">
  2321. \end_layout
  2322. \begin_layout Plain Layout
  2323. <field id="field_A" grid_ref="grid_A" operation="instant" freq_op="11ts"
  2324. freq_offset="12ts" />
  2325. \end_layout
  2326. \begin_layout Plain Layout
  2327. </file>
  2328. \end_layout
  2329. \begin_layout Plain Layout
  2330. </file_definition>
  2331. \end_layout
  2332. \end_inset
  2333. \end_layout
  2334. \begin_layout Enumerate
  2335. In this example, we suppose that the timestep is equal to one hour and that
  2336. the simulation starts at midnight.
  2337. We show how to compute the weekly average of the field value at midday:
  2338. \begin_inset Newline newline
  2339. \end_inset
  2340. \begin_inset listings
  2341. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2342. inline false
  2343. status open
  2344. \begin_layout Plain Layout
  2345. <file_definition>
  2346. \end_layout
  2347. \begin_layout Plain Layout
  2348. <file name="output" output_freq="1w">
  2349. \end_layout
  2350. \begin_layout Plain Layout
  2351. <field id="field_A" grid_ref="grid_A" operation="average" freq_op="1d"
  2352. freq_offset="12h" />
  2353. \end_layout
  2354. \begin_layout Plain Layout
  2355. </file>
  2356. \end_layout
  2357. \begin_layout Plain Layout
  2358. </file_definition>
  2359. \end_layout
  2360. \end_inset
  2361. \end_layout
  2362. \begin_layout Section
  2363. How to use field references
  2364. \end_layout
  2365. \begin_layout Standard
  2366. It is quite common that different temporal operations must be applied to
  2367. the same instant data provided by the model.
  2368. In theory, the only solution to handle this scenario would be to define
  2369. a field for each operation, give them different
  2370. \series bold
  2371. id
  2372. \series default
  2373. and and call
  2374. \begin_inset Flex Code
  2375. status open
  2376. \begin_layout Plain Layout
  2377. xios_send_field
  2378. \end_layout
  2379. \end_inset
  2380. with the same array of data for each of those fields.
  2381. \begin_inset Newline newline
  2382. \end_inset
  2383. \begin_inset Newline newline
  2384. \end_inset
  2385. The following example illustrates this solution for a field for which we
  2386. want to compute the average, minimal and maximal values:
  2387. \end_layout
  2388. \begin_layout Standard
  2389. \begin_inset listings
  2390. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2391. inline false
  2392. status open
  2393. \begin_layout Plain Layout
  2394. <?xml version="1.0"?>
  2395. \end_layout
  2396. \begin_layout Plain Layout
  2397. <simulation>
  2398. \end_layout
  2399. \begin_layout Plain Layout
  2400. <context id="test">
  2401. \end_layout
  2402. \begin_layout Plain Layout
  2403. <calendar type="Gregorian" timestep="1h" />
  2404. \end_layout
  2405. \begin_layout Plain Layout
  2406. \end_layout
  2407. \begin_layout Plain Layout
  2408. <grid_definition>
  2409. \end_layout
  2410. \begin_layout Plain Layout
  2411. <grid id="grid_A"><!-- Definition ommited --></grid>
  2412. \end_layout
  2413. \begin_layout Plain Layout
  2414. </grid_definition>
  2415. \end_layout
  2416. \begin_layout Plain Layout
  2417. \end_layout
  2418. \begin_layout Plain Layout
  2419. <file_definition>
  2420. \end_layout
  2421. \begin_layout Plain Layout
  2422. <file name="output" output_freq="1d">
  2423. \end_layout
  2424. \begin_layout Plain Layout
  2425. <field id="field_A_avg" grid_ref="grid_A" operation="average"
  2426. />
  2427. \end_layout
  2428. \begin_layout Plain Layout
  2429. <field id="field_A_min" grid_ref="grid_A" operation="min" />
  2430. \end_layout
  2431. \begin_layout Plain Layout
  2432. <field id="field_A_max" grid_ref="grid_A" operation="max" />
  2433. \end_layout
  2434. \begin_layout Plain Layout
  2435. </file>
  2436. \end_layout
  2437. \begin_layout Plain Layout
  2438. </file_definition>
  2439. \end_layout
  2440. \begin_layout Plain Layout
  2441. </context>
  2442. \end_layout
  2443. \begin_layout Plain Layout
  2444. </simulation>
  2445. \end_layout
  2446. \end_inset
  2447. To simplify the handling of such scenarios, XIOS has a
  2448. \begin_inset Quotes eld
  2449. \end_inset
  2450. reference
  2451. \begin_inset Quotes erd
  2452. \end_inset
  2453. feature which allows one field to inherit the attributes (except the
  2454. \series bold
  2455. id
  2456. \series default
  2457. ) and the instant data of another field.
  2458. The above example can then be rewritten:
  2459. \begin_inset listings
  2460. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2461. inline false
  2462. status open
  2463. \begin_layout Plain Layout
  2464. <?xml version="1.0"?>
  2465. \end_layout
  2466. \begin_layout Plain Layout
  2467. <simulation>
  2468. \end_layout
  2469. \begin_layout Plain Layout
  2470. <context id="test">
  2471. \end_layout
  2472. \begin_layout Plain Layout
  2473. <calendar type="Gregorian" timestep="1h" />
  2474. \end_layout
  2475. \begin_layout Plain Layout
  2476. \end_layout
  2477. \begin_layout Plain Layout
  2478. <grid_definition>
  2479. \end_layout
  2480. \begin_layout Plain Layout
  2481. <grid id="grid_A"><!-- Definition ommited --></grid>
  2482. \end_layout
  2483. \begin_layout Plain Layout
  2484. </grid_definition>
  2485. \end_layout
  2486. \begin_layout Plain Layout
  2487. \end_layout
  2488. \begin_layout Plain Layout
  2489. <file_definition>
  2490. \end_layout
  2491. \begin_layout Plain Layout
  2492. <file name="output" output_freq="1d">
  2493. \end_layout
  2494. \begin_layout Plain Layout
  2495. <field id="field_A" name="field_A_avg" grid_ref="grid_A" operation="av
  2496. erage" />
  2497. \end_layout
  2498. \begin_layout Plain Layout
  2499. <field field_ref="field_A" name="field_A_min" operation="min"
  2500. />
  2501. \end_layout
  2502. \begin_layout Plain Layout
  2503. <field field_ref="field_A" name="field_A_max" operation="max"
  2504. />
  2505. \end_layout
  2506. \begin_layout Plain Layout
  2507. </file>
  2508. \end_layout
  2509. \begin_layout Plain Layout
  2510. </file_definition>
  2511. \end_layout
  2512. \begin_layout Plain Layout
  2513. </context>
  2514. \end_layout
  2515. \begin_layout Plain Layout
  2516. </simulation>
  2517. \end_layout
  2518. \end_inset
  2519. With this configuration, only one call to
  2520. \begin_inset Flex Code
  2521. status open
  2522. \begin_layout Plain Layout
  2523. xios_send_field(
  2524. \begin_inset Quotes eld
  2525. \end_inset
  2526. field_A
  2527. \begin_inset Quotes erd
  2528. \end_inset
  2529. , field_A)
  2530. \end_layout
  2531. \end_inset
  2532. is needed.
  2533. Note how inherited attributes (like
  2534. \series bold
  2535. name
  2536. \series default
  2537. or
  2538. \series bold
  2539. operation
  2540. \series default
  2541. for example) are overwritten to obtain the desired configuration.
  2542. Additionally, be aware that it is the instant values which are inherited,
  2543. not the result of the operation on the field.
  2544. \begin_inset Newline newline
  2545. \end_inset
  2546. \begin_inset Newline newline
  2547. \end_inset
  2548. Similarly, it is sometimes useful to output the result of a temporal operation
  2549. on a field for different periods.
  2550. In this case, it does not really make sense to define the field that will
  2551. be then inherited in one file rather than another.
  2552. A solution is to make use of the
  2553. \begin_inset Flex Code
  2554. status open
  2555. \begin_layout Plain Layout
  2556. field_definition
  2557. \end_layout
  2558. \end_inset
  2559. section so that it is clear that the field can be reused in any file.
  2560. This is illustrated in the following sample configuration file:
  2561. \begin_inset listings
  2562. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2563. inline false
  2564. status open
  2565. \begin_layout Plain Layout
  2566. <?xml version="1.0"?>
  2567. \end_layout
  2568. \begin_layout Plain Layout
  2569. <simulation>
  2570. \end_layout
  2571. \begin_layout Plain Layout
  2572. <context id="test">
  2573. \end_layout
  2574. \begin_layout Plain Layout
  2575. <calendar type="Gregorian" timestep="1h" />
  2576. \end_layout
  2577. \begin_layout Plain Layout
  2578. \end_layout
  2579. \begin_layout Plain Layout
  2580. <grid_definition>
  2581. \end_layout
  2582. \begin_layout Plain Layout
  2583. <grid id="grid_A"><!-- Definition ommited --></grid>
  2584. \end_layout
  2585. \begin_layout Plain Layout
  2586. </grid_definition>
  2587. \end_layout
  2588. \begin_layout Plain Layout
  2589. \end_layout
  2590. \begin_layout Plain Layout
  2591. <field_definition>
  2592. \end_layout
  2593. \begin_layout Plain Layout
  2594. <field id="field_A" name="field_A" grid_ref="grid_A" operation="average
  2595. " />
  2596. \end_layout
  2597. \begin_layout Plain Layout
  2598. </field_definition>
  2599. \end_layout
  2600. \begin_layout Plain Layout
  2601. \end_layout
  2602. \begin_layout Plain Layout
  2603. <file_definition>
  2604. \end_layout
  2605. \begin_layout Plain Layout
  2606. <file name="output_1d" output_freq="1d">
  2607. \end_layout
  2608. \begin_layout Plain Layout
  2609. <field field_ref="field_A" />
  2610. \end_layout
  2611. \begin_layout Plain Layout
  2612. </file>
  2613. \end_layout
  2614. \begin_layout Plain Layout
  2615. <file name="output_1mo" output_freq="1mo">
  2616. \end_layout
  2617. \begin_layout Plain Layout
  2618. <field field_ref="field_A" />
  2619. \end_layout
  2620. \begin_layout Plain Layout
  2621. </file>
  2622. \end_layout
  2623. \begin_layout Plain Layout
  2624. </file_definition>
  2625. \end_layout
  2626. \begin_layout Plain Layout
  2627. </context>
  2628. \end_layout
  2629. \begin_layout Plain Layout
  2630. </simulation>
  2631. \end_layout
  2632. \end_inset
  2633. \end_layout
  2634. \begin_layout Section
  2635. How to use arithmetic operations
  2636. \end_layout
  2637. \begin_layout Standard
  2638. Since XIOS aims to reduce as much as possible the need for post-processing,
  2639. it can apply some arithmetic operations on the data it handles (regardless
  2640. of its provenance).
  2641. \begin_inset Newline newline
  2642. \end_inset
  2643. \begin_inset Newline newline
  2644. \end_inset
  2645. All usual operators (+, -, *, /, ^, that is addition, subtraction, multiplicatio
  2646. n, division and exponentiation) and some common functions (like cos, sin,
  2647. tan, exp, log, log10, sqrt) are supported.
  2648. \begin_inset Newline newline
  2649. \end_inset
  2650. \begin_inset Newline newline
  2651. \end_inset
  2652. The following example shows how to use arithmetic operations:
  2653. \begin_inset listings
  2654. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2655. inline false
  2656. status open
  2657. \begin_layout Plain Layout
  2658. <?xml version="1.0"?>
  2659. \end_layout
  2660. \begin_layout Plain Layout
  2661. <simulation>
  2662. \end_layout
  2663. \begin_layout Plain Layout
  2664. <context id="test">
  2665. \end_layout
  2666. \begin_layout Plain Layout
  2667. <calendar type="Gregorian" timestep="1h" />
  2668. \end_layout
  2669. \begin_layout Plain Layout
  2670. \end_layout
  2671. \begin_layout Plain Layout
  2672. <grid_definition>
  2673. \end_layout
  2674. \begin_layout Plain Layout
  2675. <grid id="grid_A"><!-- Definition ommited --></grid>
  2676. \end_layout
  2677. \begin_layout Plain Layout
  2678. </grid_definition>
  2679. \end_layout
  2680. \begin_layout Plain Layout
  2681. \end_layout
  2682. \begin_layout Plain Layout
  2683. <field_definition>
  2684. \end_layout
  2685. \begin_layout Plain Layout
  2686. <field id="field_A" grid_ref="grid_A" operation="average" />
  2687. \end_layout
  2688. \begin_layout Plain Layout
  2689. </field_definition>
  2690. \end_layout
  2691. \begin_layout Plain Layout
  2692. \end_layout
  2693. \begin_layout Plain Layout
  2694. <file_definition>
  2695. \end_layout
  2696. \begin_layout Plain Layout
  2697. <file name="output" output_freq="1d">
  2698. \end_layout
  2699. \begin_layout Plain Layout
  2700. <field id="field_B" field_ref="field_A">field_A + 273.15</field>
  2701. \end_layout
  2702. \begin_layout Plain Layout
  2703. <field id="field_C" field_ref="field_A">log10(field_B)</field>
  2704. \end_layout
  2705. \begin_layout Plain Layout
  2706. </file>
  2707. \end_layout
  2708. \begin_layout Plain Layout
  2709. </file_definition>
  2710. \end_layout
  2711. \begin_layout Plain Layout
  2712. </context>
  2713. \end_layout
  2714. \begin_layout Plain Layout
  2715. </simulation>
  2716. \end_layout
  2717. \end_inset
  2718. With this configuration, only one call to
  2719. \begin_inset Flex Code
  2720. status open
  2721. \begin_layout Plain Layout
  2722. xios_send_field(
  2723. \begin_inset Quotes eld
  2724. \end_inset
  2725. field_A
  2726. \begin_inset Quotes erd
  2727. \end_inset
  2728. , field_A)
  2729. \end_layout
  2730. \end_inset
  2731. is needed.
  2732. In this example
  2733. \series bold
  2734. field_ref
  2735. \series default
  2736. is used only to inherit the attributes from
  2737. \begin_inset Quotes eld
  2738. \end_inset
  2739. field_A
  2740. \begin_inset Quotes erd
  2741. \end_inset
  2742. , the instant values are not inherited since an expression has been given
  2743. for
  2744. \begin_inset Quotes eld
  2745. \end_inset
  2746. field_B
  2747. \begin_inset Quotes erd
  2748. \end_inset
  2749. and
  2750. \begin_inset Quotes eld
  2751. \end_inset
  2752. field_C
  2753. \begin_inset Quotes erd
  2754. \end_inset
  2755. .
  2756. Note that it is possible to use fields obtained from an expression in another
  2757. expression, thus the expression of
  2758. \begin_inset Quotes eld
  2759. \end_inset
  2760. field_C
  2761. \begin_inset Quotes erd
  2762. \end_inset
  2763. is equivalent to
  2764. \begin_inset Flex Code
  2765. status open
  2766. \begin_layout Plain Layout
  2767. log10(field_A + 273.15)
  2768. \end_layout
  2769. \end_inset
  2770. .
  2771. \begin_inset Newline newline
  2772. \end_inset
  2773. \begin_inset Newline newline
  2774. \end_inset
  2775. The special keyword
  2776. \series bold
  2777. this
  2778. \series default
  2779. can be used in an expression to refer to the instant data received from
  2780. the model by the current field.
  2781. For example, the previous configuration file could be rewritten as follow:
  2782. \begin_inset listings
  2783. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2784. inline false
  2785. status open
  2786. \begin_layout Plain Layout
  2787. <?xml version="1.0"?>
  2788. \end_layout
  2789. \begin_layout Plain Layout
  2790. <simulation>
  2791. \end_layout
  2792. \begin_layout Plain Layout
  2793. <context id="test">
  2794. \end_layout
  2795. \begin_layout Plain Layout
  2796. <calendar type="Gregorian" timestep="1h" />
  2797. \end_layout
  2798. \begin_layout Plain Layout
  2799. \end_layout
  2800. \begin_layout Plain Layout
  2801. <grid_definition>
  2802. \end_layout
  2803. \begin_layout Plain Layout
  2804. <grid id="grid_A"><!-- Definition ommited --></grid>
  2805. \end_layout
  2806. \begin_layout Plain Layout
  2807. </grid_definition>
  2808. \end_layout
  2809. \begin_layout Plain Layout
  2810. \end_layout
  2811. \begin_layout Plain Layout
  2812. <file_definition>
  2813. \end_layout
  2814. \begin_layout Plain Layout
  2815. <file name="output" output_freq="1d">
  2816. \end_layout
  2817. \begin_layout Plain Layout
  2818. <field id="field_B" grid_ref="grid_A" operation="average">this
  2819. + 273.15</field>
  2820. \end_layout
  2821. \begin_layout Plain Layout
  2822. <field id="field_C" field_ref="field_B">log10(field_B)</field>
  2823. \end_layout
  2824. \begin_layout Plain Layout
  2825. </file>
  2826. \end_layout
  2827. \begin_layout Plain Layout
  2828. </file_definition>
  2829. \end_layout
  2830. \begin_layout Plain Layout
  2831. </context>
  2832. \end_layout
  2833. \begin_layout Plain Layout
  2834. </simulation>
  2835. \end_layout
  2836. \end_inset
  2837. and the Fortran call would be replaced by
  2838. \begin_inset Flex Code
  2839. status open
  2840. \begin_layout Plain Layout
  2841. xios_send_field(
  2842. \begin_inset Quotes eld
  2843. \end_inset
  2844. field_B
  2845. \begin_inset Quotes erd
  2846. \end_inset
  2847. , field_A)
  2848. \end_layout
  2849. \end_inset
  2850. .
  2851. \end_layout
  2852. \begin_layout Section
  2853. How to chain multiple temporal operations
  2854. \end_layout
  2855. \begin_layout Standard
  2856. By default, all field names appearing in an expression refer to the instant
  2857. data of those fields.
  2858. To refer to the result of a temporal operation, the field name must be
  2859. prefixed with
  2860. \begin_inset Quotes eld
  2861. \end_inset
  2862. @
  2863. \begin_inset Quotes erd
  2864. \end_inset
  2865. .
  2866. \begin_inset Newline newline
  2867. \end_inset
  2868. \begin_inset Newline newline
  2869. \end_inset
  2870. This feature allows to chain multiple temporal operations as illustrated
  2871. bellow:
  2872. \end_layout
  2873. \begin_layout Standard
  2874. \begin_inset listings
  2875. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2876. inline false
  2877. status open
  2878. \begin_layout Plain Layout
  2879. <?xml version="1.0"?>
  2880. \end_layout
  2881. \begin_layout Plain Layout
  2882. <simulation>
  2883. \end_layout
  2884. \begin_layout Plain Layout
  2885. <context id="test">
  2886. \end_layout
  2887. \begin_layout Plain Layout
  2888. <calendar type="Gregorian" timestep="1h" />
  2889. \end_layout
  2890. \begin_layout Plain Layout
  2891. \end_layout
  2892. \begin_layout Plain Layout
  2893. <grid_definition>
  2894. \end_layout
  2895. \begin_layout Plain Layout
  2896. <grid id="grid_A"><!-- Definition ommited --></grid>
  2897. \end_layout
  2898. \begin_layout Plain Layout
  2899. </grid_definition>
  2900. \end_layout
  2901. \begin_layout Plain Layout
  2902. \end_layout
  2903. \begin_layout Plain Layout
  2904. <field_definition>
  2905. \end_layout
  2906. \begin_layout Plain Layout
  2907. <field id="field_A" grid_ref="grid_A" operation="average" />
  2908. \end_layout
  2909. \begin_layout Plain Layout
  2910. </field_definition>
  2911. \end_layout
  2912. \begin_layout Plain Layout
  2913. \end_layout
  2914. \begin_layout Plain Layout
  2915. <file_definition>
  2916. \end_layout
  2917. \begin_layout Plain Layout
  2918. <file name="output" output_freq="7d">
  2919. \end_layout
  2920. \begin_layout Plain Layout
  2921. <field name="field_A_min_of_average" grid_ref="grid_A" operation="min"
  2922. freq_op="1d">@field_A</field>
  2923. \end_layout
  2924. \begin_layout Plain Layout
  2925. </file>
  2926. \end_layout
  2927. \begin_layout Plain Layout
  2928. </file_definition>
  2929. \end_layout
  2930. \begin_layout Plain Layout
  2931. </context>
  2932. \end_layout
  2933. \begin_layout Plain Layout
  2934. </simulation>
  2935. \end_layout
  2936. \end_inset
  2937. This example shows how to compute the minimum on 7 days of the daily average
  2938. of
  2939. \begin_inset Quotes eld
  2940. \end_inset
  2941. field_A
  2942. \begin_inset Quotes erd
  2943. \end_inset
  2944. .
  2945. In this context, the
  2946. \series bold
  2947. freq_op
  2948. \series default
  2949. attribute defines the period of the temporal operation for all fields pointed
  2950. with the
  2951. \begin_inset Quotes eld
  2952. \end_inset
  2953. @
  2954. \begin_inset Quotes erd
  2955. \end_inset
  2956. operator in the expression.
  2957. \begin_inset Newline newline
  2958. \end_inset
  2959. \begin_inset Newline newline
  2960. \end_inset
  2961. Another use of this feature is to do arithmetic operations on the result
  2962. of temporal operations.
  2963. The following configuration file for example shows how to output the standard
  2964. deviation for a field on a one day period:
  2965. \begin_inset listings
  2966. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  2967. inline false
  2968. status open
  2969. \begin_layout Plain Layout
  2970. <?xml version="1.0"?>
  2971. \end_layout
  2972. \begin_layout Plain Layout
  2973. <simulation>
  2974. \end_layout
  2975. \begin_layout Plain Layout
  2976. <context id="test">
  2977. \end_layout
  2978. \begin_layout Plain Layout
  2979. <calendar type="Gregorian" timestep="1h" />
  2980. \end_layout
  2981. \begin_layout Plain Layout
  2982. \end_layout
  2983. \begin_layout Plain Layout
  2984. <grid_definition>
  2985. \end_layout
  2986. \begin_layout Plain Layout
  2987. <grid id="grid_A"><!-- Definition ommited --></grid>
  2988. \end_layout
  2989. \begin_layout Plain Layout
  2990. </grid_definition>
  2991. \end_layout
  2992. \begin_layout Plain Layout
  2993. \end_layout
  2994. \begin_layout Plain Layout
  2995. <field_definition>
  2996. \end_layout
  2997. \begin_layout Plain Layout
  2998. <field id="field_A" grid_ref="grid_A" operation="average" />
  2999. \end_layout
  3000. \begin_layout Plain Layout
  3001. <field id="field_A_square" field_ref="grid_A">field_A * field_A</field>
  3002. \end_layout
  3003. \begin_layout Plain Layout
  3004. </field_definition>
  3005. \end_layout
  3006. \begin_layout Plain Layout
  3007. \end_layout
  3008. \begin_layout Plain Layout
  3009. <file_definition>
  3010. \end_layout
  3011. \begin_layout Plain Layout
  3012. <file name="output" output_freq="1d">
  3013. \end_layout
  3014. \begin_layout Plain Layout
  3015. <field name="field_A_std_dev" grid_ref="grid_A" operation="instant"
  3016. freq_op="1d">sqrt(@field_A_square - @field_A^2)</field>
  3017. \end_layout
  3018. \begin_layout Plain Layout
  3019. </file>
  3020. \end_layout
  3021. \begin_layout Plain Layout
  3022. </file_definition>
  3023. \end_layout
  3024. \begin_layout Plain Layout
  3025. </context>
  3026. \end_layout
  3027. \begin_layout Plain Layout
  3028. </simulation>
  3029. \end_layout
  3030. \end_inset
  3031. Note that since an
  3032. \series bold
  3033. \emph on
  3034. \begin_inset Quotes eld
  3035. \end_inset
  3036. instant
  3037. \begin_inset Quotes erd
  3038. \end_inset
  3039. \series default
  3040. \emph default
  3041. operation is used,
  3042. \series bold
  3043. freq_op
  3044. \series default
  3045. and
  3046. \series bold
  3047. output_freq
  3048. \series default
  3049. are identical in this scenario.
  3050. \end_layout
  3051. \begin_layout Section
  3052. How to access the data of a field
  3053. \end_layout
  3054. \begin_layout Standard
  3055. In order not to waste memory, the instant data of a field can be read from
  3056. the model only if:
  3057. \end_layout
  3058. \begin_layout Itemize
  3059. it is part of a file whose attribute
  3060. \series bold
  3061. mode
  3062. \series default
  3063. is
  3064. \series bold
  3065. \emph on
  3066. \begin_inset Quotes eld
  3067. \end_inset
  3068. read
  3069. \begin_inset Quotes erd
  3070. \end_inset
  3071. \end_layout
  3072. \begin_layout Itemize
  3073. or its attribute
  3074. \series bold
  3075. read_access
  3076. \series default
  3077. is set to
  3078. \series bold
  3079. \emph on
  3080. \begin_inset Quotes eld
  3081. \end_inset
  3082. true
  3083. \begin_inset Quotes erd
  3084. \end_inset
  3085. \series default
  3086. \emph default
  3087. .
  3088. \end_layout
  3089. \begin_layout Standard
  3090. In any other case, trying to access the field data would cause an error.
  3091. \begin_inset Newline newline
  3092. \end_inset
  3093. \begin_inset Newline newline
  3094. \end_inset
  3095. The following configuration file:
  3096. \begin_inset listings
  3097. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  3098. inline false
  3099. status open
  3100. \begin_layout Plain Layout
  3101. <?xml version="1.0"?>
  3102. \end_layout
  3103. \begin_layout Plain Layout
  3104. <simulation>
  3105. \end_layout
  3106. \begin_layout Plain Layout
  3107. <context id="test">
  3108. \end_layout
  3109. \begin_layout Plain Layout
  3110. <calendar type="Gregorian" timestep="1h" />
  3111. \end_layout
  3112. \begin_layout Plain Layout
  3113. \end_layout
  3114. \begin_layout Plain Layout
  3115. <grid_definition>
  3116. \end_layout
  3117. \begin_layout Plain Layout
  3118. <grid id="grid_A"><!-- Definition ommited --></grid>
  3119. \end_layout
  3120. \begin_layout Plain Layout
  3121. </grid_definition>
  3122. \end_layout
  3123. \begin_layout Plain Layout
  3124. \end_layout
  3125. \begin_layout Plain Layout
  3126. <file_definition>
  3127. \end_layout
  3128. \begin_layout Plain Layout
  3129. <file name="input" output_freq="1ts">
  3130. \end_layout
  3131. \begin_layout Plain Layout
  3132. <field id="field_A" grid_ref="grid_A" operation="instant" />
  3133. \end_layout
  3134. \begin_layout Plain Layout
  3135. </file>
  3136. \end_layout
  3137. \begin_layout Plain Layout
  3138. </file_definition>
  3139. \end_layout
  3140. \begin_layout Plain Layout
  3141. </context>
  3142. \end_layout
  3143. \begin_layout Plain Layout
  3144. </simulation>
  3145. \end_layout
  3146. \end_inset
  3147. can be used with this Fortran code:
  3148. \end_layout
  3149. \begin_layout Standard
  3150. \begin_inset listings
  3151. lstparams "language=Fortran,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  3152. inline false
  3153. status open
  3154. \begin_layout Plain Layout
  3155. DO ts=1,numberOfTimestep
  3156. \end_layout
  3157. \begin_layout Plain Layout
  3158. ! Get field_A for current timestep
  3159. \end_layout
  3160. \begin_layout Plain Layout
  3161. CALL xios_recv_field("field_A", field_A) ! field_A must be an allocated
  3162. array with the right size
  3163. \end_layout
  3164. \begin_layout Plain Layout
  3165. ! Do useful things...
  3166. \end_layout
  3167. \begin_layout Plain Layout
  3168. ! Inform XIOS of the current timestep
  3169. \end_layout
  3170. \begin_layout Plain Layout
  3171. CALL xios_update_calendar(ts)
  3172. \end_layout
  3173. \begin_layout Plain Layout
  3174. ENDDO
  3175. \end_layout
  3176. \end_inset
  3177. The call to
  3178. \begin_inset Flex Code
  3179. status open
  3180. \begin_layout Plain Layout
  3181. xios_recv_field
  3182. \end_layout
  3183. \end_inset
  3184. might block for a while if the data was not yet received from the server(s)
  3185. but it should not happen too often thanks to the prefetching done by XIOS.
  3186. \begin_inset Newline newline
  3187. \end_inset
  3188. \begin_inset Newline newline
  3189. \end_inset
  3190. Since the
  3191. \series bold
  3192. read_access
  3193. \series default
  3194. attribute allows to the access fields which depend directly on data from
  3195. the model, you must be very careful with the order of the
  3196. \begin_inset Flex Code
  3197. status open
  3198. \begin_layout Plain Layout
  3199. xios_send_field
  3200. \end_layout
  3201. \end_inset
  3202. and
  3203. \begin_inset Flex Code
  3204. status open
  3205. \begin_layout Plain Layout
  3206. xios_recv_field
  3207. \end_layout
  3208. \end_inset
  3209. calls.
  3210. For example, consider the following configuration file (just a simple example
  3211. as in practice it does not make much sense to use it):
  3212. \begin_inset listings
  3213. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  3214. inline false
  3215. status open
  3216. \begin_layout Plain Layout
  3217. <?xml version="1.0"?>
  3218. \end_layout
  3219. \begin_layout Plain Layout
  3220. <simulation>
  3221. \end_layout
  3222. \begin_layout Plain Layout
  3223. <context id="test">
  3224. \end_layout
  3225. \begin_layout Plain Layout
  3226. <calendar type="Gregorian" timestep="1h" />
  3227. \end_layout
  3228. \begin_layout Plain Layout
  3229. \end_layout
  3230. \begin_layout Plain Layout
  3231. <grid_definition>
  3232. \end_layout
  3233. \begin_layout Plain Layout
  3234. <grid id="grid_A"><!-- Definition ommited --></grid>
  3235. \end_layout
  3236. \begin_layout Plain Layout
  3237. </grid_definition>
  3238. \end_layout
  3239. \begin_layout Plain Layout
  3240. \end_layout
  3241. \begin_layout Plain Layout
  3242. <field_definition>
  3243. \end_layout
  3244. \begin_layout Plain Layout
  3245. <field id="field_A" grid_ref="grid_A" operation="instant" />
  3246. \end_layout
  3247. \begin_layout Plain Layout
  3248. </field_definition>
  3249. \end_layout
  3250. \begin_layout Plain Layout
  3251. \end_layout
  3252. \begin_layout Plain Layout
  3253. <file_definition>
  3254. \end_layout
  3255. \begin_layout Plain Layout
  3256. <file name="output" output_freq="1ts">
  3257. \end_layout
  3258. \begin_layout Plain Layout
  3259. <field id="field_B" grid_ref="grid_A" operation="instant" read_access=
  3260. "true">field_A / 42</field>
  3261. \end_layout
  3262. \begin_layout Plain Layout
  3263. </file>
  3264. \end_layout
  3265. \begin_layout Plain Layout
  3266. </file_definition>
  3267. \end_layout
  3268. \begin_layout Plain Layout
  3269. </context>
  3270. \end_layout
  3271. \begin_layout Plain Layout
  3272. </simulation>
  3273. \end_layout
  3274. \end_inset
  3275. If you call
  3276. \begin_inset Flex Code
  3277. status open
  3278. \begin_layout Plain Layout
  3279. xios_recv_field(
  3280. \begin_inset Quotes eld
  3281. \end_inset
  3282. field_B
  3283. \begin_inset Quotes erd
  3284. \end_inset
  3285. , field_B)
  3286. \end_layout
  3287. \end_inset
  3288. before
  3289. \begin_inset Flex Code
  3290. status open
  3291. \begin_layout Plain Layout
  3292. xios_send_field(
  3293. \begin_inset Quotes eld
  3294. \end_inset
  3295. field_A
  3296. \begin_inset Quotes erd
  3297. \end_inset
  3298. , field_A)
  3299. \end_layout
  3300. \end_inset
  3301. , the requested data will never be available and a deadlock could occur.
  3302. In practice, XIOS will detect the problem and throw an error.
  3303. \end_layout
  3304. \begin_layout Section
  3305. How to reduce the size of an output file
  3306. \end_layout
  3307. \begin_layout Standard
  3308. The size of the output files can sometimes become a problem.
  3309. XIOS provides some features which may help to reduce the size of the output
  3310. files losslessly.
  3311. \begin_inset Newline newline
  3312. \end_inset
  3313. \begin_inset Newline newline
  3314. \end_inset
  3315. The first solution is to use the compression feature provided by HDF5 which
  3316. allows a field to be compressed using gzip.
  3317. Since it depends directly on HDF5, this feature works only when the NetCDF-4
  3318. format is used.
  3319. Since HDF5 does not (yet) support compression for parallel output, one
  3320. has to use two server-level functionality (see Sec.
  3321. \begin_inset CommandInset ref
  3322. LatexCommand ref
  3323. reference "sec:Launching-secondary-server"
  3324. \end_inset
  3325. ) or to engage the
  3326. \series bold
  3327. \emph on
  3328. \begin_inset Quotes eld
  3329. \end_inset
  3330. multiple_file
  3331. \begin_inset Quotes erd
  3332. \end_inset
  3333. \series default
  3334. \emph default
  3335. mode.
  3336. \begin_inset Newline newline
  3337. \end_inset
  3338. \begin_inset Newline newline
  3339. \end_inset
  3340. To enable the gzip compression of a field, you need to set the
  3341. \series bold
  3342. compression_level
  3343. \series default
  3344. attribute to any integer between 1 and 9 (by default this attribute is
  3345. set to 0 which means that compression is disabled).
  3346. Using an higher compression level should improve the compression ratio
  3347. at the cost of using more processing power.
  3348. Generally using a compression level of 2 should be a good trade-off.
  3349. \begin_inset Newline newline
  3350. \end_inset
  3351. \begin_inset Newline newline
  3352. \end_inset
  3353. The following example illustrates the use of the gzip compression:
  3354. \begin_inset listings
  3355. lstparams "language=XML,breaklines=true,tabsize=2,frame=tb,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}}"
  3356. inline false
  3357. status open
  3358. \begin_layout Plain Layout
  3359. <?xml version="1.0"?>
  3360. \end_layout
  3361. \begin_layout Plain Layout
  3362. <simulation>
  3363. \end_layout
  3364. \begin_layout Plain Layout
  3365. <context id="test">
  3366. \end_layout
  3367. \begin_layout Plain Layout
  3368. <calendar type="Gregorian" timestep="1h" />
  3369. \end_layout
  3370. \begin_layout Plain Layout
  3371. \end_layout
  3372. \begin_layout Plain Layout
  3373. <grid_definition>
  3374. \end_layout
  3375. \begin_layout Plain Layout
  3376. <grid id="grid_A"><!-- Definition ommited --></grid>
  3377. \end_layout
  3378. \begin_layout Plain Layout
  3379. </grid_definition>
  3380. \end_layout
  3381. \begin_layout Plain Layout
  3382. \end_layout
  3383. \begin_layout Plain Layout
  3384. <file_definition>
  3385. \end_layout
  3386. \begin_layout Plain Layout
  3387. <file name="output" output_freq="1ts" compression_level="2">
  3388. \end_layout
  3389. \begin_layout Plain Layout
  3390. <field id="field_A" grid_ref="grid_A" operation="average" compression_
  3391. level="4" />
  3392. \end_layout
  3393. \begin_layout Plain Layout
  3394. <field id="field_B" grid_ref="grid_A" operation="average" compression_
  3395. level="0" />
  3396. \end_layout
  3397. \begin_layout Plain Layout
  3398. <field id="field_C" grid_ref="grid_A" operation="average" />
  3399. \end_layout
  3400. \begin_layout Plain Layout
  3401. </file>
  3402. \end_layout
  3403. \begin_layout Plain Layout
  3404. </file_definition>
  3405. \end_layout
  3406. \begin_layout Plain Layout
  3407. </context>
  3408. \end_layout
  3409. \begin_layout Plain Layout
  3410. </simulation>
  3411. \end_layout
  3412. \end_inset
  3413. Note that the
  3414. \series bold
  3415. compression_level
  3416. \series default
  3417. attribute can also be set at a file level, in this case it is inherited
  3418. by all fields of the file unless they explicitly override the attribute.
  3419. \begin_inset Newline newline
  3420. \end_inset
  3421. \begin_inset Newline newline
  3422. \end_inset
  3423. The second solution is available only if you are using a grid with masked
  3424. values.
  3425. In this case, you can choose to output the indexed grid instead of the
  3426. full grid by setting the
  3427. \series bold
  3428. indexed_output
  3429. \series default
  3430. attribute to
  3431. \series bold
  3432. \emph on
  3433. \begin_inset Quotes eld
  3434. \end_inset
  3435. true
  3436. \begin_inset Quotes erd
  3437. \end_inset
  3438. \series default
  3439. \emph default
  3440. .
  3441. Missing values are then omitted and extra arrays are outputted so that
  3442. the translation from the
  3443. \begin_inset Quotes eld
  3444. \end_inset
  3445. compressed
  3446. \begin_inset Quotes erd
  3447. \end_inset
  3448. indexes to the true indexes can be done.
  3449. Due to those arrays of indexes, indexed output should be considered only
  3450. if there is enough masked values.
  3451. For more details about this feature, please refer to section 8.2
  3452. \begin_inset Quotes eld
  3453. \end_inset
  3454. Compression by Gathering
  3455. \begin_inset Quotes erd
  3456. \end_inset
  3457. of the Climate and Forecast (CF) Convention.
  3458. \end_layout
  3459. \begin_layout Standard
  3460. \begin_inset CommandInset include
  3461. LatexCommand include
  3462. filename "inputs/user/Grid.lyx"
  3463. \end_inset
  3464. \end_layout
  3465. \begin_layout Standard
  3466. \begin_inset CommandInset include
  3467. LatexCommand include
  3468. filename "inputs/user/Domain.lyx"
  3469. \end_inset
  3470. \end_layout
  3471. \begin_layout Standard
  3472. \begin_inset CommandInset include
  3473. LatexCommand include
  3474. filename "inputs/user/Axis.lyx"
  3475. \end_inset
  3476. \end_layout
  3477. \begin_layout Chapter
  3478. XIOS parameterization
  3479. \end_layout
  3480. \begin_layout Standard
  3481. Some of XIOS behaviors can be configured using options.
  3482. Those options must be expressed as variables in a specific context whose
  3483. \series bold
  3484. id
  3485. \series default
  3486. must be
  3487. \series bold
  3488. \emph on
  3489. \begin_inset Quotes eld
  3490. \end_inset
  3491. xios
  3492. \begin_inset Quotes erd
  3493. \end_inset
  3494. \series default
  3495. \emph default
  3496. as shown below.
  3497. \end_layout
  3498. \begin_layout Standard
  3499. \begin_inset listings
  3500. lstparams "breaklines=true,frame=tb,language=XML,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}},tabsize=2"
  3501. inline false
  3502. status open
  3503. \begin_layout Plain Layout
  3504. <?xml version="1.0"?>
  3505. \end_layout
  3506. \begin_layout Plain Layout
  3507. <simulation>
  3508. \end_layout
  3509. \begin_layout Plain Layout
  3510. <!-- Actual context(s) used by the simulation ommited -->
  3511. \end_layout
  3512. \begin_layout Plain Layout
  3513. \end_layout
  3514. \begin_layout Plain Layout
  3515. <context id="xios">
  3516. \end_layout
  3517. \begin_layout Plain Layout
  3518. <variable_definition>
  3519. \end_layout
  3520. \begin_layout Plain Layout
  3521. <variable id="option_name" type="option_type">option_value</variable>
  3522. \end_layout
  3523. \begin_layout Plain Layout
  3524. </variable_definition>
  3525. \end_layout
  3526. \begin_layout Plain Layout
  3527. </context>
  3528. \end_layout
  3529. \begin_layout Plain Layout
  3530. </simulation>
  3531. \end_layout
  3532. \end_inset
  3533. \end_layout
  3534. \begin_layout Section
  3535. Launching secondary server
  3536. \begin_inset CommandInset label
  3537. LatexCommand label
  3538. name "sec:Launching-secondary-server"
  3539. \end_inset
  3540. \end_layout
  3541. \begin_layout Standard
  3542. To improve I/O performance and to be able to use HDF5 compression with the
  3543. \series bold
  3544. \emph on
  3545. \begin_inset Quotes eld
  3546. \end_inset
  3547. multiple_file
  3548. \begin_inset Quotes erd
  3549. \end_inset
  3550. \series default
  3551. \emph default
  3552. mode, it is possible to separate servers into two levels: intermediaries
  3553. (level one) and writers (level two).
  3554. A single MPI communicator will be created for the intermediaries, while
  3555. multiple communicators will be created for the writers according to the
  3556. number of
  3557. \begin_inset Quotes eld
  3558. \end_inset
  3559. pools
  3560. \begin_inset Quotes erd
  3561. \end_inset
  3562. which can be set by a user.
  3563. Level-one servers will receive data from clients and will redistribute
  3564. it to be sent to pools of level-two servers whilst level-two servers will
  3565. do the I/O (important: for now level-two servers only do writing data).
  3566. Secondary servers can be launched by means of three parameters:
  3567. \end_layout
  3568. \begin_layout Itemize
  3569. \series bold
  3570. using_server2
  3571. \series default
  3572. (type:
  3573. \series bold
  3574. bool
  3575. \series default
  3576. ) activates the secondary server
  3577. \end_layout
  3578. \begin_layout Itemize
  3579. \series bold
  3580. ratio_server2
  3581. \series default
  3582. (type:
  3583. \series bold
  3584. int
  3585. \series default
  3586. ) defines the percentage of servers that will be dedicated to level two.
  3587. The parameter can take value from 0 to 100 with the default value of 50%.
  3588. In case if the requested number of level-two servers is not valid (for
  3589. example, zero or equal to the total number of servers), XIOS will run in
  3590. its classical server mode with one server level.
  3591. \end_layout
  3592. \begin_layout Itemize
  3593. \series bold
  3594. number_pools_server2
  3595. \series default
  3596. (type:
  3597. \series bold
  3598. int
  3599. \series default
  3600. ) sets the number of server-two pools (i.e.
  3601. MPI communicators on level two).
  3602. By default the number of pools is equal to the number of level-two servers,
  3603. thus permitting one process per communicator.
  3604. \end_layout
  3605. \begin_layout Standard
  3606. Shown in Fig.
  3607. \begin_inset CommandInset ref
  3608. LatexCommand ref
  3609. reference "Fig:server2"
  3610. \end_inset
  3611. is the two-level server structure for the following definitions:
  3612. \end_layout
  3613. \begin_layout Standard
  3614. \begin_inset listings
  3615. lstparams "breaklines=true,frame=tb,language=XML,postbreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\rcurvearrowse\space}}},tabsize=2"
  3616. inline false
  3617. status open
  3618. \begin_layout Plain Layout
  3619. <context id="xios">
  3620. \end_layout
  3621. \begin_layout Plain Layout
  3622. ...
  3623. \end_layout
  3624. \begin_layout Plain Layout
  3625. <variable id="using_server2" type="bool">true</variable>
  3626. \end_layout
  3627. \begin_layout Plain Layout
  3628. <variable id="ratio_server2" type="int">75</variable>
  3629. \end_layout
  3630. \begin_layout Plain Layout
  3631. <variable id="number_pools_server2" type="int">3</variable>
  3632. \end_layout
  3633. \begin_layout Plain Layout
  3634. ...
  3635. \end_layout
  3636. \begin_layout Plain Layout
  3637. </context>
  3638. \end_layout
  3639. \end_inset
  3640. \end_layout
  3641. \begin_layout Standard
  3642. \begin_inset Float figure
  3643. placement H
  3644. wide false
  3645. sideways false
  3646. status open
  3647. \begin_layout Plain Layout
  3648. \begin_inset Graphics
  3649. filename inputs/images/Server2.pdf
  3650. \end_inset
  3651. \end_layout
  3652. \begin_layout Plain Layout
  3653. \begin_inset Caption Standard
  3654. \begin_layout Plain Layout
  3655. Two levels of servers for the total number of servers of 8 and ratio_server2=75%.
  3656. The number of level-two servers is
  3657. \begin_inset Formula $8\times\text{ratio\_server2}=6$
  3658. \end_inset
  3659. and, thus, the remaining 2 servers are of level one.
  3660. \end_layout
  3661. \end_inset
  3662. \begin_inset CommandInset label
  3663. LatexCommand label
  3664. name "Fig:server2"
  3665. \end_inset
  3666. \end_layout
  3667. \end_inset
  3668. \end_layout
  3669. \begin_layout Standard
  3670. Note that with one server per pool, the I/O is actually sequential and thus
  3671. the use of HDF5 compression is possible.
  3672. \end_layout
  3673. \begin_layout Standard
  3674. By default file distribution among server-two pools is optimized for bandwidth.
  3675. An alternative way of distributing files is possible in order to minimize
  3676. memory consumption by level-two servers.
  3677. For this, two additional parameters should be specified:
  3678. \end_layout
  3679. \begin_layout Itemize
  3680. \series bold
  3681. server2_dist_file_memory
  3682. \series default
  3683. (type:
  3684. \series bold
  3685. bool
  3686. \series default
  3687. ) activates memory optimization.
  3688. \end_layout
  3689. \begin_layout Itemize
  3690. \series bold
  3691. server2_dist_file_memory_ratio
  3692. \series default
  3693. (type:
  3694. \series bold
  3695. double
  3696. \series default
  3697. ) (optional) takes value from 0 (memory optimization) to 1 (bandwidth optimizati
  3698. on).
  3699. The default value is 0.5.
  3700. \end_layout
  3701. \begin_layout Section
  3702. Buffer related options
  3703. \end_layout
  3704. \begin_layout Standard
  3705. By default, XIOS tries to guess the required buffers sizes to ensure efficient
  3706. client-server communications.
  3707. However it might sometimes be useful to tweak the buffers sizes so XIOS
  3708. provides the following options:
  3709. \end_layout
  3710. \begin_layout Itemize
  3711. \series bold
  3712. optimal_buffer_size
  3713. \series default
  3714. (type:
  3715. \series bold
  3716. string
  3717. \series default
  3718. ) can be either
  3719. \series bold
  3720. \emph on
  3721. \begin_inset Quotes eld
  3722. \end_inset
  3723. memory
  3724. \begin_inset Quotes erd
  3725. \end_inset
  3726. \series default
  3727. \emph default
  3728. or
  3729. \series bold
  3730. \emph on
  3731. \begin_inset Quotes erd
  3732. \end_inset
  3733. performance
  3734. \begin_inset Quotes erd
  3735. \end_inset
  3736. \series default
  3737. \emph default
  3738. .
  3739. When using the
  3740. \series bold
  3741. \emph on
  3742. \begin_inset Quotes eld
  3743. \end_inset
  3744. memory
  3745. \begin_inset Quotes erd
  3746. \end_inset
  3747. \series default
  3748. \emph default
  3749. mode, XIOS will try to use buffers as small as possible while still ensuring
  3750. that the bigger message will fit.
  3751. When using the
  3752. \series bold
  3753. \emph on
  3754. \begin_inset Quotes erd
  3755. \end_inset
  3756. performance
  3757. \begin_inset Quotes erd
  3758. \end_inset
  3759. \series default
  3760. \emph default
  3761. mode, XIOS will ensure that all active fields can be buffered without having
  3762. to flush the buffers.
  3763. This mode is used by default since it allows more asynchronism and thus
  3764. better performance at the cost of being quite memory hungry.
  3765. \end_layout
  3766. \begin_layout Itemize
  3767. \series bold
  3768. minimum_buffer_size
  3769. \series default
  3770. (type:
  3771. \series bold
  3772. int
  3773. \series default
  3774. ) defines the minimum buffer size in bytes (8192 by default).
  3775. This value will be used by XIOS only for buffers whose detected size is
  3776. smaller than the user defined minimum size.
  3777. \end_layout
  3778. \begin_layout Itemize
  3779. \series bold
  3780. buffer_size_factor
  3781. \series default
  3782. (type:
  3783. \series bold
  3784. int
  3785. \series default
  3786. ) allows to modify the buffers sizes by multiplying the detected sizes by
  3787. an user defined factor (
  3788. \begin_inset Formula $1.0$
  3789. \end_inset
  3790. by default).
  3791. For each allocated buffers, the used size is defined as
  3792. \begin_inset Formula
  3793. \[
  3794. {\scriptstyle used\_size\;=\;\min\left(minimum\_buffer\_size,\; detected\_size\;\times\; buffer\_size\_factor\right)}
  3795. \]
  3796. \end_inset
  3797. \end_layout
  3798. \end_body
  3799. \end_document