payu-org / payu

A workflow management tool for numerical models on the NCI computing systems
Apache License 2.0
18 stars 25 forks source link

Copying input files anti-pattern in CESM_CMEPS driver #365

Closed aidanheerdegen closed 9 months ago

aidanheerdegen commented 9 months ago

Problem

The CESM_CMEPS driver copies an input file to the work directory (and renames to mod_def.ww3).

https://github.com/payu-org/payu/blob/master/payu/models/cesm_cmeps.py#L181

This is an anti-pattern for payu for a couple of reasons:

  1. Input files are symbolically linked, that way the links can be removed during the archive step. The current implementation will save multiple identical copies of the mod_def.ww3 file in the outputXXX directories. Each one is quite large, e.g. 26M for a 320x384 domain.
  2. The file is copied to the top level of the work directory, and so is not captured by the input manifest

Possible fixes

These fixes assume the mod_def.ww3 files is not altered when the model is run. If it is altered, and the updated version needs to be retained then it is effectively an output or restart file, and the following options won't work.

Option 1: File can be read from input dir

Ideally the model could be be made to read the mod_def.ww3 from the input directory. In that case I would advise removing the code above entirely and making a symbolic link to the mod_def.ww3 file in the original input directory.

For example, the config provided by @ezhilsabareesh8 uses this file:

/g/data/ik11/inputs/access-om3/0.1.0/cime/wav/ww3/ww3a.mod_def.ww3.wwver7.14.220506

so making a symbolic link to it in the same same directory would work

ln -s /g/data/ik11/inputs/access-om3/0.1.0/cime/wav/ww3/ww3a.mod_def.ww3.wwver7.14.220506 /g/data/ik11/inputs/access-om3/0.1.0/cime/wav/ww3/mod_def.ww3

Then the config.yaml could use either the directory as an input, /g/data/ik11/inputs/access-om3/0.1.0/cime/wav/ww3, or use the full path to the symbolic link /g/data/ik11/inputs/access-om3/0.1.0/cime/wav/ww3/mod_def.ww3.

Option 2: File cannot be read from the input dir

If the path to mod_def.ww3 is hard-coded (and there is resistance to that being made user-settable parameter) then I would suggest altering the code linked above, and rather than copy the file, make a symbolic link to the linked file in the input directory.

A further version of this would be to follow the same steps above, and create a correctly named symbolic link in the original input directory, and then link to that link. This has the benefit that the manifest entry matches the name used by the model, so makes it a bit more obvious that this is the file that is actually used.

Summary

Both options avoid needless copying of an identical file, so are an improvement.

I favour option 1 if possible. While both options capture the mod_def.ww3 file used by the model in the input manifest, option 1 makes it clear that this was the file actually used by the model. Option 2 requires some inspection of the payu driver and/or the work directory to make this connection.

dougiesquire commented 9 months ago

Thanks @aidanheerdegen . I don't know/remember enough about WW3 off the top of my head to know what is the right solution here. But, I'll have a chat to @ezhilsabareesh8 and sort out a fix soon.

aidanheerdegen commented 9 months ago

Thanks.

dougiesquire commented 9 months ago

I had a chat to Ezhil, and unfortunately we think that the model definition file has to be in the work directory and called mod_def.ww3, so we'll have to go with your option 2. I'll submit a PR now.