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

NetCDF Output - Domain #365

Closed
wants to merge 35 commits into from
Closed

Conversation

N1ckP3rsl3y
Copy link
Contributor

Nicholas Persley added 21 commits August 2, 2023 12:01
- Handle actions that deal with a domain entry into the program and constant information between simulation runs
- Move longitude, latitude, altitude, slope, and aspect from SW_SITE to SW_MODEL
- Created to hold information that may not change between simulation runs
	- Most start year, end year, start doy, and end doy from SW_SITE to new struct, SW_DOMAIN
- SW_ALL gains an instance of this type
- After moving the values, longitude, latitude, elevation, slope, and aspect from SW_SITE to SW_MODEL, the same information has been moved from siteparam.in to years.in
domain.in
	- Moved time information (start year, end year, start doy, and end doy) from years.in
	- Contains information that is the same throughout simulation runs

years.in
	- Rename to `modelrun.in`
		* Specifies the location and other aspects of a site that may change between simulation runs
	- Remove time information (start year, end year, start doy, and end doy)
- Because some content was moved from siteparam.in to modelrun.in, it makes sense to now read in the information through `SW_MDL_read()`
- Deleted sections of the switch statement in `SW_SIT_read()` that reads site location
- Commented old code within `SW_MDL_read()`
- List "Input/domain.in" in "files.in" before output files
- New enumeration in SW_FileIndex - eDomain for domain.in
- Increased the number of input files (SW_NFILES) to 24
- Update years.in --> modelrun.in
- Location of the new domain file (`domain.in`) within `files.in` didn't necessarily cause problems, but was in the middle of the "Simulation outputs" in "SW_FileIndex"
	* So, rather than splitting up the output indices, the name was moved before the group
SW_MDL_read
- Removed previously commented code that has been moved to SW_DOM_read
- Now only warns the user when hemisphere is found

SW_DOM_read
- Reads in spatial and temporal information from `domain.in`
- Fails/warns if something is incorrect/missing (start/end doy)
- Removed superfluous code dealing with reading-in the end day of the year (enddayval array)
- Still fails when start year is less than end year
- Still warns the user when start year and/or end year is not input and is being set to a default

key-to-id
- Helper function to `SW_DOM_read`
- Converts a possible key within `domain.in` (e.g., StartYear) and gives an id for the caller function to use

SW_Domain.h
- New defines
* NUM_DOM_IN_KEYS - Maximum number of possible keys in `domain.in`
* KEY_NOT_FOUND - Used if a user inputs a key that is not known to the program
- New reference to `domain.in`
- Renamed years.in to modelrun.in
- Modified functions interfaces if needed to reach data from SW_Domain or to reach SW_Domain itself
* The same goes for the other structs, SW_SITE and SW_MODEL
- Qualifying files gain `SW_Domain.h` as an include

Special mention: SW_VPD_init_run & estimateVegetationFromClimate
- Removed unnecessary code setting of "veg_method" along with not explicitly sending it into estimateVegetationFromClimate
# Conflicts:
#	include/SW_Site.h
#	src/SW_Output.c
#	src/SW_Site.c
- To prepare for future parallelization, SW_DOMAIN is no longer within SW_ALL and is now a local variable within `main()`
- Because SW_DOMAIN is no longer in SW_ALL, and SW_DOMAIN, in the future, is expected to be outside simulations, SW_MODEL gains back start/end year and start/end day of year
- When reading in SW_DOMAIN, SW_DOM_read() now copies that information to SW_MODEL
- Program again uses SW_MODEL for start/end year and start/end day of year
- SW_DOMAIN is now only used within SW_DOM_read
- Updated interfaces if they SW_DOMAIN was no longer needed
Copy link
Member

@dschlaep dschlaep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

Almost there.

A couple comments including the need that SW_DOMAIN is the primary source of spatial and temporal information and cannot depend on SW_MODEL (SW_MODEL represents the space and time of one specific run out of the many that are described by SW_DOMAIN).

include/SW_Domain.h Show resolved Hide resolved
include/SW_Sky.h Outdated Show resolved Hide resolved
include/SW_Control.h Show resolved Hide resolved
include/SW_datastructs.h Outdated Show resolved Hide resolved
include/SW_Carbon.h Show resolved Hide resolved
src/SW_Domain.c Outdated Show resolved Hide resolved
src/SW_Domain.c Outdated Show resolved Hide resolved
tests/example/Input/modelrun.in Show resolved Hide resolved
tests/example/files.in Outdated Show resolved Hide resolved
tests/gtests/test_SW_Weather.cc Show resolved Hide resolved
Nicholas Persley added 4 commits August 5, 2023 13:41
- This is to represent that it is the "umbrella" input
- SW_DOM_read no longer accepts SW_MODEL as an argument and thus no longer uses it to update values
	* Start/end day of year are now only set through the input value or `Time_get_lastdoy_y()`

- New function SW_DOM_setModelTime
	* Copies temporal domain information from SW_DOMAIN to SW_MODEL
	* Sets SW_MODEL's additional year
	* Called after SW_DOM_read in `SW_CTL_read_inputs_from_disk()`
dschlaep
dschlaep previously approved these changes Aug 11, 2023
include/SW_Domain.h Outdated Show resolved Hide resolved
include/SW_datastructs.h Show resolved Hide resolved
@dschlaep dschlaep self-requested a review August 11, 2023 04:14
@dschlaep dschlaep dismissed their stale review August 11, 2023 04:15

questions about the need to export domain_inkey_to_id() and inquiry about suids

Nicholas Persley added 3 commits August 11, 2023 11:56
- The function `domain_inkey_to_id()` is not used outside of SW_Domain.c, so it has been changed to a static
- Similarly, the defines found within SW_Domain.h have been moved locally to SW_Domain.c
- To make this define more accessible in the future, it has been moved from SW_Domain.c to SW_Defines.h
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.

None yet

2 participants