From 74f9d985c7a0190f7d5ea1b2b0c4daf2c601f1eb Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Wed, 18 Jun 2008 20:56:59 +0800 Subject: [PATCH] fix portability. --- src/graphic/xgraph.cpp | 12 ++++++++++-- src/solver/ddm1e/ddm_nt1e.cc | 2 +- src/solver/ddm2e/ddm_nt2e.cc | 2 +- src/solver/ebm3e/ebm_nt3e.cc | 2 +- src/solver/mix1/mix1.cc | 5 +++-- src/solver/mix2/mix2.cc | 4 +++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/graphic/xgraph.cpp b/src/graphic/xgraph.cpp index bd401ab..ba7bbb5 100644 --- a/src/graphic/xgraph.cpp +++ b/src/graphic/xgraph.cpp @@ -848,10 +848,11 @@ void GetGCRainbow (GC *gc, unsigned short R, unsigned short G,unsigned short B) /*****************************************************************************/ /************************** DUMP SCREEN FUNCTIONS **************************/ /*****************************************************************************/ +#ifdef HAVE_TIFF #include - int GRSaveScreen (const char * tiff_file, int width, int height) { + TIFF *fout= TIFFOpen(tiff_file, "w"); if(!fout) return 1; @@ -873,7 +874,7 @@ int GRSaveScreen (const char * tiff_file, int width, int height) for (int k = 0; k < width; k++) { unsigned long c; - c = XGetPixel(ximage, k, i+j); /* X pixel value */ + c = XGetPixel(ximage, k, i+j); // X pixel value color[k+j*width].pixel = c; } XQueryColors(display, colormap, color, currentlines*width); @@ -914,7 +915,14 @@ int GRSaveScreen (const char * tiff_file, int width, int height) TIFFClose(fout); delete [] image; XDestroyImage(ximage); + + return 0; +} +#else +int GRSaveScreen (const char * tiff_file, int width, int height) +{ return 0; } +#endif #endif diff --git a/src/solver/ddm1e/ddm_nt1e.cc b/src/solver/ddm1e/ddm_nt1e.cc index 57d4c24..5430640 100644 --- a/src/solver/ddm1e/ddm_nt1e.cc +++ b/src/solver/ddm1e/ddm_nt1e.cc @@ -1973,7 +1973,7 @@ void DDM_Solver_L1E::LET_norm_estimat(PetscScalar & r) VecRestoreArray(LTE,&ll); VecNorm(LTE,NORM_2,&r); - r/=sqrt(N); + r/=sqrt((PetscScalar)N); } diff --git a/src/solver/ddm2e/ddm_nt2e.cc b/src/solver/ddm2e/ddm_nt2e.cc index cc4b0e8..fc971b5 100644 --- a/src/solver/ddm2e/ddm_nt2e.cc +++ b/src/solver/ddm2e/ddm_nt2e.cc @@ -2102,7 +2102,7 @@ void DDM_Solver_L2E::LET_norm_estimat(PetscScalar & r) VecRestoreArray(LTE,&ll); VecNorm(LTE,NORM_2,&r); - r/=sqrt(N); + r/=sqrt((PetscScalar)N); } diff --git a/src/solver/ebm3e/ebm_nt3e.cc b/src/solver/ebm3e/ebm_nt3e.cc index c277e15..018ad97 100644 --- a/src/solver/ebm3e/ebm_nt3e.cc +++ b/src/solver/ebm3e/ebm_nt3e.cc @@ -1903,7 +1903,7 @@ void EBM_Solver_L3E::LET_norm_estimat(PetscScalar & r) VecRestoreArray(LTE,&ll); VecNorm(LTE,NORM_2,&r); - r/=sqrt(N); + r/=sqrt((PetscScalar)N); } diff --git a/src/solver/mix1/mix1.cc b/src/solver/mix1/mix1.cc index d86c42d..8b89ac1 100644 --- a/src/solver/mix1/mix1.cc +++ b/src/solver/mix1/mix1.cc @@ -25,8 +25,9 @@ #include "private/snesimpl.h" #include "src/snes/impls/tr/tr.h" #include "log.h" - - +#ifdef HAVE_UNISTD_H +#include +#endif /* ---------------------------------------------------------------------------- * error_norm_pn_Mix1: This function compute X and RHS error norms. diff --git a/src/solver/mix2/mix2.cc b/src/solver/mix2/mix2.cc index 4db1210..e5abea0 100644 --- a/src/solver/mix2/mix2.cc +++ b/src/solver/mix2/mix2.cc @@ -26,7 +26,9 @@ #include "private/snesimpl.h" #include "src/snes/impls/tr/tr.h" #include "log.h" - +#ifdef HAVE_UNISTD_H +#include +#endif /* ---------------------------------------------------------------------------- * error_norm_pn_Mix2: This function compute X and RHS error norms. -- 2.11.4.GIT