[GRASS-SVN] r32944 - in grass-addons/gipe: i.albedo i.biomass
i.dn2full.l5 i.dn2full.l7 i.dn2potrad.l5 i.dn2potrad.l7
i.dn2ref.ast i.dn2ref.l7 r.evapo.MH r.gaswap.serial r.out.vic
r.soiltex2prop r.soilusda2tex r.uslek r.usler
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 20 18:21:37 EDT 2008
Author: ychemin
Date: 2008-08-20 18:21:36 -0400 (Wed, 20 Aug 2008)
New Revision: 32944
Modified:
grass-addons/gipe/i.albedo/bb_alb_aster.c
grass-addons/gipe/i.albedo/bb_alb_landsat.c
grass-addons/gipe/i.albedo/bb_alb_modis.c
grass-addons/gipe/i.albedo/bb_alb_noaa.c
grass-addons/gipe/i.biomass/biomass.c
grass-addons/gipe/i.biomass/solar_day.c
grass-addons/gipe/i.dn2full.l5/dn2rad_landsat5.c
grass-addons/gipe/i.dn2full.l5/l5inread.c
grass-addons/gipe/i.dn2full.l5/rad2ref_landsat5.c
grass-addons/gipe/i.dn2full.l5/tempk_landsat5.c
grass-addons/gipe/i.dn2full.l7/rad2ref_landsat7.c
grass-addons/gipe/i.dn2full.l7/tempk_landsat7.c
grass-addons/gipe/i.dn2potrad.l5/bb_alb_landsat.c
grass-addons/gipe/i.dn2potrad.l5/dn2rad_landsat5.c
grass-addons/gipe/i.dn2potrad.l5/emissivity_generic.c
grass-addons/gipe/i.dn2potrad.l5/et_pot_day.c
grass-addons/gipe/i.dn2potrad.l5/l5inread.c
grass-addons/gipe/i.dn2potrad.l5/main.c
grass-addons/gipe/i.dn2potrad.l5/ndvi.c
grass-addons/gipe/i.dn2potrad.l5/r_net_day.c
grass-addons/gipe/i.dn2potrad.l5/rad2ref_landsat5.c
grass-addons/gipe/i.dn2potrad.l5/solar_day.c
grass-addons/gipe/i.dn2potrad.l5/tempk_landsat5.c
grass-addons/gipe/i.dn2potrad.l7/bb_alb_landsat.c
grass-addons/gipe/i.dn2potrad.l7/dn2rad_landsat7.c
grass-addons/gipe/i.dn2potrad.l7/emissivity_generic.c
grass-addons/gipe/i.dn2potrad.l7/et_pot_day.c
grass-addons/gipe/i.dn2potrad.l7/l7inread.c
grass-addons/gipe/i.dn2potrad.l7/main.c
grass-addons/gipe/i.dn2potrad.l7/ndvi.c
grass-addons/gipe/i.dn2potrad.l7/r_net_day.c
grass-addons/gipe/i.dn2potrad.l7/rad2ref_landsat7.c
grass-addons/gipe/i.dn2potrad.l7/solar_day.c
grass-addons/gipe/i.dn2potrad.l7/tempk_landsat7.c
grass-addons/gipe/i.dn2ref.ast/main.c
grass-addons/gipe/i.dn2ref.ast/rad2ref_aster.c
grass-addons/gipe/i.dn2ref.l7/main.c
grass-addons/gipe/r.evapo.MH/main.c
grass-addons/gipe/r.evapo.MH/mh_eto.c
grass-addons/gipe/r.evapo.MH/mh_original.c
grass-addons/gipe/r.evapo.MH/mh_samani.c
grass-addons/gipe/r.gaswap.serial/evaluation.c
grass-addons/gipe/r.gaswap.serial/main.c
grass-addons/gipe/r.out.vic/main.c
grass-addons/gipe/r.soiltex2prop/main.c
grass-addons/gipe/r.soiltex2prop/prct2hf.c
grass-addons/gipe/r.soiltex2prop/prct2ksat.c
grass-addons/gipe/r.soiltex2prop/vector_multiplication.c
grass-addons/gipe/r.soilusda2tex/main.c
grass-addons/gipe/r.soilusda2tex/usda2pclay.c
grass-addons/gipe/r.soilusda2tex/usda2psand.c
grass-addons/gipe/r.soilusda2tex/usda2psilt.c
grass-addons/gipe/r.uslek/main.c
grass-addons/gipe/r.uslek/prct2tex.c
grass-addons/gipe/r.uslek/tex2usle_k.c
grass-addons/gipe/r.usler/main.c
Log:
Code cleaning + standardization
Modified: grass-addons/gipe/i.albedo/bb_alb_aster.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_aster.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.albedo/bb_alb_aster.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,6 +1,9 @@
-// Broadband albedo Aster
-// After Liang, S.L., 2001. Narrowband to broadband conversion of land surface albedo 1 Algorithms. Remote Sensing of Environment. 2001, 76, 213-238.
-// Input: Ref1, ref3, Ref5, Ref6, Ref8, Ref9
+/* Broadband albedo Aster
+ * After Liang, S.L., 2001.
+ * Narrowband to broadband conversion of land surface albedo 1 Algorithms.
+ * Remote Sensing of Environment. 2001, 76, 213-238.
+ * Input: Ref1, ref3, Ref5, Ref6, Ref8, Ref9
+ */
double bb_alb_aster( double greenchan, double nirchan, double swirchan2, double swirchan3, double swirchan5, double swirchan6 )
{
Modified: grass-addons/gipe/i.albedo/bb_alb_landsat.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_landsat.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.albedo/bb_alb_landsat.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,4 +1,6 @@
-// Broadband albedo Landsat 5TM and 7ETM+ (maybe others too but not sure)
+/* Broadband albedo Landsat 5TM and 7ETM+
+ * (maybe others too but not sure)
+ */
double bb_alb_landsat( double bluechan, double greenchan, double redchan, double nirchan, double chan5, double chan7 )
{
Modified: grass-addons/gipe/i.albedo/bb_alb_modis.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_modis.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.albedo/bb_alb_modis.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,4 +1,6 @@
-// Broadband albedo MODIS
+/*
+ * Broadband albedo MODIS
+ */
double bb_alb_modis( double redchan, double nirchan, double chan3, double chan4, double chan5, double chan6, double chan7 )
{
Modified: grass-addons/gipe/i.albedo/bb_alb_noaa.c
===================================================================
--- grass-addons/gipe/i.albedo/bb_alb_noaa.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.albedo/bb_alb_noaa.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,4 +1,7 @@
-// Broadband albedo NOAA AVHRR 14 (maybe others too but not sure)
+/*
+ * Broadband albedo NOAA AVHRR 14
+ * (maybe others too but not sure)
+ */
double bb_alb_noaa( double redchan, double nirchan )
{
Modified: grass-addons/gipe/i.biomass/biomass.c
===================================================================
--- grass-addons/gipe/i.biomass/biomass.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.biomass/biomass.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -5,11 +5,11 @@
double biomass( double fpar, double solar_day, double evap_fr, double light_use_ef )
{
double result, apar, conversion_coefs;
- //fPAR in Bastiaassen and Ali = a (= 1.257) * NDVI + b (= -0.161);
+ /*fPAR in Bastiaassen and Ali = a (= 1.257) * NDVI + b (= -0.161);*/
/*light use efficiency is variable for each crop!*/
/* Cotton light_use_ef in Uzbekistan is 1.9 */
-// apar = (b+a*ndvi);
+/* apar = (b+a*ndvi);*/
conversion_coefs = 0.0864*10;
apar = fpar*(0.48*solar_day);
result = apar*light_use_ef*evap_fr*conversion_coefs;
Modified: grass-addons/gipe/i.biomass/solar_day.c
===================================================================
--- grass-addons/gipe/i.biomass/solar_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.biomass/solar_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
+/*
+ * Average Solar Diurnal Radiation after Bastiaanssen (1995)
+ */
#define PI 3.1415927
Modified: grass-addons/gipe/i.dn2full.l5/dn2rad_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2full.l5/dn2rad_landsat5.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2full.l5/dn2rad_landsat5.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,10 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Conversion of DN to Radiance for Landsat 5TM
-// yann.chemin at gmail.com - Yann Chemin - GPL>=2, 2008.
+/* Conversion of DN to Radiance for Landsat 5TM */
-double dn2rad_landsat5(int c_year, int c_month, int c_day, int year, int month, int day, int band, int DN )
+double dn2rad_landsat5(int c_year,int c_month,int c_day,int year,int month,int day,int band,int DN)
{
double result, gain, bias;
int gain_mode;
Modified: grass-addons/gipe/i.dn2full.l5/l5inread.c
===================================================================
--- grass-addons/gipe/i.dn2full.l5/l5inread.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2full.l5/l5inread.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -79,16 +79,14 @@
}
}
-// printf("year = %i\n", year);
-// printf("month = %i\n", month);
-// printf("day = %i\n", day);
-
-// printf("sun azimuth = %f\n", sun_azimuth);
-// printf("sun elevation = %f\n", sun_elevation);
-
-// printf("latitude = %f\n", latitude);
-// printf("longitude = %f\n", longitude);
-
+/* printf("year = %i\n", year);
+ printf("month = %i\n", month);
+ printf("day = %i\n", day);
+ printf("sun azimuth = %f\n", sun_azimuth);
+ printf("sun elevation = %f\n", sun_elevation);
+ printf("latitude = %f\n", latitude);
+ printf("longitude = %f\n", longitude);
+*/
(void)fclose(f);
return;
}
Modified: grass-addons/gipe/i.dn2full.l5/rad2ref_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2full.l5/rad2ref_landsat5.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2full.l5/rad2ref_landsat5.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -4,8 +4,7 @@
#define PI 3.1415926
-// Conversion of Radiance to Reflectance for Landsat 5TM
-// ychemin at gmail.com - Yann Chemin - GPL>=2, 2008.
+/* Conversion of Radiance to Reflectance for Landsat 5TM */
double rad2ref_landsat5( double radiance, double doy,double sun_elevation, double k_exo )
{
Modified: grass-addons/gipe/i.dn2full.l5/tempk_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2full.l5/tempk_landsat5.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2full.l5/tempk_landsat5.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,10 @@
#include<math.h>
#include<stdlib.h>
-// Surface temperature for Landsat 5TM
-// Schneider and Mauser, 1996
+/*
+ * Surface temperature for Landsat 5TM
+ * Schneider and Mauser, 1996
+ */
double tempk_landsat5( double l6 )
{
Modified: grass-addons/gipe/i.dn2full.l7/rad2ref_landsat7.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/rad2ref_landsat7.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2full.l7/rad2ref_landsat7.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -4,8 +4,7 @@
#define PI 3.1415926
-// Conversion of Radiance to Reflectance for Landsat 7ETM+
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2006.
+/* Conversion of Radiance to Reflectance for Landsat 7ETM+ */
double rad2ref_landsat7( double radiance, double doy,double sun_elevation, double k_exo )
{
Modified: grass-addons/gipe/i.dn2full.l7/tempk_landsat7.c
===================================================================
--- grass-addons/gipe/i.dn2full.l7/tempk_landsat7.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2full.l7/tempk_landsat7.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Surface temperature for Landsat 7ETM+
+/* Surface temperature for Landsat 7ETM+ */
double tempk_landsat7( double l6 )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/bb_alb_landsat.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/bb_alb_landsat.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/bb_alb_landsat.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Broadband albedo Landsat 5TM and 7ETM+ (maybe others too but not sure)
-// yann.chemin at ait.ac.th LGPL, Copylefted, 2004.
+/* Broadband albedo Landsat 5TM and 7ETM+ (maybe others too but not sure)*/
double bb_alb_landsat( double bluechan, double greenchan, double redchan, double nirchan, double chan5, double chan7 )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/dn2rad_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/dn2rad_landsat5.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/dn2rad_landsat5.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Conversion of DN to Radiance for Landsat 5TM
-// yann.chemin at gmail.com - Yann Chemin - GPL>=2, 2008.
+/* Conversion of DN to Radiance for Landsat 5TM*/
double dn2rad_landsat5(int c_year, int c_month, int c_day, int year, int month, int day, int band, int DN )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/emissivity_generic.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/emissivity_generic.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/emissivity_generic.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,9 +2,10 @@
#include<math.h>
#include<stdlib.h>
-// Emissivity Generic mode (Reads directly from NDVI)
-// Estimation in the 8-14 micrometers range for sparse canopy
-// yann.chemin at gmail.com LGPL, Copylefted, 2004.
+/*
+ * Emissivity Generic mode (Reads directly from NDVI)
+ * Estimation in the 8-14 micrometers range for sparse canopy
+*/
double emissivity_generic( double ndvi )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/et_pot_day.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/et_pot_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/et_pot_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Potential ET after Bastiaanssen (1995)
+/* Average Diurnal Potential ET after Bastiaanssen (1995) */
double et_pot_day( double bbalb, double solar, double tempk, double tsw, double roh_w )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/l5inread.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/l5inread.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/l5inread.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -79,16 +79,14 @@
}
}
-// printf("year = %i\n", year);
-// printf("month = %i\n", month);
-// printf("day = %i\n", day);
-
-// printf("sun azimuth = %f\n", sun_azimuth);
-// printf("sun elevation = %f\n", sun_elevation);
-
-// printf("latitude = %f\n", latitude);
-// printf("longitude = %f\n", longitude);
-
+/* printf("year = %i\n", year);
+ printf("month = %i\n", month);
+ printf("day = %i\n", day);
+ printf("sun azimuth = %f\n", sun_azimuth);
+ printf("sun elevation = %f\n", sun_elevation);
+ printf("latitude = %f\n", latitude);
+ printf("longitude = %f\n", longitude);
+*/
(void)fclose(f);
return;
}
Modified: grass-addons/gipe/i.dn2potrad.l5/main.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,7 +1,7 @@
/****************************************************************************
*
* MODULE: i.dn2potrad.l5
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculate ETpot radiative for Landsat5 from DN.
*
* COPYRIGHT: (C) 2007-2008 by the GRASS Development Team
@@ -17,20 +17,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-//#define OMP // Comment this on single core CPU
-//#ifdef OMP
-// #include<omp.h> // OpenMP code
-// #include"/usr/lib/gcc/i486-linux-gnu/4.2.0/include/omp.h"
-//#endif
-
#include <grass/gis.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#define MAXFILES 7
-//sun exo-atmospheric irradiance
+/*sun exo-atmospheric irradiance*/
#define KEXO1 1969.0
#define KEXO2 1840.0
#define KEXO3 1551.0
@@ -56,8 +49,8 @@
int
main(int argc, char *argv[])
{
- struct Cell_head cellhd;//region+header info
- char *mapset; //mapset name
+ struct Cell_head cellhd;/*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
@@ -65,15 +58,15 @@
struct Option *input,*input1,*input2,*input3,*output;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
char history_buf[200];
- char *name; //input raster name
- char *result; //output raster name
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
- //File Descriptors
+ /*File Descriptors*/
int infd[MAXFILES];
int outfd[MAXFILES];
@@ -88,25 +81,25 @@
RASTER_MAP_TYPE out_data_type = DCELL_TYPE; /* 0=numbers 1=text */
double kexo[MAXFILES];
- //Metfile
- char *metfName; //NLAPS report file, header in text format
+ /*Metfile*/
+ char *metfName; /*NLAPS report file, header in text format*/
char b1[80],b2[80],b3[80];
char b4[80],b5[80];
- char b6[80],b7[80];//Load .tif names
+ char b6[80],b7[80];/*Load .tif names*/
double sun_elevation;
- double sun_azimuth;//not useful here, only for parser()
- int c_day,c_month,c_year;//NLAPS processing date
+ double sun_azimuth;/*not useful here, only for parser()*/
+ int c_day,c_month,c_year;/*NLAPS processing date*/
int day,month,year;
double decimal_hour;
int l5path,l5row;
- //EndofMetfile
+ /*EndofMetfile*/
int temp;
int doy;
- int not_ll=0; //if proj is not lat/long, it will be 1.
+ int not_ll=0; /*if proj is not lat/long, it will be 1.*/
struct pj_info iproj;
struct pj_info oproj;
-// char *lat;
+/* char *lat;*/
double xp, yp;
double xmin, ymin;
double xmax, ymax;
@@ -176,13 +169,14 @@
G_fatal_error (_("Something wrong with roh_w value, please check."));
}
- //******************************************
- //Fetch parameters for DN2Rad2Ref correction
+ /********************************************/
+ /*Fetch parameters for DN2Rad2Ref correction*/
l5_in_read(metfName,&l5path,&l5row,&latitude,&longitude,&sun_elevation,&sun_azimuth,&c_year,&c_month,&c_day,&day,&month,&year,&decimal_hour);
-// printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
-// for(i=0;i<MAXFILES;i++){
-// printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
-// }
+/* printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
+ for(i=0;i<MAXFILES;i++){
+ printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
+ }
+*/
doy = date2doy(day,month,year);
printf("doy=%i\n",doy);
@@ -210,7 +204,7 @@
}
/********************/
- //Prepare sun exo-atm irradiance
+ /*Prepare sun exo-atm irradiance*/
/********************/
kexo[0]=KEXO1;
@@ -218,12 +212,11 @@
kexo[2]=KEXO3;
kexo[3]=KEXO4;
kexo[4]=KEXO5;
- kexo[5]=KEXO6;//filling only
+ kexo[5]=KEXO6;/*filling only*/
kexo[6]=KEXO7;
- //******************************************
/***************************************************/
- //Band1
+ /*Band1*/
/* find map in mapset */
mapset = G_find_cell2 (b1, "");
if (mapset == NULL){
@@ -244,7 +237,7 @@
inrast[0] = G_allocate_raster_buf(in_data_type[0]);
/***************************************************/
/***************************************************/
- //Band2
+ /*Band2*/
/* find map in mapset */
mapset = G_find_cell2 (b2, "");
if (mapset == NULL){
@@ -265,7 +258,7 @@
inrast[1] = G_allocate_raster_buf(in_data_type[1]);
/***************************************************/
/***************************************************/
- //Band3
+ /*Band3*/
/* find map in mapset */
mapset = G_find_cell2 (b3, "");
if (mapset == NULL){
@@ -286,7 +279,7 @@
inrast[2] = G_allocate_raster_buf(in_data_type[2]);
/***************************************************/
/***************************************************/
- //Band4
+ /*Band4*/
/* find map in mapset */
mapset = G_find_cell2 (b4, "");
if (mapset == NULL){
@@ -307,7 +300,7 @@
inrast[3] = G_allocate_raster_buf(in_data_type[3]);
/***************************************************/
/***************************************************/
- //Band5
+ /*Band5*/
/* find map in mapset */
mapset = G_find_cell2 (b5, "");
if (mapset == NULL){
@@ -328,7 +321,7 @@
inrast[4] = G_allocate_raster_buf(in_data_type[4]);
/***************************************************/
/***************************************************/
- //Band6
+ /*Band6*/
/* find map in mapset */
mapset = G_find_cell2 (b6, "");
if (mapset == NULL){
@@ -349,7 +342,7 @@
inrast[5] = G_allocate_raster_buf(in_data_type[5]);
/***************************************************/
/***************************************************/
- //Band7
+ /*Band7*/
/* find map in mapset */
mapset = G_find_cell2 (b7, "");
if (mapset == NULL){
@@ -381,9 +374,9 @@
nrows = G_window_rows();
ncols = G_window_cols();
- // Following is for latitude conversion from UTM to Geo
- //Shamelessly stolen from r.sun !!!!
- /* Set up parameters for projection to lat/long if necessary */
+ /* Following is for latitude conversion from UTM to Geo
+ Shamelessly stolen from r.sun !!!!
+ Set up parameters for projection to lat/long if necessary */
if ((G_projection() != PROJECTION_LL)) {
not_ll=1;
struct Key_Value *in_proj_info, *in_unit_info;
@@ -401,7 +394,7 @@
sprintf(oproj.proj, "ll");
if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
G_fatal_error(_("Unable to set up lat/long projection parameters"));
- }//End of stolen from r.sun :P
+ }/*End of stolen from r.sun */
out_data_type=DCELL_TYPE;
outrast[0] = G_allocate_raster_buf(out_data_type);
@@ -416,9 +409,9 @@
DCELL d_ndvi;
DCELL d_e0;
DCELL d_lat;
-// DCELL d_doy;
+/* DCELL d_doy;*/
DCELL d_tsw;
-// DCELL d_roh_w;
+/* DCELL d_roh_w;*/
DCELL d_solar;
DCELL d_rnetd;
DCELL d_etpot;
@@ -440,12 +433,9 @@
}
}
/*process the data */
-// #ifdef OMP
-// #pragma omp parallel
-// #endif
for (col=0; col < ncols; col++)
{
- //Calculate Latitude
+ /*Calculate Latitude*/
latitude = ymax - ( row * stepy );
longitude = xmin + ( col * stepx );
if(not_ll){
@@ -453,29 +443,29 @@
G_fatal_error(_("Error in pj_do_proj"));
}
}else{
- //Do nothing
+ /*Do nothing*/
}
d_lat = latitude;
- //End of Calculate Latitude
+ /*End of Calculate Latitude*/
- // Convert DN 2 radiance 2 reflectance
+ /* Convert DN 2 radiance 2 reflectance*/
for(i=0;i<MAXFILES;i++)
{
d[i] = (double) ((CELL *) inrast[i])[col];
dout[i]=dn2rad_landsat5(c_year,c_month,c_day,year,month,day,i+1,d[i]);
- if(i==5){//if band 6, process brightness temperature
+ if(i==5){/*if band 6, process brightness temperature*/
if(dout[i]<=0.0){
dout[i]=-999.99;
}else{
dout[i]=tempk_landsat5(dout[i]);
}
- }else{//process reflectance
+ }else{/*process reflectance*/
dout[i]=rad2ref_landsat5(dout[i],doy,sun_elevation,kexo[i]);
}
}
- // End of Convert DN 2 radiance 2 reflectance
+ /* End of Convert DN 2 radiance 2 reflectance*/
- // Process regular data
+ /* Process regular data*/
d_albedo = bb_alb_landsat(dout[0],dout[1],dout[2],dout[3],dout[4],dout[6]);
if(G_is_d_null_value(&d_albedo)){
/*Do nothing*/
@@ -585,7 +575,7 @@
a=(0.36-0.05)/(i_bottom2b/100.0-i_peak1/100.0);
b=0.05-a*(i_peak1/100.0);
printf("a= %f\tb= %f\n",a,b);
- }//END OF FLAG1
+ }/*END OF FLAG1*/
/*START PROCESSING*/
for (row = 0; row < nrows; row++)
{
@@ -598,11 +588,9 @@
}
}
/*process the data */
-// #ifdef OMP
-// #pragma omp parallel
for (col=0; col < ncols; col++)
{
- //Calculate Latitude
+ /*Calculate Latitude*/
latitude = ymax - ( row * stepy );
longitude = xmin + ( col * stepx );
if(not_ll){
@@ -610,32 +598,32 @@
G_fatal_error(_("Error in pj_do_proj"));
}
}else{
- //Do nothing
+ /*Do nothing*/
}
d_lat = latitude;
- //End of Calculate Latitude
+ /*End of Calculate Latitude*/
- // Convert DN 2 radiance 2 reflectance
+ /* Convert DN 2 radiance 2 reflectance*/
for(i=0;i<MAXFILES;i++)
{
d[i] = (double) ((CELL *) inrast[i])[col];
dout[i]=dn2rad_landsat5(c_year,c_month,c_day,year,month,day,i+1,d[i]);
- if(i==5){//if band 6, process brightness temperature
+ if(i==5){/*if band 6, process brightness temperature*/
if(dout[i]<=0.0){
dout[i]=-999.99;
}else{
dout[i]=tempk_landsat5(dout[i]);
}
- }else{//process reflectance
+ }else{/*process reflectance*/
dout[i]=rad2ref_landsat5(dout[i],doy,sun_elevation,kexo[i]);
}
}
- // End of Convert DN 2 radiance 2 reflectance
+ /* End of Convert DN 2 radiance 2 reflectance*/
- // Process regular data
+ /* Process regular data*/
d_albedo = bb_alb_landsat(dout[0],dout[1],dout[2],dout[3],dout[4],dout[7]);
if(flag1->answer){
- // Post-Process Albedo
+ /* Post-Process Albedo*/
d_albedo = a*d_albedo+b;
}
d_ndvi = nd_vi(d[2],d[3]);
@@ -644,11 +632,11 @@
d_rnetd = r_net_day(d_albedo,d_solar,tsw );
d_tempk = dout[5];
d_etpot = et_pot_day(d_albedo,d_solar,d_tempk,tsw,roh_w);
- // End of process regular data
+ /* End of process regular data*/
- // write output to file
+ /* write output to file*/
((DCELL *) outrast[0])[col] = d_etpot;
- // End of write output to file
+ /* End of write output to file*/
}
if (G_put_raster_row (outfd[0], outrast[0], out_data_type) < 0)
G_fatal_error (_("Cannot write to <%s.%i>"),result,0+1);
@@ -658,34 +646,8 @@
G_free (outrast[0]);
G_close_cell (outfd[0]);
-// G_command_history(&history);
-// G_write_history(result,&history);
+ G_command_history(&history);
+ G_write_history(result,&history);
-// //fill in data source line
-// printf("1\t");
-// strncpy(history.datsrc_1,metfName,RECORD_LEN);
-// sprintf(history_buf,"year=%d",year);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"month=%d",month);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"day=%d",day);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"doy=%d",doy);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"sun_elevation=%f",sun_elevation);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"sun_azimuth=%f",sun_azimuth);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// printf("1\t");
-// history.datsrc_1[RECORD_LEN-1]='\0';//strncpy() doesn't null terminate if maxfill
-// printf("1\t");
-// G_write_history(result,&history);
-
return 0;
}
Modified: grass-addons/gipe/i.dn2potrad.l5/ndvi.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/ndvi.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/ndvi.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Normalized Difference Vegetation Index
+/* Normalized Difference Vegetation Index */
double nd_vi( double redchan, double nirchan )
Modified: grass-addons/gipe/i.dn2potrad.l5/r_net_day.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/r_net_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/r_net_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Net Radiation after Bastiaanssen (1995)
+/* Average Diurnal Net Radiation after Bastiaanssen (1995) */
double r_net_day( double bbalb, double solar, double tsw )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/rad2ref_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/rad2ref_landsat5.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/rad2ref_landsat5.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -4,8 +4,7 @@
#define PI 3.1415926
-// Conversion of Radiance to Reflectance for Landsat 5TM
-// ychemin at gmail.com - Yann Chemin - GPL>=2, 2008.
+/* Conversion of Radiance to Reflectance for Landsat 5TM */
double rad2ref_landsat5( double radiance, double doy,double sun_elevation, double k_exo )
{
Modified: grass-addons/gipe/i.dn2potrad.l5/solar_day.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/solar_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/solar_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2004.
+/* Average Solar Diurnal Radiation after Bastiaanssen (1995) */
#define PI 3.1415927
Modified: grass-addons/gipe/i.dn2potrad.l5/tempk_landsat5.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l5/tempk_landsat5.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l5/tempk_landsat5.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,10 @@
#include<math.h>
#include<stdlib.h>
-// Surface temperature for Landsat 5TM
-// Schneider and Mauser, 1996
+/*
+ * Surface temperature for Landsat 5TM
+ * Schneider and Mauser, 1996
+ */
double tempk_landsat5( double l6 )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/bb_alb_landsat.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/bb_alb_landsat.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/bb_alb_landsat.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Broadband albedo Landsat 5TM and 7ETM+ (maybe others too but not sure)
-// yann.chemin at ait.ac.th LGPL, Copylefted, 2004.
+/* Broadband albedo Landsat 5TM and 7ETM+ (maybe others too but not sure)*/
double bb_alb_landsat( double bluechan, double greenchan, double redchan, double nirchan, double chan5, double chan7 )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/dn2rad_landsat7.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/dn2rad_landsat7.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/dn2rad_landsat7.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,9 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Conversion of DN to Radiance for Landsat 7ETM+
-// http://ltpwww.gsfc.nasa.gov/IAS/handbook/handbook_htmls/chapter11/chapter11.html#section11.3
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2006.
+/* Conversion of DN to Radiance for Landsat 7ETM+
+ * http://ltpwww.gsfc.nasa.gov/IAS/handbook/handbook_htmls/chapter11/chapter11.html#section11.3
+ */
double dn2rad_landsat7( double Lmin, double LMax, double QCalMax, double QCalmin, int DN )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/emissivity_generic.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/emissivity_generic.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/emissivity_generic.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,9 +2,9 @@
#include<math.h>
#include<stdlib.h>
-// Emissivity Generic mode (Reads directly from NDVI)
-// Estimation in the 8-14 micrometers range for sparse canopy
-// yann.chemin at gmail.com LGPL, Copylefted, 2004.
+/* Emissivity Generic mode (Reads directly from NDVI)
+ * Estimation in the 8-14 micrometers range for sparse canopy
+ */
double emissivity_generic( double ndvi )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/et_pot_day.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/et_pot_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/et_pot_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Potential ET after Bastiaanssen (1995)
+/* Average Diurnal Potential ET after Bastiaanssen (1995)*/
double et_pot_day( double bbalb, double solar, double tempk, double tsw, double roh_w )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/l7inread.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/l7inread.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/l7inread.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -13,7 +13,7 @@
char band1[80],band2[80],band3[80];
char band4[80],band5[80],band61[80];
- char band62[80],band7[80],band8[80];//Load .tif names
+ char band62[80],band7[80],band8[80];/*Load .tif names*/
if((f=fopen(metfName,"r"))==NULL){
G_fatal_error (_(".met file [%s] not found, are you in the proper directory?"), metfName);
@@ -21,30 +21,23 @@
while (fgets(s,1000,f)!=NULL)
{
-// printf("2%s\n",s);
ptr = strstr(s, "ACQUISITION_DATE");
if (ptr != NULL)
{
-// printf("2\t");
p = strtok(ptr, " =");
p = strtok(NULL, " =-");
*year = atoi(p);
-// printf("3\t");
p = strtok(NULL, "-");
*month = atoi(p);
-// printf("4\t");
p = strtok(NULL, "-");
*day = atoi(p);
-// printf("5\n");
}
ptr = strstr(s, "BAND1_FILE_NAME");
if (ptr != NULL)
{
p = strtok(ptr, " =");
p = strtok(NULL, " =\"");
- // printf("l7inread.c:p=%s\n",p);
snprintf(band1, 80, "%s", p);
- // printf("l7inread.c:band1=%s\n",band1);
}
ptr = strstr(s, "BAND2_FILE_NAME");
if (ptr != NULL)
@@ -381,19 +374,18 @@
snprintf(b62, 80, "%s", band62);
snprintf(b7, 80, "%s", band7);
snprintf(b8, 80, "%s", band8);
-// printf("year = %i\n", year);
-// printf("month = %i\n", month);
-// printf("day = %i\n", day);
-
-// printf("sun azimuth = %f\n", sun_azimuth);
-// printf("sun elevation = %f\n", sun_elevation);
-
-// for (i=0;i<MAXFILES;i++){
-// printf("lmin[%i]=%f\n",i,lmin[i]);
-// printf("lmax[%i]=%f\n",i,lmax[i]);
-// printf("qcalmin[%i]=%f\n",i,qcalmin[i]);
-// printf("qcalmax[%i]=%f\n",i,qcalmax[i]);
-// }
+/* printf("year = %i\n", year);
+ printf("month = %i\n", month);
+ printf("day = %i\n", day);
+ printf("sun azimuth = %f\n", sun_azimuth);
+ printf("sun elevation = %f\n", sun_elevation);
+ for (i=0;i<MAXFILES;i++){
+ printf("lmin[%i]=%f\n",i,lmin[i]);
+ printf("lmax[%i]=%f\n",i,lmax[i]);
+ printf("qcalmin[%i]=%f\n",i,qcalmin[i]);
+ printf("qcalmax[%i]=%f\n",i,qcalmax[i]);
+ }
+*/
(void)fclose(f);
return;
}
Modified: grass-addons/gipe/i.dn2potrad.l7/main.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -17,27 +17,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-//#define OMP // Comment this on single core CPU
-//#ifdef OMP
-// #include<omp.h> // OpenMP code
-// #include"/usr/lib/gcc/i486-linux-gnu/4.2.0/include/omp.h"
-//#endif
-
#include <grass/gis.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#define MAXFILES 9
-//sun exo-atmospheric irradiance
+/*sun exo-atmospheric irradiance*/
#define KEXO1 1969.0
#define KEXO2 1840.0
#define KEXO3 1551.0
#define KEXO4 1044.0
#define KEXO5 225.7
#define KEXO7 82.07
-#define KEXO8 1385.64 //to find the real value in the internet
+#define KEXO8 1385.64 /*to find the real value in the internet*/
#define PI 3.1415926
@@ -57,25 +50,24 @@
int
main(int argc, char *argv[])
{
- struct Cell_head cellhd;//region+header info
- char *mapset; //mapset name
+ struct Cell_head cellhd;/*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
- int verbose=1;
struct GModule *module;
struct Option *input,*input1,*input2,*input3,*output;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
char history_buf[200];
- char *name; //input raster name
- char *result; //output raster name
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
- //File Descriptors
+ /*File Descriptors*/
int infd[MAXFILES];
int outfd[MAXFILES];
@@ -85,30 +77,30 @@
int i=0,j=0;
void *inrast[MAXFILES];
- unsigned char *outrast[MAXFILES];
+ DCELL *outrast[MAXFILES];
RASTER_MAP_TYPE in_data_type[MAXFILES];
RASTER_MAP_TYPE out_data_type = DCELL_TYPE; /* 0=numbers 1=text */
double kexo[MAXFILES];
- //Metfile
- char *metfName; //met file, header in text format
+ /*Metfile*/
+ char *metfName; /*met file, header in text format*/
char b1[80],b2[80],b3[80];
char b4[80],b5[80],b61[80];
- char b62[80],b7[80],b8[80];//Load .tif names
+ char b62[80],b7[80],b8[80];/*Load .tif names*/
double lmin[MAXFILES];
double lmax[MAXFILES];
double qcalmin[MAXFILES];
double qcalmax[MAXFILES];
double sun_elevation;
- double sun_azimuth;//not useful here, only for parser()
+ double sun_azimuth;/*not useful here, only for parser()*/
int day,month,year;
- //EndofMetfile
+ /*EndofMetfile*/
int doy;
- int not_ll=0; //if proj is not lat/long, it will be 1.
+ int not_ll=0; /*if proj is not lat/long, it will be 1.*/
struct pj_info iproj;
struct pj_info oproj;
-// char *lat;
+/* char *lat;*/
double xp, yp;
double xmin, ymin;
double xmax, ymax;
@@ -158,19 +150,9 @@
input3->description= _("5=band61 || 6=band62");
input3->answer = "5";
- output = G_define_option() ;
- output->key = _("output");
- output->type = TYPE_STRING;
- output->required = YES;
- output->gisprompt = _("new,cell,raster");
+ output = G_define_standard_option(G_OPT_R_OUTPUT) ;
output->description= _("ETpot output layer name");
- /* Define the different flags */
-
- flag1 = G_define_flag() ;
- flag1->key =_('q');
- flag1->description =_("Quiet");
-
/********************/
if (G_parser(argc, argv))
exit (-1);
@@ -191,45 +173,41 @@
G_fatal_error (_("Tempk band is not good, change to 5 OR 6!"));
}
- verbose = (!flag1->answer);
- //******************************************
- //Fetch parameters for DN2Rad2Ref correction
+ /******************************************/
+ /*Fetch parameters for DN2Rad2Ref correction*/
l7_in_read(metfName,b1,b2,b3,b4,b5,b61,b62,b7,b8,lmin,lmax,qcalmin,qcalmax,&sun_elevation,&sun_azimuth,&day,&month,&year);
-// printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
-// for(i=0;i<MAXFILES;i++){
-// printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
-// }
doy = date2doy(day,month,year);
-// printf("doy=%i\n",doy);
+/* printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
+ for(i=0;i<MAXFILES;i++){
+ printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
+ }
+ printf("b1=%s\n",b1);
+ printf("b2=%s\n",b2);
+ printf("b3=%s\n",b3);
+ printf("b4=%s\n",b4);
+ printf("b5=%s\n",b5);
+ printf("b61=%s\n",b61);
+ printf("b62=%s\n",b62);
+ printf("b7=%s\n",b7);
+ printf("b8=%s\n",b8);
+ printf("doy=%i\n",doy);
+*/
/********************/
-// printf("b1=%s\n",b1);
-// printf("b2=%s\n",b2);
-// printf("b3=%s\n",b3);
-// printf("b4=%s\n",b4);
-// printf("b5=%s\n",b5);
-// printf("b61=%s\n",b61);
-// printf("b62=%s\n",b62);
-// printf("b7=%s\n",b7);
-// printf("b8=%s\n",b8);
-// exit(1);
-
+ /*Prepare sun exo-atm irradiance*/
/********************/
- //Prepare sun exo-atm irradiance
- /********************/
kexo[0]=KEXO1;
kexo[1]=KEXO2;
kexo[2]=KEXO3;
kexo[3]=KEXO4;
kexo[4]=KEXO5;
- kexo[5]=0.0;//filling
- kexo[6]=0.0;//filling
+ kexo[5]=0.0;/*filling*/
+ kexo[6]=0.0;/*filling*/
kexo[7]=KEXO7;
kexo[8]=KEXO8;
- //******************************************
/***************************************************/
- //Band1
+ /*Band1*/
/* find map in mapset */
mapset = G_find_cell2 (b1, "");
if (mapset == NULL){
@@ -250,7 +228,7 @@
inrast[0] = G_allocate_raster_buf(in_data_type[0]);
/***************************************************/
/***************************************************/
- //Band2
+ /*Band2*/
/* find map in mapset */
mapset = G_find_cell2 (b2, "");
if (mapset == NULL){
@@ -271,7 +249,7 @@
inrast[1] = G_allocate_raster_buf(in_data_type[1]);
/***************************************************/
/***************************************************/
- //Band3
+ /*Band3*/
/* find map in mapset */
mapset = G_find_cell2 (b3, "");
if (mapset == NULL){
@@ -292,7 +270,7 @@
inrast[2] = G_allocate_raster_buf(in_data_type[2]);
/***************************************************/
/***************************************************/
- //Band4
+ /*Band4*/
/* find map in mapset */
mapset = G_find_cell2 (b4, "");
if (mapset == NULL){
@@ -313,7 +291,7 @@
inrast[3] = G_allocate_raster_buf(in_data_type[3]);
/***************************************************/
/***************************************************/
- //Band5
+ /*Band5*/
/* find map in mapset */
mapset = G_find_cell2 (b5, "");
if (mapset == NULL){
@@ -334,7 +312,7 @@
inrast[4] = G_allocate_raster_buf(in_data_type[4]);
/***************************************************/
/***************************************************/
- //Band61
+ /*Band61*/
/* find map in mapset */
mapset = G_find_cell2 (b61, "");
if (mapset == NULL){
@@ -355,7 +333,7 @@
inrast[5] = G_allocate_raster_buf(in_data_type[5]);
/***************************************************/
/***************************************************/
- //Band62
+ /*Band62*/
/* find map in mapset */
mapset = G_find_cell2 (b62, "");
if (mapset == NULL){
@@ -376,7 +354,7 @@
inrast[6] = G_allocate_raster_buf(in_data_type[6]);
/***************************************************/
/***************************************************/
- //Band7
+ /*Band7*/
/* find map in mapset */
mapset = G_find_cell2 (b7, "");
if (mapset == NULL){
@@ -397,7 +375,7 @@
inrast[7] = G_allocate_raster_buf(in_data_type[7]);
/***************************************************/
/***************************************************/
- //Band8
+ /*Band8*/
/* find map in mapset */
mapset = G_find_cell2 (b8, "");
if (mapset == NULL){
@@ -429,9 +407,9 @@
nrows = G_window_rows();
ncols = G_window_cols();
- // Following is for latitude conversion from UTM to Geo
- //Shamelessly stolen from r.sun !!!!
- /* Set up parameters for projection to lat/long if necessary */
+ /* Following is for latitude conversion from UTM to Geo
+ * Shamelessly stolen from r.sun !!!!
+ * Set up parameters for projection to lat/long if necessary */
if ((G_projection() != PROJECTION_LL)) {
not_ll=1;
struct Key_Value *in_proj_info, *in_unit_info;
@@ -449,7 +427,7 @@
sprintf(oproj.proj, "ll");
if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
G_fatal_error(_("Unable to set up lat/long projection parameters"));
- }//End of stolen from r.sun :P
+ }/*End of stolen from r.sun */
out_data_type=DCELL_TYPE;
outrast[0] = G_allocate_raster_buf(out_data_type);
@@ -464,9 +442,9 @@
DCELL d_ndvi;
DCELL d_e0;
DCELL d_lat;
-// DCELL d_doy;
+/* DCELL d_doy;*/
DCELL d_tsw;
-// DCELL d_roh_w;
+/* DCELL d_roh_w;*/
DCELL d_solar;
DCELL d_rnetd;
DCELL d_etpot;
@@ -483,12 +461,9 @@
}
}
/*process the data */
-// #ifdef OMP
-// #pragma omp parallel
-// #endif
for (col=0; col < ncols; col++)
{
- //Calculate Latitude
+ /*Calculate Latitude*/
latitude = ymax - ( row * stepy );
longitude = xmin + ( col * stepx );
if(not_ll){
@@ -496,29 +471,29 @@
G_fatal_error(_("Error in pj_do_proj"));
}
}else{
- //Do nothing
+ /*Do nothing*/
}
d_lat = latitude;
- //End of Calculate Latitude
+ /*End of Calculate Latitude*/
- // Convert DN 2 radiance 2 reflectance
+ /* Convert DN 2 radiance 2 reflectance*/
for(i=0;i<MAXFILES;i++)
{
d[i] = (double) ((CELL *) inrast[i])[col];
dout[i]=dn2rad_landsat7(lmin[i],lmax[i],qcalmax[i],qcalmin[i],d[i]);
- if(i==5||i==6){//if band 61/62, process brightness temperature
+ if(i==5||i==6){/*if band 61/62, process brightness temperature*/
if(dout[i]<=0.0){
dout[i]=-999.99;
}else{
dout[i]=tempk_landsat7(dout[i]);
}
- }else{//process reflectance
+ }else{/*process reflectance*/
dout[i]=rad2ref_landsat7(dout[i],doy,sun_elevation,kexo[i]);
}
}
- // End of Convert DN 2 radiance 2 reflectance
+ /* End of Convert DN 2 radiance 2 reflectance*/
- // Process regular data
+ /* Process regular data*/
d_albedo = bb_alb_landsat(dout[0],dout[1],dout[2],dout[3],dout[4],dout[7]);
d_ndvi = nd_vi(d[2],d[3]);
d_e0 = emissivity_generic( d_ndvi );
@@ -526,12 +501,11 @@
d_rnetd = r_net_day(d_albedo,d_solar,tsw );
d_tempk = dout[chosen_tempk_band];
d_etpot = et_pot_day(d_albedo,d_solar,d_tempk,tsw,roh_w);
-// d_etpot = d_solar;
- // End of process regular data
+ /* End of process regular data*/
- // write output to file
- ((DCELL *) outrast[0])[col] = d_etpot;
- // End of write output to file
+ /* write output to file*/
+ outrast[0][col] = d_etpot;
+ /* End of write output to file*/
}
if (G_put_raster_row (outfd[0], outrast[0], out_data_type) < 0)
G_fatal_error (_("Cannot write to <%s.%i>"),result,0+1);
@@ -541,34 +515,8 @@
G_free (outrast[0]);
G_close_cell (outfd[0]);
-// G_command_history(&history);
-// G_write_history(result,&history);
+ G_command_history(&history);
+ G_write_history(result,&history);
-// //fill in data source line
-// printf("1\t");
-// strncpy(history.datsrc_1,metfName,RECORD_LEN);
-// sprintf(history_buf,"year=%d",year);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"month=%d",month);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"day=%d",day);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"doy=%d",doy);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"sun_elevation=%f",sun_elevation);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// sprintf(history_buf,"sun_azimuth=%f",sun_azimuth);
-// printf("1\t");
-// strncpy(history.datsrc_1,history_buf,RECORD_LEN);
-// printf("1\t");
-// history.datsrc_1[RECORD_LEN-1]='\0';//strncpy() doesn't null terminate if maxfill
-// printf("1\t");
-// G_write_history(result,&history);
-
return 0;
}
Modified: grass-addons/gipe/i.dn2potrad.l7/ndvi.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/ndvi.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/ndvi.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Normalized Difference Vegetation Index
+/* Normalized Difference Vegetation Index */
double nd_vi( double redchan, double nirchan )
Modified: grass-addons/gipe/i.dn2potrad.l7/r_net_day.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/r_net_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/r_net_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Diurnal Net Radiation after Bastiaanssen (1995)
+/* Average Diurnal Net Radiation after Bastiaanssen (1995) */
double r_net_day( double bbalb, double solar, double tsw )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/rad2ref_landsat7.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/rad2ref_landsat7.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/rad2ref_landsat7.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -4,8 +4,7 @@
#define PI 3.1415926
-// Conversion of Radiance to Reflectance for Landsat 7ETM+
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2006.
+/* Conversion of Radiance to Reflectance for Landsat 7ETM+ */
double rad2ref_landsat7( double radiance, double doy,double sun_elevation, double k_exo )
{
Modified: grass-addons/gipe/i.dn2potrad.l7/solar_day.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/solar_day.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/solar_day.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Average Solar Diurnal Radiation after Bastiaanssen (1995)
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2004.
+/* Average Solar Diurnal Radiation after Bastiaanssen (1995) */
#define PI 3.1415927
Modified: grass-addons/gipe/i.dn2potrad.l7/tempk_landsat7.c
===================================================================
--- grass-addons/gipe/i.dn2potrad.l7/tempk_landsat7.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2potrad.l7/tempk_landsat7.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-// Surface temperature for Landsat 7ETM+
+/* Surface temperature for Landsat 7ETM+ */
double tempk_landsat7( double l6 )
{
Modified: grass-addons/gipe/i.dn2ref.ast/main.c
===================================================================
--- grass-addons/gipe/i.dn2ref.ast/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2ref.ast/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -21,7 +21,7 @@
#define MAXFILES 9
-// DN to radiance conversion factors
+/* DN to radiance conversion factors */
#define L1GAIN 0.676
#define L1OFFS -0.676
#define L2GAIN 0.862
@@ -41,7 +41,7 @@
#define L9GAIN 0.0318
#define L9OFFS -0.0318
-//sun exo-atmospheric irradiance
+/*sun exo-atmospheric irradiance */
#define KEXO1 1828.0
#define KEXO2 1559.0
#define KEXO3 1045.0
@@ -59,29 +59,28 @@
int
main(int argc, char *argv[])
{
- struct Cell_head cellhd;//region+header info
- char *mapset; //mapset name
+ struct Cell_head cellhd;/*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
- int verbose=1;
struct GModule *module;
struct Option *input,*output;
struct Option *input1,*input2;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; //input raster name
- char *result; //output raster name
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
- //Prepare new names for output files
+ /*Prepare new names for output files*/
char *result0, *result1, *result2, *result3, *result4;
char *result5, *result6, *result7, *result8;
- //File Descriptors
+ /*File Descriptors*/
int nfiles;
int infd[MAXFILES];
int outfd[MAXFILES];
@@ -95,15 +94,11 @@
int radiance=0;
void *inrast[MAXFILES];
- unsigned char *outrast[MAXFILES];
+ DCELL *outrast[MAXFILES];
int data_format; /* 0=double 1=float 2=32bit signed int 5=8bit unsigned int (ie text) */
RASTER_MAP_TYPE in_data_type[MAXFILES];
RASTER_MAP_TYPE out_data_type = DCELL_TYPE; /* 0=numbers 1=text */
- char *fileName;
-#define fileNameLe 8
-#define fileNamePosition 3
-
double gain[MAXFILES], offset[MAXFILES];
double kexo[MAXFILES];
double doy,sun_elevation;
@@ -118,12 +113,7 @@
/* Define the different options */
- input = G_define_option() ;
- input->key = _("input");
- input->type = TYPE_STRING;
- input->required = YES;
- input->multiple = YES;
- input->gisprompt = _("old,cell,raster");
+ input = G_define_standard_option(G_OPT_R_INPUTS) ;
input->description= _("Names of ASTER DN layers (9 layers)");
input1 = G_define_option() ;
@@ -140,11 +130,7 @@
input2->gisprompt = _("value, parameter");
input2->description= _("Sun elevation angle (degrees, < 90.0)");
- output = G_define_option() ;
- output->key = _("output");
- output->type = TYPE_STRING;
- output->required = YES;
- output->gisprompt = _("new,cell,raster");
+ output = G_define_standard_option(G_OPT_R_OUTPUT) ;
output->description= _("Base name of the output layers (will add .x)");
/* Define the different flags */
@@ -153,12 +139,6 @@
flag1->key = _('r');
flag1->description = _("output is radiance (W/m2)");
- flag2 = G_define_flag() ;
- flag2->key =_('q');
- flag2->description =_("Quiet");
-
-// printf("Passed Stage 1.\n");
-
/* FMEO init nfiles */
nfiles = 1;
/********************/
@@ -168,18 +148,13 @@
ok = 1;
names = input->answers;
ptr = input->answers;
-
doy = atof(input1->answer);
sun_elevation = atof(input2->answer);
-
result = output->answer;
radiance = (flag1->answer);
- verbose = (!flag2->answer);
-
-
/********************/
- //Prepare the ouput file names
+ /*Prepare the ouput file names */
/********************/
result0=result;
@@ -203,7 +178,7 @@
result8=strcat(result8,".9");
/********************/
- //Prepare radiance boundaries
+ /*Prepare radiance boundaries*/
/********************/
gain[0]=L1GAIN;
@@ -227,7 +202,7 @@
offset[8]=L9OFFS;
/********************/
- //Prepare sun exo-atm irradiance
+ /*Prepare sun exo-atm irradiance*/
/********************/
kexo[0]=KEXO1;
@@ -244,12 +219,9 @@
/********************/
for (; *ptr != NULL; ptr++)
{
-// printf("In-Loop Stage 1. nfiles = %i\n",nfiles);
if (nfiles >= MAXFILES)
G_fatal_error (_("%s - too many ETa files. Only %d allowed"), G_program_name(), MAXFILES);
-// printf("In-Loop Stage 1..\n");
name = *ptr;
-// printf("In-Loop Stage 1...\n");
/* find map in mapset */
mapset = G_find_cell2 (name, "");
if (mapset == NULL)
@@ -257,27 +229,22 @@
G_fatal_error (_("cell file [%s] not found"), name);
ok = 0;
}
-// printf("In-Loop Stage 1....\n");
if (G_legal_filename (result) < 0)
{
G_fatal_error (_("[%s] is an illegal name"), result);
ok = 0;
}
-// printf("In-Loop Stage 1.....\n");
if (!ok){
continue;
}
-// printf("In-Loop Stage 1......\n");
infd[nfiles] = G_open_cell_old (name, mapset);
if (infd[nfiles] < 0)
{
ok = 0;
continue;
}
-// printf("In-Loop Stage 1.......\n");
/* Allocate input buffer */
in_data_type[nfiles] = G_raster_map_type(name, mapset);
- //printf("%s: data_type[%i] = %i\n",name,nfiles,in_data_type[nfiles]);
if( (infd[nfiles] = G_open_cell_old(name,mapset)) < 0){
G_fatal_error(_("Cannot open cell file [%s]"), name);
}
@@ -285,22 +252,16 @@
G_fatal_error(_("Cannot read file header of [%s]"), name);
}
inrast[nfiles] = G_allocate_raster_buf(in_data_type[nfiles]);
-// printf("In-Loop Stage 1........\n");
nfiles++;
-// printf("In-Loop Stage 1.........nfiles = %i\n",nfiles);
}
nfiles--;
-// printf("Passed Loop. nfiles = %i\n",nfiles);
if (nfiles <= 1){
G_fatal_error(_("The input band number should be 6"));
}
-// printf("Passed Stage 2\n");
-
/***************************************************/
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
-// printf("Passed Stage 3\n");
out_data_type=DCELL_TYPE;
for(i=0;i<nfiles;i++){
outrast[i] = G_allocate_raster_buf(out_data_type);
@@ -323,7 +284,6 @@
G_fatal_error (_("Could not open <%s>"),result7);
if ( (outfd[8] = G_open_raster_new (result8,1)) < 0)
G_fatal_error (_("Could not open <%s>"),result8);
-// printf("Passed Stage 5\n");
/* Process pixels */
DCELL dout[MAXFILES];
@@ -331,9 +291,7 @@
for (row = 0; row < nrows; row++)
{
- if (verbose){
- G_percent (row, nrows, 2);
- }
+ G_percent (row, nrows, 2);
/* read input map */
for (i=1;i<=nfiles;i++)
{
@@ -365,7 +323,7 @@
dout[i] = gain[i]*d[i]+offset[i];
dout[i] = rad2ref_aster(dout[i],doy,sun_elevation,kexo[i]);
}
- ((DCELL *) outrast[i])[col] = dout[i];
+ outrast[i][col] = dout[i];
}
}
for(i=0;i<nfiles;i++){
Modified: grass-addons/gipe/i.dn2ref.ast/rad2ref_aster.c
===================================================================
--- grass-addons/gipe/i.dn2ref.ast/rad2ref_aster.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2ref.ast/rad2ref_aster.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -4,8 +4,7 @@
#define PI 3.1415926
-// Conversion of Radiance to Reflectance for ASTER
-// ychemin at gmail.com - Yann Chemin - LGPL, Copylefted, 2006.
+/* Conversion of Radiance to Reflectance for ASTER */
double rad2ref_aster( double radiance, double doy,double sun_elevation, double k_exo )
{
Modified: grass-addons/gipe/i.dn2ref.l7/main.c
===================================================================
--- grass-addons/gipe/i.dn2ref.l7/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/i.dn2ref.l7/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,7 +1,7 @@
/****************************************************************************
*
* MODULE: i.dn2ref.l7
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Calculate TOA Reflectance for Landsat7 from DN.
*
* COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
@@ -23,7 +23,7 @@
#define MAXFILES 7
-//sun exo-atmospheric irradiance
+/*sun exo-atmospheric irradiance*/
#define KEXO1 1969.0
#define KEXO2 1840.0
#define KEXO3 1551.0
@@ -40,29 +40,28 @@
int
main(int argc, char *argv[])
{
- struct Cell_head cellhd;//region+header info
- char *mapset; //mapset name
+ struct Cell_head cellhd;/*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
- int verbose=1;
struct GModule *module;
struct Option *input,*output;
struct Option *input1,*input2;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; //input raster name
- char *result; //output raster name
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
- //Prepare new names for output files
+ /*Prepare new names for output files*/
char *result0, *result1, *result2, *result3, *result4;
char *result5;
- //File Descriptors
+ /*File Descriptors*/
int nfiles;
int infd[MAXFILES];
int outfd[MAXFILES];
@@ -76,26 +75,22 @@
int radiance=0;
void *inrast[MAXFILES];
- unsigned char *outrast[MAXFILES];
+ DCELL *outrast[MAXFILES];
int data_format; /* 0=double 1=float 2=32bit signed int 5=8bit unsigned int (ie text) */
RASTER_MAP_TYPE in_data_type[MAXFILES];
RASTER_MAP_TYPE out_data_type = DCELL_TYPE; /* 0=numbers 1=text */
- char *fileName;
-#define fileNameLe 8
-#define fileNamePosition 3
-
double kexo[MAXFILES];
- //Metfile
- char *metfName; //met file, header in text format
+ /*Metfile*/
+ char *metfName; /*met file, header in text format*/
double lmin[MAXFILES+2];
double lmax[MAXFILES+2];
double qcalmin[MAXFILES+2];
double qcalmax[MAXFILES+2];
double sun_elevation;
- double sun_azimuth;//not useful here, only for parser()
+ double sun_azimuth;/*not useful here, only for parser()*/
int day,month,year;
- //EndofMetfile
+ /*EndofMetfile*/
int doy;
/************************************/
@@ -114,19 +109,10 @@
input->gisprompt = _(".met file");
input->description= _("Landsat 7ETM+ Header File (.met)");
- input1 = G_define_option() ;
- input1->key = _("input");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->multiple = YES;
- input1->gisprompt = _("old,cell,raster");
+ input1 = G_define_standard_option(G_OPT_R_INPUTS) ;
input1->description= _("Names of L7 DN layers (1,2,3,4,5,7)");
- output = G_define_option() ;
- output->key = _("output");
- output->type = TYPE_STRING;
- output->required = YES;
- output->gisprompt = _("new,cell,raster");
+ output = G_define_standard_option(G_OPT_R_OUTPUT) ;
output->description= _("Base name of the output layers (will add .x)");
/* Define the different flags */
@@ -135,12 +121,6 @@
flag1->key = _('r');
flag1->description = _("output is radiance (W/m2)");
- flag2 = G_define_flag() ;
- flag2->key =_('q');
- flag2->description =_("Quiet");
-
-// printf("Passed Stage 1.\n");
-
/* FMEO init nfiles */
nfiles = 1;
/********************/
@@ -155,11 +135,8 @@
result = output->answer;
radiance = (flag1->answer);
- verbose = (!flag2->answer);
-
-
/********************/
- //Prepare the ouput file names
+ /*Prepare the ouput file names */
/********************/
result0=result;
@@ -177,7 +154,7 @@
result5=strcat(result5,".7");
/********************/
- //Prepare sun exo-atm irradiance
+ /*Prepare sun exo-atm irradiance*/
/********************/
kexo[0]=KEXO1;
@@ -187,37 +164,32 @@
kexo[4]=KEXO5;
kexo[5]=KEXO7;
- //******************************************
- //Fetch parameters for DN2Rad2Ref correction
+ /******************************************/
+ /*Fetch parameters for DN2Rad2Ref correction*/
l7_in_read(metfName,lmin,lmax,qcalmin,qcalmax,&sun_elevation,&sun_azimuth,&day,&month,&year);
- //printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
- //for(i=0;i<MAXFILES;i++){
- //printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
- //}
doy = date2doy(day,month,year);
- //printf("doy=%i\n",doy);
- /********************/
- //Remap calibration parameters for this program
- //copy layer 8 (band 7) to layer 6
- //because we only use band 1,2,3,4,5,7
- //Change this if you use more bands
- //Remove this if you use all bands
- /********************/
+/* printf("%f/%f/%i-%i-%i\n",sun_elevation,sun_azimuth,day,month,year);
+ for(i=0;i<MAXFILES;i++){
+ printf("%i=>%f, %f, %f, %f\n",i,lmin[i],lmax[i],qcalmin[i],qcalmax[i]);
+ }
+ printf("doy=%i\n",doy);
+
+ Remap calibration parameters for this program
+ copy layer 8 (band 7) to layer 6
+ because we only use band 1,2,3,4,5,7
+ Change this if you use more bands
+ Remove this if you use all bands
+*/
lmin[5]=lmin[7];
lmax[5]=lmax[7];
qcalmin[5]=qcalmin[7];
qcalmax[5]=qcalmax[7];
/********************/
-
-
for (; *ptr != NULL; ptr++)
{
-// printf("In-Loop Stage 1. nfiles = %i\n",nfiles);
if (nfiles >= MAXFILES)
G_fatal_error (_("%s - too many ETa files. Only %d allowed"), G_program_name(), MAXFILES);
-// printf("In-Loop Stage 1..\n");
name = *ptr;
-// printf("In-Loop Stage 1...\n");
/* find map in mapset */
mapset = G_find_cell2 (name, "");
if (mapset == NULL)
@@ -225,27 +197,22 @@
G_fatal_error (_("cell file [%s] not found"), name);
ok = 0;
}
-// printf("In-Loop Stage 1....\n");
if (G_legal_filename (result) < 0)
{
G_fatal_error (_("[%s] is an illegal name"), result);
ok = 0;
}
-// printf("In-Loop Stage 1.....\n");
if (!ok){
continue;
}
-// printf("In-Loop Stage 1......\n");
infd[nfiles] = G_open_cell_old (name, mapset);
if (infd[nfiles] < 0)
{
ok = 0;
continue;
}
-// printf("In-Loop Stage 1.......\n");
/* Allocate input buffer */
in_data_type[nfiles] = G_raster_map_type(name, mapset);
- //printf("%s: data_type[%i] = %i\n",name,nfiles,in_data_type[nfiles]);
if( (infd[nfiles] = G_open_cell_old(name,mapset)) < 0){
G_fatal_error(_("Cannot open cell file [%s]"), name);
}
@@ -253,22 +220,17 @@
G_fatal_error(_("Cannot read file header of [%s]"), name);
}
inrast[nfiles] = G_allocate_raster_buf(in_data_type[nfiles]);
-// printf("In-Loop Stage 1........\n");
nfiles++;
-// printf("In-Loop Stage 1.........nfiles = %i\n",nfiles);
}
nfiles--;
-// printf("Passed Loop. nfiles = %i\n",nfiles);
if (nfiles <= 1){
G_fatal_error(_("The input band number should be 6"));
}
-// printf("Passed Stage 2\n");
/***************************************************/
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
-// printf("Passed Stage 3\n");
out_data_type=DCELL_TYPE;
for(i=0;i<nfiles;i++){
outrast[i] = G_allocate_raster_buf(out_data_type);
@@ -285,7 +247,6 @@
G_fatal_error (_("Could not open <%s>"),result4);
if ( (outfd[5] = G_open_raster_new (result5,1)) < 0)
G_fatal_error (_("Could not open <%s>"),result5);
-// printf("Passed Stage 5\n");
/* Process pixels */
DCELL dout[MAXFILES];
@@ -293,9 +254,7 @@
for (row = 0; row < nrows; row++)
{
- if (verbose){
- G_percent (row, nrows, 2);
- }
+ G_percent (row, nrows, 2);
/* read input map */
for (i=1;i<=nfiles;i++)
{
@@ -327,7 +286,7 @@
dout[i]=dn2rad_landsat7(lmin[i],lmax[i],qcalmax[i],qcalmin[i],d[i]);
dout[i]=rad2ref_landsat7(dout[i],doy,sun_elevation,kexo[i]);
}
- ((DCELL *) outrast[i])[col] = dout[i];
+ outrast[i][col] = dout[i];
}
}
for(i=0;i<nfiles;i++){
Modified: grass-addons/gipe/r.evapo.MH/main.c
===================================================================
--- grass-addons/gipe/r.evapo.MH/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.evapo.MH/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,8 +1,7 @@
/*****************************************************************************
*
* MODULE: r.evapo.MH
-* AUTHOR: Yann Chemin (2007)
-* yann.chemin_AT_gmail.com
+* AUTHOR: Yann Chemin yann.chemin at gmail.com
*
* PURPOSE: To estimate the reference evapotranspiration by means
* of Modified Hargreaves method (2001).
@@ -25,8 +24,6 @@
#include <grass/raster.h>
#include <grass/glocale.h>
-
-//proto ET
double mh_original(double ra,double tavg,double tmax,double tmin,double p);
double mh_eto(double ra,double tavg,double tmax,double tmin,double p);
double mh_samani(double ra,double tavg,double tmax,double tmin);
@@ -36,7 +33,7 @@
/* buffer for input-output rasters */
void *inrast_TEMPKAVG,*inrast_TEMPKMIN, *inrast_TEMPKMAX, *inrast_RNET,*inrast_P;
- unsigned char *outrast;
+ DCELL *outrast;
/* pointers to input-output raster files */
int infd_TEMPKAVG,infd_TEMPKMIN,infd_TEMPKMAX,infd_RNET,infd_P;
@@ -66,7 +63,7 @@
struct Option *input_RNET,*input_TEMPKAVG, *input_TEMPKMIN;
struct Option *input_TEMPKMAX, *input_P;
struct Option *output;
- struct Flag *flag1, *zero, *original, *samani;
+ struct Flag *zero, *original, *samani;
struct Colors color;
struct History history;
@@ -88,59 +85,36 @@
"Flag for Original Hargreaves (1985).");
/* Define different options */
- input_RNET = G_define_option();
- input_RNET->key = "RNETD";
+ input_RNET = G_define_standard_option(G_OPT_R_INPUT);
+ input_RNET->key = "rnetd";
input_RNET->key_desc = "[W/m2/d]";
- input_RNET->type = TYPE_STRING;
- input_RNET->required = YES;
- input_RNET->gisprompt = "old,cell,raster";
input_RNET->description = _("Name of Diurnal Net Radiation raster map");
- input_TEMPKAVG = G_define_option();
- input_TEMPKAVG->key = "TEMPKAVG";
+ input_TEMPKAVG = G_define_standard_option(G_OPT_R_INPUT);
+ input_TEMPKAVG->key = "tempkavg";
input_TEMPKAVG->key_desc = "[C]";
- input_TEMPKAVG->type = TYPE_STRING;
- input_TEMPKAVG->required = YES;
- input_TEMPKAVG->gisprompt = "old,cell,raster";
input_TEMPKAVG->description = _("Name of avg air temperature raster map");
- input_TEMPKMIN = G_define_option();
- input_TEMPKMIN->key = "TEMPKMIN";
+ input_TEMPKMIN = G_define_standard_option(G_OPT_R_INPUT);
+ input_TEMPKMIN->key = "tempkmin";
input_TEMPKMIN->key_desc = "[C]";
- input_TEMPKMIN->type = TYPE_STRING;
- input_TEMPKMIN->required = YES;
- input_TEMPKMIN->gisprompt = "old,cell,raster";
input_TEMPKMIN->description = _("Name of min air temperature raster map");
- input_TEMPKMAX = G_define_option();
+ input_TEMPKMAX = G_define_standard_option(G_OPT_R_INPUT);
input_TEMPKMAX->key = "TEMPKMAX";
input_TEMPKMAX->key_desc = "[C]";
- input_TEMPKMAX->type = TYPE_STRING;
- input_TEMPKMAX->required = YES;
- input_TEMPKMAX->gisprompt = "old,cell,raster";
input_TEMPKMAX->description = _("Name of max air temperature raster map");
- input_P = G_define_option();
- input_P->key = "P";
+ input_P = G_define_standard_option(G_OPT_R_INPUT);
+ input_P->key = "p";
input_P->key_desc = "[mm/month]";
- input_P->type = TYPE_STRING;
- input_P->required = NO;
- input_P->gisprompt = "old,cell,raster";
input_P->description = _("Name of precipitation raster map, disabled if original Hargreaves (1985) is enabled.");
- output = G_define_option() ;
- output->key = "output";
+ output = G_define_standard_option(G_OPT_R_OUTPUT) ;
output->key_desc = "[mm/d]";
- output->type = TYPE_STRING;
- output->required = YES;
- output->gisprompt = "new,cell,raster" ;
output->description = _("Name of output Ref Evapotranspiration layer");
/* Define the different flags */
- flag1 = G_define_flag() ;
- flag1->key = 'q' ;
- flag1->description = _("quiet");
-
zero = G_define_flag() ;
zero->key = 'z' ;
zero->description = _("set negative ETa to zero");
@@ -244,7 +218,7 @@
/* start the loop through cells */
for (row = 0; row < nrows; row++)
{
-
+ G_percent(row, nrows, 2);
/* read input raster row into line buffer*/
if (G_get_raster_row (infd_RNET, inrast_RNET, row,data_type_rnet) < 0)
G_fatal_error (_("Could not read from <%s>"),RNET);
@@ -318,23 +292,27 @@
break;
}
}
-
- //Calculate ET
- if(original->answer){
- d_daily_et = mh_original( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin, d_p );
- } else if(samani->answer){
- d_daily_et = mh_samani( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin );
+ if(G_is_d_null_value(&d_rnet)||
+ G_is_d_null_value(&d_tempkavg)||
+ G_is_d_null_value(&d_tempkmin)||
+ G_is_d_null_value(&d_tempkmax)||
+ G_is_d_null_value(&d_p)){
+ G_set_d_null_value(&outrast[col],1);
} else {
- d_daily_et = mh_eto( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin, d_p );
+ if(original->answer){
+ d_daily_et = mh_original( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin, d_p );
+ } else if(samani->answer){
+ d_daily_et = mh_samani( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin );
+ } else {
+ d_daily_et = mh_eto( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin, d_p );
+ }
+ if (zero->answer && d_daily_et<0)
+ d_daily_et=0.0;
+ /* write calculated ETP to output line buffer */
+ outrast[col] = d_daily_et;
}
- if (zero->answer && d_daily_et<0)
- d_daily_et=0.0;
-
- /* write calculated ETP to output line buffer */
- ((DCELL *) outrast)[col] = d_daily_et;
}
- if (!flag1->answer) G_percent(row, nrows, 2);
/* write output line buffer to output raster file */
if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
@@ -369,6 +347,6 @@
G_free(outrast);
G_close_cell (outfd);
- return (0);
+ return 0;
}
Modified: grass-addons/gipe/r.evapo.MH/mh_eto.c
===================================================================
--- grass-addons/gipe/r.evapo.MH/mh_eto.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.evapo.MH/mh_eto.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,8 +2,8 @@
#include<math.h>
#include<stdlib.h>
-//Droogers and Allen, 2001.
-//p is [mm/month]
+/*Droogers and Allen, 2001.*/
+/*p is [mm/month]*/
double mh_eto(double ra,double tavg,double tmax,double tmin,double p)
{
@@ -12,10 +12,10 @@
td = tmax - tmin;
if (tavg > 100.0){
- tavg=tavg-273.15;//in case temperature is in Kelvin
+ tavg=tavg-273.15;/*in case temperature is in Kelvin*/
}
- ra = ra * (84600.0 * 1000.0); // convert W -> MJ/d
+ ra = ra * (84600.0 * 1000.0); /*convert W -> MJ/d*/
result = 0.0013 * 0.408 * ra * ( tavg + 17.0 ) * pow((td - 0.0123*p),0.76) ;
Modified: grass-addons/gipe/r.evapo.MH/mh_original.c
===================================================================
--- grass-addons/gipe/r.evapo.MH/mh_original.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.evapo.MH/mh_original.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-//Hargreaves et al, 1985.
+/*Hargreaves et al, 1985.*/
double mh_original(double ra,double tavg,double tmax,double tmin,double p)
{
@@ -11,10 +11,10 @@
td = tmax - tmin;
if (tavg > 100.0){
- tavg=tavg-273.15;// in case Temperature is in Kelvin
+ tavg=tavg-273.15;/*in case Temperature is in Kelvin*/
}
- ra = ra * (84600.0 * 1000.0); // convert W -> MJ/d
+ ra = ra * (84600.0 * 1000.0); /*convert W -> MJ/d*/
result = 0.0023 * 0.408 * ra * ( tavg + 17.8 ) * pow(td,0.5) ;
Modified: grass-addons/gipe/r.evapo.MH/mh_samani.c
===================================================================
--- grass-addons/gipe/r.evapo.MH/mh_samani.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.evapo.MH/mh_samani.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -2,7 +2,7 @@
#include<math.h>
#include<stdlib.h>
-//Hargreaves-Samani, 1985.
+/*Hargreaves-Samani, 1985. */
double mh_samani(double ra,double tavg,double tmax,double tmin)
{
@@ -11,10 +11,10 @@
td = tmax - tmin;
if (tavg > 100.0){
- tavg=tavg-273.15;// in case Temperature is in Kelvin
+ tavg=tavg-273.15;/*in case Temperature is in Kelvin*/
}
- ra = ra * (84600.0 * 1000.0); // convert W -> MJ/d
+ ra = ra * (84600.0 * 1000.0); /* convert W -> MJ/d*/
result = 0.0023 * 0.408 * ra * pow(td,0.5) * ((tmax+tmin)/2+17.8)/2.45;
Modified: grass-addons/gipe/r.gaswap.serial/evaluation.c
===================================================================
--- grass-addons/gipe/r.gaswap.serial/evaluation.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.gaswap.serial/evaluation.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -26,9 +26,9 @@
#define FALSE 0
-//int generation; /* current generation number */
-//int cur_best; /* best individual */
-//FILE *galog;
+/*int generation;*/ /* current generation number */
+/*int cur_best;*/ /* best individual */
+/*FILE *galog;*/
@@ -37,32 +37,32 @@
int FECd1, FECm1, FECY1;
int STSd1, STSm1, STSy1;
int DECdloy1, FECdloy1, STSdloy1;
-// int doy;*/ /* used in date2doy1() */
-// int day, month; /* used in doy2date1() */
+/* int doy;*/ /* used in date2doy1() */
+/* int day, month;*/ /* used in doy2date1() */
int TECdoy1; /*cropping season time extent*/
int GWJan1, GWDec1; /* GW level values in 01Jan & 31Dec */
-//char *dateName[257]; /*foutput()*/
-//char *dateNameValue; /*foutput()*/
+/*char *dateName[257];*/ /*foutput()*/
+/*char *dateNameValue;*/ /*foutput()*/
char **satDATE1;
int dateCounter1; /*foutput()*/
double swapETA1[367]; /*foutput()*/
double satETA1[367]; /*foutput()*/
double tex1[4];
-//int POPSIZE; /* population size */
-//int MAXGENS; /* max. number of generations */
-//int NVARS; /* max. number of variables */
-//int NSATEL; /* max. number of satellite images*/
-//int YEAR;
+/*int POPSIZE;*/ /* population size */
+/*int MAXGENS;*/ /* max. number of generations */
+/*int NVARS;*/ /* max. number of variables */
+/*int NSATEL;*/ /* max. number of satellite images*/
+/*int YEAR;*/
int SSRUN1,ESRUN1;
double LAT1,ALT1;
char METFIL1[100];
-//double PXOVER; /* probability of crossover */
-//double PMUTATION; /* probability of mutation */
-//double TARGET_FITNESS; /* fitness value that will stop GA */
+/*double PXOVER;*/ /* probability of crossover */
+/*double PMUTATION;*/ /* probability of mutation */
+/*double TARGET_FITNESS;*/ /* fitness value that will stop GA */
/* Declaration of procedures used by this genetic algorithm */
@@ -72,8 +72,8 @@
int date2doy1(int *d, int *m);
-//void finput1(void);
-//void finput2(void);
+/*void finput1(void);*/
+/*void finput2(void);*/
void swapkey1(void);
void calfil1(void);
void capfil1(void);
@@ -86,8 +86,8 @@
void sol4fil1(void);
void sol5fil1(void);
-//int foutput(void);
-//int get_sat_eta(void);
+/*int foutput(void);*/
+/*int get_sat_eta(void);*/
int satellite_dates1(int nsatel);
int get_eta1(char *dateName, char *dateNameValue, int dateCounter1);
@@ -106,45 +106,27 @@
/*************************************************************/
void evaluate(int popsize, int nvar, int * gene, double *fitness, int DECy1, int nsatel, double text[], double ETA[], char **DATE, int ssrun, int esrun, double lat, double alt, char *metfile)
-//void evaluate(struct genotype *population)
+/*void evaluate(struct genotype *population)*/
{
int mem, i;
-// int DECdloy1,STSdloy1,TECdoy1,GWJan1,GWDec1,FECdloy1;
-// int FECd1,FECm1,FECY1;
+/* int DECdloy1,STSdloy1,TECdoy1,GWJan1,GWDec1,FECdloy1;*/
+/* int FECd1,FECm1,FECY1;*/
double fit_value, dif_value;
-
- printf("start evaluate\n");
- //printf("gene = %p\n",gene);
- fflush(stdout);
- /*printf("gene[0][0] = %d\n",*gene);
- printf("gene[0][0] = %d\n",gene[0][0]);
- fflush(stdout);*/
-
- satDATE1 = (char **)malloc((nsatel+1)*sizeof(char *));
- for(i=0;i<nsatel+1;i++)
- satDATE1[i] = (char *)malloc(367*sizeof(char));
- /*satDATE1=malloc((nsatel+1)*sizeof(char));
+ satDATE1 = (char **)malloc((nsatel+1)*sizeof(char *));
for(i=0;i<nsatel+1;i++)
- satDATE1[i]=(char *) malloc (367);
- */
+ satDATE1[i] = (char *)malloc(367*sizeof(char));
SSRUN1=ssrun;
ESRUN1=esrun;
-
LAT1 = lat;
ALT1 = alt;
sprintf(METFIL1,"%s",metfile);
-
for(i=0;i<4; i++)
tex1[i] = text[i];
for(i=1;i<=nsatel;i++) {
satETA1[i] = ETA[i];
- //printf ("We are inside looop\n");
- //fflush(stdout);
sprintf(satDATE1[i],"%s",DATE[i]);
}
-
-
swapkey1();
capfil1();
swafil1();
@@ -153,23 +135,14 @@
sol3fil1();
sol4fil1();
sol5fil1();
-//
- //printf ("File Handle properly\n");
- //fflush(stdout);
for(mem=0;mem<popsize;mem++)
{
- printf("begin loop mem = %d , popsize = %d\n",mem,popsize);
- //fflush(stdout);
fit_value=0;
DECdloy1 =(int) (*(gene + (mem * nvar) + 0) );
-
-
STSdloy1 =(int) (*(gene + (mem * nvar) + 1) );
TECdoy1 =(int) (*(gene + (mem * nvar) + 2) );
GWJan1 =(int) (*(gene + (mem * nvar) + 3) );
GWDec1 =(int) (*(gene + (mem * nvar) + 4) );
-
-
/* Create the FECd1 and FECm1 from DEC & TEC */
/*******************************************/
/* Get the FECdloy1 = DECdloy1 + TECdoy1 */
@@ -192,82 +165,49 @@
}
FECdloy1=0;
/*************************/
-
- //printf("befor doy2date function");
doy2date1(&DECdloy1,&DECy1,&DECd1,&DECm1);
- //printf("doy2date function work properly");
doy2date1(&STSdloy1,&STSy1,&STSd1,&STSm1);
-
calfil1();
bbcfil1();
crpfil1();
-
system("./swap");
satellite_dates1(nsatel);
-
- for(i=1;i<=nsatel;i++) {
-
+ for(i=1;i<=nsatel;i++){
dif_value=(int) (1000.0*(satETA1[i]-swapETA1[i]));
- fit_value=fit_value+( (double) (fabs(dif_value)/1000.0));//*(double) (fabs(dif_value)/1000.0));
+ fit_value=fit_value+( (double) (fabs(dif_value)/1000.0));
}
double const1, constraint1,lambda1;
constraint1= TECdoy1-90.0;
-
if (constraint1>=0.0)
lambda1=0.0;
-
else
lambda1=10.0;
const1 =lambda1*(pow(constraint1,2.0));
constraint1=const1;
-
fit_value=fit_value/(double) nsatel;
fit_value=1.0/(fit_value*(1.0+constraint1));
-
- printf("FIT_VALUE= %lf \n", fit_value);
- fflush(stdout);
fitness[mem] = (fit_value);
- //printf("population num %d\n",mem);
- //printf("hahaha");
- fflush(stdout);
-
}
- //for(i=0;i<nsatel+1;i++)
- // free(satDATE1[i]);
-
free(satDATE1);
-
- printf("Evaluation is completed\n");
- fflush(stdout);
-
}
-
/*********************************************/
-
int doy2date1(int *d, int *m, int *day, int *month)
{
-
/*********************************************/
/*This routine converts doy to day/month/year*/
/*********************************************/
-
-
int leap = 0;
int year,doy;
-
-
*day = 0;
*month = 0;
doy = *d;
year = *m;
-
/* Leap year if dividing by 4 leads % 0.0*/
if (year/4*4 == year) {
leap = 1;
}
-
if (doy < 32) {
*month = 1;
*day = doy;
@@ -324,18 +264,15 @@
/*This program converts day/month/year to doy*/
/*********************************************/
/*********************************************/
-
int date2doy1(int *d, int *m)
{
int leap=0;
int day_month_tot=0;
int day, month;
int doy;
-
doy=0;
day = *d;
month = *m;
-
if (month == 1) {
day_month_tot = 0;
}
@@ -372,15 +309,11 @@
else if (month == 12) {
day_month_tot = 334;
}
-
/* Leap year if dividing by 4 leads % 0.0*/
-
if (DECy1/4*4 == DECy1) {
leap = 1;
}
-
doy=day_month_tot+day+leap;
-
return(doy);
}
@@ -391,17 +324,9 @@
/* Resulting file => eval.eta */
/* Format of eval.eta: ETaRS ETaSWAP\n */
/*******************************************************/
-
-
/********************************************************/
-
-
-
/********************************************************/
-
-
/********************************************************/
-
int get_eta1(char *dateName, char *dateNameValue, int dateCounter1)
{
FILE *f;
@@ -410,9 +335,7 @@
char *p;
int TRA1=0, TRA2, EVS1=0, EVS2;
double TRA=0.0, EVS;
-
f=fopen("out.INC","r");
-
if (!f)
return 1;
@@ -449,11 +372,10 @@
/* Getting dates from "satellite.dates" file */
/* */
/*******************************************************/
-/* Thanks Dr Honda! */
+/* Thanks Dr Honda honda at ait.ac.th! */
/* */
/* Limited to 99 images so far... */
/*******************************************************/
-
int satellite_dates1(int nsatel)
{
struct tm t;
@@ -469,18 +391,9 @@
int dateCounter1=0;
char buf[BUFLEN];
- //fp=fopen("satellite.dates","rt");
- //if (!fp)
- // return 1;
-
- //iline = 1;
- //i = 1;
-
- // while (fgets( buf, BUFLEN, fp) != NULL) {
for(i=1;i<=nsatel;i++){
if(sscanf( satDATE1[i], "%d/%d/%d", &t.tm_mday, &t.tm_mon, &t.tm_year) != 3 ){
fprintf(stderr, "reading problem; line : %d: %s\n", iline, buf);
- //fclose(fp);
return 1;
}
t.tm_mon--;
@@ -492,19 +405,12 @@
} else {
sprintf(dateNameValue,dateFormat2, t.tm_mday, t.tm_mon+1,t.tm_year+1900);
}
- get_eta1(dateName, dateNameValue, dateCounter1); /* send the sat.date to get_eta1() */
+ get_eta1(dateName, dateNameValue, dateCounter1);/*send the sat.date to get_eta1()*/
dateCounter1++;
- //iline++;
}
-//(void)fclose(fp);
return 1;
}
-
-
-/*************************************************************/
-
-
/*******************************************************/
/* */
/* File Input for SWAP */
@@ -512,76 +418,49 @@
/*******************************************************/
/* Date: 20030901 */
/*******************************************************/
-
-
-
/********************************************************/
/* main program */
/********************************************************/
-
/********************************************************/
-
void swapkey1(void)
{
FILE *swapkey1; /* SWAP.KEY file-variable */
-
swapkey1 = fopen("SWAP.KEY", "w");
-
fputs(" Project = 'Rood'\n", swapkey1);
fputs(" Path = ''\n", swapkey1);
fputs(" CType = 1\n", swapkey1);
fputs(" SWSCRE = 0\n\n", swapkey1);
-
fprintf(swapkey1, " SSRUN1 = 01 01 %d\n", SSRUN1);
- //fputs(" SSRUN1 = 01 01 1991\n", swapkey1); /*variable only year*/
fprintf(swapkey1, " ESRUN1 = 31 12 %d\n", ESRUN1);
- //fputs(" ESRUN1 = 31 12 1991\n", swapkey1); /*variable only year*/
fputs(" FMAY = 1\n", swapkey1);
fputs(" Period = 1\n", swapkey1);
fputs(" SWRES = 1\n\n", swapkey1);
-
fputs(" SWODAT = 0\n", swapkey1);
fputs("*\n", swapkey1);
fputs("* DD MM YYYY\n", swapkey1);
fputs("* End_of_table\n\n", swapkey1);
-
fprintf(swapkey1, " METFIL1 = \'%s\'\n", METFIL1);
- //fputs(" METFIL1 = 'ESF'\n", swapkey1); /*variable*/
fprintf(swapkey1, " LAT1 = %lf\n", LAT1);
- //fputs(" LAT1 = 32.4\n", swapkey1); /* variable*/
fprintf(swapkey1, " ALT1 = %lf\n", ALT1);
- //fputs(" ALT1 = 1600.0\n", swapkey1); /*variable*/
fputs(" SWETR = 0\n", swapkey1);
fputs(" SWRAI = 0\n\n", swapkey1);
-
fputs("* IRGFIL CALFIL DRFIL BBCFIL OUTFIL\n", swapkey1);
fputs(" '' 'RoodC' 'none' 'Rood' 'out'\n", swapkey1);
fputs("* End_of_table\n\n", swapkey1);
-
fputs(" SWDRA = 0\n\n", swapkey1);
-
fputs(" SWSOLU = 0\n\n", swapkey1);
-
fputs(" SWHEA = 0\n\n", swapkey1);
-
fputs(" SWVAP = 0\n\n", swapkey1);
-
fputs(" SWDRF = 0\n\n", swapkey1);
-
fputs(" SWSWB = 0\n\n", swapkey1);
-
fputs(" SWAFO = 0\n",swapkey1);
fputs(" AFONAM = 'testA'\n\n", swapkey1);
-
fputs(" SWAUN = 0\n", swapkey1);
fputs(" AUNNAM = 'testA'\n\n", swapkey1);
-
fputs(" SWATE = 0\n", swapkey1);
fputs(" ATENAM = 'testA'\n\n", swapkey1);
-
fputs(" SWAIR = 0\n", swapkey1);
fputs(" AIRNAM = 'testA'\n\n", swapkey1);
-
(void)fclose(swapkey1);
return;
}
@@ -594,14 +473,11 @@
{
FILE *calfil1; /* RoodC.CAL file_variable */
-
calfil1 = fopen("RoodC.CAL", "w");
-
fputs("* CRPFIL Type CAPFIL EMERGENCE END_crop START_sch\n", calfil1);
fputs("* d1 m1 d2 m2 d3 m3\n", calfil1);
fprintf(calfil1, " 'Crop' 1 'RoodC' %i %i %i %i %i %i\n", DECd1, DECm1, FECd1, FECm1, STSd1, STSm1);
fputs("* End_of_table\n\n", calfil1);
-
(void)fclose(calfil1);
return ;
}
@@ -613,36 +489,29 @@
void capfil1(void)
{
FILE *capfil1; /* RoodC.CAP file_variable */
-
capfil1 = fopen("RoodC.CAP", "w");
-
fputs(" ISUAS = 1\n\n", capfil1);
fputs(" CIRRS = 2.56\n\n", capfil1);
-
fputs(" TCS1 = 0\n", capfil1);
fputs("* DVS Ta/Tp\n", capfil1);
fputs("0.0 0.75\n", capfil1);
fputs("2.0 0.75\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
fputs("TCS2 = 0\n", capfil1);
fputs("* DVS RAW\n", capfil1);
fputs(" 0.0 0.95\n", capfil1);
fputs(" 2.0 0.95\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
fputs("TCS3 = 0\n", capfil1);
fputs("* DVS TAW\n", capfil1);
fputs(" 0.0 0.50\n", capfil1);
fputs(" 2.0 0.50\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
fputs("TCS4 = 0\n", capfil1);
fputs("* DVS DWA\n", capfil1);
fputs(" 0.0 40.0\n", capfil1);
fputs(" 2.0 40.0\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
fputs(" TCS5 = 1\n", capfil1);
fputs(" PHORMC = 0\n", capfil1);
fputs(" DCRIT = 0.0\n", capfil1);
@@ -650,19 +519,16 @@
fputs(" 0.0 1.0\n", capfil1);
fputs(" 2.0 1.0\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
fputs(" DCS1 = 0\n", capfil1);
fputs("* DVS dI\n", capfil1);
fputs(" 0.0 0.0\n", capfil1);
fputs(" 2.0 0.0\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
fputs(" DCS2 = 1\n", capfil1);
fputs("* DVS FID\n", capfil1);
fputs(" 0.0 100.0\n", capfil1);
fputs(" 2.0 100.0\n", capfil1);
fputs("* End of table\n\n", capfil1);
-
(void)fclose(capfil1);
return;
}
@@ -674,27 +540,7 @@
void swafil1(void)
{
FILE *swafil1; /* Rood.SWA file_variable */
-
- //double tex1[4];
-
- /* Get soil tex1ture percentages */
-/* if ((soil = fopen("soil.txt","r")) == NULL)
- {
- printf("Cannot open soil tex1ture data file!\n");
- exit(1);
- }
-
- for (i=0;i<4;i++)
- {
- fscanf(soil, "%lf", &tex1ture);
- tex1[i]=tex1ture;
- }
- /
- fclose(soil);
-*/ /********************************/
-
swafil1 = fopen("Rood.SWA", "w");
-
fputs("*******************************************************************************\n", swafil1);
fputs(" PONDMX = 10.0\n\n", swafil1);
fputs("*******************************************************************************\n\n", swafil1);
@@ -734,12 +580,6 @@
fputs("*******************************************************************************\n", swafil1);
fputs(" SOLFIL = 'Rood_1' 'Rood_2' 'Rood_3' 'Rood_4' 'Rood_5'\n\n", swafil1);
fputs("* PSAND PSILT PCLAY ORGMAT\n", swafil1);
- //fputs(" 0.21 0.44 0.34 0.0051\n",swafil1);
- //fputs(" 0.10 0.26 0.64 0.0039\n",swafil1);
- //fputs(" 0.04 0.28 0.68 0.0031\n",swafil1);
- //fputs(" 0.02 0.50 0.48 0.0023\n",swafil1);
- //fputs(" 0.08 0.60 0.32 0.0020\n",swafil1);
-
fprintf(swafil1," %lf %lf %lf %lf\n",tex1[0],tex1[1],tex1[2],tex1[3]);
fprintf(swafil1," %lf %lf %lf %lf\n",tex1[0],tex1[1],tex1[2],tex1[3]);
fprintf(swafil1," %lf %lf %lf %lf\n",tex1[0],tex1[1],tex1[2],tex1[3]);
@@ -756,11 +596,6 @@
fputs(" SWSCAL = 0\n", swafil1);
fputs(" NSCALE = 0\n", swafil1);
fputs(" ISCLAY = 0\n", swafil1);
-/* fputs(" FSCALE =\n", swafil1);
- fputs(" 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00\n", swafil1);
- fputs(" 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00\n", swafil1);
- fputs(" 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00\n\n", swafil1); */
-
fputs(" SWMOBI = 0\n", swafil1);
fputs("* PF1 FM1 PF2 FM2 THETIM\n", swafil1);
fputs(" 0.0 0.0 0.0 0.0 0.0\n", swafil1);
@@ -777,19 +612,11 @@
fputs(" RAPCOEF = 0.0\n", swafil1);
fputs(" DIFDES = 0.2\n", swafil1);
fputs(" THETCR = 0.50 0.50 0.50 0.50 0.50\n\n", swafil1);
-
fputs(" SWDIVD = 0\n", swafil1);
fputs(" COFANI = 1.0 1.0 1.0 1.0 1.0\n\n", swafil1);
-
fputs(" SWINCO = 2\n", swafil1);
-/* fputs(" HI =\n", swafil1);
- fputs(" 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", swafil1);
- fputs(" 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", swafil1);
- fputs(" 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", swafil1);
- fputs(" 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n", swafil1); */
fputs(" GWLI = -200.0\n", swafil1);
fputs(" OSGWLM = 30.0\n\n", swafil1);
-
(void)fclose(swafil1);
return;
}
@@ -801,17 +628,12 @@
void bbcfil1(void)
{
FILE *bbcfil1; /* Rood.BBC file_variable */
-
bbcfil1 = fopen("Rood.BBC", "w");
-
fputs(" SWOPT1 = 1\n", bbcfil1);
fputs("* d1 m1 GWlevel\n", bbcfil1);
fprintf(bbcfil1," 1 1 -%i.0\n",GWJan1);
fprintf(bbcfil1," 31 12 -%i.0\n",GWDec1);
-/* fputs(" 1 1 -150.0\n", bbcfil1);
- fputs(" 31 12 -150.0\n", bbcfil1);
-*/ fputs("* End of table\n\n", bbcfil1);
-
+ fputs("* End of table\n\n", bbcfil1);
fputs(" SWOPT2 = 0\n", bbcfil1);
fputs(" SWC2 = 2\n", bbcfil1);
fputs(" C2AVE = 0.1\n", bbcfil1);
@@ -822,7 +644,6 @@
fputs(" 5 6 0.20\n", bbcfil1);
fputs(" 31 12 0.10\n", bbcfil1);
fputs("* End of table\n\n", bbcfil1);
-
fputs(" SWOPT3 = 0\n", bbcfil1);
fputs(" SHAPE = 0.79\n", bbcfil1);
fputs(" RIMLAY = 500\n", bbcfil1);
@@ -830,22 +651,17 @@
fputs(" AQAMP = 20.0\n", bbcfil1);
fputs(" AQTAMX = 120\n", bbcfil1);
fputs(" AQPER = 365\n\n", bbcfil1);
-
fputs(" SWOPT4 = 0\n", bbcfil1);
fputs(" COFQHA = -0.3\n", bbcfil1);
fputs(" COFQHB = -0.01\n\n", bbcfil1);
-
fputs(" SWOPT5 = 0\n", bbcfil1);
fputs("* d5 m5 GWlevel\n", bbcfil1);
fputs(" 1 1 50.0\n", bbcfil1);
fputs(" 31 12 20.0\n", bbcfil1);
fputs("* End of table\n\n", bbcfil1);
-
fputs(" SWOPT6 = 0\n", bbcfil1);
fputs(" SWOPT7 = 0\n", bbcfil1);
fputs(" SWOPT8 = 0\n", bbcfil1);
-
-
(void)fclose(bbcfil1);
return;
}
@@ -857,19 +673,14 @@
void crpfil1(void)
{
FILE *crpfil1; /* Crop.CRP file_variable */
-
crpfil1 = fopen("Crop.CRP", "w");
-
fputs(" IDEV = 1\n", crpfil1);
-// fputs(" LCC = 180\n", crpfil1);
fprintf(crpfil1,"LCC = %i\n",TECdoy1);
fputs(" TSUMEA = 1050.0\n", crpfil1);
fputs(" TSUMAM = 1000.0\n", crpfil1);
fputs(" TBASE = 0.0\n\n", crpfil1);
-
fputs(" KDIF = 0.6\n", crpfil1);
fputs(" KDIR = 0.75\n\n", crpfil1);
-
fputs(" SWGC = 1\n", crpfil1);
fputs("* DVS LAI or SCF\n", crpfil1);
fputs(" GCTB =\n", crpfil1);
@@ -885,18 +696,15 @@
fputs(" 1.8 1.04\n", crpfil1);
fputs(" 2.0 0.58\n", crpfil1);
fputs("**************\n\n", crpfil1);
-
fputs(" SWCF = 2\n", crpfil1);
fputs("* DVS CF or CH\n", crpfil1);
fputs(" CFTB = 0.00 0.0\n", crpfil1);
fputs(" 1.00 70.0\n", crpfil1);
fputs(" 2.00 70.0\n\n", crpfil1);
-
fputs("* DVS RD\n", crpfil1);
fputs(" RDTB = 0.00 0.0\n", crpfil1);
fputs(" 1.00 100.0\n", crpfil1);
fputs(" 2.00 100.0\n\n", crpfil1);
-
fputs("* DVS KY\n", crpfil1);
fputs(" KYTB = 0.0 0.2\n", crpfil1);
fputs(" 0.4 0.2\n", crpfil1);
@@ -904,7 +712,6 @@
fputs(" 1.5 0.5\n", crpfil1);
fputs(" 2.0 0.3\n\n", crpfil1);
fputs("**************\n\n", crpfil1);
-
fputs(" HLIM1 = -0.1\n", crpfil1);
fputs(" HLIM2U = -30.0\n", crpfil1);
fputs(" HLIM2L = -30.0\n", crpfil1);
@@ -914,17 +721,13 @@
fputs(" RSC = 70.0\n", crpfil1);
fputs(" ADCRH = 0.5\n", crpfil1);
fputs(" ADCRL = 0.1\n\n", crpfil1);
-
fputs(" ECMAX = 7.7\n", crpfil1);
fputs(" ECSLOP = 5.0\n\n", crpfil1);
-
fputs(" COFAB = 0.25\n\n", crpfil1);
-
fputs("* Rdepth Rdensity\n", crpfil1);
fputs(" RDCTB = 0.0 1.0\n", crpfil1);
fputs(" 1.0 0.0\n", crpfil1);
fputs("**************\n", crpfil1);
-
(void)fclose(crpfil1);
return;
}
@@ -935,13 +738,9 @@
void sol1fil1(void)
{
-
FILE *sol1fil1; /* Rood_1.SOL file_variable */
-
sol1fil1 = fopen("Rood_1.SOL", "w");
-
fputs(" SWPHYS = 1\n\n", sol1fil1);
-
fputs(" COFGEN1 = 0.000\n", sol1fil1);
fputs(" COFGEN2 = 0.492\n", sol1fil1);
fputs(" COFGEN3 = 0.500\n", sol1fil1);
@@ -950,7 +749,6 @@
fputs(" COFGEN6 = 1.1775\n", sol1fil1);
fputs(" COFGEN8 = 0.029\n", sol1fil1);
fputs("* End of file\n", sol1fil1);
-
(void)fclose(sol1fil1);
return;
}
@@ -961,13 +759,9 @@
void sol2fil1(void)
{
-
FILE *sol2fil1; /* Rood_2.SOL file_variable */
-
sol2fil1 = fopen("Rood_2.SOL", "w");
-
fputs(" SWPHYS = 1\n\n", sol2fil1);
-
fputs(" COFGEN1 = 0.000\n", sol2fil1);
fputs(" COFGEN2 = 0.516\n", sol2fil1);
fputs(" COFGEN3 = 30.206\n", sol2fil1);
@@ -976,7 +770,6 @@
fputs(" COFGEN6 = 1.1471\n", sol2fil1);
fputs(" COFGEN8 = 0.013\n", sol2fil1);
fputs("* End of file\n", sol2fil1);
-
(void)fclose(sol2fil1);
return;
}
@@ -987,13 +780,9 @@
void sol3fil1(void)
{
-
FILE *sol3fil1; /* Rood_3.SOL file_variable */
-
sol3fil1 = fopen("Rood_3.SOL", "w");
-
fputs(" SWPHYS = 1\n\n", sol3fil1);
-
fputs(" COFGEN1 = 0.000\n", sol3fil1);
fputs(" COFGEN2 = 0.501\n", sol3fil1);
fputs(" COFGEN3 = 2.295\n", sol3fil1);
@@ -1002,10 +791,9 @@
fputs(" COFGEN6 = 1.0829\n", sol3fil1);
fputs(" COFGEN8 = 0.009\n", sol3fil1);
fputs("* End of file\n", sol3fil1);
-
(void)fclose(sol3fil1);
return;
-} double const1, constraint1;
+}
/*******************************************************/
/* SOL-file number 4 */
@@ -1013,13 +801,9 @@
void sol4fil1(void)
{
-
FILE *sol4fil1; /* Rood_4.SOL file_variable */
-
sol4fil1 = fopen("Rood_4.SOL", "w");
-
fputs(" SWPHYS = 1\n\n", sol4fil1);
-
fputs(" COFGEN1 = 0.000\n", sol4fil1);
fputs(" COFGEN2 = 0.431\n", sol4fil1);
fputs(" COFGEN3 = 4.331\n", sol4fil1);
@@ -1028,7 +812,6 @@
fputs(" COFGEN6 = 1.0818\n", sol4fil1);
fputs(" COFGEN8 = 0.015\n", sol4fil1);
fputs("* End of file\n", sol4fil1);
-
(void)fclose(sol4fil1);
return;
}
@@ -1039,13 +822,9 @@
void sol5fil1(void)
{
-
FILE *sol5fil1; /* Rood_5.SOL file_variable */
-
sol5fil1 = fopen("Rood_5.SOL", "w");
-
fputs(" SWPHYS = 1\n\n", sol5fil1);
-
fputs(" COFGEN1 = 0.000\n", sol5fil1);
fputs(" COFGEN2 = 0.424\n", sol5fil1);
fputs(" COFGEN3 = 9.843\n", sol5fil1);
@@ -1054,13 +833,7 @@
fputs(" COFGEN6 = 1.1307\n", sol5fil1);
fputs(" COFGEN8 = 0.018\n", sol5fil1);
fputs("* End of file\n", sol5fil1);
-
(void)fclose(sol5fil1);
return;
}
-
/********************************************************/
-
-
-
-
Modified: grass-addons/gipe/r.gaswap.serial/main.c
===================================================================
--- grass-addons/gipe/r.gaswap.serial/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.gaswap.serial/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,7 +1,7 @@
/****************************************************************************
*
* MODULE: r.gaswap
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* Shamim Akhter - shamimakhter at gmail.com
* PURPOSE: Run SWAP model in an optimization mode from a real-coded
* genetic algorithm (Michalewicz,1996).
@@ -21,8 +21,8 @@
#include <grass/glocale.h>
#include "gaswap.h"
-#define MAXFILES 180 // input ETa max layers
-#define NVAR 6 //output file number
+#define MAXFILES 180 /* input ETa max layers */
+#define NVAR 6 /* output file number */
extern DCELL f_f(DCELL);
/* satellite ETa is in mm/day, swapETa in cm/day */
@@ -38,11 +38,9 @@
struct Option *input1, *input2, *input3, *input4, *input5, *input6,*input7,*input8,*input9,*input10,*input11,*input12,*input13,*input14,*input15,*input16,*input17,*output1, *output2, *output3, *output4, *output5, *output6;
} param;
struct Cell_head cellhd;
- struct Flag *flag1;
char *name, *mapset;
int nrows, ncols;
int row,col;
- int verbose;
name="";
/************************************/
/* FMEO Declarations*****************/
@@ -59,7 +57,7 @@
char *psand,*psilt,*pclay,*pomat;
char *result[NVAR+1];
double pmute,pxover,target_fitness;
- //char *pmute, *pxover, *target_fitness;
+ /*char *pmute, *pxover, *target_fitness;*/
int pop, maxgen;
int ok;
@@ -67,7 +65,7 @@
void *inrast[nfiles], *inrast_doy[nfiles];
void *inrast_psand, *inrast_psilt, *inrast_pclay, *inrast_pomat;
- unsigned char *outrast[NVAR+2];
+ FCELL *outrast[NVAR+2];
RASTER_MAP_TYPE data_type[nfiles];
RASTER_MAP_TYPE data_type_doy[nfiles];
RASTER_MAP_TYPE data_type_psand;
@@ -88,53 +86,39 @@
/* Define the different options */
- param.input1 = G_define_option() ;
+ param.input1 = G_define_standard_option(G_OPT_R_INPUTS) ;
param.input1->key = "input_eta";
- param.input1->type = TYPE_STRING;
- param.input1->required = YES;
- param.input1->multiple = YES;
- param.input1->gisprompt = "old,cell,raster" ;
param.input1->description= "Names of satellite ETa layers" ;
+ param.input1->guisection = "IN";
- param.input2 = G_define_option() ;
+ param.input2 = G_define_standard_option(G_OPT_R_INPUTS) ;
param.input2->key = "input_doy";
- param.input2->type = TYPE_STRING;
- param.input2->required = YES;
- param.input2->multiple = YES;
- param.input2->gisprompt = "old,cell,raster" ;
param.input2->description= "Names of satellite Doy layers" ;
+ param.input2->guisection = "IN";
- param.input3 = G_define_option() ;
+ param.input3 = G_define_standard_option(G_OPT_R_INPUT) ;
param.input3->key = "psand";
- param.input3->type = TYPE_STRING;
- param.input3->required = YES;
- param.input3->gisprompt = "old,cell,raster" ;
param.input3->description= "Name of the Soil sand fraction map [0.0-1.0]" ;
param.input3->answer = "psand";
+ param.input3->guisection = "IN";
- param.input4 = G_define_option() ;
+ param.input4 = G_define_standard_option(G_OPT_R_INPUT) ;
param.input4->key = "psilt";
- param.input4->type = TYPE_STRING;
- param.input4->required = YES;
- param.input4->gisprompt = "old,cell,raster" ;
param.input4->description= "Name of the Soil silt fraction map [0.0-1.0]" ;
param.input4->answer = "psilt";
+ param.input4->guisection = "IN";
- param.input5 = G_define_option() ;
+ param.input5 = G_define_standard_option(G_OPT_R_INPUT) ;
param.input5->key = "pclay";
- param.input5->type = TYPE_STRING;
- param.input5->required = YES;
- param.input5->gisprompt = "old,cell,raster" ;
param.input5->description= "Name of the Soil clay fraction map [0.0-1.0]" ;
param.input5->answer = "pclay";
+ param.input5->guisection = "IN";
- param.input6 = G_define_option() ;
+ param.input6 = G_define_standard_option(G_OPT_R_INPUT) ;
param.input6->key = "pomat";
- param.input6->type = TYPE_STRING;
- param.input6->required = YES;
- param.input6->gisprompt = "old,cell,raster" ;
param.input6->description= "Name of the Soil Organic Matter map [0.0-1.0]" ;
param.input6->answer = "pomat";
+ param.input6->guisection = "IN";
param.input7 = G_define_option() ;
param.input7->key = "pop";
@@ -143,6 +127,7 @@
param.input7->required = YES;
param.input7->description= "Number of Populations in GAreal";
param.input7->answer = "20";
+ param.input7->guisection = "param_GA";
param.input8 = G_define_option() ;
param.input8->key = "max_gen";
@@ -151,6 +136,7 @@
param.input8->required = YES;
param.input8->description= "Number of Generations in GAreal";
param.input8->answer = "200";
+ param.input8->guisection = "param_GA";
param.input9 = G_define_option() ;
param.input9->key = "pmute";
@@ -159,6 +145,7 @@
param.input9->required = YES;
param.input9->description= "Probability of Mutation in GAreal";
param.input9->answer = "0.3";
+ param.input9->guisection = "param_GA";
param.input10 = G_define_option() ;
param.input10->key = "pxover";
@@ -167,6 +154,7 @@
param.input10->required = YES;
param.input10->description= "Probability of Crossover in GAreal";
param.input10->answer = "0.8";
+ param.input10->guisection = "param_GA";
param.input11 = G_define_option() ;
param.input11->key = "target_fitness";
@@ -175,6 +163,7 @@
param.input11->required = YES;
param.input11->description= "Target Fitness in GAreal";
param.input11->answer = "20.0";
+ param.input11->guisection = "param_GA";
param.input12 = G_define_option() ;
param.input12->key = "year";
@@ -183,6 +172,7 @@
param.input12->required = NO;
param.input12->description= "Data Processing Year";
param.input12->answer = "2002";
+ param.input12->guisection = "param_SWAP";
param.input13 = G_define_option() ;
param.input13->key = "SSRUN_Year";
@@ -191,6 +181,7 @@
param.input13->required = NO;
param.input13->description= "Starting Crop Year";
param.input13->answer = "2002";
+ param.input13->guisection = "param_SWAP";
param.input14 = G_define_option() ;
param.input14->key = "ESRUN_Year";
@@ -199,6 +190,7 @@
param.input14->required = NO;
param.input14->description= "Ending Crop Year";
param.input14->answer = "2002";
+ param.input14->guisection = "param_SWAP";
param.input15 = G_define_option() ;
param.input15->key = "METFILE";
@@ -207,6 +199,7 @@
param.input15->required = NO;
param.input15->description= "Meteorological File Name";
param.input15->answer = "U-T";
+ param.input15->guisection = "param_SWAP";
param.input16 = G_define_option() ;
@@ -216,6 +209,7 @@
param.input16->required = NO;
param.input16->description= "Latitude of MET Station";
param.input16->answer = "14.338";
+ param.input16->guisection = "param_SWAP";
param.input17 = G_define_option() ;
@@ -225,69 +219,50 @@
param.input17->required = NO;
param.input17->description= "Altitude of MET Station";
param.input17->answer = "10.0";
+ param.input17->guisection = "param_SWAP";
- param.output1 = G_define_option() ;
+ param.output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
param.output1->key = "DEC";
- param.output1->type = TYPE_STRING;
- param.output1->required = YES;
- param.output1->gisprompt = "new,cell,raster" ;
- param.output1->description= "Name of an output DEC layer" ;
+ param.output1->description= "Name of an output Date of Emergence of Crop layer" ;
param.output1->answer = "gaswap_DEC";
+ param.output1->guisection = "OUT";
- param.output2 = G_define_option() ;
+ param.output2 = G_define_standard_option(G_OPT_R_OUTPUT) ;
param.output2->key = "FEC";
- param.output2->type = TYPE_STRING;
- param.output2->required = YES;
- param.output2->gisprompt = "new,cell,raster" ;
- param.output2->description= "Name of an output FEC layer" ;
+ param.output2->description= "Name of an output Forced End of Crop layer" ;
param.output2->answer = "gaswap_FEC";
+ param.output2->guisection = "OUT";
- param.output3 = G_define_option() ;
+ param.output3 = G_define_standard_option(G_OPT_R_OUTPUT) ;
param.output3->key = "STS";
- param.output3->type = TYPE_STRING;
- param.output3->required = YES;
- param.output3->gisprompt = "new,cell,raster" ;
- param.output3->description= "Name of an output STS layer" ;
+ param.output3->description= "Name of an output Scheduled Time of Irrigation layer" ;
param.output3->answer = "gaswap_STS";
+ param.output3->guisection = "OUT";
- param.output4 = G_define_option() ;
+ param.output4 = G_define_standard_option(G_OPT_R_OUTPUT) ;
param.output4->key = "GWJan";
- param.output4->type = TYPE_STRING;
- param.output4->required = YES;
- param.output4->gisprompt = "new,cell,raster" ;
- param.output4->description= "Name of the GW January output layer" ;
+ param.output4->description= "Name of the Ground Water Depth in January output layer" ;
param.output4->answer = "gaswap_GWJan";
+ param.output4->guisection = "OUT";
- param.output5 = G_define_option() ;
+ param.output5 = G_define_standard_option(G_OPT_R_OUTPUT) ;
param.output5->key = "GWDec";
- param.output5->type = TYPE_STRING;
- param.output5->required = YES;
- param.output5->gisprompt = "new,cell,raster" ;
- param.output5->description= "Name of the GW December output layer" ;
+ param.output5->description= "Name of the Ground Water Depth in December output layer" ;
param.output5->answer = "gaswap_GWDec";
+ param.output5->guisection = "OUT";
- param.output6 = G_define_option() ;
+ param.output6 = G_define_standard_option(G_OPT_R_OUTPUT) ;
param.output6->key = "fitness";
- param.output6->type = TYPE_STRING;
- param.output6->required = YES;
- param.output6->gisprompt = "new,cell,raster" ;
param.output6->description= "Name of the fitness output layer" ;
param.output6->answer = "gaswap_fitness";
+ param.output6->guisection = "OUT";
- /* Define the different flags */
-
- flag1 = G_define_flag() ;
- flag1->key = 'q' ;
- flag1->description = "Quiet" ;
-
/* FMEO init nfiles */
nfiles = 1;
/********************/
-
/********************/
-
if (G_parser(argc, argv))
exit (-1);
@@ -309,7 +284,6 @@
SSRUN_Year = atoi(param.input13->answer);
ESRUN_Year = atoi(param.input14->answer);
METFILE = param.input15->answer;
- //printf("meteorological file is %s\n",METFILE);
Lat = atof(param.input16->answer);
Alt = atof(param.input17->answer);
@@ -320,15 +294,7 @@
result[5] = param.output5->answer;
result[6] = param.output6->answer;
- verbose = (! flag1->answer);
- //printf("Param.output_1: %s\n",result[1]);
- //printf("Param.output_2: %s\n",result[2]);
- //printf("Param.output_3: %s\n",result[3]);
- //printf("Param.output_4: %s\n",result[4]);
- //printf("Param.output_5: %s\n",result[5]);
- //printf("Param.output_6: %s\n",result[6]);
-
- //Satellite dates...
+ /*Satellite dates...*/
for (; *doy_ptr != NULL; doy_ptr++)
{
if (nfiles >= MAXFILES)
@@ -360,7 +326,6 @@
}
/* Allocate input buffer */
data_type_doy[nfiles] = G_raster_map_type(name, mapset);
- //printf("data_type[%i] = %i\n",nfiles,data_type_doy[nfiles]);
if((infd_doy[nfiles] = G_open_cell_old(name,mapset))<0)
G_fatal_error("Cannot open cell file [%s]", name);
if(G_get_cellhd(name,mapset,&cellhd)<0)
@@ -374,15 +339,11 @@
nfiles=1;
/*****************************************************/
- //satellite eta
+ /*satellite eta*/
for (; *ptr != NULL; ptr++)
{
-
- //printf("In-Loop Stage 1.\n");
-
if (nfiles >= MAXFILES)
G_fatal_error ("%s - too many ETa files. Only %d allowed", G_program_name(), MAXFILES);
-
name = *ptr;
/* find map in mapset */
mapset = G_find_cell2 (name, "");
@@ -410,7 +371,6 @@
}
/* Allocate input buffer */
data_type[nfiles] = G_raster_map_type(name, mapset);
- //printf("data_type[%i] = %i\n",nfiles,data_type[nfiles]);
if((infd[nfiles] = G_open_cell_old(name,mapset))<0)
G_fatal_error("Cannot open cell file [%s]", name);
if(G_get_cellhd(name,mapset,&cellhd)<0)
@@ -422,7 +382,7 @@
if (nfiles <= 1)
G_fatal_error("The min specified input map is two");
- //printf("Load soil files now\n");
+ /*Load soil files now*/
/***************************************************/
mapset = G_find_cell2 (psand, "");
if (mapset == NULL) {
@@ -487,21 +447,17 @@
}
/* Create New raster files */
for (i=1;i<NVAR+1;i++){
- // printf("new raster[%i]\n",i);
if ( (outfd[i] = G_open_raster_new (result[i],1)) < 0)
G_fatal_error ("Could not open <%s>",result[i]);
}
/* Process pixels */
- //printf("Process pixels\n");
for (row = 0; row < nrows; row++)
{
FCELL f;
FCELL fe[NVAR+2];
double tex[4] = {0.0,0.0,0.0,0.0};
- if (verbose)
- G_percent (row, nrows, 2);
+ G_percent (row, nrows, 2);
/* read input map */
- // printf("read input map\n");
for (i=1;i<nfiles+1;i++){
sat[i]=0.0;
sat_doy[i]=0.0;
@@ -510,7 +466,6 @@
if(G_get_raster_row(infd_doy[i],inrast_doy[i],row,data_type[i])<0)
G_fatal_error ("Could not read from <%s>",name);
}
- // printf("read soil input map\n");
/* read soil input maps */
if(G_get_raster_row(infd_psand,inrast_psand,row,1)<0)
G_fatal_error ("Could not read from <%s>",name);
@@ -521,18 +476,56 @@
if(G_get_raster_row(infd_pomat,inrast_pomat,row,1)<0)
G_fatal_error ("Could not read from <%s>",name);
/*process the data */
- // printf("Start processing col++\n");
for (col=0; col < ncols; col++)
{
- f = ((FCELL *) inrast_psand)[col];
+ switch(data_type_psand){
+ case CELL_TYPE:
+ f = (float) ((CELL *) inrast_psand)[col];
+ break;
+ case FCELL_TYPE:
+ f = ((FCELL *) inrast_psand)[col];
+ break;
+ case DCELL_TYPE:
+ f = (float) ((DCELL *) inrast_psand)[col];
+ break;
+ }
tex[0] = f;
- f = ((FCELL *) inrast_psilt)[col];
+ switch(data_type_psilt){
+ case CELL_TYPE:
+ f = (float) ((CELL *) inrast_psilt)[col];
+ break;
+ case FCELL_TYPE:
+ f = ((FCELL *) inrast_psilt)[col];
+ break;
+ case DCELL_TYPE:
+ f = (float) ((DCELL *) inrast_psilt)[col];
+ break;
+ }
tex[1] = f;
- f = ((FCELL *) inrast_pclay)[col];
+ switch(data_type_pclay){
+ case CELL_TYPE:
+ f = (float) ((CELL *) inrast_pclay)[col];
+ break;
+ case FCELL_TYPE:
+ f = ((FCELL *) inrast_pclay)[col];
+ break;
+ case DCELL_TYPE:
+ f = (float) ((DCELL *) inrast_pclay)[col];
+ break;
+ }
tex[2] = f;
- f = ((FCELL *) inrast_pomat)[col];
+ switch(data_type_pomat){
+ case CELL_TYPE:
+ f = (float) ((CELL *) inrast_pomat)[col];
+ break;
+ case FCELL_TYPE:
+ f = ((FCELL *) inrast_pomat)[col];
+ break;
+ case DCELL_TYPE:
+ f = (float) ((DCELL *) inrast_pomat)[col];
+ break;
+ }
tex[3] = f;
- //printf("tex[0] = %f, tex[1]= %f, tex[2]= %f, tex[2]=%f\n",tex[0],tex[1],tex[2],tex[3]);
/************************************/
for(j=1;j<nfiles+1;j++){
f = ((FCELL *) inrast[j])[col];
@@ -540,26 +533,20 @@
sat[j]=f;
f = ((FCELL *) inrast_doy[j])[col];
sat_doy[j]=f;
- //printf("sat[%i] = %f-> satdoy[%i]= %f\n",j,sat[j],j,sat_doy[j]);
}
- //printf("gaswap IS GOING TO START........................\n");
gaswap(tex,sat,sat_doy,NVAR,nfiles,year,pop,maxgen, pmute, pxover,target_fitness,SSRUN_Year,ESRUN_Year,METFILE,Lat,Alt,grass_cell);
- //printf("gaswap IS FINISHED........................\n");
for (j=1;j<NVAR+2;j++)
{
fe[j] = grass_cell[j];
- ((FCELL *) outrast[j])[col] = fe[j];
+ outrast[j][col] = fe[j];
}
- //printf("************* Col=%d\n",col);
}
- //printf("*********** Row=%d\n", row);
for (i=1;i<NVAR+1;i++){
if (G_put_raster_row (outfd[i], outrast[i], data_type[i]) < 0)
G_fatal_error ("Cannot write to output raster file");
}
}
- //printf("Free all\n");
for (i=1;i<nfiles+1;i++){
G_free (inrast[i]);
G_close_cell (infd[i]);
Modified: grass-addons/gipe/r.out.vic/main.c
===================================================================
--- grass-addons/gipe/r.out.vic/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.out.vic/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -46,36 +46,36 @@
int main(int argc, char *argv[])
{
- struct Cell_head cellhd; //region+header info
- char *mapset; // mapset name
+ struct Cell_head cellhd; /*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
- int not_ll=0;//if proj is not lat/long, it will be 1.
+ int not_ll=0;/*if proj is not lat/long, it will be 1.*/
struct GModule *module;
struct Option *input1, *input2, *input3, *input4;
struct Option *input5, *input6, *input7;
struct Option *output1, *output2, *output3, *output4, *output5;
struct Flag *flag1, *flag2;
- struct History history; //metadata
+ struct History history; /*metadata*/
struct pj_info iproj;
struct pj_info oproj;
/************************************/
/* FMEO Declarations*****************/
- char *prcp_name;// input first time-series raster files names
- char *tmax_name;// input second time_series raster files names
- char *tmin_name;// input third time_series raster files names
- char *landcover_name;// input raster name
- char lai_name[12]; // input monthly raster files name
- char *fdir_name;// input flow direction raster name
- char *result1; //output file base name
- char *result2; //output Soil file name
- char *result3; //output Veg file name
- char *result4; //output flow direction file name
- char result_lat_long[50]; //output file name
- //File Descriptors
+ char *prcp_name;/* input first time-series raster files names*/
+ char *tmax_name;/* input second time_series raster files names*/
+ char *tmin_name;/* input third time_series raster files names*/
+ char *landcover_name;/* input raster name*/
+ char lai_name[12]; /* input monthly raster files name*/
+ char *fdir_name;/* input flow direction raster name*/
+ char *result1; /*output file base name*/
+ char *result2; /*output Soil file name*/
+ char *result3; /*output Veg file name*/
+ char *result4; /*output flow direction file name*/
+ char result_lat_long[50]; /*output file name*/
+ /*File Descriptors*/
int infd_prcp[MAXFILES], infd_tmax[MAXFILES], infd_tmin[MAXFILES];
int infd;
int infd_landcover, infd_lai[12], infd_fdir;
@@ -104,37 +104,37 @@
/****************************************/
/* Meteorological maps */
- FILE *f; // output ascii file
- int grid_count; // grid cell count
- double prcp[MAXFILES]; // Precipitation data
- double tmax[MAXFILES]; // Tmax data
- double tmin[MAXFILES]; // Tmin data
- char **prcp_ptr; // pointer to get the input1->answers
- char **tmax_ptr; // pointer to get the input2->answers
- char **tmin_ptr; // pointer to get the input3->answers
- int nfiles1, nfiles2, nfiles3, nfiles_shortest;// count no. input files
- char **test1, **test2, **test3; // test number of input files
- char **ptr1, **ptr2, **ptr3; // test number of input files
+ FILE *f; /* output ascii file*/
+ int grid_count; /* grid cell count*/
+ double prcp[MAXFILES]; /* Precipitation data*/
+ double tmax[MAXFILES]; /* Tmax data*/
+ double tmin[MAXFILES]; /* Tmin data*/
+ char **prcp_ptr; /* pointer to get the input1->answers*/
+ char **tmax_ptr; /* pointer to get the input2->answers*/
+ char **tmin_ptr; /* pointer to get the input3->answers*/
+ int nfiles1, nfiles2, nfiles3, nfiles_shortest;/* count no. input files*/
+ char **test1, **test2, **test3; /* test number of input files*/
+ char **ptr1, **ptr2, **ptr3; /* test number of input files*/
/****************************************/
/* Elevation map */
char *in;
- FILE *g; // output soil ascii file
- int process; // process grid cell switch
- char *dummy_data1; // dummy data part 1
- char *dummy_data2; // dummy data part 2
- double elevation; // average evevation of grid cell
+ FILE *g; /* output soil ascii file*/
+ int process; /* process grid cell switch*/
+ char *dummy_data1; /* dummy data part 1*/
+ char *dummy_data2; /* dummy data part 2*/
+ double elevation; /* average evevation of grid cell*/
/****************************************/
/* Vegetation map */
- FILE *h; // output ascii file
- char *dummy_data3; // dummy data part 1
- char *dummy_data4; // dummy data part 2
- double *lai[12]; // lAI data for each month
- char **lai_ptr; // pointer to get the input2->answers
- int nfiles; // count LAI input files
- char **test, **ptr; // test number of LAI input files
+ FILE *h; /* output ascii file*/
+ char *dummy_data3; /* dummy data part 1*/
+ char *dummy_data4; /* dummy data part 2*/
+ double *lai[12]; /* lAI data for each month*/
+ char **lai_ptr; /* pointer to get the input2->answers*/
+ int nfiles; /* count LAI input files*/
+ char **test, **ptr; /* test number of LAI input files*/
/****************************************/
/* Flow Direction */
- FILE *ef; // output flow direction ascii file
+ FILE *ef; /* output flow direction ascii file*/
/****************************************/
G_gisinit(argv[0]);
@@ -160,21 +160,18 @@
* rout/mainframe_rout1.htm");
/* Define the different options */
- input1 = G_define_standard_option(G_OPT_R_INPUT) ;
+ input1 = G_define_standard_option(G_OPT_R_INPUTS) ;
input1->key = _("prcp");
- input1->multiple = YES;
input1->description=_("Names of the precipitation input maps");
input1->guisection=_("Required");
- input2 = G_define_standard_option(G_OPT_R_INPUT) ;
+ input2 = G_define_standard_option(G_OPT_R_INPUTS) ;
input2->key = _("tmax");
- input2->multiple = YES;
input2->description=_("Names of the Tmax input maps");
input2->guisection=_("Required");
- input3 = G_define_standard_option(G_OPT_R_INPUT) ;
+ input3 = G_define_standard_option(G_OPT_R_INPUTS) ;
input3->key = _("tmin");
- input3->multiple = YES;
input3->description=_("Names of the Tmin input maps");
input3->guisection=_("Required");
@@ -188,9 +185,8 @@
input5->description=_("Name of the land cover input map");
input5->guisection=_("Required");
- input6 = G_define_standard_option(G_OPT_R_INPUT) ;
+ input6 = G_define_standard_option(G_OPT_R_INPUTS) ;
input6->key = _("LAI");
- input6->multiple = YES;
input6->required = NO;
input6->description=_("Name of the LAI input maps (12 of them!)");
@@ -407,7 +403,7 @@
nrows = G_window_rows();
ncols = G_window_cols();
- //Shamelessly stolen from r.sun !!!!
+ /*Shamelessly stolen from r.sun !!!! */
/* Set up parameters for projection to lat/long if necessary */
if ((G_projection() != PROJECTION_LL)) {
not_ll=1;
@@ -426,7 +422,7 @@
sprintf(oproj.proj, "ll");
if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
G_fatal_error(_("Unable to set up lat/long projection parameters"));
- }//End of stolen from r.sun :P
+ }/*End of stolen from r.sun */
/*Initialize soil grid cell process switch*/
g=fopen(result2,"w");
@@ -599,7 +595,7 @@
G_fatal_error(_("Error in pj_do_proj"));
}
}else{
- //Do nothing
+ /*Do nothing*/
}
if(G_is_d_null_value(&prcp[0])||
G_is_d_null_value(&d_tmax[0])||
@@ -641,7 +637,7 @@
if(input6->answer){
fprintf(h,"%5.3f %5.3f %5.3f %5.3f %5.3f %5.3f %5.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", lai[0], lai[1], lai[2], lai[3], lai[4], lai[5], lai[6], lai[7], lai[8], lai[9], lai[10], lai[11]);
} else {
- // fprintf(h,"%s\n", dummy_data4);
+ /* fprintf(h,"%s\n", dummy_data4);*/
}
grid_count=grid_count+1;
}
@@ -709,9 +705,9 @@
}
G_free (inrast_fdir);
G_close_cell (infd_fdir);
- fclose(h);// Vegetation ascii file
- fclose(g);// Soil ascii file
- fclose(ef);// Flow Direction ascii file
+ fclose(h);/* Vegetation ascii file*/
+ fclose(g);/* Soil ascii file*/
+ fclose(ef);/* Flow Direction ascii file*/
exit(EXIT_SUCCESS);
}
Modified: grass-addons/gipe/r.soiltex2prop/main.c
===================================================================
--- grass-addons/gipe/r.soiltex2prop/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soiltex2prop/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,7 +1,7 @@
/****************************************************************************
*
* MODULE: r.soiltex2prop
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Transforms percentage of texture (sand/clay)
* into USDA 1951 (p209) soil texture classes and then
* into USLE soil erodibility factor (K) as an output
@@ -28,8 +28,8 @@
int main(int argc, char *argv[])
{
- struct Cell_head cellhd; //region+header info
- char *mapset; // mapset name
+ struct Cell_head cellhd; /*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
@@ -38,15 +38,15 @@
struct Option *output1, *output2, *output3;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1; //output porosity raster name
- char *result2; //output KSat raster name
- char *result3; //output Hf raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result1; /*output porosity raster name*/
+ char *result2; /*output KSat raster name*/
+ char *result3; /*output Hf raster name*/
+ /*File Descriptors*/
int infd_psand, infd_pclay;
int outfd1, outfd2, outfd3;
@@ -147,7 +147,6 @@
DCELL d_clay;
double tex[4] = {0.0,0.0,0.0,0.0};
G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
/* read soil input maps */
if(G_get_raster_row(infd_psand,inrast_psand,row,data_type_psand)<0)
G_fatal_error(_("Could not read from <%s>"),psand);
Modified: grass-addons/gipe/r.soiltex2prop/prct2hf.c
===================================================================
--- grass-addons/gipe/r.soiltex2prop/prct2hf.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soiltex2prop/prct2hf.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -9,37 +9,37 @@
};
-// HF
+/* HF*/
double prct2hf(double sand_input, double clay_input){
int i,index;
double temp, hf;
- double silt_input=0.0; //Rawls et al (1990)
- //do not have silt input
- //printf("in prct2hf(), cm\n");
- //setup the 3Dvectors and initialize them
+ double silt_input=0.0; /*Rawls et al (1990)*/
+ /*does not have silt input*/
+ /*printf("in prct2hf(), cm\n");*/
+ /*setup the 3Dvectors and initialize them*/
struct vector cls[POLYGON_DIMENSION] = {0.0};
- //In case silt is not == 0.0, fill up explicitly
+ /*In case silt is not == 0.0, fill up explicitly*/
for(i=0;i<POLYGON_DIMENSION;i++){
cls[i].sand=0.0;
cls[i].clay=0.0;
cls[i].silt=0.0;
}
- //fill up initial polygon points
+ /*fill up initial polygon points*/
cls[0].sand=0.0;
cls[0].clay=100.0;
cls[1].sand=0.0;
cls[1].clay=54.0;
cls[2].sand=17.0;
cls[2].clay=55.0;
- //Get started
+ /*Get started*/
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
hf=175.0;
index=1;
- //printf("hf=175.0\n");
+ /*printf("hf=175.0\n");*/
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=100.0;
cls[1].sand=17.0;
@@ -49,11 +49,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=175.0\n");
+ /*printf("hf=175.0\n");*/
hf=175.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=100.0;
cls[1].sand=34.0;
@@ -63,11 +63,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=175.0\n");
+ /*printf("hf=175.0\n");*/
hf=175.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=100.0;
cls[0].clay=0.0;
cls[1].sand=72.0;
@@ -77,11 +77,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=5.0\n");
+ /*printf("hf=5.0\n");*/
hf=5.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=100.0;
cls[0].clay=0.0;
cls[1].sand=65.0;
@@ -91,11 +91,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=5.0\n");
+ /*printf("hf=5.0\n");*/
hf=5.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=100.0;
cls[0].clay=0.0;
cls[1].sand=65.0;
@@ -105,11 +105,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=5.0\n");
+ /*printf("hf=5.0\n");*/
hf=5.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=58.0;
cls[0].clay=42.0;
cls[1].sand=65.0;
@@ -119,11 +119,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=15.0\n");
+ /*printf("hf=15.0\n");*/
hf=15.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=58.0;
cls[0].clay=42.0;
cls[1].sand=65.0;
@@ -133,11 +133,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=15.0\n");
+ /*printf("hf=15.0\n");*/
hf=15.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=65.0;
cls[0].clay=15.0;
cls[1].sand=65.0;
@@ -147,11 +147,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=15.0\n");
+ /*printf("hf=15.0\n");*/
hf=15.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=65.0;
cls[0].clay=15.0;
cls[1].sand=72.0;
@@ -161,11 +161,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=15.0\n");
+ /*printf("hf=15.0\n");*/
hf=15.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=16.0;
cls[0].clay=0.0;
cls[1].sand=20.0;
@@ -175,11 +175,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=25.0\n");
+ /*printf("hf=25.0\n");*/
hf=25.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=28.0;
cls[0].clay=24.0;
cls[1].sand=20.0;
@@ -189,11 +189,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=25.0\n");
+ /*printf("hf=25.0\n");*/
hf=25.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=28.0;
cls[0].clay=24.0;
cls[1].sand=58.0;
@@ -203,11 +203,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=25.0\n");
+ /*printf("hf=25.0\n");*/
hf=25.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=28.0;
cls[0].clay=24.0;
cls[1].sand=58.0;
@@ -217,11 +217,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=25.0\n");
+ /*printf("hf=25.0\n");*/
hf=25.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=55.0;
cls[0].clay=45.0;
cls[1].sand=50.0;
@@ -231,11 +231,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=55.0;
cls[0].clay=45.0;
cls[1].sand=28.0;
@@ -245,11 +245,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=28.0;
cls[1].sand=28.0;
@@ -259,11 +259,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=28.0;
cls[1].sand=28.0;
@@ -273,11 +273,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=28.0;
cls[1].sand=10.0;
@@ -287,11 +287,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=16.0;
cls[0].clay=0.0;
cls[1].sand=10.0;
@@ -301,11 +301,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/*if index not found then continue*/
cls[0].sand=16.0;
cls[0].clay=0.0;
cls[1].sand=10.0;
@@ -315,11 +315,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=16.0;
cls[0].clay=0.0;
cls[1].sand=0.0;
@@ -329,11 +329,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=3.0;
cls[0].clay=3.0;
cls[1].sand=0.0;
@@ -343,11 +343,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=3.0;
cls[0].clay=3.0;
cls[1].sand=0.0;
@@ -357,11 +357,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=35.0\n");
+ /*printf("hf=35.0\n");*/
hf=35.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=3.0;
cls[0].clay=3.0;
cls[1].sand=0.0;
@@ -371,11 +371,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=3.0;
cls[0].clay=3.0;
cls[1].sand=0.0;
@@ -385,11 +385,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=10.0;
cls[0].clay=14.0;
cls[1].sand=0.0;
@@ -399,11 +399,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=10.0;
cls[0].clay=14.0;
cls[1].sand=0.0;
@@ -413,11 +413,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=10.0;
cls[0].clay=14.0;
cls[1].sand=20.0;
@@ -427,11 +427,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=14.0;
cls[0].clay=30.0;
cls[1].sand=20.0;
@@ -441,11 +441,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=14.0;
cls[0].clay=30.0;
cls[1].sand=20.0;
@@ -455,11 +455,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=23.0;
cls[0].clay=42.0;
cls[1].sand=20.0;
@@ -469,11 +469,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/*if index not found then continue*/
cls[0].sand=23.0;
cls[0].clay=42.0;
cls[1].sand=20.0;
@@ -483,11 +483,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=23.0;
cls[0].clay=42.0;
cls[1].sand=36.0;
@@ -497,11 +497,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=50.0;
cls[0].clay=50.0;
cls[1].sand=36.0;
@@ -511,11 +511,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=50.0;
cls[0].clay=50.0;
cls[1].sand=36.0;
@@ -525,11 +525,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=50.0\n");
+ /*printf("hf=50.0\n");*/
hf=50.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=55.0;
cls[1].sand=36.0;
@@ -539,11 +539,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=55.0;
cls[1].sand=42.0;
@@ -553,11 +553,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=55.0;
cls[1].sand=36.0;
@@ -567,11 +567,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=55.0;
cls[1].sand=0.0;
@@ -581,11 +581,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=16.0;
cls[0].clay=35.0;
cls[1].sand=0.0;
@@ -595,11 +595,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=16.0;
cls[0].clay=35.0;
cls[1].sand=0.0;
@@ -609,11 +609,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=10.0;
cls[0].clay=27.0;
cls[1].sand=0.0;
@@ -623,11 +623,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=10.0;
cls[0].clay=27.0;
cls[1].sand=0.0;
@@ -637,11 +637,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=80.0\n");
+ /*printf("hf=80.0\n");*/
hf=80.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=17.0;
cls[0].clay=55.0;
cls[1].sand=0.0;
@@ -651,11 +651,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=125.0\n");
+ /*printf("hf=125.0\n");*/
hf=125.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=17.0;
cls[0].clay=55.0;
cls[1].sand=0.0;
@@ -665,11 +665,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=125.0\n");
+ /*printf("hf=125.0\n");*/
hf=125.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=17.0;
cls[0].clay=55.0;
cls[1].sand=30.0;
@@ -679,11 +679,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=125.0\n");
+ /*printf("hf=125.0\n");*/
hf=125.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=42.0;
cls[0].clay=58.0;
cls[1].sand=30.0;
@@ -693,11 +693,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=125.0\n");
+ /*printf("hf=125.0\n");*/
hf=125.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=42.0;
cls[0].clay=58.0;
cls[1].sand=30.0;
@@ -707,7 +707,7 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("hf=125.0\n");
+ /*printf("hf=125.0\n");*/
hf=125.0;
}
}
Modified: grass-addons/gipe/r.soiltex2prop/prct2ksat.c
===================================================================
--- grass-addons/gipe/r.soiltex2prop/prct2ksat.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soiltex2prop/prct2ksat.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -9,37 +9,37 @@
};
-// KSAT
+/* KSAT*/
double prct2ksat(double sand_input, double clay_input){
int i,index;
double temp,ksat;
- double silt_input=0.0; //Rawls et al (1990)
- //do not have silt input
- //printf("in prct2ksat(), cm/h\n");
- //setup the 3Dvectors and initialize them
+ double silt_input=0.0; /*Rawls et al (1990)*/
+ /*do not have silt input*/
+ /*printf("in prct2ksat(), cm/h\n");*/
+ /*setup the 3Dvectors and initialize them*/
struct vector cls[POLYGON_DIMENSION] = {0.0};
- //In case silt is not == 0.0, fill up explicitly
+ /*In case silt is not == 0.0, fill up explicitly*/
for(i=0;i<POLYGON_DIMENSION;i++){
cls[i].sand=0.0;
cls[i].clay=0.0;
cls[i].silt=0.0;
}
- //fill up initial polygon points
+ /*fill up initial polygon points*/
cls[0].sand=0.0;
cls[0].clay=100.0;
cls[1].sand=0.0;
cls[1].clay=60.0;
cls[2].sand=7.0;
cls[2].clay=56.0;
- //Get started
+ /*Get started*/
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
ksat=0.0025;
index=1;
- //printf("Ksat=0.0025\n");
+ /*printf("Ksat=0.0025\n");*/
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=100.0;
cls[1].sand=7.0;
@@ -49,11 +49,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0025\n");
+ /*printf("Ksat=0.0025\n");*/
ksat=0.0025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=100.0;
cls[1].sand=30.0;
@@ -63,11 +63,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0025\n");
+ /*printf("Ksat=0.0025\n");*/
ksat=0.0025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=100.0;
cls[0].clay=0.0;
cls[1].sand=85.0;
@@ -77,11 +77,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=25.0\n");
+ /*printf("Ksat=25.0\n");*/
ksat=25.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=85.0;
cls[0].clay=0.0;
cls[1].sand=90.0;
@@ -91,11 +91,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=15.0\n");
+ /*printf("Ksat=15.0\n");*/
ksat=15.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=80.0;
cls[0].clay=0.0;
cls[1].sand=90.0;
@@ -105,11 +105,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=15.0\n");
+ /*printf("Ksat=15.0\n");*/
ksat=15.0;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=85.0;
cls[0].clay=15.0;
cls[1].sand=80.0;
@@ -119,11 +119,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=7.5\n");
+ /*printf("Ksat=7.5\n");*/
ksat=7.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=70.0;
cls[0].clay=0.0;
cls[1].sand=85.0;
@@ -133,11 +133,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=7.5\n");
+ /*printf("Ksat=7.5\n");*/
ksat=7.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=70.0;
cls[0].clay=0.0;
cls[1].sand=75.0;
@@ -147,11 +147,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=2.5\n");
+ /*printf("Ksat=2.5\n");*/
ksat=2.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=75.0;
cls[0].clay=25.0;
cls[1].sand=68.0;
@@ -161,11 +161,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=2.5\n");
+ /*printf("Ksat=2.5\n");*/
ksat=2.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=70.0;
cls[0].clay=0.0;
cls[1].sand=35.0;
@@ -175,11 +175,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=2.5\n");
+ /*printf("Ksat=2.5\n");*/
ksat=2.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=17.0;
cls[0].clay=0.0;
cls[1].sand=35.0;
@@ -189,11 +189,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=1.5\n");
+ /*printf("Ksat=1.5\n");*/
ksat=1.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=5.0;
cls[1].sand=35.0;
@@ -203,11 +203,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=1.5\n");
+ /*printf("Ksat=1.5\n");*/
ksat=1.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=5.0;
cls[1].sand=68.0;
@@ -217,11 +217,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=1.5\n");
+ /*printf("Ksat=1.5\n");*/
ksat=1.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=25.0;
cls[1].sand=68.0;
@@ -231,11 +231,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=1.5\n");
+ /*printf("Ksat=1.5\n");*/
ksat=1.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=25.0;
cls[1].sand=65.0;
@@ -245,11 +245,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=1.5\n");
+ /*printf("Ksat=1.5\n");*/
ksat=1.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=17.0;
cls[0].clay=0.0;
cls[1].sand=10.0;
@@ -259,11 +259,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=12.0;
cls[1].sand=10.0;
@@ -273,11 +273,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=12.0;
cls[1].sand=42.0;
@@ -287,11 +287,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=25.0;
cls[1].sand=42.0;
@@ -301,11 +301,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=25.0;
cls[1].sand=42.0;
@@ -315,11 +315,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=25.0;
cls[1].sand=65.0;
@@ -329,11 +329,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=63.0;
cls[0].clay=38.0;
cls[1].sand=65.0;
@@ -343,11 +343,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.8\n");
+ /*printf("Ksat=0.8\n");*/
ksat=0.8;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=55.0;
cls[0].clay=35.0;
cls[1].sand=60.0;
@@ -357,11 +357,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=55.0;
cls[0].clay=35.0;
cls[1].sand=57.0;
@@ -371,11 +371,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=55.0;
cls[0].clay=35.0;
cls[1].sand=57.0;
@@ -385,11 +385,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=42.0;
cls[0].clay=20.0;
cls[1].sand=57.0;
@@ -399,11 +399,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=42.0;
cls[0].clay=20.0;
cls[1].sand=23.0;
@@ -413,11 +413,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=7.0;
cls[0].clay=3.0;
cls[1].sand=23.0;
@@ -427,11 +427,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=7.0;
cls[0].clay=3.0;
cls[1].sand=10.0;
@@ -441,11 +441,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=7.0;
cls[0].clay=3.0;
cls[1].sand=10.0;
@@ -455,11 +455,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=7.0;
cls[0].clay=3.0;
cls[1].sand=0.0;
@@ -469,11 +469,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.5\n");
+ /*printf("Ksat=0.5\n");*/
ksat=0.5;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=7.0;
cls[0].clay=3.0;
cls[1].sand=0.0;
@@ -483,11 +483,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=16.0;
cls[1].sand=0.0;
@@ -497,11 +497,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=7.0;
cls[0].clay=3.0;
cls[1].sand=23.0;
@@ -511,11 +511,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=29.0;
cls[1].sand=23.0;
@@ -525,11 +525,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=29.0;
cls[1].sand=23.0;
@@ -539,11 +539,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=23.0;
cls[1].sand=23.0;
@@ -553,11 +553,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=23.0;
cls[1].sand=50.0;
@@ -567,11 +567,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=38.0;
cls[0].clay=23.0;
cls[1].sand=50.0;
@@ -581,11 +581,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=40.0;
cls[1].sand=50.0;
@@ -595,11 +595,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=60.0;
cls[0].clay=40.0;
cls[1].sand=50.0;
@@ -609,11 +609,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.3\n");
+ /*printf("Ksat=0.3\n");*/
ksat=0.3;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=38.0;
cls[1].sand=50.0;
@@ -623,11 +623,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=38.0;
cls[1].sand=55.0;
@@ -637,11 +637,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=38.0;
cls[1].sand=50.0;
@@ -651,11 +651,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=38.0;
cls[1].sand=30.0;
@@ -665,11 +665,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=29.0;
cls[1].sand=30.0;
@@ -679,11 +679,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=29.0;
cls[1].sand=30.0;
@@ -693,11 +693,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=22.0;
cls[0].clay=29.0;
cls[1].sand=9.0;
@@ -707,11 +707,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=16.0;
cls[1].sand=9.0;
@@ -721,11 +721,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=16.0;
cls[1].sand=0.0;
@@ -735,11 +735,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.15\n");
+ /*printf("Ksat=0.15\n");*/
ksat=0.15;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=0.0;
cls[0].clay=33.0;
cls[1].sand=0.0;
@@ -749,11 +749,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=29.0;
cls[1].sand=0.0;
@@ -763,11 +763,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=29.0;
cls[1].sand=30.0;
@@ -777,11 +777,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=41.0;
cls[1].sand=30.0;
@@ -791,11 +791,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=20.0;
cls[0].clay=41.0;
cls[1].sand=30.0;
@@ -805,11 +805,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=38.0;
cls[1].sand=30.0;
@@ -819,11 +819,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=38.0;
cls[1].sand=55.0;
@@ -833,11 +833,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.075\n");
+ /*printf("Ksat=0.075\n");*/
ksat=0.075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=50.0;
cls[1].sand=20.0;
@@ -847,11 +847,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=50.0;
cls[1].sand=18.0;
@@ -861,11 +861,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=35.0;
cls[0].clay=55.0;
cls[1].sand=18.0;
@@ -875,11 +875,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=35.0;
cls[0].clay=55.0;
cls[1].sand=43.0;
@@ -889,11 +889,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=50.0;
cls[1].sand=20.0;
@@ -903,11 +903,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=50.0;
cls[1].sand=0.0;
@@ -917,11 +917,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=13.0;
cls[0].clay=50.0;
cls[1].sand=0.0;
@@ -931,11 +931,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.025\n");
+ /*printf("Ksat=0.025\n");*/
ksat=0.025;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=8.0;
cls[0].clay=56.0;
cls[1].sand=0.0;
@@ -945,11 +945,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=8.0;
cls[0].clay=56.0;
cls[1].sand=13.0;
@@ -959,11 +959,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=8.0;
cls[0].clay=56.0;
cls[1].sand=13.0;
@@ -973,11 +973,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=8.0;
cls[0].clay=56.0;
cls[1].sand=30.0;
@@ -987,11 +987,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=35.0;
cls[0].clay=55.0;
cls[1].sand=30.0;
@@ -1001,11 +1001,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=35.0;
cls[0].clay=55.0;
cls[1].sand=30.0;
@@ -1015,11 +1015,11 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
- if (index==0){// if index not found then continue
+ if (index==0){/* if index not found then continue*/
cls[0].sand=40.0;
cls[0].clay=63.0;
cls[1].sand=30.0;
@@ -1029,7 +1029,7 @@
index=point_in_triangle(sand_input,clay_input,silt_input,cls[0].sand,cls[0].clay,cls[0].silt,cls[1].sand,cls[1].clay,cls[1].silt,cls[2].sand,cls[2].clay,cls[2].silt);
if(index==1){
index=1;
- //printf("Ksat=0.0075\n");
+ /*printf("Ksat=0.0075\n");*/
ksat=0.0075;
}
}
Modified: grass-addons/gipe/r.soiltex2prop/vector_multiplication.c
===================================================================
--- grass-addons/gipe/r.soiltex2prop/vector_multiplication.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soiltex2prop/vector_multiplication.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -9,21 +9,21 @@
};
int point_in_triangle(double point_x, double point_y, double point_z, double t1_x, double t1_y, double t1_z, double t2_x, double t2_y, double t2_z, double t3_x, double t3_y, double t3_z){
- //printf("in function: sand=%5.3f clay=%5.3f silt=%5.3f\n",point_x,point_y,point_z);
+ /*printf("in function: sand=%5.3f clay=%5.3f silt=%5.3f\n",point_x,point_y,point_z);*/
int index=0;
double answer;
double answer1_x, answer1_y, answer1_z;
double answer2_x, answer2_y, answer2_z;
double answer3_x, answer3_y, answer3_z;
- // Consider three points forming a trinagle from a given soil class boundary ABC
- // Consider F an additional point in space
- double af1, af2, af3; //Points for vector AF
- double bf1, bf2, bf3; //Points for vector BF
- double cf1, cf2, cf3; //Points for vector CF
- double ab1, ab2, ab3; //Points for vector AB
- double bc1, bc2, bc3; //Points for vector BC
- double ca1, ca2, ca3; //Points for vector CA
- // Create vectors AB, BC and CA
+ /* Consider three points forming a trinagle from a given soil class boundary ABC */
+ /* Consider F an additional point in space */
+ double af1, af2, af3; /*Points for vector AF*/
+ double bf1, bf2, bf3; /*Points for vector BF*/
+ double cf1, cf2, cf3; /*Points for vector CF*/
+ double ab1, ab2, ab3; /*Points for vector AB*/
+ double bc1, bc2, bc3; /*Points for vector BC*/
+ double ca1, ca2, ca3; /*Points for vector CA*/
+ /* Create vectors AB, BC and CA*/
ab1=(t2_x-t1_x);
ab2=(t2_y-t1_y);
ab3=(t2_z-t1_z);
@@ -33,7 +33,7 @@
ca1=(t1_x-t3_x);
ca2=(t1_y-t3_y);
ca3=(t1_z-t3_z);
- // Create vectors AF, BF and CF
+ /* Create vectors AF, BF and CF*/
af1=(point_x-t1_x);
af2=(point_y-t1_y);
af3=(point_z-t1_z);
@@ -43,23 +43,23 @@
cf1=(point_x-t3_x);
cf2=(point_y-t3_y);
cf3=(point_z-t3_z);
- // Calculate the following CrossProducts:
- // AFxAB
+ /* Calculate the following CrossProducts:*/
+ /* AFxAB*/
answer1_x=(af2*ab3)-(af3*ab2);
answer1_y=(af3*ab1)-(af1*ab3);
answer1_z=(af1*ab2)-(af2*ab1);
-// printf("answer(AFxAB)= %f %f %f\n",answer1_x, answer1_y, answer1_z);
- //BFxBC
+/* printf("answer(AFxAB)= %f %f %f\n",answer1_x, answer1_y, answer1_z);*/
+ /*BFxBC*/
answer2_x=(bf2*bc3)-(bf3*bc2);
answer2_y=(bf3*bc1)-(bf1*bc3);
answer2_z=(bf1*bc2)-(bf2*bc1);
-// printf("answer(BFxBC)= %f %f %f\n",answer2_x, answer2_y, answer2_z);
- //CFxCA
+/* printf("answer(BFxBC)= %f %f %f\n",answer2_x, answer2_y, answer2_z);*/
+ /*CFxCA*/
answer3_x=(cf2*ca3)-(cf3*ca2);
answer3_y=(cf3*ca1)-(cf1*ca3);
answer3_z=(cf1*ca2)-(cf2*ca1);
-// printf("answer(CFxCA)= %f %f %f\n",answer3_x, answer3_y, answer3_z);
- answer=0.0;//initialize value
+/* printf("answer(CFxCA)= %f %f %f\n",answer3_x, answer3_y, answer3_z);*/
+ answer=0.0;/*initialize value*/
if(answer1_x>0&&answer2_x>0&&answer3_x>0){
answer+=1.0;
} else if(answer1_x<0&&answer2_x<0&&answer3_x<0){
Modified: grass-addons/gipe/r.soilusda2tex/main.c
===================================================================
--- grass-addons/gipe/r.soilusda2tex/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soilusda2tex/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -26,8 +26,8 @@
int main(int argc, char *argv[])
{
- struct Cell_head cellhd; //region+header info
- char *mapset; // mapset name
+ struct Cell_head cellhd; /*region+header info*/
+ char *mapset; /* mapset name*/
int nrows, ncols;
int row,col;
@@ -35,13 +35,13 @@
struct Option *input1,*output1,*output2,*output3,*output4;
struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result1,*result2,*result3; //output raster name
- //File Descriptors
+ char *name; /* input raster name*/
+ char *result1,*result2,*result3; /*output raster name*/
+ /*File Descriptors*/
int infd_soilusda;
int outfd1, outfd2, outfd3;
@@ -130,8 +130,17 @@
/*process the data */
for (col=0; col < ncols; col++)
{
- d_soilusda = ((DCELL *) inrast_soilusda)[col];
- // printf("inrast_pomat = %f\n", d_om);
+ switch(data_type_soilusda){
+ case CELL_TYPE:
+ d_soilusda = (double) ((CELL *) inrast_soilusda)[col];
+ break;
+ case FCELL_TYPE:
+ d_soilusda = (double) ((FCELL *) inrast_soilusda)[col];
+ break;
+ case DCELL_TYPE:
+ d_soilusda = ((DCELL *) inrast_soilusda)[col];
+ break;
+ }
if(G_is_d_null_value(&d_soilusda)){
G_set_d_null_value(&outrast1[col],1);
G_set_d_null_value(&outrast2[col],1);
Modified: grass-addons/gipe/r.soilusda2tex/usda2pclay.c
===================================================================
--- grass-addons/gipe/r.soilusda2tex/usda2pclay.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soilusda2tex/usda2pclay.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,73 +1,73 @@
#include<stdio.h>
-// From FAOSOIL CD, after USDA 1951, p209
+/* From FAOSOIL CD, after USDA 1951, p209*/
double usda2pclay(int texture){
double psand;
double psilt;
double pclay;
if(texture==0){
-// printf("clay\n");
+/* printf("clay\n");*/
psand=0.2;
psilt=0.2;
pclay=0.8;
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
psand=0.5;
psilt=0.1;
pclay=0.4;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
psand=0.05;
psilt=0.5;
pclay=0.45;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
psand=0.6;
psilt=0.15;
pclay=0.25;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
psand=0.3;
psilt=0.35;
pclay=0.35;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
psand=0.1;
psilt=0.55;
pclay=0.35;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
psand=0.9;
psilt=0.05;
pclay=0.05;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
psand=0.85;
psilt=0.05;
pclay=0.1;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
psand=0.65;
psilt=0.25;
pclay=0.1;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
psand=0.4;
psilt=0.4;
pclay=0.2;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
psand=0.2;
psilt=0.65;
pclay=0.15;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
psand=0.05;
psilt=0.9;
pclay=0.05;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
}
return pclay;
}
Modified: grass-addons/gipe/r.soilusda2tex/usda2psand.c
===================================================================
--- grass-addons/gipe/r.soilusda2tex/usda2psand.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soilusda2tex/usda2psand.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,73 +1,73 @@
#include<stdio.h>
-// From FAOSOIL CD, after USDA 1951, p209
+/* From FAOSOIL CD, after USDA 1951, p209*/
double usda2psand(int texture){
double psand;
double psilt;
double pclay;
if(texture==0){
-// printf("clay\n");
+/* printf("clay\n");*/
psand=0.2;
psilt=0.2;
pclay=0.8;
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
psand=0.5;
psilt=0.1;
pclay=0.4;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
psand=0.05;
psilt=0.5;
pclay=0.45;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
psand=0.6;
psilt=0.15;
pclay=0.25;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
psand=0.3;
psilt=0.35;
pclay=0.35;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
psand=0.1;
psilt=0.55;
pclay=0.35;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
psand=0.9;
psilt=0.05;
pclay=0.05;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
psand=0.85;
psilt=0.05;
pclay=0.1;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
psand=0.65;
psilt=0.25;
pclay=0.1;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
psand=0.4;
psilt=0.4;
pclay=0.2;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
psand=0.2;
psilt=0.65;
pclay=0.15;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
psand=0.05;
psilt=0.9;
pclay=0.05;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
}
return psand;
}
Modified: grass-addons/gipe/r.soilusda2tex/usda2psilt.c
===================================================================
--- grass-addons/gipe/r.soilusda2tex/usda2psilt.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.soilusda2tex/usda2psilt.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,73 +1,73 @@
#include<stdio.h>
-// From FAOSOIL CD, after USDA 1951, p209
+/* From FAOSOIL CD, after USDA 1951, p209*/
double usda2psilt(int texture){
double psand;
double psilt;
double pclay;
if(texture==0){
-// printf("clay\n");
+/* printf("clay\n");*/
psand=0.2;
psilt=0.2;
pclay=0.8;
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
psand=0.5;
psilt=0.1;
pclay=0.4;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
psand=0.05;
psilt=0.5;
pclay=0.45;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
psand=0.6;
psilt=0.15;
pclay=0.25;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
psand=0.3;
psilt=0.35;
pclay=0.35;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
psand=0.1;
psilt=0.55;
pclay=0.35;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
psand=0.9;
psilt=0.05;
pclay=0.05;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
psand=0.85;
psilt=0.05;
pclay=0.1;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
psand=0.65;
psilt=0.25;
pclay=0.1;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
psand=0.4;
psilt=0.4;
pclay=0.2;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
psand=0.2;
psilt=0.65;
pclay=0.15;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
psand=0.05;
psilt=0.9;
pclay=0.05;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
}
return psilt;
}
Modified: grass-addons/gipe/r.uslek/main.c
===================================================================
--- grass-addons/gipe/r.uslek/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.uslek/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,12 +1,12 @@
/****************************************************************************
*
* MODULE: r.uslek
- * AUTHOR(S): Yann Chemin - ychemin at gmail.com
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
* PURPOSE: Transforms percentage of texture (sand/clay/silt)
* into USDA 1951 (p209) soil texture classes and then
* into USLE soil erodibility factor (K) as an output
*
- * COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -26,23 +26,20 @@
int main(int argc, char *argv[])
{
- struct Cell_head cellhd; //region+header info
- char *mapset; // mapset name
+ struct Cell_head cellhd; /*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
- int verbose=1;
struct GModule *module;
struct Option *input1, *input2, *input3, *input4,*output1;
- struct Flag *flag1;
- struct History history; //metadata
-
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /* input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_psand, infd_psilt, infd_pclay, infd_pomat;
int outfd;
@@ -51,7 +48,7 @@
int i=0,j=0;
void *inrast_psand, *inrast_psilt, *inrast_pclay, *inrast_pomat;
- unsigned char *outrast;
+ DCELL *outrast;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_psand;
RASTER_MAP_TYPE data_type_psilt;
@@ -66,50 +63,31 @@
module->description = _("USLE Soil Erodibility Factor (K)");
/* Define the different options */
- input1 = G_define_option() ;
+ input1 = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key = _("psand");
- input1->type = TYPE_STRING;
- input1->required = YES;
- input1->gisprompt =_("old,cell,raster") ;
input1->description=_("Name of the Soil sand fraction map [0.0-1.0]");
input1->answer =_("psand");
- input2 = G_define_option() ;
+ input2 = G_define_standard_option(G_OPT_R_INPUT) ;
input2->key =_("pclay");
- input2->type = TYPE_STRING;
- input2->required = YES;
- input2->gisprompt =_("old,cell,raster");
input2->description=_("Name of the Soil clay fraction map [0.0-1.0]");
input2->answer =_("pclay");
- input3 = G_define_option() ;
+ input3 = G_define_standard_option(G_OPT_R_INPUT) ;
input3->key =_("psilt");
- input3->type = TYPE_STRING;
- input3->required = YES;
- input3->gisprompt =_("old,cell,raster");
input3->description=_("Name of the Soil silt fraction map [0.0-1.0]");
input3->answer =_("psilt");
- input4 = G_define_option() ;
+ input4 = G_define_standard_option(G_OPT_R_INPUT) ;
input4->key =_("pomat");
- input4->type = TYPE_STRING;
- input4->required = YES;
- input4->gisprompt =_("old,cell,raster");
input4->description=_("Name of the Soil Organic Matter map [0.0-1.0]");
input4->answer =_("pomat");
- output1 = G_define_option() ;
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
output1->key =_("usle_k");
- output1->type = TYPE_STRING;
- output1->required = YES;
- output1->gisprompt =_("new,cell,raster");
output1->description=_("Name of the output USLE K factor layer");
output1->answer =_("usle_k");
- flag1 = G_define_flag();
- flag1->key = 'q';
- flag1->description = _("Quiet");
-
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -119,8 +97,7 @@
psilt = input3->answer;
pomat = input4->answer;
- result = output1->answer;
- verbose = (!flag1->answer);
+ result = output1->answer;
/***************************************************/
mapset = G_find_cell2(psand, "");
if (mapset == NULL) {
@@ -182,9 +159,7 @@
DCELL d_silt;
DCELL d_om;
double tex[4] = {0.0,0.0,0.0,0.0};
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
+ G_percent(row,nrows,2);
/* read soil input maps */
if(G_get_raster_row(infd_psand,inrast_psand,row,data_type_psand)<0)
G_fatal_error(_("Could not read from <%s>"),psand);
@@ -197,49 +172,72 @@
/*process the data */
for (col=0; col < ncols; col++)
{
- // printf("col=%i/%i ",col,ncols);
- d_sand = ((DCELL *) inrast_psand)[col];
- //tex[0] = d;
- // printf("psand = %5.3f", d_sand);
- d_silt = ((DCELL *) inrast_psilt)[col];
- //tex[1] = d;
- // printf(" psilt = %5.3f", d_silt);
- d_clay = ((DCELL *) inrast_pclay)[col];
- //tex[2] = d;
- // printf(" pclay = %5.3f", d_clay);
- d_om = ((DCELL *) inrast_pomat)[col];
- //tex[3] = d;
- // printf("inrast_pomat = %f\n", d_om);
- if(G_is_d_null_value(&d_sand)){
- ((DCELL *) outrast)[col] = 0.0;
- }else if(G_is_d_null_value(&d_clay)){
- ((DCELL *) outrast)[col] = 0.0;
- }else if(G_is_d_null_value(&d_silt)){
- ((DCELL *) outrast)[col] = 0.0;
+ switch(data_type_psand){
+ case CELL_TYPE:
+ d_sand = (double) ((CELL *) inrast_psand)[col];
+ break;
+ case FCELL_TYPE:
+ d_sand = (double) ((FCELL *) inrast_psand)[col];
+ break;
+ case DCELL_TYPE:
+ d_sand = ((DCELL *) inrast_psand)[col];
+ break;
+ }
+ switch(data_type_psilt){
+ case CELL_TYPE:
+ d_silt = (double) ((CELL *) inrast_psilt)[col];
+ break;
+ case FCELL_TYPE:
+ d_silt = (double) ((FCELL *) inrast_psilt)[col];
+ break;
+ case DCELL_TYPE:
+ d_silt = ((DCELL *) inrast_psilt)[col];
+ break;
+ }
+ switch(data_type_pclay){
+ case CELL_TYPE:
+ d_clay = (double) ((CELL *) inrast_pclay)[col];
+ break;
+ case FCELL_TYPE:
+ d_clay = (double) ((FCELL *) inrast_pclay)[col];
+ break;
+ case DCELL_TYPE:
+ d_clay = ((DCELL *) inrast_pclay)[col];
+ break;
+ }
+ switch(data_type_pomat){
+ case CELL_TYPE:
+ d_om = (double) ((CELL *) inrast_pomat)[col];
+ break;
+ case FCELL_TYPE:
+ d_om = (double) ((FCELL *) inrast_pomat)[col];
+ break;
+ case DCELL_TYPE:
+ d_om = ((DCELL *) inrast_pomat)[col];
+ break;
+ }
+ if(G_is_d_null_value(&d_sand)||
+ G_is_d_null_value(&d_clay)||
+ G_is_d_null_value(&d_silt)){
+ G_set_d_null_value(&outrast[col],1);
}else {
/************************************/
/* convert to usle_k */
d = (double) prct2tex(d_sand, d_clay, d_silt);
- // printf(" || d=%5.3f",d);
if((d_sand+d_clay+d_silt)!=1.0){
- printf("d=%icol=%i||%5.3f%5.3f%5.3f\n",d,col,d_sand,d_clay,d_silt);
- // exit(EXIT_SUCCESS);
+ G_message("d=%icol=%i||%5.3f%5.3f%5.3f\n",d,col,d_sand,d_clay,d_silt);
}
if(G_is_d_null_value(&d_om)){
- d_om=0.0;//if OM==NULL then make it 0.0
+ d_om=0.0;/*if OM==NULL then make it 0.0*/
}
d = tex2usle_k((int) d, d_om);
- printf(" -> %5.3f",d);
+ /*G_message(_(" -> %5.3f",d));*/
/************************************/
- if(d>1.0){//in case some map input not standard
+ if(d>1.0){/*in case some map input not standard*/
d=0.0;
}
- ((DCELL *) outrast)[col] = d;
- // printf(" -> %5.3f\n",d);
+ outrast[col] = d;
}
- // if(row==50){
- // exit(EXIT_SUCCESS);
- // }
}
if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
G_fatal_error(_("Cannot write to output raster file"));
Modified: grass-addons/gipe/r.uslek/prct2tex.c
===================================================================
--- grass-addons/gipe/r.uslek/prct2tex.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.uslek/prct2tex.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,7 +1,7 @@
#include<stdio.h>
#define POLYGON_DIMENSION 20
-// From FAOSOIL CD, after USDA 1951, p209
+/* From FAOSOIL CD, after USDA 1951, p209*/
struct vector{
double sand;
@@ -10,20 +10,20 @@
};
double point_in_triangle(double point_x, double point_y, double point_z, double t1_x, double t1_y, double t1_z, double t2_x, double t2_y, double t2_z, double t3_x, double t3_y, double t3_z){
- //printf("in function: sand=%5.3f clay=%5.3f silt=%5.3f\n",point_x,point_y,point_z);
+ /*printf("in function: sand=%5.3f clay=%5.3f silt=%5.3f\n",point_x,point_y,point_z);*/
double answer;
double answer1_x, answer1_y, answer1_z;
double answer2_x, answer2_y, answer2_z;
double answer3_x, answer3_y, answer3_z;
- // Consider three points forming a trinagle from a given soil class boundary ABC
- // Consider F an additional point in space
- double af1, af2, af3; //Points for vector AF
- double bf1, bf2, bf3; //Points for vector BF
- double cf1, cf2, cf3; //Points for vector CF
- double ab1, ab2, ab3; //Points for vector AB
- double bc1, bc2, bc3; //Points for vector BC
- double ca1, ca2, ca3; //Points for vector CA
- // Create vectors AB, BC and CA
+ /* Consider three points forming a trinagle from a given soil class boundary ABC*/
+ /* Consider F an additional point in space*/
+ double af1, af2, af3; /*Points for vector AF*/
+ double bf1, bf2, bf3; /*Points for vector BF*/
+ double cf1, cf2, cf3; /*Points for vector CF*/
+ double ab1, ab2, ab3; /*Points for vector AB*/
+ double bc1, bc2, bc3; /*Points for vector BC*/
+ double ca1, ca2, ca3; /*Points for vector CA*/
+ /* Create vectors AB, BC and CA*/
ab1=(t2_x-t1_x);
ab2=(t2_y-t1_y);
ab3=(t2_z-t1_z);
@@ -33,7 +33,7 @@
ca1=(t1_x-t3_x);
ca2=(t1_y-t3_y);
ca3=(t1_z-t3_z);
- // Create vectors AF, BF and CF
+ /* Create vectors AF, BF and CF*/
af1=(point_x-t1_x);
af2=(point_y-t1_y);
af3=(point_z-t1_z);
@@ -43,23 +43,23 @@
cf1=(point_x-t3_x);
cf2=(point_y-t3_y);
cf3=(point_z-t3_z);
- // Calculate the following CrossProducts:
- // AFxAB
+ /* Calculate the following CrossProducts:*/
+ /* AFxAB*/
answer1_x=(af2*ab3)-(af3*ab2);
answer1_y=(af3*ab1)-(af1*ab3);
answer1_z=(af1*ab2)-(af2*ab1);
-// printf("answer(AFxAB)= %f %f %f\n",answer1_x, answer1_y, answer1_z);
- //BFxBC
+/* printf("answer(AFxAB)= %f %f %f\n",answer1_x, answer1_y, answer1_z);*/
+ /*BFxBC*/
answer2_x=(bf2*bc3)-(bf3*bc2);
answer2_y=(bf3*bc1)-(bf1*bc3);
answer2_z=(bf1*bc2)-(bf2*bc1);
-// printf("answer(BFxBC)= %f %f %f\n",answer2_x, answer2_y, answer2_z);
- //CFxCA
+/* printf("answer(BFxBC)= %f %f %f\n",answer2_x, answer2_y, answer2_z);*/
+ /*CFxCA*/
answer3_x=(cf2*ca3)-(cf3*ca2);
answer3_y=(cf3*ca1)-(cf1*ca3);
answer3_z=(cf1*ca2)-(cf2*ca1);
-// printf("answer(CFxCA)= %f %f %f\n",answer3_x, answer3_y, answer3_z);
- answer=0.0;//initialize value
+/* printf("answer(CFxCA)= %f %f %f\n",answer3_x, answer3_y, answer3_z);*/
+ answer=0.0;/*initialize value*/
if((int)answer1_x>=0&&(int)answer2_x>=0&&(int)answer3_x>=0){
answer+=1.0;
} else if((int)answer1_x<=0&&(int)answer2_x<=0&&(int)answer3_x<=0){
@@ -84,38 +84,38 @@
}
int prct2tex(double sand_input, double clay_input, double silt_input){
- //printf("%5.3f||%5.3f||%5.3f",sand_input,clay_input,silt_input);
+ /*printf("%5.3f||%5.3f||%5.3f",sand_input,clay_input,silt_input);*/
int i;
double temp;
- // set up index for soil texture classes
+ /* set up index for soil texture classes*/
int index=20;
- // set up mark index for inside/outside polygon check
+ /* set up mark index for inside/outside polygon check*/
double mark[POLYGON_DIMENSION]={0.0};
- //printf("in prct2tex()\n");
- //setup the 3Dvectors and initialize them
- // index 0
+ /*printf("in prct2tex()\n");*/
+ /*setup the 3Dvectors and initialize them*/
+ /* index 0*/
struct vector cls_clay[POLYGON_DIMENSION] = {0.0};
- // index 1
+ /* index 1*/
struct vector cls_sandy_clay[POLYGON_DIMENSION] = {0.0};
- // index 2
+ /* index 2*/
struct vector cls_silty_clay[POLYGON_DIMENSION] = {0.0};
- // index 3
+ /* index 3*/
struct vector cls_sandy_clay_loam[POLYGON_DIMENSION] = {0.0};
- // index 4
+ /* index 4*/
struct vector cls_clay_loam[POLYGON_DIMENSION] = {0.0};
- // index 5
+ /* index 5*/
struct vector cls_silty_clay_loam[POLYGON_DIMENSION] = {0.0};
- // index 6
+ /* index 6*/
struct vector cls_sand[POLYGON_DIMENSION] = {0.0};
- // index 7
+ /* index 7*/
struct vector cls_loamy_sand[POLYGON_DIMENSION] = {0.0};
- // index 8
+ /* index 8*/
struct vector cls_sandy_loam[POLYGON_DIMENSION] = {0.0};
- // index 9
+ /* index 9*/
struct vector cls_loam[POLYGON_DIMENSION] = {0.0};
- // index 10
+ /* index 10*/
struct vector cls_silt_loam[POLYGON_DIMENSION] = {0.0};
- // index 11
+ /* index 11*/
struct vector cls_silt[POLYGON_DIMENSION] = {0.0};
if((sand_input+clay_input+silt_input)<=10.0){
@@ -123,9 +123,9 @@
clay_input=clay_input*100.0;
silt_input=silt_input*100.0;
}
- //printf("%5.3f||%5.3f||%5.3f|",sand_input,clay_input,silt_input);
+ /*printf("%5.3f||%5.3f||%5.3f|",sand_input,clay_input,silt_input);*/
- //Feed the polygons for index 0
+ /*Feed the polygons for index 0*/
cls_clay[0].sand=0.0;
cls_clay[0].clay=100.0;
cls_clay[0].silt=0.0;
@@ -141,20 +141,20 @@
cls_clay[4].sand=50.0;
cls_clay[4].clay=50.0;
cls_clay[4].silt=0.0;
- // Check for index 0
-// printf("in prct2tex(): check for index 0\n");
+ /* Check for index 0*/
+/* printf("in prct2tex(): check for index 0\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_clay[0].sand,cls_clay[0].clay,cls_clay[0].silt,cls_clay[1].sand,cls_clay[1].clay,cls_clay[1].silt,cls_clay[2].sand,cls_clay[2].clay,cls_clay[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_clay[0].sand,cls_clay[0].clay,cls_clay[0].silt,cls_clay[2].sand,cls_clay[2].clay,cls_clay[2].silt,cls_clay[3].sand,cls_clay[3].clay,cls_clay[3].silt);
mark[2]=point_in_triangle(sand_input,clay_input,silt_input,cls_clay[0].sand,cls_clay[0].clay,cls_clay[0].silt,cls_clay[3].sand,cls_clay[3].clay,cls_clay[3].silt,cls_clay[4].sand,cls_clay[4].clay,cls_clay[4].silt);
-// printf("Clay: mark[0]=%f\n",mark[0]);
-// printf("Clay: mark[1]=%f\n",mark[1]);
-// printf("Clay: mark[2]=%f\n",mark[2]);
+/* printf("Clay: mark[0]=%f\n",mark[0]);*/
+/* printf("Clay: mark[1]=%f\n",mark[1]);*/
+/* printf("Clay: mark[2]=%f\n",mark[2]);*/
if(mark[0]==1||mark[1]==1||mark[2]==1){
index=0;
-// printf("Clay: index labelled as 0\n");
+/* printf("Clay: index labelled as 0\n");*/
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 1
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 1*/
cls_sandy_clay[0].sand=50.0;
cls_sandy_clay[0].clay=50.0;
cls_sandy_clay[0].silt=0.0;
@@ -164,17 +164,17 @@
cls_sandy_clay[2].sand=65.0;
cls_sandy_clay[2].clay=35.0;
cls_sandy_clay[2].silt=0.0;
- // Check for index 1
+ /* Check for index 1*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_clay[0].sand,cls_sandy_clay[0].clay,cls_sandy_clay[0].silt,cls_sandy_clay[1].sand,cls_sandy_clay[1].clay,cls_sandy_clay[1].silt,cls_sandy_clay[2].sand,cls_sandy_clay[2].clay,cls_sandy_clay[2].silt);
-// printf("Sandy Clay: mark[0]=%f\n",mark[0]);
+/* printf("Sandy Clay: mark[0]=%f\n",mark[0]);*/
if(mark[0]==1){
index=1;
-// printf("Sandy Clay: index labelled as 1\n");
+/* printf("Sandy Clay: index labelled as 1\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 2
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 2*/
cls_silty_clay[0].sand=0.0;
cls_silty_clay[0].clay=60.0;
cls_silty_clay[0].silt=40.0;
@@ -184,18 +184,18 @@
cls_silty_clay[2].sand=20.0;
cls_silty_clay[2].clay=40.0;
cls_silty_clay[2].silt=40.0;
- // Check for index 2
- // printf("sand=%5.3f||clay=%5.3f||silt=%5.3f\n",sand_input,clay_input,silt_input);
+ /* Check for index 2*/
+ /* printf("sand=%5.3f||clay=%5.3f||silt=%5.3f\n",sand_input,clay_input,silt_input); */
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_silty_clay[0].sand,cls_silty_clay[0].clay,cls_silty_clay[0].silt,cls_silty_clay[1].sand,cls_silty_clay[1].clay,cls_silty_clay[1].silt,cls_silty_clay[2].sand,cls_silty_clay[2].clay,cls_silty_clay[2].silt);
- // printf("Silty Clay: mark[0]=%f\n",mark[0]);
+ /* printf("Silty Clay: mark[0]=%f\n",mark[0]);*/
if(mark[0]==1){
index=2;
- // printf("Silty Clay: index labelled as 2\n");
+ /* printf("Silty Clay: index labelled as 2\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 3
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 3*/
cls_sandy_clay_loam[0].sand=65.0;
cls_sandy_clay_loam[0].clay=35.0;
cls_sandy_clay_loam[0].silt=0.0;
@@ -211,21 +211,21 @@
cls_sandy_clay_loam[4].sand=75.0;
cls_sandy_clay_loam[4].clay=25.0;
cls_sandy_clay_loam[4].silt=0.0;
- // Check for index 0
-// printf("in prct2tex(): check for index 3\n");
+ /* Check for index 0*/
+/* printf("in prct2tex(): check for index 3\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_clay_loam[0].sand,cls_sandy_clay_loam[0].clay,cls_sandy_clay_loam[0].silt,cls_sandy_clay_loam[1].sand,cls_sandy_clay_loam[1].clay,cls_sandy_clay_loam[1].silt,cls_sandy_clay_loam[2].sand,cls_sandy_clay_loam[2].clay,cls_sandy_clay_loam[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_clay_loam[0].sand,cls_sandy_clay_loam[0].clay,cls_sandy_clay_loam[0].silt,cls_sandy_clay_loam[2].sand,cls_sandy_clay_loam[2].clay,cls_sandy_clay_loam[2].silt,cls_sandy_clay_loam[3].sand,cls_sandy_clay_loam[3].clay,cls_sandy_clay_loam[3].silt);
mark[2]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_clay_loam[0].sand,cls_sandy_clay_loam[0].clay,cls_sandy_clay_loam[0].silt,cls_sandy_clay_loam[3].sand,cls_sandy_clay_loam[3].clay,cls_sandy_clay_loam[3].silt,cls_sandy_clay_loam[4].sand,cls_sandy_clay_loam[4].clay,cls_sandy_clay_loam[4].silt);
-// printf("Sandy Clay Loam: mark[0]=%f\n",mark[0]);
-// printf("Sandy Clay Loam: mark[1]=%f\n",mark[1]);
-// printf("Sandy Clay Loam: mark[2]=%f\n",mark[2]);
+/* printf("Sandy Clay Loam: mark[0]=%f\n",mark[0]);*/
+/* printf("Sandy Clay Loam: mark[1]=%f\n",mark[1]);*/
+/* printf("Sandy Clay Loam: mark[2]=%f\n",mark[2]);*/
if(mark[0]==1||mark[1]==1||mark[2]==1){
index=3;
-// printf("Sandy Clay Loam: index labelled as 3\n");
+/* printf("Sandy Clay Loam: index labelled as 3\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 4
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 4*/
cls_clay_loam[0].sand=20.0;
cls_clay_loam[0].clay=40.0;
cls_clay_loam[0].silt=40.0;
@@ -238,19 +238,19 @@
cls_clay_loam[3].sand=10.0;
cls_clay_loam[3].clay=50.0;
cls_clay_loam[3].silt=40.0;
- // Check for index 4
-// printf("in prct2tex(): check for index 4\n");
+ /* Check for index 4*/
+/* printf("in prct2tex(): check for index 4\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_clay_loam[0].sand,cls_clay_loam[0].clay,cls_clay_loam[0].silt,cls_clay_loam[1].sand,cls_clay_loam[1].clay,cls_clay_loam[1].silt,cls_clay_loam[2].sand,cls_clay_loam[2].clay,cls_clay_loam[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_clay_loam[0].sand,cls_clay_loam[0].clay,cls_clay_loam[0].silt,cls_clay_loam[2].sand,cls_clay_loam[2].clay,cls_clay_loam[2].silt,cls_clay_loam[3].sand,cls_clay_loam[3].clay,cls_clay_loam[3].silt);
-// printf("Clay Loam: mark[0]=%f\n",mark[0]);
-// printf("Clay Loam: mark[1]=%f\n",mark[1]);
+/* printf("Clay Loam: mark[0]=%f\n",mark[0]);*/
+/* printf("Clay Loam: mark[1]=%f\n",mark[1]);*/
if(mark[0]==1||mark[1]==1){
index=4;
-// printf("Clay Loam: index labelled as 4\n");
+/* printf("Clay Loam: index labelled as 4\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 5
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 5*/
cls_silty_clay_loam[0].sand=0.0;
cls_silty_clay_loam[0].clay=40.0;
cls_silty_clay_loam[0].silt=60.0;
@@ -263,19 +263,19 @@
cls_silty_clay_loam[3].sand=20.0;
cls_silty_clay_loam[3].clay=40.0;
cls_silty_clay_loam[3].silt=40.0;
- // Check for index 5
-// printf("in prct2tex(): check for index 5\n");
+ /* Check for index 5*/
+/* printf("in prct2tex(): check for index 5\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_silty_clay_loam[0].sand,cls_silty_clay_loam[0].clay,cls_silty_clay_loam[0].silt,cls_silty_clay_loam[1].sand,cls_silty_clay_loam[1].clay,cls_silty_clay_loam[1].silt,cls_silty_clay_loam[2].sand,cls_silty_clay_loam[2].clay,cls_silty_clay_loam[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_silty_clay_loam[0].sand,cls_silty_clay_loam[0].clay,cls_silty_clay_loam[0].silt,cls_silty_clay_loam[2].sand,cls_silty_clay_loam[2].clay,cls_silty_clay_loam[2].silt,cls_silty_clay_loam[3].sand,cls_silty_clay_loam[3].clay,cls_silty_clay_loam[3].silt);
-// printf("Silty Clay Loam: mark[0]=%f\n",mark[0]);
-// printf("Silty Clay Loam: mark[1]=%f\n",mark[1]);
+/* printf("Silty Clay Loam: mark[0]=%f\n",mark[0]);*/
+/* printf("Silty Clay Loam: mark[1]=%f\n",mark[1]);*/
if(mark[0]==1||mark[1]==1){
index=5;
-// printf("Silty Clay Loam: index labelled as 5\n");
+/* printf("Silty Clay Loam: index labelled as 5\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 6
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 6*/
cls_sand[0].sand=85.0;
cls_sand[0].clay=15.0;
cls_sand[0].silt=0.0;
@@ -285,16 +285,16 @@
cls_sand[2].sand=100.0;
cls_sand[2].clay=0.0;
cls_sand[2].silt=0.0;
- // Check for index 6
+ /* Check for index 6*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_sand[0].sand,cls_sand[0].clay,cls_sand[0].silt,cls_sand[1].sand,cls_sand[1].clay,cls_sand[1].silt,cls_sand[2].sand,cls_sand[2].clay,cls_sand[2].silt);
-// printf("Sand: mark[0]=%f\n",mark[0]);
+/* printf("Sand: mark[0]=%f\n",mark[0]);*/
if(mark[0]==1){
index=6;
-// printf("Sand: index labelled as 6\n");
+/* printf("Sand: index labelled as 6\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 7
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 7*/
cls_loamy_sand[0].sand=80.0;
cls_loamy_sand[0].clay=20.0;
cls_loamy_sand[0].silt=0.0;
@@ -307,20 +307,20 @@
cls_loamy_sand[3].sand=85.0;
cls_loamy_sand[3].clay=15.0;
cls_loamy_sand[3].silt=0.0;
- // Check for index 7
-// printf("in prct2tex(): check for index 7\n");
+ /* Check for index 7*/
+/* printf("in prct2tex(): check for index 7\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_loamy_sand[0].sand,cls_loamy_sand[0].clay,cls_loamy_sand[0].silt,cls_loamy_sand[1].sand,cls_loamy_sand[1].clay,cls_loamy_sand[1].silt,cls_loamy_sand[2].sand,cls_loamy_sand[2].clay,cls_loamy_sand[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_loamy_sand[0].sand,cls_loamy_sand[0].clay,cls_loamy_sand[0].silt,cls_loamy_sand[2].sand,cls_loamy_sand[2].clay,cls_loamy_sand[2].silt,cls_loamy_sand[3].sand,cls_loamy_sand[3].clay,cls_loamy_sand[3].silt);
-// printf("Loamy Sand: mark[0]=%f\n",mark[0]);
-// printf("Loamy Sand: mark[1]=%f\n",mark[1]);
+/* printf("Loamy Sand: mark[0]=%f\n",mark[0]);*/
+/* printf("Loamy Sand: mark[1]=%f\n",mark[1]);*/
if(mark[0]==1||mark[1]==1){
index=7;
-// printf("Loamy Sand: index labelled as 7\n");
+/* printf("Loamy Sand: index labelled as 7\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 8
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 8*/
cls_sandy_loam[0].sand=75.0;
cls_sandy_loam[0].clay=25.0;
cls_sandy_loam[0].silt=0.0;
@@ -342,23 +342,23 @@
cls_sandy_loam[6].sand=80.0;
cls_sandy_loam[6].clay=20.0;
cls_sandy_loam[6].silt=0.0;
- // Check for index 8
-// printf("in prct2tex(): check for index 8\n");
+ /* Check for index 8*/
+/* printf("in prct2tex(): check for index 8\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_loam[2].sand,cls_sandy_loam[2].clay,cls_sandy_loam[2].silt,cls_sandy_loam[3].sand,cls_sandy_loam[3].clay,cls_sandy_loam[3].silt,cls_sandy_loam[4].sand,cls_sandy_loam[4].clay,cls_sandy_loam[4].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_loam[2].sand,cls_sandy_loam[2].clay,cls_sandy_loam[2].silt,cls_sandy_loam[4].sand,cls_sandy_loam[4].clay,cls_sandy_loam[4].silt,cls_sandy_loam[5].sand,cls_sandy_loam[5].clay,cls_sandy_loam[5].silt);
mark[2]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_loam[2].sand,cls_sandy_loam[2].clay,cls_sandy_loam[2].silt,cls_sandy_loam[5].sand,cls_sandy_loam[5].clay,cls_sandy_loam[5].silt,cls_sandy_loam[6].sand,cls_sandy_loam[6].clay,cls_sandy_loam[6].silt);
mark[3]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_loam[2].sand,cls_sandy_loam[2].clay,cls_sandy_loam[2].silt,cls_sandy_loam[6].sand,cls_sandy_loam[6].clay,cls_sandy_loam[6].silt,cls_sandy_loam[0].sand,cls_sandy_loam[0].clay,cls_sandy_loam[0].silt);
mark[4]=point_in_triangle(sand_input,clay_input,silt_input,cls_sandy_loam[2].sand,cls_sandy_loam[2].clay,cls_sandy_loam[2].silt,cls_sandy_loam[0].sand,cls_sandy_loam[0].clay,cls_sandy_loam[0].silt,cls_sandy_loam[1].sand,cls_sandy_loam[1].clay,cls_sandy_loam[1].silt);
-// printf("Sandy Loam: mark[0]=%f\n",mark[0]);
-// printf("Sandy Loam: mark[1]=%f\n",mark[1]);
+/* printf("Sandy Loam: mark[0]=%f\n",mark[0]);*/
+/* printf("Sandy Loam: mark[1]=%f\n",mark[1]);*/
if(mark[0]==1||mark[1]==1||mark[2]==1||mark[3]==1||mark[4]==1){
index=8;
-// printf("Sandy Loam: index labelled as 8\n");
+/* printf("Sandy Loam: index labelled as 8\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 9
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 9*/
cls_loam[0].sand=50.0;
cls_loam[0].clay=30.0;
cls_loam[0].silt=20.0;
@@ -374,21 +374,21 @@
cls_loam[4].sand=55.0;
cls_loam[4].clay=25.0;
cls_loam[4].silt=15.0;
- // Check for index 9
-// printf("in prct2tex(): check for index 9\n");
+ /* Check for index 9*/
+/* printf("in prct2tex(): check for index 9\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_loam[0].sand,cls_loam[0].clay,cls_loam[0].silt,cls_loam[1].sand,cls_loam[1].clay,cls_loam[1].silt,cls_loam[2].sand,cls_loam[2].clay,cls_loam[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_loam[0].sand,cls_loam[0].clay,cls_loam[0].silt,cls_loam[2].sand,cls_loam[2].clay,cls_loam[2].silt,cls_loam[3].sand,cls_loam[3].clay,cls_loam[3].silt);
mark[2]=point_in_triangle(sand_input,clay_input,silt_input,cls_loam[0].sand,cls_loam[0].clay,cls_loam[0].silt,cls_loam[3].sand,cls_loam[3].clay,cls_loam[3].silt,cls_loam[4].sand,cls_loam[4].clay,cls_loam[4].silt);
-// printf("Sandy Loam: mark[0]=%f\n",mark[0]);
-// printf("Sandy Loam: mark[1]=%f\n",mark[1]);
+/* printf("Sandy Loam: mark[0]=%f\n",mark[0]);*/
+/* printf("Sandy Loam: mark[1]=%f\n",mark[1]);*/
if(mark[0]==1||mark[1]==1||mark[2]==1){
index=9;
-// printf("Loam: index labelled as 9\n");
+/* printf("Loam: index labelled as 9\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 10
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 10*/
cls_silt_loam[0].sand=20.0;
cls_silt_loam[0].clay=30.0;
cls_silt_loam[0].silt=50.0;
@@ -407,24 +407,24 @@
cls_silt_loam[5].sand=50.0;
cls_silt_loam[5].clay=0.0;
cls_silt_loam[5].silt=50.0;
- // Check for index 10
-// printf("in prct2tex(): check for index 10\n");
+ /* Check for index 10*/
+/* printf("in prct2tex(): check for index 10\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_silt_loam[3].sand,cls_silt_loam[3].clay,cls_silt_loam[3].silt,cls_silt_loam[4].sand,cls_silt_loam[4].clay,cls_silt_loam[4].silt,cls_silt_loam[5].sand,cls_silt_loam[5].clay,cls_silt_loam[5].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_silt_loam[3].sand,cls_silt_loam[3].clay,cls_silt_loam[3].silt,cls_silt_loam[5].sand,cls_silt_loam[5].clay,cls_silt_loam[5].silt,cls_silt_loam[0].sand,cls_silt_loam[0].clay,cls_silt_loam[0].silt);
mark[2]=point_in_triangle(sand_input,clay_input,silt_input,cls_silt_loam[3].sand,cls_silt_loam[3].clay,cls_silt_loam[3].silt,cls_silt_loam[0].sand,cls_silt_loam[0].clay,cls_silt_loam[0].silt,cls_silt_loam[1].sand,cls_silt_loam[1].clay,cls_silt_loam[1].silt);
mark[3]=point_in_triangle(sand_input,clay_input,silt_input,cls_silt_loam[3].sand,cls_silt_loam[3].clay,cls_silt_loam[3].silt,cls_silt_loam[1].sand,cls_silt_loam[1].clay,cls_silt_loam[1].silt,cls_silt_loam[2].sand,cls_silt_loam[2].clay,cls_silt_loam[2].silt);
-// printf("Silt Loam: mark[0]=%f\n",mark[0]);
-// printf("Silt Loam: mark[1]=%f\n",mark[1]);
-// printf("Silt Loam: mark[2]=%f\n",mark[2]);
-// printf("Silt Loam: mark[3]=%f\n",mark[3]);
+/* printf("Silt Loam: mark[0]=%f\n",mark[0]);*/
+/* printf("Silt Loam: mark[1]=%f\n",mark[1]);*/
+/* printf("Silt Loam: mark[2]=%f\n",mark[2]);*/
+/* printf("Silt Loam: mark[3]=%f\n",mark[3]);*/
if(mark[0]==1||mark[1]==1||mark[2]==1||mark[3]==1){
index=10;
-// printf("Silt Loam: index labelled as 10\n");
+/* printf("Silt Loam: index labelled as 10\n");*/
}
}
- if (index==20){// if index not found then continue
- //Feed the polygons for index 11
+ if (index==20){/* if index not found then continue*/
+ /*Feed the polygons for index 11*/
cls_silt[0].sand=15.0;
cls_silt[0].clay=10.0;
cls_silt[0].silt=75.0;
@@ -437,15 +437,15 @@
cls_silt[3].sand=25.0;
cls_silt[3].clay=0.0;
cls_silt[3].silt=75.0;
- // Check for index 11
-// printf("in prct2tex(): check for index 11\n");
+ /* Check for index 11*/
+/* printf("in prct2tex(): check for index 11\n");*/
mark[0]=point_in_triangle(sand_input,clay_input,silt_input,cls_silt[0].sand,cls_silt[0].clay,cls_silt[0].silt,cls_silt[1].sand,cls_silt[1].clay,cls_silt[1].silt,cls_silt[2].sand,cls_silt[2].clay,cls_silt[2].silt);
mark[1]=point_in_triangle(sand_input,clay_input,silt_input,cls_silt[0].sand,cls_silt[0].clay,cls_silt[0].silt,cls_silt[2].sand,cls_silt[2].clay,cls_silt[2].silt,cls_silt[3].sand,cls_silt[3].clay,cls_silt[3].silt);
-// printf("Silt: mark[0]=%f\n",mark[0]);
-// printf("Silt: mark[1]=%f\n",mark[1]);
+/* printf("Silt: mark[0]=%f\n",mark[0]);*/
+/* printf("Silt: mark[1]=%f\n",mark[1]);*/
if(mark[0]==1||mark[1]==1){
index=11;
-// printf("Silt: index labelled as 11\n");
+/* printf("Silt: index labelled as 11\n");*/
}
}
/* if(index==0){
Modified: grass-addons/gipe/r.uslek/tex2usle_k.c
===================================================================
--- grass-addons/gipe/r.uslek/tex2usle_k.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.uslek/tex2usle_k.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -1,214 +1,214 @@
#include<stdio.h>
-// From FAOSOIL CD, after USDA 1951, p209
+/* From FAOSOIL CD, after USDA 1951, p209*/
double tex2usle_k(int texture, double om_in){
double usle_k=200.0;
- //printf("texture=%i, om=%5.3f",texture, om_in);
+ /*printf("texture=%i, om=%5.3f",texture, om_in);*/
if(om_in<0.5){
if(texture==0){
-// printf("clay\n");
- usle_k=0.29;//Took max value @0.2
+/* printf("clay\n");*/
+ usle_k=0.29;/*Took max value @0.2*/
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
usle_k=0.14;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
usle_k=0.25;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
usle_k=0.27;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
usle_k=0.28;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
usle_k=0.37;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
usle_k=0.05;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
usle_k=0.12;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
usle_k=0.27;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
usle_k=0.38;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
usle_k=0.48;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
usle_k=0.60;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
- usle_k=500.0;//change value to show it was processed
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
+ usle_k=500.0;/*change value to show it was processed*/
}
} else if(om_in>=0.5&&om_in<0.2){
if(texture==0){
-// printf("clay\n");
- usle_k=0.29;//Range=[0.13-0.29]@0.2, took max
+/* printf("clay\n");*/
+ usle_k=0.29;/*Range=[0.13-0.29]@0.2, took max*/
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
usle_k=0.135;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
usle_k=0.24;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
usle_k=0.26;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
usle_k=0.265;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
usle_k=0.345;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
usle_k=0.04;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
usle_k=0.11;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
usle_k=0.255;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
usle_k=0.36;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
usle_k=0.45;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
usle_k=0.56;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
- usle_k=500.0;//change value to show it was processed
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
+ usle_k=500.0;/*change value to show it was processed*/
}
} else if(om_in==0.2){
if(texture==0){
-// printf("clay\n");
- usle_k=0.22;//Range=[0.13-0.29]@0.2, took average
+/* printf("clay\n");*/
+ usle_k=0.22;/*Range=[0.13-0.29]@0.2, took average*/
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
usle_k=0.13;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
usle_k=0.23;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
usle_k=0.25;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
usle_k=0.25;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
usle_k=0.32;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
usle_k=0.03;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
usle_k=0.10;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
usle_k=0.24;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
usle_k=0.34;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
usle_k=0.42;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
usle_k=0.52;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
- usle_k=500.0;//change value to show it was processed
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
+ usle_k=500.0;/*change value to show it was processed*/
}
} else if(om_in>0.2&&om_in<0.4){
if(texture==0){
-// printf("clay\n");
- usle_k=0.13;//Range=[0.13-0.29]@0.2, took min
+/* printf("clay\n");*/
+ usle_k=0.13;/*Range=[0.13-0.29]@0.2, took min*/
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
usle_k=0.125;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
usle_k=0.21;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
usle_k=0.23;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
usle_k=0.23;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
usle_k=0.29;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
usle_k=0.025;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
usle_k=0.09;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
usle_k=0.215;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
usle_k=0.325;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
usle_k=0.375;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
usle_k=0.47;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
- usle_k=500.0;//change value to show it was processed
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
+ usle_k=500.0;/*change value to show it was processed*/
}
- } else if(om_in>=0.4){ //May not be right (>4), but i have no other data
+ } else if(om_in>=0.4){ /*May not be right (>4), but i have no other data*/
if(texture==0){
-// printf("clay\n");
- usle_k=0.13;//took from value min @0.2 (table empty here)
+/* printf("clay\n");*/
+ usle_k=0.13;/*took from value min @0.2 (table empty here)*/
} else if (texture==1){
-// printf("sandy clay\n");
+/* printf("sandy clay\n");*/
usle_k=0.12;
} else if (texture==2){
-// printf("silty clay\n");
+/* printf("silty clay\n");*/
usle_k=0.19;
} else if (texture==3){
-// printf("sandy clay loam\n");
+/* printf("sandy clay loam\n");*/
usle_k=0.21;
} else if (texture==4){
-// printf("clay loam\n");
+/* printf("clay loam\n");*/
usle_k=0.21;
} else if (texture==5){
-// printf("silty clay loam\n");
+/* printf("silty clay loam\n");*/
usle_k=0.26;
} else if (texture==6){
-// printf("sand\n");
+/* printf("sand\n");*/
usle_k=0.02;
} else if (texture==7){
-// printf("loamy sand\n");
+/* printf("loamy sand\n");*/
usle_k=0.08;
} else if (texture==8){
-// printf("sandy loam\n");
+/* printf("sandy loam\n");*/
usle_k=0.19;
} else if (texture==9){
-// printf("loam\n");
+/* printf("loam\n");*/
usle_k=0.29;
} else if (texture==10){
-// printf("silt loam\n");
+/* printf("silt loam\n");*/
usle_k=0.33;
} else if (texture==11){
-// printf("silt\n");
+/* printf("silt\n");*/
usle_k=0.42;
} else {
- //printf("i am confused here...Can you do it yourself please?\n");
- usle_k=500.0;//change value to show it was processed
+ /*printf("i am confused here...Can you do it yourself please?\n");*/
+ usle_k=500.0;/*change value to show it was processed*/
}
}
return usle_k;
Modified: grass-addons/gipe/r.usler/main.c
===================================================================
--- grass-addons/gipe/r.usler/main.c 2008-08-20 22:14:40 UTC (rev 32943)
+++ grass-addons/gipe/r.usler/main.c 2008-08-20 22:21:36 UTC (rev 32944)
@@ -27,26 +27,23 @@
int main(int argc, char *argv[])
{
- struct Cell_head cellhd; //region+header info
- char *mapset; // mapset name
+ struct Cell_head cellhd; /*region+header info*/
+ char *mapset; /*mapset name*/
int nrows, ncols;
int row,col;
- int verbose=1;
-
- char *nameflag;// Switch for particular method
+ char *nameflag;/*Switch for particular method*/
struct GModule *module;
struct Option *input1, *input2, *output;
- struct Flag *flag1;
- struct History history; //metadata
+ struct History history; /*metadata*/
/************************************/
/* FMEO Declarations*****************/
- char *name; // input raster name
- char *result; //output raster name
- //File Descriptors
+ char *name; /*input raster name*/
+ char *result; /*output raster name*/
+ /*File Descriptors*/
int infd_annual_pmm;
int outfd;
@@ -55,7 +52,7 @@
int i=0,j=0;
void *inrast_annual_pmm;
- unsigned char *outrast;
+ DCELL *outrast;
RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
RASTER_MAP_TYPE data_type_annual_pmm;
@@ -75,26 +72,16 @@
input1->description=_("Name of USLE R equation: roose, morgan, foster, elswaify.");
input1->answer =_("morgan");
- input2 = G_define_option() ;
+ input2 = G_define_standard_option(G_OPT_R_INPUT) ;
input2->key = _("annual_precip");
- input2->type = TYPE_STRING;
- input2->required = YES;
- input2->gisprompt =_("old,cell,raster") ;
input2->description=_("Name of the annual precipitation map");
input2->answer =_("annual_pmm");
- output= G_define_option() ;
+ output= G_define_standard_option(G_OPT_R_OUTPUT) ;
output->key =_("usler");
- output->type = TYPE_STRING;
- output->required = YES;
- output->gisprompt =_("new,cell,raster");
output->description=_("Name of the output usler layer");
output->answer =_("usler");
- flag1 = G_define_flag();
- flag1->key = 'q';
- flag1->description = _("Quiet");
-
/********************/
if (G_parser(argc, argv))
exit (EXIT_FAILURE);
@@ -102,7 +89,6 @@
annual_pmm = input2->answer;
result = output->answer;
- verbose = (!flag1->answer);
/***************************************************/
mapset = G_find_cell2(annual_pmm, "");
if (mapset == NULL) {
@@ -128,9 +114,7 @@
{
DCELL d;
DCELL d_annual_pmm;
- if(verbose)
- G_percent(row,nrows,2);
-// printf("row = %i/%i\n",row,nrows);
+ G_percent(row,nrows,2);
/* read input map */
if(G_get_raster_row(infd_annual_pmm,inrast_annual_pmm,row,data_type_annual_pmm)<0)
G_fatal_error(_("Could not read from <%s>"),annual_pmm);
@@ -139,28 +123,28 @@
{
d_annual_pmm = ((DCELL *) inrast_annual_pmm)[col];
if(G_is_d_null_value(&d_annual_pmm)){
- ((DCELL *) outrast)[col] = -999.99;
+ G_set_d_null_value(&outrast[col],1);
} else {
/************************************/
/*calculate morgan */
if (!strcoll(nameflag,"morgan")){
d = morgan_1974(d_annual_pmm);
- ((DCELL *) outrast)[col] = d;
+ outrast[col] = d;
}
/*calculate roose */
if (!strcoll(nameflag,"roose")){
d = roose_1975(d_annual_pmm);
- ((DCELL *) outrast)[col] = d;
+ outrast[col] = d;
}
/*calculate foster */
if (!strcoll(nameflag,"foster")){
d = foster_1981(d_annual_pmm);
- ((DCELL *) outrast)[col] = d;
+ outrast[col] = d;
}
/*calculate elswaify */
if (!strcoll(nameflag,"elswaify")){
d = elswaify_1985(d_annual_pmm);
- ((DCELL *) outrast)[col] = d;
+ outrast[col] = d;
}
}
}
More information about the grass-commit
mailing list