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

Development towards v8.0.0 #378

Merged
merged 397 commits into from
Jul 15, 2024
Merged

Development towards v8.0.0 #378

merged 397 commits into from
Jul 15, 2024

Conversation

dschlaep
Copy link
Member

@dschlaep dschlaep commented Oct 25, 2023

@dschlaep dschlaep marked this pull request as draft October 25, 2023 11:23
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Attention: Patch coverage is 75.31599% with 332 lines in your changes missing coverage. Please review.

Project coverage is 73.00%. Comparing base (306aa3a) to head (3dc16b2).

Files Patch % Lines
src/SW_Control.c 66.77% 99 Missing ⚠️
src/SW_Main_lib.c 13.51% 96 Missing ⚠️
src/SW_Flow.c 80.00% 51 Missing ⚠️
src/SW_Markov.c 80.47% 33 Missing ⚠️
src/SW_Carbon.c 65.43% 28 Missing ⚠️
src/SW_Files.c 88.23% 14 Missing ⚠️
src/SW_Flow_lib_PET.c 96.47% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #378      +/-   ##
==========================================
+ Coverage   71.00%   73.00%   +1.99%     
==========================================
  Files          21       20       -1     
  Lines        5591     6005     +414     
==========================================
+ Hits         3970     4384     +414     
  Misses       1621     1621              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

N1ckP3rsl3y and others added 28 commits December 16, 2023 19:29
- New function `fill_domain_netCDF_vars()` which fill specific variables within the generated domain netCDF file with values
	* Fills horizontal coordinate variables with upper/lower bound coordinates provided by the user
	* Fills the domain variable with SUIDs
	* Fills the "site" variable with site numbers (same as SUIDs) if applicable

- New functions that are general purpose to help this function
	* `fill_netCDF_var_uint()` - Fills a variable with unsigned integer values
	* `fill_netCDF_var_double()` - Fills a variable with double values

- Modify `fill_domain_netCDF_*()` to return lat/lon variable IDs

- `SW_NC_create_domain_template()`
	* Update calls to helper functions
	* Add call to `fill_domain_netCDF_vars()`
	* Add the closing of the domain file when exiting early

- Moved the calculation of number of SUIDs to before the domain netCDF is generated
- Calculate global nc attribute "coordinate_system" from user inputs: primary CRS and provided CRS(s) -- instead of a separate user input
- error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
- warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
- warning: passing 'const int *' to parameter of type 'int *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
- and several similar errors/warnings

-> define arrays as const that hold nc attributes and nc attribute values
-> update arguments of function that deal with attributes, to be const where needed
- default inputs for the spatial bounding box now produce identical coordinates as previously (i.e., lat/lon coordinates from "modelrun.in")
`fill_domain_netCDF_xy()`
	- Now returns the variable IDs for "*_bnds" as a parameter

`fill_domain_netCDF_vals()`
	- Renamed from `fill_domain_netCDF_vars()`
	- Correct error checking at the beginning after allocation
	- Now writes `*_bnds` values

New function `alloc_netCDF_domain_vars()`
	- Allocates arrays for variables that will be written out, if a variable is not to be written out, it will not be allocated

New function `dealloc_netCDF_domain_vars()`
	- Deallocates all arrays that were allocated within `alloc_netCDF_domain_vars()`
`fill_domain_netCDF_xy()` / `fill_domain_netCDF_s()`
	- Gains argument - units - for y/x variables
	- Correct lat/lon variable units ("degrees_*")
- New functions `SW_NC_init_ptrs()` and `SW_NC_deconstruct()`
	* Initialize pointers within the structs SW_NETCDF & SW_CRS
	* Free any memory that is allocated within the struct(s)
- Functions are called in main() if SW_NETCDF is defined
- `SW_NC_check()` now accepts a file name for error description purposes
- Function now makes sure that the following things are consistent between a given netCDF file and `domain.in`
	* Domain type (crs_bbox in `domain.in` and `long_name` in a netCDF file)
	* Dimensions (sites or latitude/longitude, may also be called "y" and "x")

- New functions `get_dim_val()`
	* Uses new function `get_dim_identifier()`
		* Gets the ID of a dimension in a netCDF
	* Gets the value of a dimension within a netCDF, if it exists
- New function `is_wgs84()` which checks to see if a "long_name" and/or "crs_bbox" are a synonym of "WGS84"
- New function `varExists()` which tests to see if a specific variable exists within a netCDF file and does not report an error if the test fails
- Changed the variable `crs_bbox`'s memory from dynamic to static - 27 characters - which holds "World Geodetic System 1984" + null character
- Two new functions that generalize the initialization of pointers and deconstruction of file information and netCDF information
	* `SW_DOM_init_ptrs()` & `SW_DOM_deconstruct()`
- Removed the function `SW_NC_read_domain()` and is replaced with `SW_NC_check()`
- New functions
	* `get_var_identifier()` - Gets the variable ID from within a given netCDF file
	* `get_str_att_val()` - Gets the string value of an attribute
	* `get_double_att_val()` - Gets the double value of an attribute (can be an array)
