/* ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c program to perform a basic dump of the UKMO correlative data files c obtained from the UARS Project. The data files contain the following c parameter profiles representative of 1200 UTC and available at the c 22 standard UARS pressure levels (1000 to .316 mb) : c c Temperature (K) c Geopotential Height (m) c Zonal Wind Component (m/s) c Meridional Wind Component (m/s) c Vertical Velocity Omega (pascals/s) c c The fields are mapped to a 2.5 degree latitude by 3.75 degree c longitude grid, ordered North to South, West to East, and starting c at (90N,0E) for the temperature and height fields, and at c (87.5N, 1.875E) for the wind fields. The wind grid is staggered c by half a grid length, implying grid dimensions of (72 x 96) and c (73 x 96) for the wind and temperature/height fields, respectively. c c Additional information on the UKMO correlative data files can be c found in the following on-buffer UARS documents: ACASM_META.DOC c c This program is designed for use with the translated VMS-to-Unix c UKMO correlative data files archived at the GSFC DAAC. c c Author : George Serafino c Translated to C language by Ke-Jun Sun c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ #include #include main(argc,argv) int argc; char *argv[]; { char buffer[30000]; char csfdu[90],cuarsh[255],corpar[100],blnk[27900]; char *prname; int iarray[45],nrdata,numrec,irdata,numlat,numlon,i,j,*int4; float array[19],grid[7008],xlat[100],xlon[100]; float prslvl, xlat0,xlon0,xltint,xlnint,*float4; char temp[50],*fname,type[4]; char str[80],data_file[180]; FILE *meta_ifp,*data_ifp; int rec_size,numb_par,index,n,j1,j2,ret; /* Open Meta data file first */ meta_ifp = fopen(argv[1],"r"); if (meta_ifp == NULL) { printf(" Can not open meta data file:%s \n",argv[1]); exit(); } for(i=0;i<10;i++) fgets(buffer,80,meta_ifp); /* get data file name from line 10 or from meta data file name */ /* strncpy(str,&buffer[14],50); sscanf(str,"%s",data_file); */ strncpy(data_file,argv[1],(strlen(argv[1])-5)); strcat(data_file,"_PROD"); fgets(buffer,80,meta_ifp); fgets(buffer,80,meta_ifp); /* get record size from meta file */ strncpy(temp,&buffer[16],5); rec_size = atoi(temp); fclose(meta_ifp); data_ifp = fopen(data_file,"r"); /* open data file */ if (data_ifp == NULL) { printf(" Can not open data file %s\n",data_file); exit(0); } printf("DATA WILL BE READ FROM CORRELATIVE FILE : \n"); printf("%s\n\n",data_file); printf(" ------------------------- \n"); printf(" SFDU INFORMATION FOR FILE \n"); printf(" ------------------------- \n"); memset(temp,' ',25); fread(csfdu,1,86,data_ifp); /* csfdu */ strncpy(temp,&csfdu[0],12); printf(" Tz_Field : %s\n",temp); memset(temp,' ',12); strncpy(temp,&csfdu[12],8); printf(" Lz_Field : %s\n",temp); strncpy(temp,&csfdu[20],12); printf(" Ti_Field : %s\n",temp); memset(temp,' ',12); strncpy(temp,&csfdu[32],8); printf(" Li_Field : %s\n",temp); strncpy(temp,&csfdu[40],46); printf(" Vi_Field : %s\n\n",temp); memset(temp,' ',49); printf("\n -------------------------------- \n"); printf(" UARS HEADER INFORMATION FOR FILE \n"); printf(" -------------------------------- \n"); fread(cuarsh,1,253,data_ifp); strncpy(temp,&cuarsh[0],4); printf(" Project_name : %s\n",temp); strncpy(temp,&cuarsh[4],20); printf(" UARS_PI : %s\n",temp); strncpy(temp,&cuarsh[24],20); printf(" UARS_CMI : %s\n",temp); memset(temp,' ',35); strncpy(temp,&cuarsh[44],8); printf(" Corr_Data_Class : %s\n",temp); strncpy(temp,&cuarsh[52],12); printf(" Instrument_Type : %s\n",temp); strncpy(temp,&cuarsh[64],12); printf(" Obs_Station_Id : %s\n",temp); strncpy(temp,&cuarsh[76],12); printf(" Corr_Data_FT_ID : %s\n",temp); strncpy(temp,&cuarsh[88],23); printf(" File_Start_Time : %s\n",temp); strncpy(temp,&cuarsh[111],23); printf(" File_Stop_Time : %s\n",temp); memset(temp,' ',35); strncpy(temp,&cuarsh[134],7); printf(" Maximum_Lat : %s\n",temp); strncpy(temp,&cuarsh[141],7); printf(" Minimum_Lat : %s\n",temp); strncpy(temp,&cuarsh[148],7); printf(" Maximum_Lon : %s\n",temp); strncpy(temp,&cuarsh[155],7); printf(" Minimum_Lon : %s\n",temp); strncpy(temp,&cuarsh[162],8); printf(" Maximum_Alt_Km : %s\n",temp); strncpy(temp,&cuarsh[170],8); printf(" Minimum_Alt_Km : %s\n",temp); strncpy(temp,&cuarsh[178],8); printf(" Maximum_Alt_Mb : %s\n",temp); strncpy(temp,&cuarsh[186],8); printf(" Minimum_Alt_Mb : %s\n",temp); memset(temp,' ',8); strncpy(temp,&cuarsh[194],6); printf(" Record_Size : %s\n",temp); strncpy(temp,&cuarsh[200],6); numrec = atoi(temp); printf(" Num_Rec_File : %6d\n",numrec); memset(temp,' ',6); strncpy(temp,&cuarsh[206],3); printf(" Data_Quality_1 : %s\n",temp); strncpy(temp,&cuarsh[209],3); printf(" Data_Quality_2 : %s\n",temp); strncpy(temp,&cuarsh[212],41); printf(" User_Comments : %s\n\n",temp); memset(temp,' ',45); fread(corpar,1,99,data_ifp); strncpy(temp,&corpar[39],12); printf(" Corr_Param_1 : %s\n",temp); strncpy(temp,&corpar[51],12); printf(" Corr_Param_2 : %s\n",temp); strncpy(temp,&corpar[63],12); printf(" Corr_Param_3 : %s\n",temp); strncpy(temp,&corpar[75],12); printf(" Corr_Param_4 : %s\n",temp); strncpy(temp,&corpar[87],12); printf(" Corr_Param_5 : %s\n",temp); memset(temp,' ',45); fread(blnk,1,27850,data_ifp); /* finish reading header */ nrdata = numrec - 1; irdata = 0; do { ret = fread(buffer,1,rec_size,data_ifp); if (ret > 0) { irdata ++; index = 0; printf("\n ----------------------------------- \n"); printf(" DATA RECORD NUMBER %8d\n",irdata); printf(" ----------------------------------- \n"); for (i=0;i<45;i++) { int4 = (int *)&buffer[index]; iarray[i] = *int4; index += 4; } for (i=0;i<19;i++) { float4 = (float *)&buffer[index]; array[i] = *float4; index += 4; } for (i=0;i<7008;i++) { float4 = (float *)&buffer[index]; grid[i] = *float4; index += 4; } printf(" Year Valid : %14d\n",iarray[0]); printf(" Month Valid : %14d\n",iarray[1]); printf(" Month Day : %14d\n",iarray[2]); printf(" Hour_Valid : %14d\n",iarray[3]); printf(" Minute_Valid : %14d\n",iarray[4]); printf(" Time_Indicator : %14d\n",iarray[12]); printf(" Forecast_Period : %14d\n",iarray[13]); printf(" Hemisphere : %14d\n",iarray[16]); printf(" Number_Rows : %14d\n",iarray[17]); printf(" Number_Cols : %14d\n",iarray[18]); printf(" Field_Code : %14d\n",iarray[22]); printf(" Vert_Coord_Type : %14d\n",iarray[25]); printf(" Level_Value : %14f\n",array[6]); printf(" Datum_Value : %14f\n",array[4]); printf(" Lat_Zeroth_Row : %14f\n",array[13]); printf(" Lat_Interval : %14f\n",array[14]); printf(" Lon_Zeroth_Point : %14f\n",array[15]); printf(" Lon_Interval : %14f\n",array[16]); printf(" Miss_Data_indic : %14f\n",array[17]); printf(" MKS_Scale_Factor : %14f\n\n",array[18]); /* ------------------------------------------------------- c obtain geophysical parameter type for the record c------------------------------------------------------- */ if ( iarray[22] == 1 ) prname = "HEIGHT "; if ( iarray[22] == 16 ) prname = "TEMPERATURE"; if ( iarray[22] == 48 ) prname = "ZONAL WIND "; if ( iarray[22] == 56 ) prname = "ZONAL WIND "; if ( iarray[22] == 49 ) prname = "MERID WIND "; if ( iarray[22] == 57 ) prname = "MERID WIND "; if ( iarray[22] == 40 ) prname = "OMEGA "; /* ------------------------------------------------------- c obtain pressure altitude for the record c------------------------------------------------------- */ prslvl = array[ 6]; /* ------------------------------------------------------ c obtain spatial grid characteristics for the record c------------------------------------------------------- */ numlat = iarray[17]; numlon = iarray[18]; xlat0 = array[13]; xlon0 = array[15]; xltint = array[14]; xlnint = array[16]; for ( i = 0;i < numlat; i++) xlat[i] = xlat0 + (i+1) * xltint; for ( j = 0; j < numlon; j++) xlon[j] = xlon0 + (j+1) * xlnint; /* ------------------------------------------------------- c write out subsampled parameter values forthe record c------------------------------------------------------- */ printf(" "); printf(" Subsampled UKMO parameter %s",prname); printf(" at level %8.2f mb\n\n",prslvl); printf(" "); for (j=0;j0) printf("-"); printf("\n"); for (i = 1;i < numlat+1;i += 4) { j1 = (i-1) * numlon + 1; j2 = j1 + numlon - 1; printf("%8.2f |",xlat[i-1]); for (j = j1;j < j2; j += 14) printf("%10.3f",grid[j-1]); printf("\n"); } } /* if ret > 0 */ } while (ret > 0); printf(" Total number of data records in file was %d\n",irdata); fclose(data_ifp); }