Skip to content

Methods (eventually?) needed to deallocate all parameter-related arrays #1440

@samsrabin

Description

@samsrabin

In #1432, I'm adding unit tests that require reading a parameter file. Initially I made this happen at the beginning of each unit test in my test file, but that failed after the first test with "already allocated" errors on parameter-related arrays. Parameters registered with fates_parameters_type have no such problem because of its Destroy() method, but other parameters fail.

The first offending array was hydr_htftype_node in EDParamsMod (why isn't this on fates_parameters_type?), so I added a subroutine there to deallocate it.

Next I ran into a bigger problem: prt_param_type has a ton of arrays but no Destroy() method—or indeed, any method. Here are some ways I thought to resolve this:

  1. Add a Destroy() method to prt_param_type with a deallocate() for every parameter array. This is a bad idea because it means the unit tests would break every time a parameter array is added or removed.
  2. Add a Destroy() method to prt_param_type modeled after that in fates_parameters_type, which would require adding a bunch of other analogous methods. I don't love all the duplication in this solution.
  3. Delete prt_param_type; move all parameters in prt_param_type to the fates_params object (type fates_parameters_type). There may be a good reason to keep the PARTEH parameters on a separate object, though; I see that @rgknox did it as part of PR Nutrient Enabled Aquisition (parteh pt 3) #598 but I don't know why.
  4. Delete prt_param_type; make the prt_params object just another instance of fates_parameters_type.

I like 4 since it avoids duplicating the infrastructure code while still allowing PARTEH parameters to remain separate from the other FATES parameters.

For now, I'm working around this by just reading the parameter file once. However, I can imagine eventual unit tests that would want to perform multiple reads in the same test file—thus this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    ❕Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions