void CASSETTE :: ADDITION(void) { MENU menu ; char filename[13], casname[36], ch ; int cascode, valid ; do { strcpy(filename,menu.CHOICE_MENU()) ; if (!strcmpi(filename,"FAILED")) return ; cascode = LASTCODE(filename) + 1 ; LINES line ; line.BOX(10,6,71,21,219) ; line.LINE_HOR(11,70,10,196) ; gotoxy(72,1) ; cout <<"<0>=EXIT" ; gotoxy(27,8) ; cout <<"ADDITION OF NEW CASSETTES" ; gotoxy(20,12) ; cout <<"Code # " <<cascode ; do { valid = 1 ; gotoxy(5,25) ; clreol() ; cout <<"ENTER NAME OF THE CASSETTE" ; gotoxy(20,14) ; cout <<" " ; gotoxy(20,14) ; cout <<"Name : " ; gets(casname) ; if (casname[0] == '0') return ; if (strlen(casname) < 1 || strlen(casname) > 35) { valid = 0 ; gotoxy(5,25) ; clreol() ; cout <<"\7Enter Correctly (Range: 1..35)" ; getch() ; } } while (!valid) ; gotoxy(5,25) ; clreol() ; do { gotoxy(20,17) ; cout <<" " ; gotoxy(20,17) ; cout <<"Do you want to save (y/n) " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'Y' && ch != 'N') ; if (ch == 'Y') { char casstatus='A' ; int ccode=0 ; ADD_RECORD(filename,cascode,casname,casstatus,ccode) ; cascode++ ; } do { gotoxy(20,19) ; cout <<" " ; gotoxy(20,19) ; cout <<"Do you want to Add more (y/n) " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'Y' && ch != 'N') ; if (ch == 'N') return ; } while (ch == 'Y') ; }
//--------------------------------------------------------- CDVWK_SoilMoisture::CDVWK_SoilMoisture(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Soil Moisture Content")); Set_Author (SG_T("(c) 2002 by O.Conrad")); Set_Description (_TW( "The WEELS (Wind Erosion on European Light Soils) soil moisture " "model dynamically calculates the soil moisture based on the rules " "proposed by the DVWK (1996) with input data about:\n" "- soil properties (grids: field capacity and permanent wilting point)\n" "- land use (grid: crop types)\n" "- climate (table: daily values of precipitation, temperature, air humidity)\n\n" "References:\n" "- DVWK - Deutscher Verband fuer Wasserwirtschaft und Kulturbau e.V. (1996): " "'Ermittlung der Verdunstung von Land- und Wasserflaechen', " "DVWK Merkblaetter 238/1996, Bonn, 135p.\n" "- Boehner, J., Schaefer, W., Conrad, O., Gross, J., Ringeler, A. (2001): " "'The WEELS Model: methods, results and limits of wind erosion modelling', " "In: Catena, Special Issue\n") ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "STA_FC" , _TL("Field Capacity [mm]"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "STA_FC_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Double , 20.0 , 0.0, true ); pNode = Parameters.Add_Grid( NULL , "STA_PWP" , _TL("Permanent Wilting Point [mm]"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "STA_PWP_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Double , 2.0 , 0.0, true ); pNode = Parameters.Add_Grid( NULL , "LANDUSE" , _TL("Land Use"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "LANDUSE_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Int , -1.0 ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "DYN_W" , _TL("Soil Moisture"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- pNode = Parameters.Add_FixedTable( NULL , "DYN_CLIMATE" , _TL("Climate Data"), _TL("") ); pClimate = pNode->asTable(); pClimate->Set_Name(_TL("Climate Data")); pClimate->Add_Field(_TL("Precipitation [mm]") , SG_DATATYPE_Double); pClimate->Add_Field(_TL("Temperature (2pm) [DegreeC]"), SG_DATATYPE_Double); pClimate->Add_Field(_TL("Air Humidity (2pm) [%%]"), SG_DATATYPE_Double); //----------------------------------------------------- pNode = Parameters.Add_FixedTable( NULL , "STA_KC" , _TL("Crop Coefficients"), _TL("") ); pCropCoeff = pNode->asTable(); pCropCoeff->Set_Name(_TL("Crop Coefficients")); pCropCoeff->Add_Field(_TL("Land Use ID") , SG_DATATYPE_Int); pCropCoeff->Add_Field(_TL("Name") , SG_DATATYPE_String); pCropCoeff->Add_Field(_TL("January") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("February") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("March") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("April") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("May") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("June") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("July") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("August") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("September") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("October") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("November") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("December") , SG_DATATYPE_Double); CSG_Table_Record *pRec; #define ADD_RECORD(ID, NAME, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12) pRec = pCropCoeff->Add_Record();\ pRec->Set_Value( 0, ID); pRec->Set_Value( 1, NAME);\ pRec->Set_Value( 2, m01); pRec->Set_Value( 3, m02); pRec->Set_Value( 4, m03); pRec->Set_Value( 5, m04);\ pRec->Set_Value( 6, m05); pRec->Set_Value( 7, m06); pRec->Set_Value( 8, m07); pRec->Set_Value( 9, m08);\ pRec->Set_Value(10, m09); pRec->Set_Value(11, m10); pRec->Set_Value(12, m11); pRec->Set_Value(13, m12); // ID NAME Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dec ADD_RECORD(1.0, _TL("Maehweide") , 1 , 1 , 1 , 1 , 1.05, 1.10, 1.10, 1.05, 1.05, 1 , 1 , 1 ); ADD_RECORD(2.0, _TL("Winterweizen") , 0.65, 0.65, 0.80, 0.85, 1.15, 1.45, 1.40, 1 , 0.80, 0.70, 0.65, 0.65); ADD_RECORD(3.0, _TL("Wintergerste") , 1 , 1 , 0.85, 0.95, 1.30, 1.35, 1.25, 1 , 1 , 1 , 1 , 1 ); ADD_RECORD(4.0, _TL("Sommergerste") , 1 , 1 , 0.80, 0.90, 1.20, 1.35, 1.20, 1 , 1 , 1 , 1 , 1 ); ADD_RECORD(5.0, _TL("Winterroggen") , 0.65, 0.65, 0.85, 0.90, 1.20, 1.30, 1.25, 0.95, 0.80, 0.70, 0.65, 0.65); ADD_RECORD(6.0, _TL("Hafer" ) , 1 , 1 , 0.65, 0.70, 1.10, 1.45, 1.35, 0.95, 1 , 1 , 1 , 1 ); ADD_RECORD(7.0, _TL("Zuckerrueben") , 1 , 1 , 1 , 0.50, 0.75, 1.05, 1.40, 1.30, 1.10, 0.85, 1 , 1 ); ADD_RECORD(8.0, _TL("Kartoffeln") , 1 , 1 , 1 , 0.50, 0.90, 1.05, 1.45, 1.20, 0.90, 1 , 1 , 1 ); ADD_RECORD(9.0, _TL("Winterraps") , 0.65, 0.65, 0.85, 1 , 1.35, 1.35, 1.10, 0.85, 1 , 1 , 0.65, 0.65); ADD_RECORD(0.0, _TL("Unknown") , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); #undef ADD_RECORD }
fint ftsd_mkhead_c( fchar set , /* name of set */ fint8 *cwblo , /* lower cw of subset frame */ fint8 *cwbhi , /* upper cw of subset frame */ bool *blocked , /* blocked tape ? */ fchar header , /* the fits header */ fint *maxrec ) /* maximum number of records */ { char bval[FITSSTRINGLEN+1]; /* buffer */ char record[FITSRECORDLEN+1]; /* buffer for one FITS record */ double dval; /* double precision dummy */ fchar cval; /* f character */ fint8 cwfhi; /* c.w. upper frame */ fint8 cwflo; /* c.w. lower frame */ fint8 *gbhi; /* grids upper box */ fint8 *gblo; /* grids lower box */ fint gerror = 0; /* GDS error return code */ fint8 *gfhi; /* grids upper frame */ fint8 *gflo; /* grids lower frame */ fint8 level = 0; /* level in set */ fint naxis; /* number of axes */ fint *perm; /* axis permutation */ fint r = 0; /* return value */ fint setdim; /* dimension of set */ fint8 subset; /* subset level */ fint subdim; /* dimension of subset */ int inhead = 0; /* number of characters */ int n; /* counter */ int nd; /* number of axis descriptors */ int ni; /* inside subset counter */ int no; /* outside subset counter */ cval.a = bval; /* address */ cval.l = FITSSTRINGLEN; /* length */ bval[FITSSTRINGLEN] = 0; /* trailing zero byte */ if (!tobool(gds_exist_c( set, &gerror ))) { /* set does not exist */ return( -1 ); /* code: set doesn not exist */ } setdim = gdsc_ndims_c( set, &level ); /* dimension of set */ /* get subset level */ subset = gdsc_substruct_c( set, cwblo, cwbhi, &gerror ); subdim = gdsc_ndims_c( set, &subset ); /* dimensions of subset */ /* get frame of set */ gdsc_range_c( set, &level, &cwflo, &cwfhi, &gerror ); gbhi = calloc( sizeof( fint ), setdim ); /* allocate memory */ if (gbhi == NULL) { /* allocation problems */ return( -2 ); /* code: allocation error */ } gblo = calloc( sizeof( fint ), setdim ); /* allocate memory */ if (gblo == NULL) { /* allocation problems */ free( gbhi ); /* deallocate */ return( -2 ); /* code: allocation error */ } gfhi = calloc( sizeof( fint ), setdim ); /* allocate memory */ if (gfhi == NULL) { /* allocation problems */ free( gbhi ); /* deallocate */ free( gblo ); /* deallocate */ return( -2 ); /* code: allocation error */ } gflo = calloc( sizeof( fint ), setdim ); /* allocate memory */ if (gflo == NULL) { /* allocation problems */ free( gbhi ); /* deallocate */ free( gblo ); /* deallocate */ free( gfhi ); /* deallocate */ return( -2 ); /* code: allocation error */ } perm = calloc( sizeof( fint ), setdim ); /* allocate memory */ if (perm == NULL) { /* allocation problems */ free( gbhi ); /* deallocate */ free( gblo ); /* deallocate */ free( gfhi ); /* deallocate */ free( gflo ); /* deallocate */ return( -2 ); /* code: allocation error */ } /* loop to get axis order */ for (ni = 0, no = subdim, n = 0; n < setdim; n++) { fint axnum = n + 1; /* axis sequence number */ fint grid; fint idx; /* axis index */ grid = gdsc_grid_c( set, &axnum, &subset, &gerror ); if (gerror) { /* inside subset */ idx = ni++; gerror = 0; gbhi[idx] = gdsc_grid_c( set, &axnum, cwbhi, &gerror ); gblo[idx] = gdsc_grid_c( set, &axnum, cwblo, &gerror ); } else { /* outside subset */ idx = no++; gbhi[idx] = gblo[idx] = grid; } perm[n] = idx; /* set permutation */ gfhi[idx] = gdsc_grid_c( set, &axnum, &cwfhi, &gerror ); gflo[idx] = gdsc_grid_c( set, &axnum, &cwflo, &gerror ); } FITS_INT_DSC( record, "NAXIS", (int) setdim, " / NUMBER OF AXES" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); for (n = 0; n < setdim; n++) { char dsco[FITSNAMELEN+1]; (void) sprintf( dsco, "NAXIS%d", n + 1 ); naxis = gbhi[n] - gblo[n] + 1; FITS_INT_DSC( record, dsco, (int) naxis, " / LENGTH OF AXIS" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } FITS_LOG_DSC( record, "BLOCKED", *blocked, " / TAPE MAY BE BLOCKED" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); for (nd = 1, n = 0; nd; n++) { char dsci[FITSNAMELEN+1]; char dsco[FITSNAMELEN+1]; int axnumi; int axnumo = n + 1; nd = 0; if (n < setdim) { axnumi = perm[n] + 1; } else { axnumi = axnumo; } if (n < setdim) { nd += 1; } (void) sprintf( dsci, "CDELT%d", axnumi ); (void) sprintf( dsco, "CDELT%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; FITS_DBLE_DSC( record, dsco, dval, " / PRIMARY PIXEL SEPARATION" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "CROTA%d", axnumi ); (void) sprintf( dsco, "CROTA%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; FITS_DBLE_DSC( record, dsco, dval, " / PRIMARY ROTATION OF AXIS" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "CRPIX%d", axnumi ); (void) sprintf( dsco, "CRPIX%d", axnumo ); if (n < setdim) { gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); } else { fint axnumber = axnumi; dval = gdsc_origin_c( set, &axnumber, &gerror ); } if (!gerror) { nd += 1; if (n < setdim) { dval += ( gflo[n] - gblo[n] ); } FITS_DBLE_DSC( record, dsco, dval, " / PRIMARY REFERENCE PIXEL" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "CRVAL%d", axnumi ); (void) sprintf( dsco, "CRVAL%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; FITS_DBLE_DSC( record, dsco, dval, " / PRIMARY REFERENCE VALUE" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "CTYPE%d", axnumi ); (void) sprintf( dsco, "CTYPE%d", axnumo ); gdsd_rchar_c( set, tofchar( dsci ), &level, cval, &gerror ); if (!gerror) { /* Number of programs follow the AIPS convention i.e the */ /* axis names must be filled up to 4 positions with dashes */ /* followed by a dash and the projection. */ /* Only RA and DEC have to be checked. */ nd += 1; if (strncmp(bval,"RA",2)==0 || strncmp(bval,"DEC",3)==0) { char buf[FITSSTRINGLEN+1]; int i = 0, j = 0; while (i < nelc_c(cval) ) { if (bval[i] != '-') { buf[j++] = bval[i++]; } else { while (j < 5) buf[j++] = '-'; while (bval[i] == '-') i++; } } buf[j] = '\0'; FITS_CHAR_DSC( record, dsco, buf, " / PRIMARY AXIS NAME" ); } else { FITS_CHAR_DSC( record, dsco, bval, " / PRIMARY AXIS NAME" ); } if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "CUNIT%d", axnumi ); (void) sprintf( dsco, "CUNIT%d", axnumo ); gdsd_rchar_c( set, tofchar( dsci ), &level, cval, &gerror ); if (!gerror) { nd += 1; FITS_CHAR_DSC( record, dsco, bval, " / PRIMARY AXIS UNITS" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "DDELT%d", axnumi ); (void) sprintf( dsco, "DDELT%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; FITS_DBLE_DSC( record, dsco, dval, " / SECONDARY PIXEL SEPARATION" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "DROTA%d", axnumi ); (void) sprintf( dsco, "DROTA%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; FITS_DBLE_DSC( record, dsco, dval, " / SECONDARY ROTATION OF AXIS" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "DRPIX%d", axnumi ); (void) sprintf( dsco, "DRPIX%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; if (n < setdim) { dval += ( gflo[n] - gblo[n] ); } FITS_DBLE_DSC( record, dsco, dval, " / SECONDARY REFERENCE PIXEL" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "DRVAL%d", axnumi ); (void) sprintf( dsco, "DRVAL%d", axnumo ); gdsd_rdble_c( set, tofchar( dsci ), &level, &dval, &gerror ); if (!gerror) { nd += 1; FITS_DBLE_DSC( record, dsco, dval, " / SECONDARY REFERENCE VALUE" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "DTYPE%d", axnumi ); (void) sprintf( dsco, "DTYPE%d", axnumo ); gdsd_rchar_c( set, tofchar( dsci ), &level, cval, &gerror ); if (!gerror) { nd += 1; FITS_CHAR_DSC( record, dsco, bval, " / SECONDARY AXIS NAME" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; (void) sprintf( dsci, "DUNIT%d", axnumi ); (void) sprintf( dsco, "DUNIT%d", axnumo ); gdsd_rchar_c( set, tofchar( dsci ), &level, cval, &gerror ); if (!gerror) { nd += 1; FITS_CHAR_DSC( record, dsco, bval, " / SECONDARY AXIS UNITS" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; } gdsd_rdble_c( set, tofchar( "EPOCH" ), &level, &dval, &gerror ); if (!gerror) { FITS_DBLE_DSC( record, "EPOCH", dval, " / EPOCH" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; gdsd_rdble_c( set, tofchar( "FREQ0" ), &level, &dval, &gerror ); if (!gerror) { FITS_DBLE_DSC( record, "FREQ0", dval, " / REST FREQUENCY" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } gerror = 0; gdsd_rchar_c( set, tofchar( "INSTRUME" ), &level, cval, &gerror ); if (!gerror) { FITS_CHAR_DSC( record, "INSTRUME", bval, " / INSTRUMENT" ); if (r++ < *maxrec) ADD_RECORD( record, header, inhead ); } free( gbhi ); /* deallocate */ free( gblo ); /* deallocate */ free( gfhi ); /* deallocate */ free( gflo ); /* deallocate */ free( perm ); /* deallocate */ if (r > *maxrec) r = -3; /* header too small */ return( r ); /* return to caller */ }