Constructor for objects representing a gadget model input file.

gadgetfile(file_name, file_type = "generic", components = list())

Arguments

file_name

Filename the output should be written to / read from

file_type

What sort of gadget file this is, e.g. 'time', 'area', ... See Rgadget::gadget_filetypes for recognised types. Setting this will enable any quirks of that particular file type,

components

A list of lists, representing each component.

Value

A gadgetfile S3 class, use write.gadget.file to write it to disk

Details

gadgetfile objects break all files down into the following form:

; preamble before the first unnamed component
key	value
; preamble before the second named component
[component2_name]
key1	value
key2	value
; preamble before the second named component
[component3_name]
key	value
  . . .
; preamble before the data component
[data_component]
; -- data --
; a	b	c
1	2	3

Note that values can also be gadgetfile objects, in this case That gadgetfile is written out separately, and value is replaced with the filename of the sub-file.

Examples

gadgetfile("cod.likelihood", "likelihood",
   components = list(
       component = list(type = "penalty", aggfile = gadgetfile("aggfile", components = list()))
   ))
#> ; Generated by Rgadget 0.5
#> [component]
#> type	penalty
#> aggfile	aggfile
gadgetfile('tv', file_type='timevariable',
   components=list(
       list('tvname', multipler=1),
           timedata = expand.grid(year=1988:1990, step=1:4, value=0.2/4)))
#> ; Generated by Rgadget 0.5
#> 	tvname
#> multipler	1
#> ; year	step	value
#> 1988	1	0.05
#> 1989	1	0.05
#> 1990	1	0.05
#> 1988	2	0.05
#> 1989	2	0.05
#> 1990	2	0.05
#> 1988	3	0.05
#> 1989	3	0.05
#> 1990	3	0.05
#> 1988	4	0.05
#> 1989	4	0.05
#> 1990	4	0.05
gadgetfile('sv', file_type='stockvariable',
   components=list(
       list('svname', multipler=1,
           stockdata = list(biomass=0, c('immature.capelin', 'mature.capelin')))))
#> ; Generated by Rgadget 0.5
#> 	svname
#> multipler	1
#> stockdata
#> biomass	0
#> 	immature.capelin	mature.capelin