/* comp_to_v5d.c */ /* Convert old COMP file to new .v5d file */ /* * Vis5D system for visualizing five dimensional gridded data sets. * Copyright (C) 1990 - 2000 Bill Hibbard, Johan Kellum, Brian Paul, * Dave Santek, and Andre Battaiola. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * As a special exception to the terms of the GNU General Public * License, you are permitted to link Vis5D with (and distribute the * resulting source and executables) the LUI library (copyright by * Stellar Computer Inc. and licensed for distribution with Vis5D), * the McIDAS library, and/or the NetCDF library, where those * libraries are governed by the terms of their own licenses. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "../config.h" #include #include #include #include #include /* * Global vars describing the file header. */ static int NumTimes, NumVars; static int Nr, Nc, Nl, nl[MAXVARS]; static float NorthLat[MAXTIMES]; static float WestLon[MAXTIMES]; static float LatInc, LonInc; static char VarName[MAXVARS][10]; static float MinVal[MAXVARS], MaxVal[MAXVARS]; static float Bottom, HgtInc; static int DateStamp[MAXTIMES], TimeStamp[MAXTIMES]; static int projection; static float proj_args[4]; static int vertical; static float vert_args[2]; #if SIZEOF_SIGNED_CHAR == 1 typedef signed char int_1; #else /* defined(stellar) || defined(hp) || defined(sun) */ typedef char int_1; /* 1-byte signed integer */ #endif /* * Read the header info in the COMP* file and put into global vars. */ static int read_comp_header( int f ) { int id, gridtimes, gridvars, i, j, ip; /* read id */ read_int4( f, &id ); if (id==0x80808080 || id==0x80808081) { float top; if (id==0x80808080) { gridtimes = 300; gridvars = 20; } else { gridtimes = 400; gridvars = 30; } read_int4( f, &NumTimes ); read_int4( f, &NumVars ); read_int4( f, &Nr ); read_int4( f, &Nc ); read_int4( f, &Nl ); read_float4( f, &NorthLat[0] ); read_float4( f, &WestLon[0] ); read_float4( f, &top ); read_float4( f, &LatInc ); read_float4( f, &LonInc ); read_float4( f, &HgtInc ); Bottom = top - HgtInc * (Nl-1); for (i=1;i0;j--) { if (VarName[i][j]==' ' || VarName[i][j]==0) VarName[i][j] = 0; else break; } } } else if (id==0x80808082 || id==0x80808083) { float height[MAXLEVELS]; read_int4( f, &gridtimes ); read_int4( f, &NumVars ); read_int4( f, &NumTimes ); read_int4( f, &Nr ); read_int4( f, &Nc ); read_int4( f, &Nl ); read_float4( f, &LatInc ); read_float4( f, &LonInc ); read_float4_array( f, height, Nl ); Bottom = height[0]; HgtInc = (height[Nl-1] - height[0]) / (Nl-1); for (ip=0;ip0;j--) { if (VarName[ip][j]==' ' || VarName[ip][j]==0) VarName[ip][j] = 0; else break; } } read_float4_array( f, MinVal, NumVars ); read_float4_array( f, MaxVal, NumVars ); read_int4_array( f, TimeStamp, gridtimes ); read_int4_array( f, DateStamp, gridtimes ); read_float4_array( f, NorthLat, gridtimes ); read_float4_array( f, WestLon, gridtimes ); } for (i=0;imax) max = data[p]; if (data[p]