--- MITgcm_contrib/darwinview/src/darwin.c 2007/07/16 19:16:26 1.5 +++ MITgcm_contrib/darwinview/src/darwin.c 2007/08/03 14:37:15 1.8 @@ -9,58 +9,58 @@ #define RIGHT 102 #define LEFT 100 #define MAX 700 +#define SCALE .06 int NX, NY, NZ; void do_byteswap_f32( float arr[], int nel ), global(), local( int, int, int ); void readnames( char[] ), readarray( float[], char[], int ), readjet(), readxz( float[], char[] ); -void readyz( float[], char[] ); -void TimerFunction( int ), bitmap( char[], int, int ); +void readyz( float[], char[] ), readdepths( char[] ); +void TimerFunction( int ), stroke( char[], int, int ); float data[MAX][MAX*MAX], mxval, mnval, jet[64][3]; float globalmx=0, globalmn=100; -int win[MAX], ilev=1, howmany, sets, count=0, glo=0, usr=0, anim=0, logscale=0, xz=0, nonegs=1, endian=0; -int xmax, ymax, yoffset=0, xoffset=0, yz=0; +int win[MAX], ilev=1, howmany, sets, count=0, glo=0, usr=0, anim=0, endian=0; +int xmax, ymax, yoffset=0, xoffset=0, yz=0, logscale=0, xz=0, nonegs=1; +int depths[MAX], scaledepth=0, totaldepth=0, scalecount=0; char initfns[MAX][MAX], fns[MAX][MAX][MAX]; -void menu(int value){ // called when menu is opened on right click +void menu( int value ){ // called when menu is opened on right click switch( value ){ case 1: usr=glo=0; // unset glo & usr, sets local max/min - glutPostRedisplay(); // recall display func with new values break; case 2: glo=1; // enables global max/min usr=0; // unsets usr mxval=globalmx; // sets max to globalmx mnval=globalmn; // sets min to globalmn - glutPostRedisplay(); // recall display func with new values break; case 3: usr=1; // switch to user-set max/min glo=0; // unset glo printf( "Max=" ); scanf( "%f", &mxval ); // prompt user for new max printf( "Min=" ); scanf( "%f", &mnval ); // prompt user for new min - glutPostRedisplay(); // recall display func with new values break; - case 4: logscale=(logscale+1)%2; // switch log scale on/off - glutPostRedisplay(); + case 4: logscale=( logscale+1 )%2; // switch log scale on/off break; - case 5: nonegs=(nonegs+1)%2; // switch allowance of negatives on/off - glutPostRedisplay(); + case 5: nonegs=( nonegs+1 )%2; // switch allowance of negatives on/off break; - case 6: endian=(endian+1)%2; // switch between big/little endian - glutPostRedisplay(); + case 6: endian=( endian+1 )%2; // switch between big/little endian break; } + glutPostRedisplay(); } + void display(){ // called on glutPostRedisplay - int i, j, ioff, q; - float r, g, b, k, y; + int i, h, ioff, q; + float r, g, b, k, y, j, tmp; double num, logmx, logmn; char str[MAX]; + for( q=0; q=0; i-- ){ + fscanf( fp, "%d ", &depths[i] ); + totaldepth+=depths[i]; + } + + fclose( fp ); +} + void readjet(){ //reads in color scale values FILE* fp; int i, j; @@ -470,25 +517,31 @@ } } -void black(){ +void black( ){ glClear( GL_COLOR_BUFFER_BIT ); glutSwapBuffers(); - glFlush(); + glFlush(); } + int main( int argc, char *argv[] ){ int i, setsx, setsy, tmpx, tmpy, winx, winy, parent; - char filename[MAX]; + char str[MAX], filename[MAX]; + FILE* fp; + + if( strcmp(argv[1], "binary") == 0 ) + fp=fopen( ".darwinview/binconfig", "r" ); + else + if( strcmp(argv[1],"netcdf") == 0 ) + fp=fopen( ".darwinview/ncconfig", "r" ); - sscanf( argv[1], "%dx%d", &winx, &winy ); // reads screen resolution from command line + fscanf( fp, "%dx%d ", &winx, &winy ); winy-=60; winx-=20; // adjusts resolution so edges won't get cut off - - printf( "Please enter x, y and z dimensions.\n" ); - scanf( "%d %d %d", &NX, &NY, &NZ ); // prompts user for NX, NY, NZ - printf( "Please enter filename.\n" ); - scanf( "%s", filename ); // prompts user for initial filenames - printf( "Please enter dimensions of data sets.\n" ); - scanf( "%dx%d", &setsx, &setsy ); // prompts user for dimensions of subwindows + fscanf( fp, "%d %d %d ", &NX, &NY, &NZ ); + fscanf( fp, "%dx%d ", &setsx, &setsy ); // prompts user for dimensions of subwindows + fscanf( fp, "%s", filename ); + + fclose( fp ); xmax=NX; ymax=NY; @@ -514,7 +567,7 @@ tmpy = (i/setsx)*(winy/setsy); // y coordinate of top left corner of subwindow win[i]=glutCreateSubWindow( parent, tmpx, tmpy, winx/setsx, winy/setsy ); // creates subwindow - gluOrtho2D( 0, NX+35, 0, NY+15 ); // sets how data is mapped to subwindow + gluOrtho2D( 0, NX+35, 0, NY+25 ); // sets how data is mapped to subwindow glutKeyboardFunc( key ); // called on key press glutSpecialFunc( specialkey ); // called on special key press (arrow keys) if( i >= sets ) //