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

Outfile Dimensions #303

Merged
merged 16 commits into from
Jan 25, 2016
Merged

Conversation

wietsefranssen
Copy link
Contributor

We have added lat, lon and time variables in the NetCDF output files. One can choose between 1D and 2D lat/lon variables by setting COORD_DIMS_OUT in the global parameter file.

Adapted time dimension in NetCDF output:
Number of timesteps was based on MODEL_STEPS_PER_DAY in the global parameter file.
Now the number of timesteps is based on OUTPUT_STEPS_PER_DAY in the global parameter file.

@@ -63,6 +70,7 @@ typedef struct {
size_t n_nx; /**< size of x-index; */
size_t n_ny; /**< size of y-index */
location_struct *locations; /**< locations structs for local domain */
location_grid_struct *locations_grid; /**< locations structs for full unmasked latlon domain */
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if there is a better way to do this. Perhaps we could create a location_struct for all grid cells, even if they are not being run. We would just need to add an active (or something similar) member to the location_struct. When we do the decomposition, we would only split up active grid cells so nothing would change below the MASTER_PROC level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is possible, but keep in mind that in that case the indexes are changing. I mean the following:
In the case you suggest, location_struct is bigger because the unmasked gridcells are now included. This means that location_struct[n] refers to another lonlat combination. We have to be very careful that this will not effect other parts of the VIC code.
What shall we do now to solve it?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, let's leave this as is here and we'll revisit it in #313.

@jhamman
Copy link
Member

jhamman commented Nov 10, 2015

@wietsefranssen - good start here. I made a bunch of comments to keep this moving.

global_domain->locations_grid = (location_grid_struct *)
malloc(
global_domain->n_ny * global_domain->n_nx *
sizeof(location_grid_struct));
Copy link
Member

Choose a reason for hiding this comment

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

see #257 and update the cast syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it into (made also a calloc of it):
global_domain->locations_grid = calloc( global_domain->n_ny * global_domain->n_nx, sizeof(*global_domain->locations_grid));
I just used the same syntax as a few lines earlier eg line 76. Why do these one still use the old cast syntax? Or just because you didn't push the last commit to github yet?

Copy link
Member

Choose a reason for hiding this comment

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

That PR is still in the works (see #257).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I'll wait for a next commit :)

@bartnijssen
Copy link
Member

@wietsefranssen : Can you resolve the merge conflicts before I merge this? Since you started this branch a while ago, you probably need to merge the existing develop into your branch first. After that you probably won't have any merge conflicts.

@jhamman
Copy link
Member

jhamman commented Nov 14, 2015

@bartnijssen - I don't think we're ready to merge here yet. We still need to resolve the calendar and time handling pieces.

@bartnijssen
Copy link
Member

OK - sounds good - still need to resolve the conflict though.

derived time units from 'global_param' to output NetCDF.
fixed time init by adding 'initialize_time()' to 'vic_init.c'
sprintf(strUnit, "days");
}
else {
sprintf(strUnit, "-");
Copy link
Member

Choose a reason for hiding this comment

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

better to raise an error here if we don't know what the time units are.


grid_size = global_domain.n_ny * global_domain.n_nx;

// allocate memory for variables to be stored
dvar = (double *) malloc(local_domain.ncells * sizeof(double));
dvar = calloc(local_domain.ncells, sizeof(*dvar));
Copy link
Member

Choose a reason for hiding this comment

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

did you mean to change this from malloc to calloc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it was a mistake of me while adapting the cast syntax you mentioned. I am used to use calloc in stead of malloc (calloc is a bit slower because it it zeroing out memory is'nt it?). anyway I changed it to:

    dvar = malloc(local_domain.ncells * sizeof(*dvar));

@jhamman jhamman changed the title Feature/outfile time Outfile Dimensions Nov 19, 2015
initialize_location_grid(location_grid_struct *location_grid)
{
location_grid->latitude = 0;
location_grid->longitude = 0;
Copy link
Member

Choose a reason for hiding this comment

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

can you use MISSING instead of 0 here?

@jhamman
Copy link
Member

jhamman commented Nov 19, 2015

@wietsefranssen - almost there. I'm working on #312 today.

@wietsefranssen
Copy link
Contributor Author

@jhamman Hi Joe, I just made some changes in order to retreive the number of dimensions from the domain file. I also removed the global_domain_grid struct and replaced them for ncells_total.
It is still perfect yet (need to tidy up and need fix one mpi error).
In case you find some time, it would be nice to have a quick look at it to give some suggestions.

*****************************************************************************/
int
get_nc_varndimensions(char *nc_name,
char *var_name)
Copy link
Member

Choose a reason for hiding this comment

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

the indentation looks off here.

@jhamman
Copy link
Member

jhamman commented Dec 24, 2015

This looks pretty good. I had a few minor comments. Once you've addressed those, please ping @bartnijssen and @tbohn for their code reviews.

@wietsefranssen
Copy link
Contributor Author

@jhamman I just fixed the things Joe suggested. @tbohn and @bartnijssen Can you please have a look at the code? Thank you beforehand.

@jhamman
Copy link
Member

jhamman commented Jan 23, 2016

@tbohn and @bartnijssen - last call for comments here.

@wietsefranssen - can you merge in the current develop branch?

I'll give this one last read through and then merge if there are no failing tests and no objections by others.

@jhamman
Copy link
Member

jhamman commented Jan 25, 2016

this pr closes #297

jhamman pushed a commit that referenced this pull request Jan 25, 2016
@jhamman jhamman merged commit 60293f1 into UW-Hydro:develop Jan 25, 2016
@jhamman
Copy link
Member

jhamman commented Jan 25, 2016

Merging now. Thanks @wietsefranssen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants