/* tobinary.c
* *
* Emilio 6/23-25/99
* Created and debugged application.
* *
* COMPILE AS: gcc -o tobinary tobinary.c -DUNIX -lm -lnetcdf -L./ -R./ -lemu
* RUN AS: tobinary
******************************************************************************/
#include "emu.h"
const char * cpszUsage = {"usage: tobinary \n\
Program to convert XYT data from any format (eg, netcdf) into\n\
flat formats like binary or ascii, as individual XY files.\n\
\n\
"};
/* local variables */
float *x;
int main(int argc, char *argv[])
{
int i, v, yr, mo, tvar = 0; int bug=0;
char from[8], to[6];
VAR *fromvar;
Initialize(&argc, argv, NOMASK);
x = alloc1d_f(0,nRows*nCols-1);
for (v = 0; v < nVars/2; v++)
{
sprintf(from, "FROM%d", v+1);
sprintf(to, "TO%d", v+1);
fromvar = &pstVars[GetVarNo(from)];
for (tvar = 0; tvar < nTimeSteps; tvar++)
{
getyrmonth(tvar, &yr, &mo);
ReadXY(x, *fromvar, yr, mo);
for (i = 0; i < nRows*nCols; i++)
x[i] = (x[i] - fromvar->add_offset) / fromvar->scale_factor;
WriteXY(x, pstVars[GetVarNo(to)], yr, mo);
}
}
free1d_f(x,0,nRows*nCols-1);
CleanUp();
}
/* ================================================================= */
void ProcessCommandLineArgs(int * pArgc, char * argv[])
{}
/* ================================================================= */
void LocalCleanUp(void)
{}