Skip to content

Commit 5fb3358

Browse files
committed
Update the docs
1 parent bcf6498 commit 5fb3358

3 files changed

Lines changed: 38 additions & 16 deletions

File tree

components/omega/doc/devGuide/Field.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Fields are created with standard metadata using
3737
StdName, ///< [in] CF standard Name (string)
3838
ValidMin, ///< [in] min valid field value (same type as
3939
ValidMax, ///< [in] max valid field value field data)
40-
FillValue, ///< [in] scalar used for undefined entries
4140
NumDims, ///< [in] number of dimensions (int)
4241
Dimensions, ///< [in] dim names (vector of strings)
4342
TimeDependent ///< [in] (opt, default true) if time varying
@@ -49,9 +48,13 @@ not exist, an empty string can be provided. This is uncommon for most fields
4948
since the CF conventions maintain a fairly complete list, but can be the case
5049
for some intermediate calculations or unique analyses. If there is no
5150
restriction on valid range, an appropriately large range should be provided for
52-
the data type. Similarly, if a FillValue is not being used, a very unique
53-
number should be supplied to prevent accidentally treating valid data as a
54-
FillValue. The optional TimeDependent argument can be omitted and is assumed
51+
the data type. The fill value is not specified when creating a field; it is
52+
automatically deduced from the element type of the array passed to
53+
`attachData()` and set to the corresponding standard constant from `FillValues.h`
54+
(`FillValueI4`, `FillValueI8`, `FillValueR4`, or `FillValueR8`). These match
55+
the NetCDF-C `NC_FILL_*` standard values recognized by analysis tools such as
56+
ncview, Xarray, and NCO. The optional TimeDependent argument can be omitted
57+
and is assumed
5558
to be true by default. Fields with this attribute will be output with the
5659
unlimited time dimension added. Time should not be added explicitly in the
5760
dimension list since it will be added during I/O. Fields that do not change
@@ -113,6 +116,13 @@ is provided using the field name:
113116
InDataArray // [in] Array with data to attach
114117
);
115118
```
119+
When `attachData` is called, every element of the attached array is automatically
120+
initialized to the field's declared fill value. This ensures that inactive entries
121+
(e.g., ocean layers below `MaxLayerCell`) hold a well-defined NetCDF-standard
122+
sentinel in output without any explicit initialization in module code. Subsequent
123+
compute calls overwrite active entries; the fill value persists only where no valid
124+
data is written.
125+
116126
Note that the data is assumed to reside in only one location so if a mirror
117127
array exists (eg if replicated on host and device), a separate Field may be
118128
needed. However, it is is better to define only one location and allow the

components/omega/doc/devGuide/Tracers.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@ static void defineAllTracers() {
2424
"sea_water_potential_temperature", ///< [in] CF standard Name
2525
-273.15, ///< [in] min valid field value
2626
100.0, ///< [in] max valid field value
27-
1.e33, ///< [in] value for undef entries
27+
FillValueReal, ///< [in] value for undef entries
2828
IndxTemp); ///< [out] (optional) static index
2929

30-
define("Salt", "Salinity", "psu", "sea_water_salinity", 0.0, 50.0, 1.e33,
31-
IndxSalt);
32-
define("Debug1", "Debug Tracer 1", "none", "none", 0.0, 100.0, 1.e33);
33-
define("Debug2", "Debug Tracer 2", "none", "none", 0.0, 100.0, 1.e33);
34-
define("Debug3", "Debug Tracer 3", "none", "none", 0.0, 100.0, 1.e33);
30+
define("Salt", "Salinity", "psu", "sea_water_salinity", 0.0, 50.0,
31+
FillValueReal, IndxSalt);
32+
define("Debug1", "Debug Tracer 1", "none", "none", 0.0, 100.0, FillValueReal);
33+
define("Debug2", "Debug Tracer 2", "none", "none", 0.0, 100.0, FillValueReal);
34+
define("Debug3", "Debug Tracer 3", "none", "none", 0.0, 100.0, FillValueReal);
3535
}
3636
```
3737

38+
The `FillValueReal` constant is defined in `FillValues.h` and matches the
39+
NetCDF-C standard fill value (`NC_FILL_DOUBLE` or `NC_FILL_FLOAT` depending on
40+
the build precision). It is automatically in scope in `TracerDefs.inc` via
41+
`Field.h`. New tracers should always use `FillValueReal` (or `FillValueI4` /
42+
`FillValueI8` for integer fields) rather than hardcoded literals.
43+
3844
To add a new tracer, simply call the `define` function with the appropriate
3945
arguments. Index argument is optional one that allows to access the tracer
4046
data using the given tracer index variable.

components/omega/doc/userGuide/Tracers.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@ static void defineAllTracers() {
2626
"sea_water_potential_temperature", ///< [in] CF standard Name
2727
-273.15, ///< [in] min valid field value
2828
100.0, ///< [in] max valid field value
29-
1.e33, ///< [in] value for undef entries
29+
FillValueReal, ///< [in] value for undef entries
3030
IndxTemp); ///< [out] (optional) static index
3131

32-
define("Salt", "Salinity", "psu", "sea_water_salinity", 0.0, 50.0, 1.e33,
33-
IndxSalt);
34-
define("Debug1", "Debug Tracer 1", "none", "none", 0.0, 100.0, 1.e33);
35-
define("Debug2", "Debug Tracer 2", "none", "none", 0.0, 100.0, 1.e33);
36-
define("Debug3", "Debug Tracer 3", "none", "none", 0.0, 100.0, 1.e33);
32+
define("Salt", "Salinity", "psu", "sea_water_salinity", 0.0, 50.0,
33+
FillValueReal, IndxSalt);
34+
define("Debug1", "Debug Tracer 1", "none", "none", 0.0, 100.0, FillValueReal);
35+
define("Debug2", "Debug Tracer 2", "none", "none", 0.0, 100.0, FillValueReal);
36+
define("Debug3", "Debug Tracer 3", "none", "none", 0.0, 100.0, FillValueReal);
3737
}
3838
```
3939

40+
The `FillValueReal` constant is defined in `FillValues.h` and matches the
41+
NetCDF-C standard fill value (`NC_FILL_DOUBLE` or `NC_FILL_FLOAT` depending on
42+
the build precision). It is automatically in scope in `TracerDefs.inc` via
43+
`Field.h`. New tracers should always use `FillValueReal` (or `FillValueI4` /
44+
`FillValueI8` for integer fields) rather than hardcoded literals.
45+
4046
To add a new tracer, simply call the `define` function with the appropriate
4147
arguments. Index argument is optional one that allows to access the tracer
4248
data using the given tracer index variable.

0 commit comments

Comments
 (0)