- Redo the code within `SW_NC_check()` to cover more cases like checking both projected and geographic CRS if provided
- Remove rogue printf call
- Remove const for strings in `is_wgs84()`
- Horizontal coordinate variables that are written to in the domain netCDF now depend on the CRS bounding box user input
- Mostly replaced the checking of if the main CRS is a geographic one, we now get the bounding box CRS
- Make sure the CRS bounding box name and one CRS long name match

- Simplify the interfaces of functions that create/fill the variable (values) to use SW_DOMAIN
- Update the documentation note of the function `fill_domain_netCDF_vals()`

- Update the function mentioned in the call to `Mem_Malloc()` within `alloc_netCDF_domain_vars()`
- Fill the function `SW_NC_read_inputs()` to read the latitude/longitude from a file (currently only domain.nc)
	* Created a helper function - `get_single_double_val()` - which gets a single double value from a netCDF file

- New functions
	* `SW_NC_open_files()` - Open files (currently only domain.nc) if they exist to read from
	* `SW_NC_close_files()` - Close all files that were left open during the program run (currently only domain.nc)

- Changed the order of the calculated/translated SUID in `SW_DOM_calc_ncSuid()` for the netCDF library to properly use
- Cast "allocArr" to void
- Change name "numFreeVars" to "numAllocVars" to be more appropriate
- Use the C-netCDF provided function `nc_def_var_deflate()` with the compression level of 5 (0 - 9)
- Change this name to be consistent with the rest of the programs SW_* argument names
- Adjust whitespace in some places to try to help with readability
- Correct/modify some function documentation
- Attempt to make long function calls fit within 80 characters
- Make it so that all trinary operators have () around the conditional
N1ckP3rsl3y and others added 3 commits July 8, 2024 12:57
- SW_OUTDOM_init_ptrs - Initialize pointers found in SW_OUT_DOM
- SW_OUTDOM_deepCopy - Copies all pointers within SW_OUT_DOM, including SW_NETCDF information if defined
Reduce the copying of domain-specific information throughout simulation runs achieved by the changes
* Rename SW_ALL to SW_RUN to clarify that the information within it is simulation-dependent (#412)
* Remove SW_OUTPUT, SW_OUTPUT_POINTERS, SW_GEN_OUT
* Create two new structs: SW_OUT_DOM and SW_OUT_RUN (#395)
@dschlaep dschlaep requested a review from N1ckP3rsl3y July 9, 2024 12:29
N1ckP3rsl3y and others added 6 commits July 9, 2024 10:46
…construct()`

- Previously, the call to `memset()` would erase the information of `OutDom` when used with STEPWAT2
- STEPWAT2 will now handle the setting of this variable after the function call so that the call to `memset()` can stay
- Increase the buffer `varKey` and write size in `snprintf()` by one
- `SW_CTL_setup_model()` gains same parameter
- Update calls to these functions with new boolean value
- previously, the makefile attempt (but failed) to modify user provided environmental variables `NC_LIBS` and `UD_LIBS`
--> now, makefile first takes a local copy of the user provided environmental variables before modifying their content

- previously, `EX_LIBS` was hard-coded to "-lexpat" (if undefined) which failed if the "expat" library was not on the search path (which was unnecessarily if udunits2 was statically compiled with the expat dependency)
--> now, `EX_LIBS` remains undefined

- previously, if `nc-config --cflags` provided non-include paths for `NC_CFLAGS`, then the guess for `UD_CFLAGS` produced non-sensical outcome, e.g., "-DpgiFortran/udunits"
--> now, guessing the path for udunits2 include headers only considers an include path, and the first if multiple, from `NC_CFLAGS`
Current capabilities include: library for STEPWAT2; library for rSOILWAT2; netCDF-c; udunits2; text
- print message if text-based or nc-based SOILWAT2 fails
- print information on which of the text-based, nc-based, and rSOILWAT2 runs produced output (and which didn't)
- update README to illustrate how to pass environmental variable to make when running this script
src/SW_Output.c Outdated Show resolved Hide resolved
N1ckP3rsl3y
N1ckP3rsl3y previously approved these changes Jul 10, 2024
dschlaep added 2 commits July 10, 2024 16:01
Improve tools for nc-based SOILWAT2

- Fix makefile for user provided flags for netcdf-c, udunits2, and expat
- sw_print_version() now prints capabilities
- Improve tools/check_outputModes.sh: information on which of the output modes succeeded and which ones failed
@dschlaep dschlaep requested a review from N1ckP3rsl3y July 11, 2024 20:54
N1ckP3rsl3y
N1ckP3rsl3y previously approved these changes Jul 11, 2024
@dschlaep dschlaep marked this pull request as ready for review July 15, 2024 15:38
@dschlaep dschlaep requested a review from N1ckP3rsl3y July 15, 2024 15:38
@dschlaep dschlaep merged commit 3e5657a into master Jul 15, 2024
20 checks passed
@dschlaep dschlaep deleted the release/devel_v8.0.0 branch July 15, 2024 15:44
@dschlaep dschlaep mentioned this pull request Jul 18, 2024
11 tasks
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

Successfully merging this pull request may close these issues.

3 participants