diff --git a/Documents/RMuso.aux b/Documents/RMuso.aux new file mode 100644 index 0000000..168898f --- /dev/null +++ b/Documents/RMuso.aux @@ -0,0 +1,5 @@ +\relax +\catcode \string ``=12 +\@writefile{toc}{\select@language{magyar} \contentsline {section}{\numberline {1}A csomag alapf\IeC {\"u}ggv\IeC {\'e}nyei}{1}} +\@writefile{toc}{\select@language{magyar} \contentsline {section}{\numberline {2}Tartalmazott f\IeC {\"u}ggv\IeC {\'e}ny-csoportok \IeC {\'a}ttekint\IeC {\'e}se}{1}} +\@writefile{toc}{\select@language{magyar} \contentsline {section}{\numberline {3}Haszn\IeC {\'a}lat}{2}} diff --git a/Documents/RMuso.log b/Documents/RMuso.log new file mode 100644 index 0000000..578cee3 --- /dev/null +++ b/Documents/RMuso.log @@ -0,0 +1,589 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2016.10.24) 2 NOV 2016 11:20 +entering extended mode + restricted \write18 enabled. + file:line:error style messages enabled. + %&-line parsing enabled. +**\input RMuso.tex +(./RMuso.tex (/usr/share/texmf-dist/tex/latex/base/article.cls +Document Class: article 2007/10/19 v1.4h Standard LaTeX document class +(/usr/share/texmf-dist/tex/latex/base/size12.clo +File: size12.clo 2007/10/19 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texmf-dist/tex/latex/base/inputenc.sty +Package: inputenc 2014/04/30 v1.2b Input encoding file +\inpenc@prehook=\toks14 +\inpenc@posthook=\toks15 + +(/usr/share/texmf-dist/tex/latex/base/utf8.def +File: utf8.def 2008/04/05 v1.1m UTF-8 support for inputenc +Now handling font encoding OML ... +... no UTF-8 mapping file for font encoding OML +Now handling font encoding T1 ... +... processing UTF-8 mapping file for font encoding T1 + +(/usr/share/texmf-dist/tex/latex/base/t1enc.dfu +File: t1enc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc + defining Unicode char U+00A1 (decimal 161) + defining Unicode char U+00A3 (decimal 163) + defining Unicode char U+00AB (decimal 171) + defining Unicode char U+00BB (decimal 187) + defining Unicode char U+00BF (decimal 191) + defining Unicode char U+00C0 (decimal 192) + defining Unicode char U+00C1 (decimal 193) + defining Unicode char U+00C2 (decimal 194) + defining Unicode char U+00C3 (decimal 195) + defining Unicode char U+00C4 (decimal 196) + defining Unicode char U+00C5 (decimal 197) + defining Unicode char U+00C6 (decimal 198) + defining Unicode char U+00C7 (decimal 199) + defining Unicode char U+00C8 (decimal 200) + defining Unicode char U+00C9 (decimal 201) + defining Unicode char U+00CA (decimal 202) + defining Unicode char U+00CB (decimal 203) + defining Unicode char U+00CC (decimal 204) + defining Unicode char U+00CD (decimal 205) + defining Unicode char U+00CE (decimal 206) + defining Unicode char U+00CF (decimal 207) + defining Unicode char U+00D0 (decimal 208) + defining Unicode char U+00D1 (decimal 209) + defining Unicode char U+00D2 (decimal 210) + defining Unicode char U+00D3 (decimal 211) + defining Unicode char U+00D4 (decimal 212) + defining Unicode char U+00D5 (decimal 213) + defining Unicode char U+00D6 (decimal 214) + defining Unicode char U+00D8 (decimal 216) + defining Unicode char U+00D9 (decimal 217) + defining Unicode char U+00DA (decimal 218) + defining Unicode char U+00DB (decimal 219) + defining Unicode char U+00DC (decimal 220) + defining Unicode char U+00DD (decimal 221) + defining Unicode char U+00DE (decimal 222) + defining Unicode char U+00DF (decimal 223) + defining Unicode char U+00E0 (decimal 224) + defining Unicode char U+00E1 (decimal 225) + defining Unicode char U+00E2 (decimal 226) + defining Unicode char U+00E3 (decimal 227) + defining Unicode char U+00E4 (decimal 228) + defining Unicode char U+00E5 (decimal 229) + defining Unicode char U+00E6 (decimal 230) + defining Unicode char U+00E7 (decimal 231) + defining Unicode char U+00E8 (decimal 232) + defining Unicode char U+00E9 (decimal 233) + defining Unicode char U+00EA (decimal 234) + defining Unicode char U+00EB (decimal 235) + defining Unicode char U+00EC (decimal 236) + defining Unicode char U+00ED (decimal 237) + defining Unicode char U+00EE (decimal 238) + defining Unicode char U+00EF (decimal 239) + defining Unicode char U+00F0 (decimal 240) + defining Unicode char U+00F1 (decimal 241) + defining Unicode char U+00F2 (decimal 242) + defining Unicode char U+00F3 (decimal 243) + defining Unicode char U+00F4 (decimal 244) + defining Unicode char U+00F5 (decimal 245) + defining Unicode char U+00F6 (decimal 246) + defining Unicode char U+00F8 (decimal 248) + defining Unicode char U+00F9 (decimal 249) + defining Unicode char U+00FA (decimal 250) + defining Unicode char U+00FB (decimal 251) + defining Unicode char U+00FC (decimal 252) + defining Unicode char U+00FD (decimal 253) + defining Unicode char U+00FE (decimal 254) + defining Unicode char U+00FF (decimal 255) + defining Unicode char U+0102 (decimal 258) + defining Unicode char U+0103 (decimal 259) + defining Unicode char U+0104 (decimal 260) + defining Unicode char U+0105 (decimal 261) + defining Unicode char U+0106 (decimal 262) + defining Unicode char U+0107 (decimal 263) + defining Unicode char U+010C (decimal 268) + defining Unicode char U+010D (decimal 269) + defining Unicode char U+010E (decimal 270) + defining Unicode char U+010F (decimal 271) + defining Unicode char U+0110 (decimal 272) + defining Unicode char U+0111 (decimal 273) + defining Unicode char U+0118 (decimal 280) + defining Unicode char U+0119 (decimal 281) + defining Unicode char U+011A (decimal 282) + defining Unicode char U+011B (decimal 283) + defining Unicode char U+011E (decimal 286) + defining Unicode char U+011F (decimal 287) + defining Unicode char U+0130 (decimal 304) + defining Unicode char U+0131 (decimal 305) + defining Unicode char U+0132 (decimal 306) + defining Unicode char U+0133 (decimal 307) + defining Unicode char U+0139 (decimal 313) + defining Unicode char U+013A (decimal 314) + defining Unicode char U+013D (decimal 317) + defining Unicode char U+013E (decimal 318) + defining Unicode char U+0141 (decimal 321) + defining Unicode char U+0142 (decimal 322) + defining Unicode char U+0143 (decimal 323) + defining Unicode char U+0144 (decimal 324) + defining Unicode char U+0147 (decimal 327) + defining Unicode char U+0148 (decimal 328) + defining Unicode char U+014A (decimal 330) + defining Unicode char U+014B (decimal 331) + defining Unicode char U+0150 (decimal 336) + defining Unicode char U+0151 (decimal 337) + defining Unicode char U+0152 (decimal 338) + defining Unicode char U+0153 (decimal 339) + defining Unicode char U+0154 (decimal 340) + defining Unicode char U+0155 (decimal 341) + defining Unicode char U+0158 (decimal 344) + defining Unicode char U+0159 (decimal 345) + defining Unicode char U+015A (decimal 346) + defining Unicode char U+015B (decimal 347) + defining Unicode char U+015E (decimal 350) + defining Unicode char U+015F (decimal 351) + defining Unicode char U+0160 (decimal 352) + defining Unicode char U+0161 (decimal 353) + defining Unicode char U+0162 (decimal 354) + defining Unicode char U+0163 (decimal 355) + defining Unicode char U+0164 (decimal 356) + defining Unicode char U+0165 (decimal 357) + defining Unicode char U+016E (decimal 366) + defining Unicode char U+016F (decimal 367) + defining Unicode char U+0170 (decimal 368) + defining Unicode char U+0171 (decimal 369) + defining Unicode char U+0178 (decimal 376) + defining Unicode char U+0179 (decimal 377) + defining Unicode char U+017A (decimal 378) + defining Unicode char U+017B (decimal 379) + defining Unicode char U+017C (decimal 380) + defining Unicode char U+017D (decimal 381) + defining Unicode char U+017E (decimal 382) + defining Unicode char U+200C (decimal 8204) + defining Unicode char U+2013 (decimal 8211) + defining Unicode char U+2014 (decimal 8212) + defining Unicode char U+2018 (decimal 8216) + defining Unicode char U+2019 (decimal 8217) + defining Unicode char U+201A (decimal 8218) + defining Unicode char U+201C (decimal 8220) + defining Unicode char U+201D (decimal 8221) + defining Unicode char U+201E (decimal 8222) + defining Unicode char U+2030 (decimal 8240) + defining Unicode char U+2031 (decimal 8241) + defining Unicode char U+2039 (decimal 8249) + defining Unicode char U+203A (decimal 8250) + defining Unicode char U+2423 (decimal 9251) +) +Now handling font encoding OT1 ... +... processing UTF-8 mapping file for font encoding OT1 + +(/usr/share/texmf-dist/tex/latex/base/ot1enc.dfu +File: ot1enc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc + defining Unicode char U+00A1 (decimal 161) + defining Unicode char U+00A3 (decimal 163) + defining Unicode char U+00B8 (decimal 184) + defining Unicode char U+00BF (decimal 191) + defining Unicode char U+00C5 (decimal 197) + defining Unicode char U+00C6 (decimal 198) + defining Unicode char U+00D8 (decimal 216) + defining Unicode char U+00DF (decimal 223) + defining Unicode char U+00E6 (decimal 230) + defining Unicode char U+00EC (decimal 236) + defining Unicode char U+00ED (decimal 237) + defining Unicode char U+00EE (decimal 238) + defining Unicode char U+00EF (decimal 239) + defining Unicode char U+00F8 (decimal 248) + defining Unicode char U+0131 (decimal 305) + defining Unicode char U+0141 (decimal 321) + defining Unicode char U+0142 (decimal 322) + defining Unicode char U+0152 (decimal 338) + defining Unicode char U+0153 (decimal 339) + defining Unicode char U+2013 (decimal 8211) + defining Unicode char U+2014 (decimal 8212) + defining Unicode char U+2018 (decimal 8216) + defining Unicode char U+2019 (decimal 8217) + defining Unicode char U+201C (decimal 8220) + defining Unicode char U+201D (decimal 8221) +) +Now handling font encoding OMS ... +... processing UTF-8 mapping file for font encoding OMS + +(/usr/share/texmf-dist/tex/latex/base/omsenc.dfu +File: omsenc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc + defining Unicode char U+00A7 (decimal 167) + defining Unicode char U+00B6 (decimal 182) + defining Unicode char U+00B7 (decimal 183) + defining Unicode char U+2020 (decimal 8224) + defining Unicode char U+2021 (decimal 8225) + defining Unicode char U+2022 (decimal 8226) +) +Now handling font encoding OMX ... +... no UTF-8 mapping file for font encoding OMX +Now handling font encoding U ... +... no UTF-8 mapping file for font encoding U + defining Unicode char U+00A9 (decimal 169) + defining Unicode char U+00AA (decimal 170) + defining Unicode char U+00AE (decimal 174) + defining Unicode char U+00BA (decimal 186) + defining Unicode char U+02C6 (decimal 710) + defining Unicode char U+02DC (decimal 732) + defining Unicode char U+200C (decimal 8204) + defining Unicode char U+2026 (decimal 8230) + defining Unicode char U+2122 (decimal 8482) + defining Unicode char U+2423 (decimal 9251) +)) +(/usr/share/texmf-dist/tex/generic/babel/babel.sty +Package: babel 2014/09/25 3.9l The Babel package + +(/usr/share/texmf-dist/tex/generic/babel-hungarian/magyar.ldf +Language: magyar 2007/10/19 v1.5 Magyar support from the babel v3.7 system + +(/usr/share/texmf-dist/tex/generic/babel/babel.def +File: babel.def 2014/09/25 3.9l Babel common definitions +\babel@savecnt=\count87 +\U@D=\dimen103 +) +Package babel Info: Making ` an active character on input line 2732. +\c@footnote@add=\count88 +\c@footnote@ch=\count89 +)) +(/usr/share/texmf-dist/tex/latex/base/fontenc.sty +Package: fontenc 2005/09/27 v1.99g Standard LaTeX package + +(/usr/share/texmf-dist/tex/latex/base/t1enc.def +File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file +LaTeX Font Info: Redeclaring font encoding T1 on input line 43. +)) +(/usr/share/texmf-dist/tex/latex/amsmath/amsmath.sty +Package: amsmath 2013/01/14 v2.14 AMS math features +\@mathmargin=\skip43 + +For additional information on amsmath, use the `?' option. +(/usr/share/texmf-dist/tex/latex/amsmath/amstext.sty +Package: amstext 2000/06/29 v2.01 + +(/usr/share/texmf-dist/tex/latex/amsmath/amsgen.sty +File: amsgen.sty 1999/11/30 v2.0 +\@emptytoks=\toks16 +\ex@=\dimen104 +)) +(/usr/share/texmf-dist/tex/latex/amsmath/amsbsy.sty +Package: amsbsy 1999/11/29 v1.2d +\pmbraise@=\dimen105 +) +(/usr/share/texmf-dist/tex/latex/amsmath/amsopn.sty +Package: amsopn 1999/12/14 v2.01 operator names +) +\inf@bad=\count90 +LaTeX Info: Redefining \frac on input line 210. +\uproot@=\count91 +\leftroot@=\count92 +LaTeX Info: Redefining \overline on input line 306. +\classnum@=\count93 +\DOTSCASE@=\count94 +LaTeX Info: Redefining \ldots on input line 378. +LaTeX Info: Redefining \dots on input line 381. +LaTeX Info: Redefining \cdots on input line 466. +\Mathstrutbox@=\box26 +\strutbox@=\box27 +\big@size=\dimen106 +LaTeX Font Info: Redeclaring font encoding OML on input line 566. +LaTeX Font Info: Redeclaring font encoding OMS on input line 567. +\macc@depth=\count95 +\c@MaxMatrixCols=\count96 +\dotsspace@=\muskip10 +\c@parentequation=\count97 +\dspbrk@lvl=\count98 +\tag@help=\toks17 +\row@=\count99 +\column@=\count100 +\maxfields@=\count101 +\andhelp@=\toks18 +\eqnshift@=\dimen107 +\alignsep@=\dimen108 +\tagshift@=\dimen109 +\tagwidth@=\dimen110 +\totwidth@=\dimen111 +\lineht@=\dimen112 +\@envbody=\toks19 +\multlinegap=\skip44 +\multlinetaggap=\skip45 +\mathdisplay@stack=\toks20 +LaTeX Info: Redefining \[ on input line 2665. +LaTeX Info: Redefining \] on input line 2666. +) +(/usr/share/texmf-dist/tex/latex/amsfonts/amsfonts.sty +Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support +\symAMSa=\mathgroup4 +\symAMSb=\mathgroup5 +LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold' +(Font) U/euf/m/n --> U/euf/b/n on input line 106. +) +(/usr/share/texmf-dist/tex/latex/amsfonts/amssymb.sty +Package: amssymb 2013/01/14 v3.01 AMS font symbols +) +(/usr/share/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/04/25 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/05/08 v1.15 key=value parser (DPC) +\KV@toks@=\toks21 +) +(/usr/share/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 1999/03/16 v1.09 sin cos tan (DPC) +) +(/usr/share/texmf-dist/tex/latex/latexconfig/graphics.cfg +File: graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live +) +Package graphics Info: Driver file: pdftex.def on input line 91. + +(/usr/share/texmf-dist/tex/latex/pdftex-def/pdftex.def +File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX + +(/usr/share/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO) +) +(/usr/share/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count102 +)) +\Gin@req@height=\dimen113 +\Gin@req@width=\dimen114 +) +(/usr/share/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO) +Package ifpdf Info: pdfTeX in PDF mode is detected. +) +(/usr/share/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2010/03/01 v1.5 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count103 +\Gm@cntv=\count104 +\c@Gm@tempcnt=\count105 +\Gm@bindingoffset=\dimen115 +\Gm@wd@mp=\dimen116 +\Gm@odd@mp=\dimen117 +\Gm@even@mp=\dimen118 +\Gm@layoutwidth=\dimen119 +\Gm@layoutheight=\dimen120 +\Gm@layouthoffset=\dimen121 +\Gm@layoutvoffset=\dimen122 +\Gm@dimlist=\toks22 +) +No file RMuso.aux. +\openout1 = `RMuso.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 16. +LaTeX Font Info: ... okay on input line 16. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 16. +LaTeX Font Info: ... okay on input line 16. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 16. +LaTeX Font Info: ... okay on input line 16. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 16. +LaTeX Font Info: ... okay on input line 16. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 16. +LaTeX Font Info: ... okay on input line 16. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 16. +LaTeX Font Info: ... okay on input line 16. + +LaTeX Warning: Please use \usepackage[latin2]{inputenc} with + \usepackage[magyar]{babel}. + +(/usr/share/texmf-dist/tex/context/base/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count106 +\scratchdimen=\dimen123 +\scratchbox=\box28 +\nofMPsegments=\count107 +\nofMParguments=\count108 +\everyMPshowfont=\toks23 +\MPscratchCnt=\count109 +\MPscratchDim=\dimen124 +\MPnumerator=\count110 +\makeMPintoPDFobject=\count111 +\everyMPtoPDFconversion=\toks24 +) (/usr/share/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2010/02/09 v2.5 Base part for package epstopdf + +(/usr/share/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2010/08/19 v1.1 Manage graphics extensions (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2011/04/07 v1.3 Define keys (HO) +)) +(/usr/share/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2011/06/30 v3.11 Key value format for package options (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO) + +(/usr/share/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 452. + +(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +*geometry* driver: auto-detecting +*geometry* detected driver: pdftex +*geometry* verbose mode - [ preamble ] result: +* driver: pdftex +* paper: a4paper +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* modes: +* h-part:(L,W,R)=(56.9055pt, 483.69687pt, 56.9055pt) +* v-part:(T,H,B)=(56.9055pt, 731.23584pt, 56.9055pt) +* \paperwidth=597.50787pt +* \paperheight=845.04684pt +* \textwidth=483.69687pt +* \textheight=731.23584pt +* \oddsidemargin=-15.36449pt +* \evensidemargin=-15.36449pt +* \topmargin=-52.36449pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=12.0pt +* \footskip=30.0pt +* \marginparwidth=35.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.8pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +(/usr/share/texmf-dist/tex/latex/base/article.cls +LaTeX Info: Redefining \cal on input line 506. +LaTeX Info: Redefining \mit on input line 507. +) +LaTeX Font Info: Try loading font information for U+msa on input line 17. + +(/usr/share/texmf-dist/tex/latex/amsfonts/umsa.fd +File: umsa.fd 2013/01/14 v3.01 AMS symbols A +) +LaTeX Font Info: Try loading font information for U+msb on input line 17. + +(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd +File: umsb.fd 2013/01/14 v3.01 AMS symbols B +) + +LaTeX Warning: No \author given. + +LaTeX Font Info: Try loading font information for OMS+cmr on input line 23. +(/usr/share/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <12> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 23. + [1 + + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] +Underfull \hbox (badness 10000) in paragraph at lines 53--57 + + [] + + +Underfull \hbox (badness 10000) in paragraph at lines 53--57 + + [] + + +./RMuso.tex:67: LaTeX Error: There's no line here to end. + +See the LaTeX manual or LaTeX Companion for explanation. +Type H for immediate help. + ... + +l.67 \newline + \newline +Your command was ignored. +Type I to replace it with another command, +or to continue without it. + + +./RMuso.tex:67: LaTeX Error: There's no line here to end. + +See the LaTeX manual or LaTeX Companion for explanation. +Type H for immediate help. + ... + +l.67 \newline \newline + +Your command was ignored. +Type I to replace it with another command, +or to continue without it. + + +Underfull \hbox (badness 10000) in paragraph at lines 68--74 + + [] + +[2] (./RMuso.aux) ) +Here is how much of TeX's memory you used: + 4613 strings out of 494011 + 64248 string characters out of 6160039 + 139041 words of memory out of 5000000 + 7925 multiletter control sequences out of 15000+600000 + 12103 words of font info for 34 fonts, out of 8000000 for 9000 + 600 hyphenation exceptions out of 8191 + 38i,6n,27p,336b,361s stack positions out of 5000i,500n,10000p,200000b,80000s +{/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1. +enc} +Output written on RMuso.pdf (2 pages, 109426 bytes). +PDF statistics: + 40 PDF objects out of 1000 (max. 8388607) + 28 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 1 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/Documents/RMuso.pdf b/Documents/RMuso.pdf new file mode 100644 index 0000000..848604d Binary files /dev/null and b/Documents/RMuso.pdf differ diff --git a/Documents/RMuso.tex b/Documents/RMuso.tex new file mode 100644 index 0000000..d889b09 --- /dev/null +++ b/Documents/RMuso.tex @@ -0,0 +1,75 @@ +\documentclass[12pt,a4paper]{article} +\usepackage[utf8]{inputenc} +\usepackage[magyar]{babel} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{graphicx} +\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} +\frenchspacing + +\title{Az RMuso csomag használata} +%\author{Hollós Roland} + + +\begin{document} +\maketitle +\section{A csomag alapfüggvényei} + +Az R-muso csomag az alábbi fő függvényeket használja: + +\begin{itemize} +\item muso.R +\item changecontent.R +\item setup.R +\item other\_usefull\_functions.R +\item getOutput.R +\end{itemize} +\section{Tartalmazott függvény-csoportok áttekintése} +\subsubsection*{setup.R} +Ebben az R fileban találhatjuk a \textit{setup()} függvényt, amelyben beállíthatjuk a fő paramétereket, mint például a végrehajtható fájl(muso.exe) neve/elérési útvonala, az outputfile-ok elérési helye. +\subsubsection*{muso.R} +Itt olyan fügvények találhatók, mint a \textit{rungetMuso()}, valamint a \textit{spinupMuso()} és a \textit{normalMuso()}. Az előbbi bekéri a bemeneti paramétereket. +\subsubsection*{chagecontent.R} +Itt definiáltuk azt a függvényt( \textit{changemulline()}), ami alkalmas arra, hogy adott fájlnak, adott sorait, adott tartalmakra cserélje. +\subsubsection*{other\_usefull\_functions.R} +Két függvényt tartalmaz: \textit{getyearlycum()} és \textit{getyearlymax()} Az előbbi éves összegzést végez a megfelelő változóra vonatkozóan, az utóbbi pedig meghatározza az éves maximumértéket. +\subsubsection*{getOutput.R} +Ez a file felelős az output adadok beolvasásáért, a \textit{getdailyout()}, a \textit{getmonthlyout()} és a \textit{getyearlyout()} függvények nevüknek megfelelő formátum szerint adják vissza a kimeneti értékeket. +\section{Használat} + +\subsubsection*{setup()} +A függvény, mely beállítja a környezetet a MuSo számára összesen 8 paramétert fogad el, ezek sorban: executable, parallel, calibrationpar, outputloc, inputloc, metinput, ininput, epcinput. Ezekből 11 elemű lista képződik, amit a rungetMuso igényel. Részletesebben: + +\begin{itemize} +\item \textbf{executable}: A muso/muso.exe file helye és neve. +\item \textbf{calibrationpar}: A kalibráláshoz kiválasztott változók sorszáma az epc file-ban. +\item \textbf{inputloc}: Az .ini file-ok helye. +\item \textbf{metinput}: A met. file-ok helye. +\item \textbf{epcinput}: Az epc file-ok helye. +\end{itemize} + +Alapértelmezés szerint a végrehatjható fájl az ini, a met, és az epc fájlokkal megegyező helyen található.\\ +\newline \newline +\textbf{Példa:}\\ + settings=setup(executable = "executable", calibrationpar = c(,,,), inputloc = "inputloc", metimput = "metinput", ininput = "ininput", epcinput = "epcinput") +\subsubsection*{rungetMuso} +A rungetMuso az RMuso fő függvénye. 3 dolgot csinál: a felhasználó igényei alapján megváltoztatja a bemeneti paramétereket, futtatja spinup és normal módban a MuSo-t, kiírja a kimeneti fájlokat igény szerint. Elsődlegesen a képernyőre, de az könnyen átirányítható egy változóba. \par + +Mindehhez az alábbi 3 bemenetre van szüksége: + +\begin{itemize} +\item \textbf{settings}: ez egy 11 elemű lista, amit akár a setup() függvénnyel is legenerálhatunk. +\item \textbf{parameters}: ez a változó tartalmazza az új értékeket. +\item \textbf{timee}: A változó tartalmazza, hogy az output milyen felbontásban érkezzen. 3 értéke lehet: "d"(napi) ,"m" (havi),"y" (évi). Az évi az alapértelmezett. +\end{itemize} +\newline \newline +\textbf{Példa:}\newline \newline +I. mód:\newline +settings<-setup(...)\\ +rungetMuso(settings,parameters,timee="y")\\ +II.mód:\newline +rungetMuso(setup(..),parameters,timee="y") + +\end{document} diff --git a/HOLLOS_et_al_RBBGCMuso_An_R_package_for_running_Biome-BGCMuSo_draft_04.docx b/HOLLOS_et_al_RBBGCMuso_An_R_package_for_running_Biome-BGCMuSo_draft_04.docx new file mode 100644 index 0000000..b268afe Binary files /dev/null and b/HOLLOS_et_al_RBBGCMuso_An_R_package_for_running_Biome-BGCMuSo_draft_04.docx differ diff --git a/RBBGCMuso.pdf b/RBBGCMuso.pdf new file mode 100644 index 0000000..b8b4ab9 Binary files /dev/null and b/RBBGCMuso.pdf differ diff --git a/RBBGCMuso.tex b/RBBGCMuso.tex new file mode 100644 index 0000000..3c436e4 --- /dev/null +++ b/RBBGCMuso.tex @@ -0,0 +1,75 @@ +\documentclass[12pt,a4paper]{article} +\usepackage[utf8]{inputenc} +\usepackage[magyar]{babel} +\usepackage[T1]{fontenc} +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{graphicx} +\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} +\frenchspacing + +\title{Az RBBGCMuso csomag használata} +%\author{Hollós Roland} + + +\begin{document} +\maketitle +\section{A csomag alapfüggvényei} + +Az R-muso csomag az alábbi fő függvényeket használja: + +\begin{itemize} +\item muso.R +\item changecontent.R +\item setup.R +\item other\_usefull\_functions.R +\item getOutput.R +\end{itemize} +\section{Tartalmazott függvény-csoportok áttekintése} +\subsubsection*{setup.R} +Ebben az R fileban találhatjuk a \textit{setup()} függvényt, amelyben beállíthatjuk a fő paramétereket, mint például a végrehajtható fájl(muso.exe) neve/elérési útvonala, az outputfile-ok elérési helye. +\subsubsection*{muso.R} +Itt olyan fügvények találhatók, mint a \textit{rungetMuso()}, valamint a \textit{spinupMuso()} és a \textit{normalMuso()}. Az előbbi bekéri a bemeneti paramétereket. +\subsubsection*{chagecontent.R} +Itt definiáltuk azt a függvényt( \textit{changemulline()}), ami alkalmas arra, hogy adott fájlnak, adott sorait, adott tartalmakra cserélje. +\subsubsection*{other\_usefull\_functions.R} +Két függvényt tartalmaz: \textit{getyearlycum()} és \textit{getyearlymax()} Az előbbi éves összegzést végez a megfelelő változóra vonatkozóan, az utóbbi pedig meghatározza az éves maximumértéket. +\subsubsection*{getOutput.R} +Ez a file felelős az output adadok beolvasásáért, a \textit{getdailyout()}, a \textit{getmonthlyout()} és a \textit{getyearlyout()} függvények nevüknek megfelelő formátum szerint adják vissza a kimeneti értékeket. +\section{Használat} + +\subsubsection*{setup()} +A függvény, mely beállítja a környezetet a MuSo számára összesen 8 paramétert fogad el, ezek sorban: executable, parallel, calibrationpar, outputloc, inputloc, metinput, ininput, epcinput. Ezekből 11 elemű lista képződik, amit a rungetMuso igényel. Részletesebben: + +\begin{itemize} +\item \textbf{executable}: A muso/muso.exe file helye és neve. +\item \textbf{calibrationpar}: A kalibráláshoz kiválasztott változók sorszáma az epc file-ban. +\item \textbf{inputloc}: Az .ini file-ok helye. +\item \textbf{metinput}: A met. file-ok helye. +\item \textbf{epcinput}: Az epc file-ok helye. +\end{itemize} + +Alapértelmezés szerint a végrehatjható fájl az ini, a met, és az epc fájlokkal megegyező helyen található.\\ +\newline \newline +\textbf{Példa:}\\ + settings=setup(executable = "executable", calibrationpar = c(,,,), inputloc = "inputloc", metimput = "metinput", ininput = "ininput", epcinput = "epcinput") +\subsubsection*{rungetMuso} +A rungetMuso az RMuso fő függvénye. 3 dolgot csinál: a felhasználó igényei alapján megváltoztatja a bemeneti paramétereket, futtatja spinup és normal módban a MuSo-t, kiírja a kimeneti fájlokat igény szerint. Elsődlegesen a képernyőre, de az könnyen átirányítható egy változóba. \par + +Mindehhez az alábbi 3 bemenetre van szüksége: + +\begin{itemize} +\item \textbf{settings}: ez egy 11 elemű lista, amit akár a setup() függvénnyel is legenerálhatunk. +\item \textbf{parameters}: ez a változó tartalmazza az új értékeket. +\item \textbf{timee}: A változó tartalmazza, hogy az output milyen felbontásban érkezzen. 3 értéke lehet: "d"(napi) ,"m" (havi),"y" (évi). Az évi az alapértelmezett. +\end{itemize} + +\textbf{Példa:}\newline \newline +I. mód:\newline +settings<-setup(...)\\ +rungetMuso(settings,parameters,timee="y")\\ +II.mód:\newline +rungetMuso(setup(..),parameters,timee="y") + +\end{document} diff --git a/RBBGCMuso/.Rbuildignore b/RBBGCMuso/.Rbuildignore new file mode 100644 index 0000000..91114bf --- /dev/null +++ b/RBBGCMuso/.Rbuildignore @@ -0,0 +1,2 @@ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/RBBGCMuso/DESCRIPTION b/RBBGCMuso/DESCRIPTION new file mode 100644 index 0000000..8946203 --- /dev/null +++ b/RBBGCMuso/DESCRIPTION @@ -0,0 +1,11 @@ +Package: RBBGCMuso +Title: What the Package Does (one line, title case) +Version: 0.1.7 +Authors@R: person("Roland", "Hollos", , "hollorol@gmail.com", role = c("aut", "cre")) +Description: What the package does (one paragraph) +License: GPL-2 +LazyData: true +NeedsCompilation: no +Packaged: 2016-11-15 13:58:04 UTC; hollorol +Author: First Last [aut, cre] +Maintainer: First Last diff --git a/RBBGCMuso/NAMESPACE b/RBBGCMuso/NAMESPACE new file mode 100644 index 0000000..9c9f9ac --- /dev/null +++ b/RBBGCMuso/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[^\\.]") diff --git a/RBBGCMuso/R/#rungetmuso.R# b/RBBGCMuso/R/#rungetmuso.R# new file mode 100644 index 0000000..27ae898 --- /dev/null +++ b/RBBGCMuso/R/#rungetmuso.R# @@ -0,0 +1,217 @@ +#' This runs the BBGC-MuSo model +#' @author Roland Hollós +#' @param filename Name of the initialisation files +#' @return No return, outputs are written to file +#' @usage The function works only, if ... + +Linuxp <-(Sys.info()[1]=="Linux") + +rungetMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE){ + +############################################################# +############################spinup run############################ + ########################################################## + + ##Copy the variables from settings + inputloc <- settings$inputloc + executable <- settings$executable + ininput <- settings$ininput + epc <- settings$epcinput + calibrationpar <- settings$calibrationpar + + + ##Sometimes a bug occure due to logfiles and controlfiles in the input loc directory + + + if(silent!=TRUE){ + if(length(grep("(dayout$)|(log$)",list.files(inputloc)))>0){ + cat(" \n \n WARMING: there is a log or dayout file nearby the ini files, that may cause problemes. \n \n If you want to avoid that possible problemes, please copy the log or dayout files into a save place, and after do a cleanupMuso(), or delete these manually, or run the rungetMuso(), with the agressive=TRUE parameter \n \n") + + } + + } + + if(aggressive==TRUE){ + cleanupMuso() + } + + ##change the epc file if and only if there are given parameters + if(!is.null(parameters)){ + changemulline(filename=epc[2],calibrationpar,parameters) + } + + ##We change the working directory becase of the model, but we want to avoid sideeffects, so we save the current location and after that we will change everything to it. + + whereAmI<-getwd() + ## Set the working directory to the inputloc temporary. + setwd(inputloc) + + + ##Run the model for the spinup run. + + if(silent){#silenc mode + if(Linuxp){ + #In this case, in linux machines + system(paste(executable,ininput[1],"> /dev/null",sep=" ")) + } else { + #In windows machines there is a show.output.on.console option + system(paste(executable,ininput[1],sep=" "),show.output.on.console = FALSE) + } + + } else { + system(paste(executable,ininput[1],sep=" ")) + } + + + + logspinup<-list.files(inputloc)[grep("log$",list.files(inputloc))]#load the logfiles + if(length(logspinup)==0){ + return("Modell Failure")#in that case the modell did not create even a logfile + } + + spincrash<-tail(readLines(paste(inputloc,logspinup,sep=""),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes + + if(!spincrash){##If spinup did not crashed, run the normal run. + + ##################################################################### + ###########################normal run######################### + ################################################################# + + ##for the sake of safe we set the location again + setwd(inputloc) + + if(silent){ + if(Linuxp){ + system(paste(executable,ininput[2],"> /dev/null",sep=" ")) + } else { + system(paste(executable,ininput[2],sep=" "),show.output.on.console = FALSE) + } + + } else { + system(paste(executable,ininput[2],sep=" ")) + } + + + ##read the output + + switch(timee, + "d"=(Reva<-getdailyout(settings)), + "m"=(Reva<-getmonthlyout(settings)), + "y"=(Reva<-getyearlyout(settings)) + ) + } + + + logfiles <- list.files(inputloc)[grep("log$",list.files(inputloc))]#creating a vector for logfilenames + +############################################### +#############LOG SECTION####################### +############################################### + + perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error + + if((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on + #If log or ERROR directory does not exists create it! + dirName<-paste(inputloc,"LOG",sep="") + dirERROR<-paste(inputloc,"ERROR",sep="") + + if(!dir.exists(dirName)){ + dir.create(dirName) + } + + if(!dir.exists(dirERROR)){ + dir.create(dirERROR) + } + } + +##if errorsign is 1 there is error, if it is 0 everything ok + if(length(perror)>sum(perror)){ + errorsign <- 1 + } else { + errorsign <- 0 + } + + + if(keepEpc){#if keepepc option tured on + + if(length(unique(dirname(epc)))>1){ + print("Why are you playing with my nervs? Seriously? You hold your epc-s in different folders?") + } else { + epcdir <- dirname(epc[1]) + + WRONGEPC<-paste(inputloc,"WRONGEPC",sep="") + EPCS<-paste(inputloc,"EPCS",sep="") + + if(!dir.exists(WRONGEPC)){ + dir.create(WRONGEPC) + } + + if(!dir.exists(EPCS)){ + dir.create(EPCS) + } + + epcfiles <- list.files(epcdir)[grep("epc$",list.files(epcdir))] + stampnum<-stamp(EPCS) + lapply(epcfiles,function (x) file.copy(from = paste(epcdir,"/",x,sep=""),to=paste(EPCS,"/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply(epcfiles,function (x) file.copy(from = paste(EPCS,"/",(stampnum+1),"-",x,sep=""), to=WRONGEPC)) + } + + } + } + + + + + + if(debugging=="stamplog"){ + stampnum<-stamp(dirName) + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.copy(from=paste(dirName, "/",(stampnum+1),"-",x,sep=""), to=dirERROR ))} + + } else { if(debugging){ + if(is.null(logfilename)){ + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName,"/", x, sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName,"/", x, sep=""), to=dirERROR)) + } + + } else { + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",logfilename,"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName, "/",logfilename,"-",x,sep=""), to=dirERROR)) + } + } + + }} + + cleanupMuso() + + if(errorsign==1){ + return("Modell Failure") + } + + if(timee=="d"){ + colnames(Reva) <- unlist(settings$outputvars[[1]]) + } else { + if(timee=="y") + colnames(Reva) <- unlist(settings$outputvars[[2]]) + } + + if(export!=FALSE){ + setwd(whereAmI) + + ## switch(fextension(export), + ## "csv"=(write.csv(Reva,export)), + ## "xlsx"=(), + ## "odt"= + + + ## ) + + + } else{ + setwd(whereAmI) + return(Reva)} +} diff --git a/RBBGCMuso/R/.Rhistory b/RBBGCMuso/R/.Rhistory new file mode 100644 index 0000000..4fbde38 --- /dev/null +++ b/RBBGCMuso/R/.Rhistory @@ -0,0 +1 @@ +list.files() diff --git a/RBBGCMuso/R/changcontent.R b/RBBGCMuso/R/changcontent.R new file mode 100644 index 0000000..b6cceb4 --- /dev/null +++ b/RBBGCMuso/R/changcontent.R @@ -0,0 +1,30 @@ +#' This function calls the UNIX(-like) sed program to change specific line to other, using the row numbers. +#' @author Roland +#' @param The name of the file which is needed to be changed in some lines, the numbers of this lines(vector), and +#' the contents(vector). +#' @return void + + +changeSpecLine<-function(lineNumber,content,file){ + TOT=readLines(file,-1) + TOT[lineNumber]<-content + writeLines(TOT,file) + } + +changemulline <- function(filename,calibrationpar,contents){ + #This is the function which is capable change multiple specific lines to other using their row numbers. + #The function uses the previous changspecline function to operate. + varnum <- length(calibrationpar) + if(length(contents)!=varnum) + { + cat("Error: number of the values is not the same as the number of the changed parameters") + } + + TOT=readLines(filename,-1) + TOT[calibrationpar]<-contents + writeLines(TOT,filename) +} + + + + diff --git a/RBBGCMuso/R/cleanup.R b/RBBGCMuso/R/cleanup.R new file mode 100644 index 0000000..d8d87f5 --- /dev/null +++ b/RBBGCMuso/R/cleanup.R @@ -0,0 +1,55 @@ +cleanupMuso <- function(location=NULL,deep=FALSE){ + + whereAmI <- getwd() + if(!is.null(location)){ + setwd(location) + } + + if(deep){ + if(dir.exists("LOG")){ + setwd("LOG") + file.remove( + grep("(out$)|(endpoint$)|(log$)", + list.files(), value = T) + )} + + if(dir.exists("../ERROR")){ + setwd("../ERROR") + + file.remove( + grep("(out$)|(endpoint$)|(log$)", + list.files(), value = T) + )} + + if(dir.exists("../EPCS")){ + setwd("../EPCS") + + file.remove( + grep("(out$)|(endpoint$)|(log$)|(epc$)", + list.files(), value = T) + )} + + if(dir.exists("../WRONGEPC")){ + setwd("../WRONGEPC") + + file.remove( + grep("(out$)|(endpoint$)|(log$)|(epc$)", + list.files(), value = T) + )} + + setwd("..") + file.remove( + grep("(out$)|(endpoint$)|(log$)", + list.files(), value = T) + ) + + } + + file.remove( + grep("(out$)|(endpoint$)|(log$)", + list.files(), value = T) + ) + + setwd(whereAmI) + +} diff --git a/RBBGCMuso/R/getOutput.R b/RBBGCMuso/R/getOutput.R new file mode 100644 index 0000000..598de78 --- /dev/null +++ b/RBBGCMuso/R/getOutput.R @@ -0,0 +1,39 @@ +getthewholedata<-function(settings){ + f1<-settings$ininput[2] + filename = paste(settings$inputloc,settings$outputname,"_ann.txt",sep="") + alloutput<-read.table(filename,skip=22, header = FALSE) + return(alloutput) +} + +getthespecdata<-function(settings,colnumbers){ + filename<-paste(settings$inputloc,settings$outputname,"_ann.txt",sep="") + specoutput<-read.table(filename,skip=22, header = FALSE)[,colnumbers] + return(specoutput) +} + +getdailyout<-function(settings){ + binaryname<-paste(settings$inputloc,settings$outputname,".dayout",sep="") + d<-file(binaryname,"rb") + dayoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[1])),(settings$numyears*365),byrow=TRUE) + close(d) + return(dayoutput) +} + +getmonthlyout<-function(settings){ + binaryname<-paste(settings$inputloc,settings$outputname,".monavgout",sep="") + d<-file(binaryname,"rb") + monoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[2])),(settings$numyears*12),byrow=TRUE) + close(d) + return(monoutput) +} + +getyearlyout<-function(settings){ + binaryname<-paste(settings$inputloc,settings$outputname,".annout",sep="") + d<-file(binaryname,"rb") + yearoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[3])),(settings$numyears),byrow=TRUE) + close(d) + return(yearoutput) +} + + + diff --git a/RBBGCMuso/R/musotime.R b/RBBGCMuso/R/musotime.R new file mode 100644 index 0000000..1a5a274 --- /dev/null +++ b/RBBGCMuso/R/musotime.R @@ -0,0 +1,80 @@ + +isLeapyear <- function(year){ + + if(((year%%4==0)&(year%%100!=0))|(year%%400==0)){ + return(TRUE) + } else { + return(FALSE) + } +} + +dayOfMonths <- function(year){ + + dayMonths <- c(31,28,31,30,31,30,31,31,30,31,30,31) + + if(isLeapyear(year)==TRUE){ + dayMonths[2] <-29 + } + + return(dayMonths) +} + +dayOfYears <- function(year){ + + if(isLeapyear(year)==TRUE){ + return(366) + } else { + return(365) + } + +} + +sumDaysOfPeriod <- function(year, periodlen){ + years <- year:(year+periodlen) + years100 <-length(which(years%%100==0)) + years400 <-length(which(years%%400==0)) + years4 <- length(which(years%%4==0)) + numberOfLeapdays <- years4-years100+years400 + days <- periodlen*365+numberOfLeapdays + return(days) +} + + +musoDate <- function(settings,timestep="d",combined=TRUE, corrigate=TRUE){ + + days <- sumDaysOfPeriod(settings$startyear,settings$numyears) + dates <- matrix(rep(NA,days*3),ncol=3) + dates[1,] <- c(settings$startyear,1,1) + + for(i in 2:days){ + dates[i,]<-dates[(i-1),] + if((dates[i-1,2]==12)&(dates[i-1,3]==31)){ + dates[i,] <-c((dates[(i-1),1]+1),1,1) + } else { + if(dates[i-1,3]==(dayOfMonths(dates[(i-1),1])[dates[(i-1),2]] )){ + dates[i,]<-c(dates[(i-1),1],(dates[(i-1),2]+1),1) + } else { + dates[i,3]<-dates[(i-1),3]+1 + } + } + + } + + if(corrigate==TRUE){ + if(comined==TRUE){ + dates <- apply(dates,1,function(x) paste(x,collapse="."))[1:(settings$numyears*365)] + return(dates) + } + + dates<-dates[(1:(settings$numyears*365)),] + + } + + if(comined==TRUE){ + dates <- apply(dates,1,function(x) paste(x,collapse=".")) + return(dates) + } + + return(dates) + +} diff --git a/RBBGCMuso/R/normalmuso.R b/RBBGCMuso/R/normalmuso.R new file mode 100644 index 0000000..970de1c --- /dev/null +++ b/RBBGCMuso/R/normalmuso.R @@ -0,0 +1,79 @@ +normalMuso<- function(settings,parameters=c(" ECOPHYS"),timee="d",debugging=FALSE,logfilename=NULL){ + changemulline(settings,parameters) + + inputloc<-settings$inputloc + executable<-settings$executable + ininput<-settings$ininput + + + + + setwd(inputloc) + #normal run + system(paste(executable,ininput[2],sep=" ")) + + switch(timee, + "d"=(Reva<-getdailyout(settings)), + "m"=(Reva<-getmonthlyout(settings)), + "y"=(Reva<-getyearlyout(settings)) + ) + + + logfiles<-list.files(inputloc)[grep("log$",list.files(inputloc))] + +#############LOG SECTION####################### + perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1)))) + dirName<-paste(inputloc,"/LOG",sep="") + dirERROR<-paste(inputloc,"/ERROR",sep="") + ERROR_EPC<-paste(inputloc,"/ERROR_EPC",sep="") + + if(!dir.exists(dirName)){ + dir.create(dirName) + } + + if(!dir.exists(dirERROR)){ + dir.create(dirERROR) + } + + if(length(perror)>sum(perror)){ + errorsign <- 1 + } else { + errorsign <- 0 + } + + + + if(debugging=="stamplog"){ + stampnum<-stamp(dirName) + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.copy(from=paste(dirName, "/",(stampnum+1),"-",x,sep=""), to=dirERROR ))} + + } else { if(debugging){ + if(is.null(logfilename)){ + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName,"/", x, sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName,"/", x, sep=""), to=dirERROR)) + } + + } else { + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",logfilename,"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName, "/",logfilename,"-",x,sep=""), to=dirERROR)) + } + } + + }} + + + cleanupMuso() + if(errorsign==1){ + return("Modell Failure") + } + + + + + return(Reva) + +} diff --git a/RBBGCMuso/R/other_usefull_functions.R b/RBBGCMuso/R/other_usefull_functions.R new file mode 100644 index 0000000..5165fa0 --- /dev/null +++ b/RBBGCMuso/R/other_usefull_functions.R @@ -0,0 +1,53 @@ +#' 'Funtion for getting cumulative yearly data from observations +#' @author Roland Hollós +#' @param A vector of the daily observations. +#' @return A vector of yearly data + + +getyearlycum<-function(daily_observations){ + number_of_years<-length(daily_observations)/365 + # daily_observations[is.na(daily_observations)]<-0 # 3+NA=NA + fr<-1 + yearlycum<-rep(NA,number_of_years) + for(i in 1:number_of_years){ + to<-i*365 + yearlycum[i]<-sum(daily_observations[fr:to],na.rm = TRUE) + fr<-i*365+1 + } + return(yearlycum) +} + +#' 'Function for getting the maximum values of the years, from daily data +#' @author Roland Hollós +#' @param A vector of the daily observations +#' @return A vector of yearly data + +getyearlymax<-function(daily_observations){ + number_of_years<-length(daily_observations)/365 + # daily_observations[is.na(daily_observations)]<-0 # 3+NA=NA + fr<-1 + yearlycum<-rep(NA,number_of_years) + for(i in 1:number_of_years){ + to<-i*365 + yearlymax[i]<-max(daily_observations[fr:to],na.rm=TRUE) + fr<-i*365+1 + } + return(yearlymax) +} + +fextension <- function(x){ + #this function gives back the given filenames extension + fextension <- tail(unlist(strsplit(x,"\\.")),1) +} + +supportedMuso <- function(x="outputs"){ + supportedFormats <- c("xls","xlsx","odt","csv","txt") + + if(x=="outputs"){ + #If you add new format supports, please expand the lists + return(supportedFormats) + } + if(x=="message"){ + return(cat("Supported formats are ",supportedFormats,"If your fileformat is something else, we automaticle coerced it to csv.\n")) + } +} diff --git a/RBBGCMuso/R/output_mapping.R b/RBBGCMuso/R/output_mapping.R new file mode 100644 index 0000000..c5d5706 --- /dev/null +++ b/RBBGCMuso/R/output_mapping.R @@ -0,0 +1,5 @@ +musoMapping <- function(code){ +variableCodes<-c("1","0","2","1","3","2","4","3","5","4","6","5","7","6","8","7","9","8","10","9","11","10","12","11","13","12","14","13","15","14","16","15","17","16","18","17","19","18","20","19","21","20","22","21","23","22","24","23","25","24","26","25","27","26","28","27","29","28","30","29","31","30","32","31","33","32","34","34","35","35","36","36","37","37","38","38","39","39","40","40","41","41","42","42","43","43","44","44","45","45","46","46","47","47","48","48","49","49","50","50","51","51","52","52","53","53","54","54","55","55","56","56","57","57","58","58","59","59","60","60","61","61","62","62","63","63","64","64","65","65","66","66","67","67","68","68","69","69","70","70","71","71","72","72","73","73","74","74","75","75","76","76","77","77","78","78","79","79","80","80","81","81","82","82","83","83","84","84","85","85","86","86","87","87","88","88","89","89","90","90","91","91","92","92","93","93","94","94","95","95","96","96","97","97","98","98","99","99","100","100","101","101","102","102","103","103","104","104","105","105","106","106","107","107","108","108","109","109","110","110","111","111","112","112","113","113","114","114","115","115","116","116","117","117","118","118","119","119","120","120","121","121","122","122","123","123","124","124","125","125","126","126","127","127","128","128","129","129","130","130","131","131","132","132","133","133","134","134","135","135","136","136","137","137","138","138","139","139","140","140","141","141","142","142","143","143","144","144","145","145","146","146","147","147","148","148","149","149","150","150","151","151","152","152","153","153","154","154","155","155","156","156","157","157","158","158","159","159","160","160","161","161","162","162","163","163","164","164","165","165","166","166","167","167","168","168","169","169","170","170","171","171","172","172","173","173","174","174","175","175","176","176","177","177","178","178","179","179","180","180","181","181","182","182","183","183","184","184","185","185","186","186","187","187","188","188","189","189","190","190","191","191","192","192","193","193","194","194","195","195","196","196","197","197","198","198","199","199","200","200","201","201","202","202","203","203","204","204","205","205","206","206","207","207","208","208","209","209","210","210","211","211","212","212","213","213","214","214","215","215","216","216","217","217","218","218","219","219","220","220","221","221","222","222","223","223","224","224","225","225","226","226","227","227","228","228","229","229","230","230","231","231","232","232","233","233","234","234","235","235","236","236","237","237","238","238","239","239","240","240","241","241","242","242","243","243","244","244","245","245","246","246","247","247","248","248","249","249","250","250","251","251","252","252","253","253","254","280","255","281","256","282","257","283","258","284","259","285","260","286","261","287","262","288","263","289","264","290","265","291","266","292","267","293","268","294","269","295","270","296","271","297","272","298","273","299","274","300","275","301","276","302","277","303","278","304","279","305","280","306","281","307","282","308","283","309","284","310","285","311","286","312","287","313","288","314","289","315","290","316","291","317","292","318","293","319","294","320","295","321","296","322","297","323","298","324","299","325","300","326","301","327","302","328","303","329","304","340","305","341","306","342","307","343","308","344","309","345","310","346","311","347","312","348","313","349","314","350","315","351","316","352","317","353","318","354","319","355","320","356","321","357","322","358","323","359","324","360","325","361","326","362","327","363","328","364","329","365","330","366","331","367","332","368","333","369","334","370","335","371","336","372","337","373","338","374","339","375","340","376","341","377","342","378","343","379","344","380","345","381","346","382","347","383","348","384","349","385","350","386","351","387","352","388","353","389","354","390","355","391","356","392","357","393","358","394","359","395","360","396","361","397","362","398","363","399","364","400","365","401","366","402","367","403","368","404","369","405","370","406","371","407","372","408","373","409","374","410","375","411","376","412","377","413","378","414","379","415","380","416","381","417","382","418","383","419","384","420","385","421","386","422","387","423","388","424","389","425","390","426","391","427","392","428","393","429","394","430","395","431","396","433","397","434","398","435","399","436","400","437","401","438","402","439","403","440","404","441","405","442","406","443","407","444","408","445","409","446","410","447","411","448","412","449","413","450","414","451","415","452","416","453","417","454","418","455","419","456","420","457","421","458","422","459","423","460","424","461","425","462","426","463","427","464","428","480","429","481","430","482","431","483","432","484","433","500","434","501","435","502","436","503","437","504","438","505","439","506","440","507","441","508","442","509","443","510","444","511","445","512","446","513","447","514","448","515","449","516","450","517","451","518","452","519","453","520","454","521","455","522","456","526","457","527","458","528","459","529","460","530","461","531","462","532","463","533","464","534","465","535","466","536","467","537","468","538","469","539","470","540","471","541","472","542","473","543","474","544","475","545","476","546","477","547","478","548","479","549","480","550","481","551","482","552","483","553","484","560","485","561","486","562","487","563","488","564","489","565","490","566","491","567","492","568","493","569","494","570","495","571","496","572","497","573","498","574","499","575","500","576","501","577","502","578","503","579","504","590","505","591","506","592","507","593","508","594","509","595","510","596","511","597","512","598","513","599","514","600","515","601","516","602","517","603","518","604","519","605","520","606","521","607","522","608","523","609","524","612","525","613","526","614","527","615","528","616","529","617","530","618","531","619","532","620","533","621","534","622","535","623","536","624","537","625","538","626","539","627","540","628","541","629","542","630","543","631","544","632","545","633","546","634","547","635","548","636","549","637","550","638","551","639","552","640","553","641","554","642","555","643","556","644","557","645","558","646","559","647","560","648","561","649","562","650","563","651","564","652","565","653","566","654","567","655","568","656","569","657","570","658","571","prcp","572","tmax","573","tmin","574","tavg","575","tday","576","tnight","577","tsoil_avg","578","vpd","579","swavgfd","580","swabs","581","swtrans","582","swabs_per_plaisun","583","swabs_per_plaishade","584","ppfd_per_plaisun","585","ppfd_per_plaishade","586","par","587","GDD","588","pa","589","co2","590","dayl","591","soilw_SUM","592","snoww","593","canopyw","594","prcp_src","595","runoff_snk","596","soilevap_snk","597","snowsubl_snk","598","canopyevap_snk","599","trans_snk","600","deeppercolation_snk","601","deepdiffusion_snk","602","deeptrans_src","603","groundwater_src","604","evapotransp","605","prcp_to_canopyw","606","prcp_to_soilw","607","prcp_to_snoww","608","canopyw_evap","609","canopyw_to_soilw","610","snoww_subl","611","snoww_to_soilw","612","soilw_evap","613","soilw_trans_SUM","614","prcp_to_runoff","615","canopyw_to_THN","616","canopyw_to_MOW","617","canopyw_to_GRZ","618","canopyw_to_HRV","619","canopyw_to_PLG","620","leafc","621","leafc_storage","622","leafc_transfer","623","frootc","624","frootc_storage","625","frootc_transfer","626","livestemc","627","livestemc_storage","628","livestemc_transfer","629","deadstemc","630","deadstemc_storage","631","deadstemc_transfer","632","livecrootc","633","livecrootc_storage","634","livecrootc_transfer","635","deadcrootc","636","deadcrootc_storage","637","deadcrootc_transfer","638","gresp_storage","639","gresp_transfer","640","cwdc","641","litr1c","642","litr2c","643","litr3c","644","litr4c","645","soil1c","646","soil2c","647","soil3c","648","soil4c","649","STDBc","650","CTDBc","651","psnsun_src","652","leaf_mr_snk","653","leaf_gr_snk","654","froot_mr_snk","655","froot_gr_snk","656","livestem_mr_snk","657","livestem_gr_snk","658","deadstem_gr_snk","659","livecroot_mr_snk","660","livecroot_gr_snk","661","deadcroot_gr_snk","662","litr1_hr_snk","663","litr2_hr_snk","664","litr4_hr_snk","665","soil1_hr_snk","666","soil2_hr_snk","667","soil3_hr_snk","668","soil4_hr_snk","669","fire_snk","670","fruitc","671","fruitc_storage","672","fruitc_transfer","673","softstemc","674","softstemc_storage","675","softstemc_transfer","676","THNsnk","677","THNsrc","678","MOWsnk","679","MOWsrc","680","GRZsnk","681","GRZsrc","682","HRVsnk","683","HRVsrc","684","PLGsnk","685","PLGsrc","686","PLTsrc","687","FRZsrc","688","SNSCsnk","689","SNSCsrc","690","m_leafc_to_litr1c","691","m_leafc_to_litr2c","692","m_leafc_to_litr3c","693","m_leafc_to_litr4c","694","m_frootc_to_litr1c","695","m_frootc_to_litr2c","696","m_frootc_to_litr3c","697","m_frootc_to_litr4c","698","m_leafc_storage_to_litr1c","699","m_frootc_storage_to_litr1c","700","m_livestemc_storage_to_litr1c","701","m_deadstemc_storage_to_litr1c","702","m_livecrootc_storage_to_litr1c","703","m_deadcrootc_storage_to_litr1c","704","m_leafc_transfer_to_litr1c","705","m_frootc_transfer_to_litr1c","706","m_livestemc_transfer_to_litr1c","707","m_deadstemc_transfer_to_litr1c","708","m_livecrootc_transfer_to_litr1c","709","m_deadcrootc_transfer_to_litr1c","710","m_livestemc_to_cwdc","711","m_deadstemc_to_cwdc","712","m_livecrootc_to_cwdc","713","m_deadcrootc_to_cwdc","714","m_gresp_storage_to_litr1c","715","m_gresp_transfer_to_litr1c","716","m_leafc_to_fire","717","m_frootc_to_fire","718","m_leafc_storage_to_fire","719","m_frootc_storage_to_fire","720","m_livestemc_storage_to_fire","721","m_deadstemc_storage_to_fire","722","m_livecrootc_storage_to_fire","723","m_deadcrootc_storage_to_fire","724","m_leafc_transfer_to_fire","725","m_frootc_transfer_to_fire","726","m_livestemc_transfer_to_fire","727","m_deadstemc_transfer_to_fire","728","m_livecrootc_transfer_to_fire","729","m_deadcrootc_transfer_to_fire","730","m_livestemc_to_fire","731","m_deadstemc_to_fire","732","m_livecrootc_to_fire","733","m_deadcrootc_to_fire","734","m_gresp_storage_to_fire","735","m_gresp_transfer_to_fire","736","m_litr1c_to_fire","737","m_litr2c_to_fire","738","m_litr3c_to_fire","739","m_litr4c_to_fire","740","m_cwdc_to_fire","741","leafc_transfer_to_leafc","742","frootc_transfer_to_frootc","743","livestemc_transfer_to_livestemc","744","deadstemc_transfer_to_deadstemc","745","livecrootc_transfer_to_livecrootc","746","deadcrootc_transfer_to_deadcrootc","747","leafc_to_litr1c","748","leafc_to_litr2c","749","leafc_to_litr3c","750","leafc_to_litr4c","751","frootc_to_litr1c","752","frootc_to_litr2c","753","frootc_to_litr3c","754","frootc_to_litr4c","755","leaf_day_mr","756","leaf_night_mr","757","froot_mr","758","livestem_mr","759","livecroot_mr","760","psnsun_to_cpool","761","psnshade_to_cpool","762","cwdc_to_litr2c","763","cwdc_to_litr3c","764","cwdc_to_litr4c","765","litr1_hr","766","litr1c_to_soil1c","767","litr2_hr","768","litr2c_to_soil2c","769","litr3c_to_litr2c","770","litr4_hr","771","litr4c_to_soil3c","772","soil1_hr","773","soil1c_to_soil2c","774","soil2_hr","775","soil2c_to_soil3c","776","soil3_hr","777","soil3c_to_soil4c","778","soil4_hr","779","cpool_to_leafc","780","cpool_to_leafc_storage","781","cpool_to_frootc","782","cpool_to_frootc_storage","783","cpool_to_livestemc","784","cpool_to_livestemc_storage","785","cpool_to_deadstemc","786","cpool_to_deadstemc_storage","787","cpool_to_livecrootc","788","cpool_to_livecrootc_storage","789","cpool_to_deadcrootc","790","cpool_to_deadcrootc_storage","791","cpool_to_gresp_storage","792","cpool_leaf_gr","793","transfer_leaf_gr","794","cpool_froot_gr","795","transfer_froot_gr","796","cpool_livestem_gr","797","transfer_livestem_gr","798","cpool_deadstem_gr","799","transfer_deadstem_gr","800","cpool_livecroot_gr","801","transfer_livecroot_gr","802","cpool_deadcroot_gr","803","transfer_deadcroot_gr","804","leafc_storage_to_leafc_transfer","805","frootc_storage_to_frootc_transfer","806","livestemc_storage_to_livestemc_transfer","807","deadstemc_storage_to_deadstemc_transfer","808","livecrootc_storage_to_livecrootc_transfer","809","deadcrootc_storage_to_deadcrootc_transfer","810","gresp_storage_to_gresp_transfer","811","livestemc_to_deadstemc","812","livecrootc_to_deadcrootc","813","leafc_to_MOW","814","STDBc_to_GRZ","815","STDBc_to_MOW","816","STDBc_to_HRV","817","STDBc_to_PLG","818","CTDBc_to_PLG","819","CH4_flux_soil","820","CH4_flux_FERMENT","821","CH4_flux_MANURE","822","m_vegc_to_SNSC","823","m_STDBc_to_SNSC","824","leafn","825","leafn_storage","826","leafn_transfer","827","frootn","828","frootn_storage","829","frootn_transfer","830","livestemn","831","livestemn_storage","832","livestemn_transfer","833","deadstemn","834","deadstemn_storage","835","deadstemn_transfer","836","livecrootn","837","livecrootn_storage","838","livecrootn_transfer","839","deadcrootn","840","deadcrootn_storage","841","deadcrootn_transfer","842","cwdn","843","litr1n","844","litr2n","845","litr3n","846","litr4n","847","soil1n","848","soil2n","849","soil3n","850","soil4n","851","sminn_RZ","852","retransn","853","npool","854","nfix_src","855","ndep_src","856","nleached_snk","857","nvol_snk","858","fire_snk","859","THNsnk","860","MOWsnk","861","GRZsnk","862","GRZsrc","863","HRVsnk","864","HRVsrc","865","PLGsnk","866","PLGsrc","867","PLTsrc","868","FRZsrc","869","SNSCsnk","870","SNSCsrc","871","BNDRYsrc","872","ndiffused_snk","873","STDBn","874","m_leafn_to_litr1n","875","m_leafn_to_litr2n","876","m_leafn_to_litr3n","877","m_leafn_to_litr4n","878","m_frootn_to_litr1n","879","m_frootn_to_litr2n","880","m_frootn_to_litr3n","881","m_frootn_to_litr4n","882","m_leafn_storage_to_litr1n","883","m_frootn_storage_to_litr1n","884","m_livestemn_storage_to_litr1n","885","m_deadstemn_storage_to_litr1n","886","m_livecrootn_storage_to_litr1n","887","m_deadcrootn_storage_to_litr1n","888","m_leafn_transfer_to_litr1n","889","m_frootn_transfer_to_litr1n","890","m_livestemn_transfer_to_litr1n","891","m_deadstemn_transfer_to_litr1n","892","m_livecrootn_transfer_to_litr1n","893","m_deadcrootn_transfer_to_litr1n","894","m_livestemn_to_litr1n","895","m_livestemn_to_cwdn","896","m_deadstemn_to_cwdn","897","m_livecrootn_to_litr1n","898","m_livecrootn_to_cwdn","899","m_deadcrootn_to_cwdn","900","m_retransn_to_litr1n","901","m_leafn_to_fire","902","m_frootn_to_fire","903","m_leafn_storage_to_fire","904","m_frootn_storage_to_fire","905","m_livestemn_storage_to_fire","906","m_deadstemn_storage_to_fire","907","m_livecrootn_storage_to_fire","908","m_deadcrootn_storage_to_fire","909","m_leafn_transfer_to_fire","910","m_frootn_transfer_to_fire","911","m_livestemn_transfer_to_fire","912","m_deadstemn_transfer_to_fire","913","m_livecrootn_transfer_to_fire","914","m_deadcrootn_transfer_to_fire","915","m_livestemn_to_fire","916","m_deadstemn_to_fire","917","m_livecrootn_to_fire","918","m_deadcrootn_to_fire","919","m_retransn_to_fire","920","m_litr1n_to_fire","921","m_litr2n_to_fire","922","m_litr3n_to_fire","923","m_litr4n_to_fire","924","m_cwdn_to_fire","925","leafn_transfer_to_leafn","926","frootn_transfer_to_frootn","927","livestemn_transfer_to_livestemn","928","deadstemn_transfer_to_deadstemn","929","livecrootn_transfer_to_livecrootn","930","deadcrootn_transfer_to_deadcrootn","931","leafn_to_litr1n","932","leafn_to_litr2n","933","leafn_to_litr3n","934","leafn_to_litr4n","935","leafn_to_retransn","936","frootn_to_litr1n","937","frootn_to_litr2n","938","frootn_to_litr3n","939","frootn_to_litr4n","940","ndep_to_sminn","941","nfix_to_sminn","942","cwdn_to_litr2n","943","cwdn_to_litr3n","944","cwdn_to_litr4n","945","litr1n_to_soil1n","946","sminn_to_soil1n_l1","947","litr2n_to_soil2n","948","sminn_to_soil2n_l2","949","litr3n_to_litr2n","950","litr4n_to_soil3n","951","sminn_to_soil3n_l4","952","soil1n_to_soil2n","953","sminn_to_soil2n_s1","954","soil2n_to_soil3n","955","sminn_to_soil3n_s2","956","soil3n_to_soil4n","957","sminn_to_soil4n_s3","958","soil4n_to_sminn","959","sminn_to_nvol_l1s1","960","sminn_to_nvol_l2s2","961","sminn_to_nvol_l4s3","962","sminn_to_nvol_s1s2","963","sminn_to_nvol_s2s3","964","sminn_to_nvol_s3s4","965","sminn_to_nvol_s4","966","retransn_to_npool","967","sminn_to_npool","968","npool_to_leafn","969","npool_to_leafn_storage","970","npool_to_frootn","971","npool_to_frootn_storage","972","npool_to_livestemn","973","npool_to_livestemn_storage","974","npool_to_deadstemn","975","npool_to_deadstemn_storage","976","npool_to_livecrootn","977","npool_to_livecrootn_storage","978","npool_to_deadcrootn","979","npool_to_deadcrootn_storage","980","leafn_storage_to_leafn_transfer","981","frootn_storage_to_frootn_transfer","982","livestemn_storage_to_livestemn_transfer","983","deadstemn_storage_to_deadstemn_transfer","984","livecrootn_storage_to_livecrootn_transfer","985","deadcrootn_storage_to_deadcrootn_transfer","986","livestemn_to_deadstemn","987","livestemn_to_retransn","988","livecrootn_to_deadcrootn","989","livecrootn_to_retransn","990","STDBn_to_GRZ","991","STDBn_to_HRV","992","STDBn_to_PLG","993","STDBn_to_MOW","994","N2O_flux_soil","995","N2O_flux_GRZ","996","N2O_flux_FRZ","997","nplus","998","remdays_curgrowth","999","remdays_transfer","1000","remdays_litfall","1001","predays_transfer","1002","predays_litfall","1003","day_leafc_litfall_increment","1004","day_frootc_litfall_increment","1005","day_livestemc_turnover_increment","1006","day_livecrootc_turnover_increment","1007","annmax_leafc","1008","annmax_frootc","1009","annmax_livestemc","1010","annmax_livecrootc","1011","dsr","1012","proj_lai","1013","all_lai","1014","plaisun","1015","plaishade","1016","sun_proj_sla","1017","shade_proj_sla","1018","psi_avg","1019","vwc_avg","1020","dlmr_area_sun","1021","dlmr_area_shade","1022","gl_t_wv_sun","1023","gl_t_wv_shade","1024","assim_sun","1025","assim_shade","1026","daily_gross_nmin","1027","daily_gross_nimmob","1028","daily_net_nmin","1029","m_tmin","1030","m_soilstress","1031","max_conduct","1032","m_ppfd_sun","1033","m_ppfd_shade","1034","m_vpd","1035","m_final_sun","1036","m_final_shade","1037","gl_bl","1038","gl_c","1039","gl_s_sun","1040","gl_s_shade","1041","gl_e_wv","1042","gl_sh","1043","gc_e_wv","1044","gc_sh","1045","ytd_maxplai","1046","vwc[0]","1047","vwc[1]","1048","vwc[2]","1049","vwc[3]","1050","vwc[4]","1051","vwc[5]","1052","vwc[6]","1053","n_limitation","1054","pa","1055","co2","1056","t","1057","lnc","1058","flnr","1059","ppfd","1060","g","1061","dlmr","1062","Ci","1063","O2","1064","Ca","1065","gamma","1066","Kc","1067","Ko","1068","Vmax","1069","Jmax","1070","J","1071","Av","1072","Aj","1073","A","1074","pa","1075","co2","1076","t","1077","lnc","1078","flnr","1079","ppfd","1080","g","1081","dlmr","1082","Ci","1083","O2","1084","Ca","1085","gamma","1086","Kc","1087","Ko","1088","Vmax","1089","Jmax","1090","J","1091","Av","1092","Aj","1093","A","1094","abgc","1095","cum_npp_ann","1096","sum_ndemand","1097","PLG_cpool","1098","PLG_npool","1099","litr_aboveground","1100","litr_belowground","1101","daily_nbp","1102","daily_npp","1103","daily_nep","1104","daily_nee","1105","daily_gpp","1106","daily_mr","1107","daily_gr","1108","daily_hr","1109","daily_fire","1110","cum_npp","1111","cum_nep","1112","cum_nee","1113","cum_gpp","1114","cum_mr","1115","cum_gr","1116","cum_hr","1117","cum_fire","1118","vegc","1119","litrc","1120","soilc","1121","soiln","1122","daily_litfallc","1123","Cchange_MOW","1124","Cchange_HRV","1125","Cchange_PLG","1126","Cchange_GRZ","1127","Cchange_FRZ","1128","Cchange_PLT","1129","Cchange_SNSC","1130","daily_sr","1131","daily_tr","1132","cum_ET","1133","tsoil[0]","1134","tsoil[1]","1135","tsoil[2]","1136","tsoil[3]","1137","tsoil[4]","1138","tsoil[5]","1139","tsoil[6]","1140","tsoil_surface") +variableCodes <- matrix(variableCodes[seq(from=2,to=2280,by=2)],2,byrow=TRUE) +return(variableCodes[2,][which(variableCodes[1,]==as.character(code))]) +} diff --git a/RBBGCMuso/R/plotMuso.R b/RBBGCMuso/R/plotMuso.R new file mode 100644 index 0000000..d31d5b7 --- /dev/null +++ b/RBBGCMuso/R/plotMuso.R @@ -0,0 +1,51 @@ +plotMuso <- function(settings, + variable, + ##compare, + ##plotname, + parameters="ECOPHYS", + timee="d", + silent=TRUE, + debugging=FALSE, + keepEpc=FALSE, + logfilename=NULL, + export=FALSE){ + + + musoData <- rungetMuso(settings=settings, + silent=silent, + timee=timee, + parameters=parameters, + debugging=debugging, + keepEpc=keepEpc, + logfilename=logfilename, + export=export) + + xlab_muso<- switch(timee, "d"="days","y"="years","m"=months) + numVari <- ncol(musoData) + + if(is.numeric(variable)){ + if((variable>numVari)|(variable<1)){ + return(print(paste("The variable parameter must be between 1 and ",numVari))) + } + + + plot(musoData[,variable],pch=20,col = "dark blue",xlab=xlab_muso,ylab=colnames(musoData)[variable]) + } else { + if(variable=="all"){ + + musoData <- rbind((1:ncol(musoData)),musoData) #creating the column indexes + par(mfrow = c(2,numVari/2)) + + apply(musoData, 2, function(x) plot(x[2:length(x)],pch=20,col="dark blue",xlab=xlab_muso,ylab = colnames(musoData)[x[1]])) + return(print("Everything was Ok. ;)")) + } else { + return(print("The variable option is the coloumn number of the output data-matrix, so it must be numeric, of if you want to plot the whole data matrix set it \"all\"")) + } + + + } + + + + +} diff --git a/RBBGCMuso/R/rungetmuso.R b/RBBGCMuso/R/rungetmuso.R new file mode 100644 index 0000000..39b90a0 --- /dev/null +++ b/RBBGCMuso/R/rungetmuso.R @@ -0,0 +1,216 @@ +#' This runs the BBGC-MuSo model +#' @author Roland Hollós +#' @param filename Name of the initialisation files +#' @return No return, outputs are written to file +#' @usage The function works only, if ... + +Linuxp <-(Sys.info()[1]=="Linux") + +rungetMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE){ + +############################################################# +############################spinup run############################ + ########################################################## + + ##Copy the variables from settings + inputloc <- settings$inputloc + executable <- settings$executable + ininput <- settings$ininput + epc <- settings$epcinput + calibrationpar <- settings$calibrationpar + + + ##Sometimes a bug occure due to logfiles and controlfiles in the input loc directory +##alma + + if(silent!=TRUE){ + if(length(grep("(dayout$)|(log$)",list.files(inputloc)))>0){ + cat(" \n \n WARMING: there is a log or dayout file nearby the ini files, that may cause problemes. \n \n If you want to avoid that possible problemes, please copy the log or dayout files into a save place, and after do a cleanupMuso(), or delete these manually, or run the rungetMuso(), with the agressive=TRUE parameter \n \n") + + } + + } + + if(aggressive==TRUE){ + cleanupMuso() + } + + ##change the epc file if and only if there are given parameters + if(!is.null(parameters)){ + changemulline(filename=epc[2],calibrationpar,parameters) + } + + ##We change the working directory becase of the model, but we want to avoid sideeffects, so we save the current location and after that we will change everything to it. + + whereAmI<-getwd() + ## Set the working directory to the inputloc temporary. + setwd(inputloc) + + + ##Run the model for the spinup run. + + if(silent){#silenc mode + if(Linuxp){ + #In this case, in linux machines + system(paste(executable,ininput[1],"> /dev/null",sep=" ")) + } else { + #In windows machines there is a show.output.on.console option + system(paste(executable,ininput[1],sep=" "),show.output.on.console = FALSE) + } + + } else { + system(paste(executable,ininput[1],sep=" ")) + } + + + + logspinup<-list.files(inputloc)[grep("log$",list.files(inputloc))]#load the logfiles + if(length(logspinup)==0){ + return("Modell Failure")#in that case the modell did not create even a logfile + } + + spincrash<-tail(readLines(paste(inputloc,logspinup,sep=""),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes + + if(!spincrash){##If spinup did not crashed, run the normal run. + + ##################################################################### + ###########################normal run######################### + ################################################################# + + ##for the sake of safe we set the location again + setwd(inputloc) + + if(silent){ + if(Linuxp){ + system(paste(executable,ininput[2],"> /dev/null",sep=" ")) + } else { + system(paste(executable,ininput[2],sep=" "),show.output.on.console = FALSE) + } + + } else { + system(paste(executable,ininput[2],sep=" ")) + } + + + ##read the output + + switch(timee, + "d"=(Reva<-getdailyout(settings)), + "m"=(Reva<-getmonthlyout(settings)), + "y"=(Reva<-getyearlyout(settings)) + ) + } + + + logfiles <- list.files(inputloc)[grep("log$",list.files(inputloc))]#creating a vector for logfilenames + +############################################### +#############LOG SECTION####################### +############################################### + + perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error + + if((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on + #If log or ERROR directory does not exists create it! + dirName<-paste(inputloc,"LOG",sep="") + dirERROR<-paste(inputloc,"ERROR",sep="") + + if(!dir.exists(dirName)){ + dir.create(dirName) + } + + if(!dir.exists(dirERROR)){ + dir.create(dirERROR) + } + } + +##if errorsign is 1 there is error, if it is 0 everything ok + if(length(perror)>sum(perror)){ + errorsign <- 1 + } else { + errorsign <- 0 + } + + + if(keepEpc){#if keepepc option tured on + + if(length(unique(dirname(epc)))>1){ + print("Why are you playing with my nervs? Seriously? You hold your epc-s in different folders?") + } else { + epcdir <- dirname(epc[1]) + + WRONGEPC<-paste(inputloc,"WRONGEPC",sep="") + EPCS<-paste(inputloc,"EPCS",sep="") + + if(!dir.exists(WRONGEPC)){ + dir.create(WRONGEPC) + } + + if(!dir.exists(EPCS)){ + dir.create(EPCS) + } + + epcfiles <- list.files(epcdir)[grep("epc$",list.files(epcdir))] + stampnum<-stamp(EPCS) + lapply(epcfiles,function (x) file.copy(from = paste(epcdir,"/",x,sep=""),to=paste(EPCS,"/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply(epcfiles,function (x) file.copy(from = paste(EPCS,"/",(stampnum+1),"-",x,sep=""), to=WRONGEPC)) + } + + } + } + + + + + + if(debugging=="stamplog"){ + stampnum<-stamp(dirName) + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.copy(from=paste(dirName, "/",(stampnum+1),"-",x,sep=""), to=dirERROR ))} + + } else { if(debugging){ + if(is.null(logfilename)){ + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName,"/", x, sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName,"/", x, sep=""), to=dirERROR)) + } + + } else { + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",logfilename,"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName, "/",logfilename,"-",x,sep=""), to=dirERROR)) + } + } + + }} + + cleanupMuso() + if(errorsign==1){ + return("Modell Failure") + } + + if(timee=="d"){ + colnames(Reva) <- unlist(settings$outputvars[[1]]) + } else { + if(timee=="y") + colnames(Reva) <- unlist(settings$outputvars[[2]]) + } + + if(export!=FALSE){ + setwd(whereAmI) + + ## switch(fextension(export), + ## "csv"=(write.csv(Reva,export)), + ## "xlsx"=(), + ## "odt"= + + + ## ) + + + } else{ + setwd(whereAmI) + return(Reva)} +} diff --git a/RBBGCMuso/R/setup.r b/RBBGCMuso/R/setup.r new file mode 100644 index 0000000..ffc1be3 --- /dev/null +++ b/RBBGCMuso/R/setup.r @@ -0,0 +1,272 @@ +#' This runs the BBGC-MuSo model +#' @author Roland Hollós +#' @param calibrationpar vector with line numbers +#' @return No return, outputs are written to file +setup <- function(executable=NULL, + parallel = F, + calibrationpar =c(1), + outputloc=NULL, + inputloc=NULL, + metinput=NULL, + CO2input=NULL, + plantinput=NULL, + thininput=NULL, + mowinput=NULL, + grazinput=NULL, + harvinput=NULL, + plouginput=NULL, + fertinput=NULL, + irrinput=NULL, + nitinput=NULL, + ininput=NULL, + epcinput=NULL + ){ + + Linuxp <-(Sys.info()[1]=="Linux") + + if(is.null(inputloc)){ + inputloc<- "./" + } + + inp <- unlist(strsplit(inputloc,"")) #This is the charactervector of the given imput location + + if(inp[length(inp)]!="/"){ + inp<-c(inp,"/") + inputloc <- paste(inp,collapse = "") + rm(inp) + }# If inp not ends in / paste one at the end, then make a string, that will be the new inputloc + + ##Example: "a/b/c ==> a/b/c/" + + if(is.null(outputloc)){ + outputloc<-inputloc + } + + if(is.null(ininput)){ + spinups<-grep("s.ini$",list.files(inputloc),value=TRUE) + normals<-grep("n.ini$",list.files(inputloc),value=TRUE) + + if(length(spinups)==1){ + ininput[1]<-paste(inputloc,spinups,sep="") + } else {return(print("There are multiple or no spinup files, please choose"))} + + + if(length(normals)==1){ + ininput[2]<-paste(inputloc,normals,sep="") + } else {return(print("There are multiple or no normal files, please choose"))} + + } + + ##read the ini files for the further changes + + inifiles<-lapply(ininput, function (x) readLines(x,-1)) + + if(is.null(epcinput)){ + epcflag=TRUE + epcinput[1] <- unlist(strsplit(grep(" EPC file name",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + epcinput[2] <- unlist(strsplit(grep(" EPC file name",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep(" EPC file name",inifiles[[1]])]<-paste(epcinput[1],"\t EPC file name",sep="") + + if(length(epcinput)==2){ + inifiles[[2]][grep(" EPC file name",inifiles[[2]])]<-paste(epcinput[2],"\t EPC file name",sep="") + } + } + + if(is.null(metinput)){ + metflag=TRUE + metinput[1] <- unlist(strsplit(grep(" met file name",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + metinput[2] <- unlist(strsplit(grep(" met file name",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep(" met file name",inifiles[[1]])]<-paste(metinput[1],"\t met file name",sep="") + + if(length(metinput)==2){ + inifiles[[2]][grep(" met file name",inifiles[[2]])]<-paste(metinput[2],"\t EPC file name",sep="") + }} + + if(is.null(CO2input)){ + CO2flag=TRUE + CO2input[1] <- unlist(strsplit(grep(" CO2 file",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + CO2input[2] <- unlist(strsplit(grep(" CO2 file",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep(" CO2 file",inifiles[[1]])]<-paste(CO2input[1],"\t CO2 file",sep="") + + if(length(CO2input)==2){ + inifiles[[2]][grep(" CO2 file",inifiles[[2]])]<-paste(CO2input[2],"\t CO2 file",sep="") + }} + + if(is.null(nitinput)){ + nitflag=TRUE + nitinput[1] <- unlist(strsplit(grep("N-dep file",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + nitinput[2] <- unlist(strsplit(grep("N-dep file",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("N-dep file",inifiles[[1]])]<-paste(nitinput[1],"N-dep file",sep="N-dep file") + + if(length(epcinput)==2){ + inifiles[[2]][grep("N-dep file",inifiles[[2]])]<-paste(nitinput[2],"N-dep file",sep="") + }} + + if(is.null(thininput)){ + thinflag=TRUE + thininput[1] <- unlist(strsplit(grep("do THINNING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + thininput[2] <- unlist(strsplit(grep("do THINNING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do THINNING",inifiles[[1]])]<-paste(thininput[1],"do THINNING",sep="") + + if(length(thininput)==2){ + inifiles[[2]][grep("do THINNING",inifiles[[2]])]<-paste(thininput[2],"do THINNING",sep="") + }} + + if(is.null(plantinput)){ + plantflag=TRUE + plantinput[1] <- unlist(strsplit(grep("do PLANTING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + plantinput[2] <- unlist(strsplit(grep("do PLANTING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do PLANTING",inifiles[[1]])]<-paste(plantinput[1],"do PLANTING",sep="") + + if(length(plantinput)==2){ + inifiles[[2]][grep("do PLANTING",inifiles[[2]])]<-paste(plantinput[2],"do PLANTING",sep="") + }} + + if(is.null(mowinput)){ + mowflag=TRUE + mowinput[1] <- unlist(strsplit(grep("do MOWING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + mowinput[2] <- unlist(strsplit(grep("do MOWING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do MOWING",inifiles[[1]])]<-paste(mowinput[1],"do MOWING",sep="") + + if(length(mowinput)==2){ + inifiles[[2]][grep("do MOWING",inifiles[[2]])]<-paste(mowinput[2],"do MOWING",sep="") + }} + + if(is.null(grazinput)){ + grazflag=TRUE + grazinput[1] <- unlist(strsplit(grep("do GRAZING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + grazinput[2] <- unlist(strsplit(grep("do GRAZING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do GRAZING",inifiles[[1]])]<-paste(grazinput[1],"do GRAZING",sep="") + + if(length(grazinput)==2){ + inifiles[[2]][grep("do GRAZING",inifiles[[2]])]<-paste(grazinput[2],"do GRAZING",sep="") + }} + + if(is.null(harvinput)){ + harvflag=TRUE + harvinput[1] <- unlist(strsplit(grep("do HARVESTING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + harvinput[2] <- unlist(strsplit(grep("do HARVESTING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do HARVESTING",inifiles[[1]])]<-paste(harvinput[1],"do HARVESTING",sep="") + + if(length(harvinput)==2){ + inifiles[[2]][grep("do HARVESTING",inifiles[[2]])]<-paste(harvinput[2],"do HARVESTING",sep="") + }} + + if(is.null(plouginput)){ + plougflag=TRUE + plouginput[1] <- unlist(strsplit(grep("do PLOUGHING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + plouginput[2] <- unlist(strsplit(grep("do PLOUGHING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do PLOUGHING",inifiles[[1]])]<-paste(plouginput[1],"do PLOUGHING",sep="") + + if(length(plouginput)==2){ + inifiles[[2]][grep("do PLOUGHING",inifiles[[2]])]<-paste(plouginput[2],"do PLOUGHING",sep="") + }} + + if(is.null(fertinput)){ + fertflag=TRUE + fertinput[1] <- unlist(strsplit(grep("do FERTILIZING",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + fertinput[2] <- unlist(strsplit(grep("do FERTILIZING",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do FERTILIZING",inifiles[[1]])]<-paste(fertinput[1],"do FERTILIZING",sep="") + + if(length(fertinput)==2){ + inifiles[[2]][grep("do FERTILIZING",inifiles[[2]])]<-paste(fertinput[2],"do FERTILIZING",sep="") + }} + + if(is.null(irrinput)){ + irrflag=TRUE + irrinput[1] <- unlist(strsplit(grep("do IRRIGATION",inifiles[[1]],value=TRUE),"[\ \t]"))[1] + irrinput[2] <- unlist(strsplit(grep("do IRRIGATION",inifiles[[2]],value=TRUE),"[\ \t]"))[1] + } else { + inifiles[[1]][grep("do IRRIGATION",inifiles[[1]])]<-paste(irrinput[1],"do IRRIGATION",sep="") + + if(length(irrinput)==2){ + inifiles[[2]][grep("do IRRIGATION",inifiles[[2]])]<-paste(irrinput[2],"do IRRIGATION",sep="") + }} + + c<-grep("DAILY_OUTPUT",inifiles[[2]])+1 + numVar<-as.numeric(unlist(strsplit(inifiles[[2]][c],"[\ \t]"))[1]) + dailyVarCodes<-inifiles[[2]][(c+1):(c+numVar)] + dailyVarnames<-lapply(dailyVarCodes, function(x) musoMapping(unlist(strsplit(x,"[\ \t]"))[1])) + + c<-grep("ANNUAL_OUTPUT",inifiles[[2]])+1 + numVar<-as.numeric(unlist(strsplit(inifiles[[2]][c],"[\ \t]"))[1]) + annualVarCodes<-inifiles[[2]][(c+1):(c+numVar)] + annualVarnames<-lapply(annualVarCodes, function(x) musoMapping(unlist(strsplit(x,"[\ \t]"))[1])) + outputvars<-list(dailyVarnames,annualVarnames) + + + if(is.null(executable)){ + if(Linuxp){ + executable<-paste(inputloc,"muso",sep="") + } else { + executable<-paste(inputloc,"muso.exe",sep="") + } + } else { + file.copy(executable,inputloc) + if(Linuxp){ + executable<-paste(inputloc,"muso",sep="") + } else { + executable<-paste(inputloc,"muso.exe",sep="") + } + + } +5+4 + + outputname <- unlist(strsplit(grep("prefix for output files",inifiles[[2]],value=TRUE),"[\ \t]"))[1] +## outputname<-unlist(read.table(ininput[2],skip=93,nrows = 1))[1] + inputfiles<-c(ininput,epcinput,metinput) + numdata<-rep(NA,3) + numyears <- as.numeric(unlist(strsplit(grep("simulation years",inifiles[[2]],value=TRUE),"[\ \t]"))[1]) + ## numyears<-unlist(read.table(ininput[2],skip = 14,nrows = 1)[1]) + numvalues <- as.numeric(unlist(strsplit(grep("number of daily output variables",inifiles[[2]],value=TRUE),"[\ \t]"))[1]) + ## numvalues<-unlist(read.table(ininput[2],skip=102,nrows = 1)[1]) + startyear <- as.numeric(unlist(strsplit(grep("first simulation year",inifiles[[2]],value=TRUE),"[\ \t]"))[1]) + numdata[1]<-numyears*numvalues*365 + numdata[2]<-numyears*numvalues*12 + numdata[3]<-numyears*numvalues + + settings = list(executable = executable, + calibrationpar = calibrationpar, + outputloc=outputloc, + outputnames=outputname, + inputloc=inputloc, + ininput=ininput, + metinput=metinput, + epcinput=epcinput, + thininput=thininput, + CO2input=CO2input, + mowinput=mowinput, + grazinput=grazinput, + harvinput=harvinput, + plouginput=plouginput, + fertinput=fertinput, + irrinput=irrinput, + nitinput=nitinput, + inputfiles=inputfiles, + numdata=numdata, + startyear=startyear, + numyears=numyears, + outputvars=outputvars + ) + + if(!(epcflag&CO2flag&nitflag&thinflag&plantflag&mowflag&grazflag&harvflag&plougflag&fertflag&irrflag)){ + writeLines(inifiles[[1]],ininput[[1]]) + if(epcinput[1]!=epcinput[2]){ + writeLines(inifiles[[2]],ininput[[2]]) + } + } + return(settings) + +} + diff --git a/RBBGCMuso/R/soilcalib.R b/RBBGCMuso/R/soilcalib.R new file mode 100644 index 0000000..59b6ebd --- /dev/null +++ b/RBBGCMuso/R/soilcalib.R @@ -0,0 +1 @@ +soilMatrix <- function(numberOfLayers=) diff --git a/RBBGCMuso/R/spinupmuso.R b/RBBGCMuso/R/spinupmuso.R new file mode 100644 index 0000000..217e9a5 --- /dev/null +++ b/RBBGCMuso/R/spinupmuso.R @@ -0,0 +1,119 @@ +spinupMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, silent=FALSE, aggressive=FALSE){ + ##Copy the variables from settings + inputloc <- settings$inputloc + executable <- settings$executable + ininput <- settings$ininput + epc <- settings$epcinput + calibrationpar <- settings$calibrationpar + + ##Sometimes a bug occure due to logfiles and controlfiles in the input loc directory + + if(silent!=TRUE){ + if(length(grep("(dayout$)|(log$)",list.files(inputloc)))>0){ + cat(" \n \n WARMING: there is a log or dayout file nearby the ini files, that may cause problemes. \n \n If you want to avoid that possible problemes, please copy the log or dayout files into a save place, and after do a cleanupMuso(), or delete these manually, or run the rungetMuso(), with the agressive=TRUE parameter \n \n") + + } + + } + ##With the aggressive option every unneeded file will deleted + if(aggressive==TRUE){ + cleanupMuso() + } + + + ##change the epc file if and only if there are given parameters + if(!is.null(parameters)){ + changemulline(settings, parameters) + } + + ##We change the working directory becase of the model, but we want to avoid sideeffects, so we save the current location and after that we will change everything to it. + + whereAmI<-getwd() + ## Set the working directory to the inputloc temporary. + setwd(inputloc) + ##Run the spinup + system(paste(executable,ininput[1],sep=" ")) + + logfiles<-list.files(inputloc)[grep("log$",list.files(inputloc))] + perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1)))) + dirName<-paste(inputloc,"/LOG",sep="") + dirERROR<-paste(inputloc,"/ERROR",sep="") + ERROR_EPC<-paste(inputloc,"/ERROR_EPC",sep="") + + + + + if(!dir.exists(dirName)){ + dir.create(dirName) + } + + if(!dir.exists(dirERROR)){ + dir.create(dirERROR) + } + + if(length(perror)>sum(perror)){ + errorsign <- 1 + } else { + errorsign <- 0 + } + + + if(keepEpc){#if keepepc option tured on + + if(length(unique(dirname(epc)))>1){ + print("Why are you playing with my nervs? Seriously? You hold your epc-s in different folders?") + } else { + epcdir <- dirname(epc[1]) + + WRONGEPC<-paste(inputloc,"WRONGEPC",sep="") + EPCS<-paste(inputloc,"EPCS",sep="") + + if(!dir.exists(WRONGEPC)){ + dir.create(WRONGEPC) + } + + if(!dir.exists(EPCS)){ + dir.create(EPCS) + } + + epcfiles <- list.files(epcdir)[grep("epc$",list.files(epcdir))] + stampnum<-stamp(EPCS) + lapply(epcfiles,function (x) file.copy(from = paste(epcdir,"/",x,sep=""),to=paste(EPCS,"/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply(epcfiles,function (x) file.copy(from = paste(EPCS,"/",(stampnum+1),"-",x,sep=""), to=WRONGEPC)) + } + + } + } + + if(debugging=="stamplog"){ + stampnum<-stamp(dirName) + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",(stampnum+1),"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.copy(from=paste(dirName, "/",(stampnum+1),"-",x,sep=""), to=dirERROR ))} + + } else { if(debugging){ + if(is.null(logfilename)){ + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName,"/", x, sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName,"/", x, sep=""), to=dirERROR)) + } + + } else { + lapply( logfiles, function (x) file.rename(from=paste(inputloc,x, sep=""), to=paste(dirName, "/",logfilename,"-",x,sep=""))) + if(errorsign==1){ + lapply( logfiles, function (x) file.rename(from=paste(dirName, "/",logfilename,"-",x,sep=""), to=dirERROR)) + } + } + + }} + + + cleanupMuso() + if(errorsign==1){ + return("Modell Failure") + } + + +} + diff --git a/RBBGCMuso/R/stamp.R b/RBBGCMuso/R/stamp.R new file mode 100644 index 0000000..919a867 --- /dev/null +++ b/RBBGCMuso/R/stamp.R @@ -0,0 +1,17 @@ +numcut<-function(string){ + #This function returns only the starting numbers of a string + unlist(strsplit(grep("^[0-9]",string,value = TRUE),"[aAzZ-]"))[1] + } + +numcutall<-function(vector){ + #numcall apply numcut for all elements of a string vector +as.numeric(unlist(apply(as.matrix(vector),1,numcut))) +} + +stamp<-function(path="./"){ + #It gives back a stamp wich is the maximum number of the output numcall + numbers<-numcutall(list.files(path)) + if(length(numbers)==0){ + return (0)} else { + return(max(numbers))} +} diff --git a/RBBGCMuso/RBBGCMuso.Rproj b/RBBGCMuso/RBBGCMuso.Rproj new file mode 100644 index 0000000..3a76475 --- /dev/null +++ b/RBBGCMuso/RBBGCMuso.Rproj @@ -0,0 +1,16 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/RBBGCMuso/forarcheologists b/RBBGCMuso/forarcheologists new file mode 100644 index 0000000..a9f4cf3 --- /dev/null +++ b/RBBGCMuso/forarcheologists @@ -0,0 +1,88 @@ + + +## runMuso <- function(settings, parameters=c(" ECOPHYS")){ +## #changing section +## # for(i in changeinput){ +## # changemulline(settings, parameters[[i]]) +## # } +## changemulline(settings,parameters) + +## #spinup run +## # changemulline(type=1,setup(), parameters[[2]]) +## setwd(settings$inputloc) +## system(paste(settings$executable,settings$ininput[1],sep=" ")) +## #normal run +## setwd(settings$inputloc) +## system(paste(settings$executable,settings$ininput[2],sep=" ")) +## } + +## rungetMusowc <- function(settings,parameters=c(" ECOPHYS"),timee="y",logfile=FALSE,logfilename=NULL){ +## #spinup run +## # changemulline(type=1,setup(), parameters[[2]]) +## changemulline(settings,parameters) +## setwd(settings$inputloc) +## system(paste(settings$executable,settings$ininput[1],sep=" ")) +## #normal run +## setwd(settings$inputloc) +## system(paste(settings$executable,settings$ininput[2],sep=" ")) + +## switch(timee, +## "d"=(Reva<-getdailyout(settings)), +## "m"=(Reva<-getmonthlyout(settings)), +## "y"=(Reva<-getyearlyout(settings)) +## ) +## return(Reva) +## } + + + +##For this functions there is a built in dirname function in R, which do the same. +## splitstr <- function(string, sep){ +## return(unlist(strsplit(string,sep))) +## } + +## containerdir<-function(string){ +## return(paste(splitstr(string,"/")[1:(length(splitstr(string,"/"))-1)],collapse = "/")) +##} + + + +## changspecline <- function(filename, line_number,content){ +## #This function calls the UNIX(-like) sed program to change specific line to other, using the row numbers. +## for_command_line <- paste("sed -i '",line_number,"s/.*/",content,"/'"," ",filename, sep="") +## system(for_command_line) +## } + +## changespecline<- function(filename,line_number,content){ +## TOT=readLines(filename,-1) +## TOT[line_number]<-content +## writeLines(TOT,filename) +## } + +## changemulline <- function(settings,contents){ +## #This is the function which is capable change multiple specific lines to other using their row numbers. +## #The function uses the previous changspecline function to operate. +## varnum <- length(settings$calibrationpar) +## if(length(contents)!=varnum) +## { +## cat("Error: number of the values is not the same as the number of the changed parameters") +## } + +## for(i in 1:varnum){ +## changspecline(settings$epcinput,settings$calibrationpar[i], contents[i] ) +## } +## } + +## changmulline2 <- function(settings,contents){ +## #This is the function which is capable change multiple specific lines to other using their row numbers. +## #The function uses the previous changspecline function to operate. +## varnum <- length(settings$calibrationpar) +## if(length(contents)!=varnum) +## { +## cat("Error: number of the values is not the same as the number of the changed parameters") +## } + +## for(i in 1:varnum){ +## changespecline(settings$epcinput,settings$calibrationpar[i], contents[i] ) +## } +## } \ No newline at end of file diff --git a/RBBGCMuso/man/#setup.Rd# b/RBBGCMuso/man/#setup.Rd# new file mode 100644 index 0000000..1e5e3d1 --- /dev/null +++ b/RBBGCMuso/man/#setup.Rd# @@ -0,0 +1,23 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/setup.r +\name{setup} +\alias{setup} +\title{This runs the Muso model} +\usage{ +setup(executable = NULL, parallel = F, calibrationpar = c(1), + outputloc = NULL, inputloc = NULL, metinput = NULL, ininput = NULL, + epcinput = NULL) +} +\arguments{ +\item{calibrationpar}{vector with line numbers} +} +\value{ +No return, outputs are written to file +} +\description{ +This runs the Muso model +} +\author{ +Roland +} + diff --git a/RBBGCMuso/man/changspecline.Rd b/RBBGCMuso/man/changspecline.Rd new file mode 100644 index 0000000..bcd5ac7 --- /dev/null +++ b/RBBGCMuso/man/changspecline.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/changcontent.R +\name{changspecline} +\alias{changspecline} +\title{This function calls the UNIX(-like) sed program to change specific line to other, using the row numbers.} +\usage{ +changspecline(filename, line_number, content) +} +\arguments{ +\item{The}{name of the file which is needed to be changed in some lines, the numbers of this lines(vector), and +the contents(vector).} +} +\value{ +void +} +\description{ +This function calls the UNIX(-like) sed program to change specific line to other, using the row numbers. +} +\author{ +Roland +} + diff --git a/RBBGCMuso/man/getyearlycum.Rd b/RBBGCMuso/man/getyearlycum.Rd new file mode 100644 index 0000000..87a3168 --- /dev/null +++ b/RBBGCMuso/man/getyearlycum.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/other_usefull_functions.R +\name{getyearlycum} +\alias{getyearlycum} +\title{'Funtion for getting cumulative yearly data from observations} +\usage{ +getyearlycum(daily_observations) +} +\arguments{ +\item{A}{vector of the daily observations.} +} +\value{ +A vector of yearly data +} +\description{ +'Funtion for getting cumulative yearly data from observations +} +\author{ +Roland Hollós +} + diff --git a/RBBGCMuso/man/getyearlymax.Rd b/RBBGCMuso/man/getyearlymax.Rd new file mode 100644 index 0000000..68f01f3 --- /dev/null +++ b/RBBGCMuso/man/getyearlymax.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/other_usefull_functions.R +\name{getyearlymax} +\alias{getyearlymax} +\title{'Function for getting the maximum values of the years, from daily data} +\usage{ +getyearlymax(daily_observations) +} +\arguments{ +\item{A}{vector of the daily observations} +} +\value{ +A vector of yearly data +} +\description{ +'Function for getting the maximum values of the years, from daily data +} +\author{ +Roland Hollós +} + diff --git a/RBBGCMuso/man/runMuso.Rd b/RBBGCMuso/man/runMuso.Rd new file mode 100644 index 0000000..fb4c5d4 --- /dev/null +++ b/RBBGCMuso/man/runMuso.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/muso.R +\name{runMuso} +\alias{runMuso} +\title{This runs the Muso model} +\usage{ +The function works only, if ... +} +\arguments{ +\item{filename}{Name of the initialisation files} +} +\value{ +No return, outputs are written to file +} +\description{ +This runs the Muso model +} +\author{ +Roland +} + diff --git a/RBBGCMuso/man/setup.Rd b/RBBGCMuso/man/setup.Rd new file mode 100644 index 0000000..1e5e3d1 --- /dev/null +++ b/RBBGCMuso/man/setup.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/setup.r +\name{setup} +\alias{setup} +\title{This runs the Muso model} +\usage{ +setup(executable = NULL, parallel = F, calibrationpar = c(1), + outputloc = NULL, inputloc = NULL, metinput = NULL, ininput = NULL, + epcinput = NULL) +} +\arguments{ +\item{calibrationpar}{vector with line numbers} +} +\value{ +No return, outputs are written to file +} +\description{ +This runs the Muso model +} +\author{ +Roland +} + diff --git a/RBBGCMuso_0.1.7.tar.gz b/RBBGCMuso_0.1.7.tar.gz new file mode 100644 index 0000000..598bb24 Binary files /dev/null and b/RBBGCMuso_0.1.7.tar.gz differ diff --git a/RBBGCMuso_0.1.7.tar.gz.bcg b/RBBGCMuso_0.1.7.tar.gz.bcg new file mode 100644 index 0000000..c7f096c Binary files /dev/null and b/RBBGCMuso_0.1.7.tar.gz.bcg differ diff --git a/RBBGCMuso_archive/RBBGCMuso_0.1.1.tar.gz b/RBBGCMuso_archive/RBBGCMuso_0.1.1.tar.gz new file mode 100644 index 0000000..546f8dc Binary files /dev/null and b/RBBGCMuso_archive/RBBGCMuso_0.1.1.tar.gz differ diff --git a/RBBGCMuso_archive/RBBGCMuso_0.1.2.tar.gz b/RBBGCMuso_archive/RBBGCMuso_0.1.2.tar.gz new file mode 100644 index 0000000..36bbd4f Binary files /dev/null and b/RBBGCMuso_archive/RBBGCMuso_0.1.2.tar.gz differ diff --git a/RBBGCMuso_archive/RBBGCMuso_0.1.3.tar.gz b/RBBGCMuso_archive/RBBGCMuso_0.1.3.tar.gz new file mode 100644 index 0000000..cc9032f Binary files /dev/null and b/RBBGCMuso_archive/RBBGCMuso_0.1.3.tar.gz differ diff --git a/RBBGCMuso_archive/RBBGCMuso_0.1.4.tar.gz b/RBBGCMuso_archive/RBBGCMuso_0.1.4.tar.gz new file mode 100644 index 0000000..be7fb73 Binary files /dev/null and b/RBBGCMuso_archive/RBBGCMuso_0.1.4.tar.gz differ diff --git a/RBBGCMuso_archive/RBBGCMuso_0.1.5.tar.gz b/RBBGCMuso_archive/RBBGCMuso_0.1.5.tar.gz new file mode 100644 index 0000000..0f2ee61 Binary files /dev/null and b/RBBGCMuso_archive/RBBGCMuso_0.1.5.tar.gz differ diff --git a/RBBGCMuso_archive/RBBGCMuso_0.1.6.tar.gz b/RBBGCMuso_archive/RBBGCMuso_0.1.6.tar.gz new file mode 100644 index 0000000..516a418 Binary files /dev/null and b/RBBGCMuso_archive/RBBGCMuso_0.1.6.tar.gz differ diff --git a/README b/README new file mode 100644 index 0000000..8d26c11 --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +README + +This is one of the most important part of the package \ No newline at end of file diff --git a/RECOMENDATION b/RECOMENDATION new file mode 100644 index 0000000..fafeb1c --- /dev/null +++ b/RECOMENDATION @@ -0,0 +1,7 @@ +RECOMENDATIONS + +- +- +- +- +-