Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to add or remove fields from nml #255

Open
jordansread opened this issue Sep 14, 2019 · 4 comments
Open

ability to add or remove fields from nml #255

jordansread opened this issue Sep 14, 2019 · 4 comments

Comments

@jordansread
Copy link
Member

Most pressing case right now is adding the Kw_file to the &light block in the glm3.nml

I need to do:

nml$light$Kw_file = 'Kw_file.csv'

which is :(

@hdugan
Copy link
Collaborator

hdugan commented Sep 18, 2019

get_nml_value(glm_nml, arg_name = 'Kw_file')
glm_nml <- set_nml(glm_nml, arg_name = 'Kw_file', arg_val = 'kw1.csv') 

These work if you already have Kw_file in the glm3.nml file.
Are you looking for the functionality to add parameters to the gml3.nml file? (can you do that with other parameters?)

@hdugan
Copy link
Collaborator

hdugan commented Sep 18, 2019

I didn't actually read the title of this issue, so apologies on the stupid question.

@hdugan
Copy link
Collaborator

hdugan commented Sep 18, 2019

This works:

glm_nml <- read_nml(nml_file = 'glm3.nml')
glm_nml$light$Kw_file = 'kd.csv'
write_nml(glm_nml, file = 'glm3.nml')

To remove it
glm_nml$light$Kw_file = NULL

@jordansread
Copy link
Member Author

Yes, that works but it is kind of a backdoor that goes around the get/set API for the nml object. But it requires you to know the nml is actually a list and you need to know how it is structured...It also requires you to know which block the parameter is in, which can change with different versions of GLM (for example Kw used to be in the set up block and is now in the light block).

I'm ok with this as a hack we can use, but it isn't ideal for other users of the package that shouldn't need to know the details of the nml object. Likewise, if we ever change the structure of the nml object, we can keep the API to it the same (if needed) and avoid code-breaking changes.

I'd say this is a low priority, but seems useful to expose a way to add or remove things directly w/ the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants