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

Create a "Progress" netCDF #388

Merged
merged 28 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
39bca68
Create new SW_netCDF.c function stubs for the branch
N1ckP3rsl3y Dec 29, 2023
4de69cd
New input file - `progress.nc`
N1ckP3rsl3y Dec 29, 2023
c6c2195
Merge branch 'release/devel_v8.0.0' into feature_nc_progress
N1ckP3rsl3y Jan 5, 2024
575008b
Correct function headers in `SW_Domain.c`/`SW_netCDF.c`
N1ckP3rsl3y Jan 5, 2024
d021c0b
SW_NETCDF stores variable IDs + update `SW_NC_open_files()`
N1ckP3rsl3y Jan 5, 2024
bcf2d8b
Fill `SW_NC_create_template()`
N1ckP3rsl3y Jan 5, 2024
819a368
Fill `SW_NC_CreateProgress()`
N1ckP3rsl3y Jan 5, 2024
0450407
Fill `SW_NC_set_progress`/`SW_NC_check_progress()`
N1ckP3rsl3y Jan 5, 2024
dab1827
Update `get_dim_identifier()` arguments to use `const char*`
N1ckP3rsl3y Jan 5, 2024
501e72b
Fix SW_NC_read(): new switch case was missing a break
dschlaep Jan 7, 2024
5be7b20
Fix SW_CTL_RunSimSet(): numDomainErrors was no longer incremented if …
dschlaep Jan 7, 2024
217226f
progress: identify failed simulation runs
dschlaep Jan 7, 2024
2e90c24
progress.nc gains attributes "flag_values" and "flag_meanings"
dschlaep Jan 7, 2024
fe4b1d6
Fix missing ";" in non-SWNETCDF code
dschlaep Jan 7, 2024
0cbaa04
Fix Bool vs bool conversion for C++ gtests
dschlaep Jan 7, 2024
0ca81ba
Fix buffer overflow in SW_NC_read_inputs()
dschlaep Jan 7, 2024
b10a6dd
Update NEWS to describe "progress" tracking
dschlaep Jan 7, 2024
42cc205
Allow for progress variable to be within domain netCDF
N1ckP3rsl3y Jan 8, 2024
4b4e01d
Add back progress netCDF checking
N1ckP3rsl3y Jan 8, 2024
3d28889
Clarify comments and documentation for domain/progress variables/files
dschlaep Jan 9, 2024
ae9dd59
fill_prog_netCDF_vals(): free allocated memory
dschlaep Jan 9, 2024
7fd06e9
Allow user-specified hostname and username to replace automatic values
dschlaep Jan 8, 2024
1573959
New timeStringISO8601()
dschlaep Jan 9, 2024
147b191
Address warnings/errors in tests compilation with `-DSWNETCDF`
N1ckP3rsl3y Jan 9, 2024
11c03fb
Deep copy netCDF information in tests
N1ckP3rsl3y Jan 9, 2024
6bbdaf2
Simple progress messages on the console
dschlaep Jan 9, 2024
d75e5d1
Fix SW_WT_ReportTime()
dschlaep Jan 9, 2024
84dbffc
Fix progress message of creating a progress tracker
dschlaep Jan 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/SW_datastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ typedef struct {
Bool stopRun; // Specifies if an error has occurred and
// the program needs to stop early (backtrack)

Bool QuietMode; /**< Don't print version, error message, or notify user about logfile (only used by SOILWAT2) */
Bool QuietMode, /**< Don't print version, error message, or notify user about logfile (only used by SOILWAT2) */
printProgressMsg; /**< Do/don't print progress messages to the console */
} LOG_INFO;

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions include/filefuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Bool MkDir(const char *dname, LOG_INFO* LogInfo);
Bool RemoveFiles(const char *fspec, LOG_INFO* LogInfo);
Bool CopyFile(const char *from, const char *to, LOG_INFO* LogInfo);
void LogError(LOG_INFO* LogInfo, const int mode, const char *fmt, ...);
void sw_message(const char *msg);

int key_to_id(const char* key, const char **possibleKeys,
int numPossKeys);
Expand Down
8 changes: 8 additions & 0 deletions src/SW_Control.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ void SW_CTL_RunSimSet(SW_ALL *sw_template, SW_OUTPUT_POINTERS SW_OutputPtrs[],

set_walltime(&tss, &ok_tss);

#if defined(SOILWAT)
if(main_LogInfo->printProgressMsg) {
sw_message("is running simulations across the domain ...");
}
#endif

/* Loop over suids in simulation set of domain */
for(suid = SW_Domain->startSimSet; suid < SW_Domain->endSimSet; suid++)
{
Expand All @@ -238,6 +244,8 @@ void SW_CTL_RunSimSet(SW_ALL *sw_template, SW_OUTPUT_POINTERS SW_OutputPtrs[],

LOG_INFO local_LogInfo;
sw_init_logs(main_LogInfo->logfp, &local_LogInfo);
local_LogInfo.printProgressMsg = main_LogInfo->printProgressMsg;


/* Check if suid needs to be simulated */
SW_DOM_calc_ncSuid(SW_Domain, suid, ncSuid);
Expand Down
6 changes: 6 additions & 0 deletions src/SW_Domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ void SW_DOM_SimSet(SW_DOMAIN* SW_Domain, unsigned long userSUID,
*startSimSet = userSUID - 1;
*endSimSet = userSUID;
} else {
#if defined(SOILWAT)
if(LogInfo->printProgressMsg) {
sw_message("is identifying the simulation set ...");
}
#endif

*endSimSet = SW_Domain->nSUIDs;
for(*startSimSet = 0; *startSimSet < *endSimSet; (*startSimSet)++) {
SW_DOM_calc_ncSuid(SW_Domain, *startSimSet, startSuid);
Expand Down
14 changes: 10 additions & 4 deletions src/SW_Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ int main(int argc, char **argv) {
goto finishProgram;
}

// Print version if not in quiet mode
if (!LogInfo.QuietMode) {
sw_print_version();
}
// SOILWAT2: do print progress to console unless user requests quiet
LogInfo.printProgressMsg = (Bool)(!LogInfo.QuietMode);

if (LogInfo.printProgressMsg) {
sw_message("started.");
sw_print_version();
}

// setup and construct domain
SW_CTL_setup_domain(userSUID, &SW_Domain, &LogInfo);
Expand Down Expand Up @@ -162,6 +165,9 @@ int main(int argc, char **argv) {
SW_WT_ReportTime(SW_WallTime, &LogInfo);
sw_wrapup_logs(&LogInfo);
sw_fail_on_error(&LogInfo);
if (LogInfo.printProgressMsg) {
sw_message("ended.");
}
}

return 0;
Expand Down
4 changes: 4 additions & 0 deletions src/SW_Main_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ void sw_fail_on_error(LOG_INFO* LogInfo) {
if(!LogInfo->QuietMode) {
fprintf(stderr, "%s", LogInfo->errorMsg);
}
if(LogInfo->printProgressMsg) {
sw_message("ended.");
}
exit(EXIT_FAILURE);
}
#endif
Expand All @@ -280,6 +283,7 @@ void sw_init_logs(FILE* logInitPtr, LOG_INFO* LogInfo) {

LogInfo->stopRun = swFALSE;
LogInfo->QuietMode = swFALSE;
LogInfo->printProgressMsg = swFALSE;
LogInfo->numWarnings = 0;
LogInfo->numDomainWarnings = 0;
LogInfo->numDomainErrors = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/SW_Output_outtext.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ void SW_OUT_create_files(SW_FILE_STATUS* SW_FileStatus, SW_OUTPUT* SW_Output,

OutPeriod pd;

#if defined(SOILWAT)
if(LogInfo->printProgressMsg) {
sw_message("is creating output files ...");
}
#endif

ForEachOutPeriod(pd) {
if (GenOutput->use_OutPeriod[pd]) {
_create_csv_files(SW_FileStatus, pd, InFiles, LogInfo);
Expand Down
11 changes: 11 additions & 0 deletions src/SW_netCDF.c
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,12 @@ void SW_NC_create_domain_template(SW_DOMAIN* SW_Domain, LOG_INFO* LogInfo) {
return; // Exit prematurely due to error
}

#if defined(SOILWAT)
if(LogInfo->printProgressMsg) {
sw_message("is creating a domain template ...");
}
#endif

if(nc_create(DOMAIN_TEMP, NC_NETCDF4, domFileID) != NC_NOERR) {
LogError(LogInfo, LOGERROR, "Could not create new domain template due "
"to something internal.");
Expand Down Expand Up @@ -2024,6 +2030,11 @@ void SW_NC_create_progress(SW_DOMAIN* SW_Domain, LOG_INFO* LogInfo) {
create_full_var(progFileID, NC_BYTE, 0, 0, progVarName,
attNames, attVals, numAtts, LogInfo);
} else {
#if defined(SOILWAT)
if(LogInfo->printProgressMsg) {
sw_message("is creating a progress tracker ...");
N1ckP3rsl3y marked this conversation as resolved.
Show resolved Hide resolved
}
#endif
SW_NC_create_template(domFileName, domFileID, progFileName,
progFileID, NC_BYTE, 0, 0, progVarName, attNames, attVals,
numAtts, swFALSE, freq, LogInfo);
Expand Down
18 changes: 18 additions & 0 deletions src/filefuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "include/filefuncs.h"
#include "include/myMemory.h"
#include "include/Times.h"


/* 01/05/2011 (drs) removed unused variable *p from MkDir()
Expand Down Expand Up @@ -207,6 +208,23 @@ void LogError(LOG_INFO* LogInfo, const int mode, const char *fmt, ...) {
}




/**
@brief Print a SOILWAT2 status message

@param[in] msg Message string.
*/
void sw_message(const char *msg) {
char timeString[21];
timeStringISO8601(timeString, sizeof timeString);

swprintf("SOILWAT2 (%s) %s\n", timeString, msg);
}




/**************************************************************/
Bool GetALine(FILE *f, char buf[], int numChars) {
/* Read a line of possibly commented input from the file *f.
Expand Down