📄 output.c
字号:
/* * Copyright (c) 2001-2005 Falk Feddersen * * 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. * * 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 <stdio.h>#include <stdlib.h>#include "output.h"//#include "routines_new.h"void verbose_output(timing *T, double KE, double PE){ static int flag=1; gdouble time; if (flag) { fprintf(stderr," Time (units) Total Kinetic Energy (m^3/s^2) Total Potential Energy (m^3/s^2)\n"); flag = 0; } time = get_time_in_current_units(T); fprintf(stderr,"%9.3lf %s %9.2g %9.2g\n",time,T->units_ptr,KE, PE);}/* Writing routinues to files *//* This is now in flags.c double point_var(variable_t var, int i, int j){ switch (var) { case U_M: return DR2(UU,i,j); case V_M: return DR2(VV,i,j); case ETA_M: return DR2(PP,i,j); default: funwaveC_error_message("unknown switch in output_new.c:point_var()"); } return -1.0; // This should never happen!}*/FILE* open_file_for_writing(char *s){ FILE *fp; if ((fp=fopen(s,"w"))==NULL) { fprintf(stderr,"Cannot open file for writing: %s\n",s); exit(-1); } return fp;} /* This function writes a longshore array in ascii in one row. the array is written at cross-shore location i - with checking*/void write_alongshore_array_ascii(FILE *fout, field2D *F, int i){ int j; int M = F->M; /* check to make sure i is in bounds */ if ((i<0)||(i>=F->N)) funwaveC_error_message("i is out of bounds in write_alongshore_array_ascii!\n"); for (j=0;j<M;j++) fprintf(fout,"%.12e ",DR2(F,i,j)); fprintf(fout,"\n");}void write_alongshore_array_binary(FILE *fout, field2D *F, int i){ size_t size; if ((i<0)||(i>=F->N)) funwaveC_error_message("i is out of bounds in write_alongshore_array_binary()!\n"); size = sizeof(double); fwrite(F->row[i],size,F->M,fout);}/* This routinue writes a cross-shore array at location j in one row in ascii */void write_cross_shore_array_ascii(FILE *fout, field2D *F, int j){ int i; if ((j<0)||(j>=F->M)) funwaveC_error_message("j is out of bounds in write_cross_shore_array_ascii()!\n"); for (i=0;i<F->N;i++) fprintf(fout,"%.12e ",DR2(F,i,j)); fprintf(fout,"\n");}void write_cross_shore_array_ascii_bounds(FILE *fout, field2D *F, int j, int imin, int imax){ int i; if ((j<0)||(j>=F->M)) funwaveC_error_message("j is out of bounds in write_cross_shore_array_ascii()!\n"); if ((imin<0)||(imax>=F->N)) funwaveC_error_message("Bad arg to write_cross_shore_array_ascii()\n"); for (i=imin;i<imax;i++) fprintf(fout,"%e ",DR2(F,i,j)); fprintf(fout,"\n");}void write_cross_shore_array_binary(FILE *fout, field2D *F, int j){ int i; size_t size; if ((j<0)||(j>=F->M)) funwaveC_error_message("j is out of bounds in write_cross_shore_array_binary()!\n"); size = sizeof(double); for (i=0;i<F->N;i++) fwrite(&(DR2(F,i,j)),size,1,fout);}void write_cross_shore_array_binary_bounds(FILE *fout, field2D *F, int j, int imin, int imax){ int i; size_t size; if ((j<0)||(j>=F->M)) funwaveC_error_message("j is out of bounds in write_cross_shore_array_binary()!\n"); if ((imin<0)||(imax>=F->N)) funwaveC_error_message("Bad arg to write_cross_shore_array_binary()\n"); size = sizeof(double); for (i=imin;i<imax;i++) fwrite(&(DR2(F,i,j)),size,1,fout);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -