h1_summary.c
changeset 4 dd8e6719647b
parent 1 2ce4ee911439
equal deleted inserted replaced
1:9a0330997f5f 2:4d245ba9dc66
   786 void copy_metadata(int in_ncid, struct var *in_var_head,
   786 void copy_metadata(int in_ncid, struct var *in_var_head,
   787 	struct dim **in_dim_idx, int out_ncid, struct var *out_var_head,
   787 	struct dim **in_dim_idx, int out_ncid, struct var *out_var_head,
   788 	double *tbounds)
   788 	double *tbounds)
   789 {
   789 {
   790 	int i, j;
   790 	int i, j;
   791 	float hr[HOURS_PER_DAY];
   791 	float hr[HOURS_PER_DAY], mean_time;
   792 	struct var *in_vnode, *out_vnode;
   792 	struct var *in_vnode, *out_vnode;
   793 	void *val;
   793 	void *val;
   794 
   794 
   795 	for (i = 0; i < HOURS_PER_DAY; i++) hr[i] = (float)i;
   795 	for (i = 0; i < HOURS_PER_DAY; i++) hr[i] = (float)i;
   796 
   796 
   821 time-based metadata variable %s\n", in_vnode->name);
   821 time-based metadata variable %s\n", in_vnode->name);
   822 #endif /* DEBUG */
   822 #endif /* DEBUG */
   823 					val = read_timeslice(in_ncid, in_vnode->ncvarid, in_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, ((input_dim_idx[in_vnode->dimids[0]])->len - 1));
   823 					val = read_timeslice(in_ncid, in_vnode->ncvarid, in_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, ((input_dim_idx[in_vnode->dimids[0]])->len - 1));
   824 					if (!strcmp(in_vnode->name, time_bounds_name))
   824 					if (!strcmp(in_vnode->name, time_bounds_name))
   825 						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, tbounds, 0);
   825 						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, tbounds, 0);
       
   826 					else if (!strcmp(in_vnode->name, time_name)) {
       
   827 						/* force the timestamp to be the
       
   828 						 * mean of the time bounds */
       
   829 						mean_time = (tbounds[0] + tbounds[1]) / 2.0;
       
   830 						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, &mean_time, 0);
       
   831 					}
   826 					else
   832 					else
   827 						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, val, 0);
   833 						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, val, 0);
   828 				}
   834 				}
   829 				free(val);
   835 				free(val);
   830 				/*
   836 				/*