/******************************************************************************* Description: Integer function get_granule_times.c Parses granule start date, hour, and minute from IFF attribute. Called from get_GDAS.c Input arguments: s1 granule start time string from IFF attribute Output arguments: targhr decimal granule start hour (target hour for time interplation of GDAS variables) Function output: int return_code successful completion is zero, otherwise non-zero Revision History: 10/2012 R. Frey Original version Calls: none *******************************************************************************/ // Includes #include <stdio.h> #include <string.h> #include <stdlib.h> /******************************************************************************/ int get_granule_times(char s1[64], float *targhr) { /******************************************************************************/ // Declarations and initializations. char s2[64]; char search[2]; char *start_time = "0"; char *start_date = "0"; char *start_hour = "0"; char *start_min = "0"; int imin; int return_code = 0; /******************************************************************************/ // Get granule start date, hour, and minute. (void) strcpy(search, " "); start_date = strtok(s1, search); start_time = strtok(NULL, search); (void) strcpy(s2, start_time); (void) strcpy(search, ":"); start_hour = strtok(s2, search); start_min = strtok(NULL, search); printf("\nstart date, hour and minute: %s %s %s\n", start_date, start_hour, start_min); // Set decimal target hour for time interpolation. imin = atoi(start_min); *(targhr) = (float)atoi(start_hour) + ((float)imin / 60.0); /******************************************************************************/ return (return_code); /******************************************************************************/ }