コード例 #1
0
std::string seti_time::printjd() const {
    char s[32];
    //sprintf(s, "%lf", jd().uval());     
    sprintf(s, "%lf", julian());     
    std::string jd_string(s);
    return(jd_string);
}
コード例 #2
0
ファイル: ssb_build.cpp プロジェクト: sunyangkobe/db_research
long
mk_time(long index, dss_time_t *t)
	{
		long      m = 0;
		long      y;
		long      d;
		
		t->timekey = index + JDAY_BASE;
		y = julian(index + STARTDATE - 1) / 1000;
		d = julian(index + STARTDATE - 1) % 1000;
		while (d > months[m].dcnt + LEAP_ADJ(y, m))
			m++;
		PR_DATE(t->alpha, y, m,
			d - months[m - 1].dcnt - ((LEAP(y) && m > 2) ? 1 : 0));
		t->year = 1900 + y;
		t->month = m + 12 * y + JMNTH_BASE;
		t->week = (d + T_START_DAY - 1) / 7 + 1;
		t->day = d - months[m - 1].dcnt - LEAP_ADJ(y, m-1);
		
		return (0);
		}
コード例 #3
0
ファイル: moon_phase.cpp プロジェクト: ccaroon/arduino
double moon_phase(int year, int month, int day, double hour) {
    double j  = julian(year, month, (double)day+(hour/24.0))-2444238.5;
    double ls = sun_position(j);
    double lm = moon_position(j, ls);
    double t = lm - ls;

    if (t < 0) {
        t += 360;
    }
//    *ip = (int)((t + 22.5)/45) & 0x7;
    
    return (1.0 - cos((t)*RAD))/2;
}
コード例 #4
0
ファイル: filtr2.cpp プロジェクト: Corwinian/Term.Cross
/*************************************************\
Инициализация навигационной подсистемы.
\*************************************************/
TStraightReferencer* navigationSystemInit( const TBlk0& blk0, double *pjulian_date ) throw (TRequestExc) {
	try {
		TNOAAImageParams NOAAImageParams(blk0);
		TCorrectionParams corrParams(blk0);
		*pjulian_date =
			julian(NOAAImageParams.fYear, NOAAImageParams.fYearTime+1);
		TIniSatParams iniSatParams( blk0);
		TOrbitalModel orbitalModel(iniSatParams, NOAAImageParams.fYear, NOAAImageParams.fYearTime + 1, corrParams);
		return (new TStraightReferencer(iniSatParams, NOAAImageParams, corrParams));
	} catch(...) {
		throw TRequestExc( 1, "navigationSystemInit: ошибка инициализации навигационной подсистемы" );
	}
	//return 0;
}
コード例 #5
0
ファイル: ODATE.cpp プロジェクト: spippolatore/7kaa
//-------- Begin of function DateInfo::add_months ------//
//
// Add months to the given julian date.
//
// <int> inDate   = the input julian date
// <int> addMonth = the no. of months to add
//
// return : <int> - the result julian date
//
int DateInfo::add_months(int inDate, int addMonth)
{
	int inYear  = year(inDate);
	int inMonth = month(inDate);
	int inDay   = day(inDate);

	inMonth += addMonth;

	if( inMonth > 12 )
	{
		inMonth -= 12;
		inYear++;
	}

	if( inDay > days_in_month(inMonth) )
		inDay = days_in_month(inMonth);

	return julian( inYear, inMonth, inDay );
}
コード例 #6
0
ファイル: timing.c プロジェクト: changliao/PRMS
/*--------------------------------------------------------------------*\
 | FUNCTION     : julian_
 | COMMENT		:
 | PARAMETERS   :
 | RETURN VALUE : 
 | RESTRICTIONS :
\*--------------------------------------------------------------------*/
long julian_ (char *jwhen, char *jtype, ftnlen jwhenlen, ftnlen jtypelen) {

//  char *when, *type;
  char when[80], type[80];
  long retval;

  /*
   * copy strings and terminate
   */

//  when = (char *) umalloc(jwhenlen + 1);
//  strncpy(when, jwhen, jwhenlen);
//  when[jwhenlen] = '\0';
    strncpy (when, jwhen, jwhenlen);
    *(when + jwhenlen) = '\0';

//  type = (char *) umalloc(jtypelen + 1);
//  strncpy(type, jtype, jtypelen);
//  type[jtypelen] = '\0';
    strncpy (type, jtype, jtypelen);
    *(type + jtypelen) = '\0';

  /*
   * call C version of julian()
   */

  retval = julian(when, type);

  /*
   * free up arrays
   */

//ufree(when);
//ufree(type);

  return retval;

}
コード例 #7
0
ファイル: snowxv.cpp プロジェクト: HydroCouple/UEBComponent
//************************** hourlyRI () To get hourly radiation index
void hyri(int YEAR, int MONTH, int DAY, float HOUR, float DT, float SLOPE, float AZI, float LAT, float &HRI, float &COSZEN)
{
	float  LP,LAT1;   
	// lp= latitude of equivalent plane in radians
	// lat1 = latitude in radians
	// lat = latitude in degrees
	// a number that speaks for itself - every kissable digit
	float PI=3.141592653589793238462643383279502884197169399375105820974944592308;
	float CRAD = PI/180.0;
	//  crad = degree to radian conversion factor
	//    CONVERT timeS TO RADIANS FROM NOON
	float T = (HOUR-12.0)*PI/12.0;
	float DELT1= DT*PI/12.0;
	//    CONVERT angles TO RADIANS
	float SLOPE1=SLOPE*CRAD;
	float AZI1=AZI*CRAD;
	LAT1=LAT*CRAD;
	float   FJULIAN = (float) julian(YEAR,MONTH,DAY);
	float D = CRAD*23.5* sin((FJULIAN-82.0)*0.017214206321); 
	// 0.017214206321 is 2 pi / 365  
	// D is solar declination
	LP=asin(sin(SLOPE1)*cos(AZI1)*cos(LAT1) + cos(SLOPE1)*sin(LAT1));
	// LP is latitude of equivalent plane
	//     TD=ACOS(-TAN(LAT1)*TAN(D))  This formula abandoned 1/8/04 
	//     to make the code work for polar conditions
	// TD is half day length, i.e. the time from noon to sunset.  Sunrise is at -TD
	float tanprod = tan(LAT1)* tan(D);
	float td;
	if(tanprod > 1.0)
		td=PI;  // This is the condition for perpetual light
	else if(tanprod < -1.)
		td=0;   // The condition for perpetual night
	else
		td=acos(-tanprod);  // The condition where there is a sunrise and set

	//  Equivalent longitude offset.  Modified on 1/8/04
	//  so that it correctly accounts for shift in longitude if equivalent 
	//  plane slope goes over a pole.  Achieved using atan2.
	//     DDT=ATAN(sin(AZI1)*sin(SLOPE1)/(cos(SLOPE1)*cos(LAT1)
	//    *    -cos(AZI1)*sin(SLOPE1)*sin(LAT1)))
	float ddt= atan2(sin(AZI1)*sin(SLOPE1), (cos(SLOPE1)*cos(LAT1) - cos(AZI1)*sin(SLOPE1)*sin(LAT1)));  

	//  Now similar logic as before needs to be repeated for equivalent plane
	//  but with times reflecting
	float tpeqp = tan(LP)*tan(D);
	// Keep track of beginning and end of exposure of equiv plane to sunlight
	float tpbeg, tpend;
	if(tpeqp > 1.0)
	{
		tpbeg = -PI;   // perpetual light
		tpend= PI;
	}
	else if (tpeqp < -1.)
	{
		tpbeg=0.0;  // perpetual dark
		tpend=0.0 ;
	}
	else
	{
		tpbeg = -acos(-tpeqp) - ddt;
		tpend = acos(-tpeqp) - ddt;
	}


	//  Start and end times for integration of radiation exposure
	//  need to account for both horizon, slope and time step
	float T1, T2;
	T1 = findMax(T,tpbeg);
	T1 = findMax(T1,-td);
	T2 = findMin(T+DELT1,td);
	T2 = findMin(T2,tpend);
	//     write(6,*)t1,t2
	if(T2 <= T1) 
		HRI=0.0;
	else
		HRI = (sin(D)*sin(LP)*(T2-T1) + cos(D)*cos(LP)*(sin(T2+ddt) - sin(T1+ddt)) ) / (cos(SLOPE1)*DELT1);
	//  In the above the divide by cos slope normalizes illumination to per unit horizontal area

	//  There is a special case if tpbeg is less than -pi that occurs in polar regions
	//  where a poleward facing slope may be illuminated at night more than the day.
	//  Add this in
	if(tpbeg < -PI)
	{
		T1 = findMax(T, 2*PI-tpbeg);
		T1 = findMax(T1,-td);
		T2 = findMin(T+DELT1,td);
		if(T2 > T1)
		{
			HRI = HRI + (sin(D)*sin(LP)*(T2-T1) + cos(D)*cos(LP)*(sin(T2+ddt) - sin(T1+ddt))) / (cos(SLOPE1)*DELT1);
		}
	}
	// for the purposes of calculating albedo we need a cosine of the
	// illumination angle.  This does not have slope correction so back
	// this out again.  This is an average over the time step
	COSZEN = HRI*cos(SLOPE1);
	//     write(6,*)hri,coszen
	return;
}
コード例 #8
0
ファイル: ODATE.cpp プロジェクト: spippolatore/7kaa
//--------- Begin of function DateInfo::julian ---------//
//
// Convert a string such as "07/03/93" to long number
//
// Returns:
// <int> >0  -  Julian day
//              That is the number of days since the date  Jan 1, 4713 BC
//              Ex.  Jan 1, 1981 is  2444606
//        0  -  NULL Date (dbf_date is all blank)
//       -1  -  Illegal Date
//
long DateInfo::julian( char *dateStr )
{
   return julian( m.atoi( dateStr,4 ), m.atoi( dateStr+4,2 ),
                  m.atoi( dateStr+6,2 ) );
}
コード例 #9
0
ファイル: varsub.c プロジェクト: pologood/squall
void
varsub(int qnum, int vnum, int flags)
{
    static char param[11][128];
    static FILE *lfp = NULL;
    char *ptr;
    int i = 0,
        size[10],
        tmp_date;

    if (vnum == 0)
    {
        if ((flags & DFLT) == 0)
        {
            switch(qnum)
            {
            case 1:
                sprintf(param[1], "%d", UnifInt((long)60,(long)120,(long)qnum));
                param[2][0] = '\0';
                break;
            case 2:
                sprintf(param[1], "%d",
                        UnifInt((long)P_SIZE_MIN, (long)P_SIZE_MAX, qnum));
                pick_str(&p_types_set, qnum, param[3]);
                ptr = param[3] + strlen(param[3]);
                while (*(ptr - 1) != ' ') ptr--;
                strcpy(param[2], ptr);
                pick_str(&regions, qnum, param[3]);
                param[4][0] = '\0';
                break;
            case 3:
                pick_str(&c_mseg_set, qnum, param[1]);
                /*
                 * pick a random offset within the month of march and add the
                 * appropriate magic numbers to position the output functions
                 * at the start of March '95
                 */
                tmp_date = UnifInt((long)0, (long)30, (long)qnum);
                strcpy(param[2], *(asc_date + tmp_date + 1155));
                if (oldtime)
                {
                    for (i=0; strcmp(*(asc_date + i), param[2]); i++);
                    sprintf(param[2],"%ld", julian(i + STARTDATE));
                }
                param[3][0] = '\0';
                break;
            case 4:
                tmp_date = UnifInt(1,58,qnum);
                sprintf(param[1],"19%02d-%02d-01",
                        93 + tmp_date/12, tmp_date%12 + 1);
                if (oldtime)
                {
                    for (i=0; strcmp(*(asc_date + i), param[1]); i++);
                    sprintf(param[1],"%ld", julian(i + STARTDATE));
                }
                param[2][0] = '\0';
                break;
            case 5:
                pick_str(&regions, qnum, param[1]);
                tmp_date = UnifInt((long)93,(long)97,(long)qnum);
                if (oldtime) sprintf(param[2],"%ld", tmp_date);
                else sprintf(param[2], "19%d-01-01", tmp_date);
                param[3][0] = '\0';
                break;
            case 6:
                tmp_date = UnifInt(93,97,qnum);
                if (oldtime)
                    sprintf(param[1],"%ld001", tmp_date);
                else
                    sprintf(param[1], "19%d-01-01", tmp_date);
                sprintf(param[2], "0.0%d", UnifInt(2, 9, qnum));
                sprintf(param[3], "%d", UnifInt((long)24, (long)25, (long)qnum));
                param[4][0] = '\0';
                break;
            case 7:
                tmp_date = pick_str(&nations2, qnum, param[1]);
                while (pick_str(&nations2, qnum, param[2]) == tmp_date);
                param[3][0] = '\0';
                break;
            case 8:
                tmp_date = pick_str(&nations2, qnum, param[1]);
                tmp_date = nations.list[tmp_date].weight;
                strcpy(param[2], regions.list[tmp_date].text);
                pick_str(&p_types_set, qnum, param[3]);
                param[4][0] = '\0';
                break;
            case 9:
                pick_str(&colors, qnum, param[1]);
                param[2][0] = '\0';
                break;
            case 10:
                tmp_date = UnifInt(1,24,qnum);
                sprintf(param[1],"19%02d-%02d-01",
                        93 + tmp_date/12, tmp_date%12 + 1);
                if (oldtime)
                {
                    for (i=0; strcmp(*(asc_date + i), param[1]); i++);
                    sprintf(param[1],"%ld", julian(i + STARTDATE));
                }
                param[2][0] = '\0';
                break;
            case 11:
                pick_str(&nations2, qnum, param[1]);
                sprintf(param[2], "%11.10f", Q11_FRACTION / flt_scale );
                param[3][0] = '\0';
                break;
            case 12:
                tmp_date = pick_str(&l_smode_set, qnum, param[1]);
                while (tmp_date == pick_str(&l_smode_set, qnum, param[2]));
                tmp_date = UnifInt(93,97,qnum);
                if (oldtime) sprintf(param[3],"%d", tmp_date*1000 + 1);
                else sprintf(param[3], "19%d-01-01", tmp_date);
                param[4][0] = '\0';
                break;
            case 13:
                sprintf(param[1], O_CLRK_FMT, O_CLRK_TAG,
                        UnifInt((long)1,
                                (long) MAX((scale * O_CLRK_SCL), O_CLRK_SCL),
                                (long)qnum));

                param[2][0] = '\0';
                break;
            case 14:
                tmp_date = UnifInt(1,60,qnum);
                sprintf(param[1],"19%02d-%02d-01",
                        93 + tmp_date/12, tmp_date%12 + 1);
                if (oldtime)
                {
                    for (i=0; strcmp(*(asc_date + i), param[1]); i++);
                    sprintf(param[1],"%ld", julian(i + STARTDATE));
                }
                param[2][0] = '\0';
                break;
            case 15:
                tmp_date = UnifInt(1,58,qnum);
                sprintf(param[1],"19%02d-%02d-01",
                        93 + tmp_date/12, tmp_date%12 + 1);
                if (oldtime)
                {
                    for (i=0; strcmp(*(asc_date + i), param[1]); i++);
                    sprintf(param[1],"%ld", julian(i + STARTDATE));
                }
                param[2][0] = '\0';
                break;
            case 16:
                sprintf(param[1], "Brand#%d%d",
                        UnifInt(1, 5, qnum),
                        UnifInt(1, 5, qnum));
                pick_str(&p_types_set, qnum, param[2]);
                ptr = param[2] + strlen(param[2]);
                while (*(--ptr) != ' ');
                *ptr = '\0';
                i=0;
next:
                size[i] = UnifInt(1, 50, qnum);
                tmp_date = 0;
                while (tmp_date < i)
                    if (size[i] == size[tmp_date])
                        goto next;
                    else
                        tmp_date++;
                sprintf(param[i + 3], "%d", size[i]);
                if (++i <= TYPE_CNT)
                    goto next;
                param[i + 2][0] = '\0';
                break;
            case 17:
                sprintf(param[1], "Brand#%ld%ld",
                        UnifInt(1, 5, qnum),
                        UnifInt(1, 5, qnum));
                pick_str(&p_cntr_set, qnum, param[2]);
                param[3][0] = '\0';
                break;
            case 18:
            case 19:
                break;
            default:
                fprintf(stderr,
                        "No variable definitions available for query %d\n",
                        qnum);
            }
        }

        if (flags & LOG)
        {
            if (lfp == NULL)
            {
                lfp = fopen(lfile, "a");
                OPEN_CHECK(lfp, lfile);
            }
            fprintf(lfp, "%d", qnum);
            for (i=1; i <= 10; i++)
                if (flags & DFLT)
                {
                    if (defaults[i - 1] == NULL)
                        break;
                    else
                        fprintf(lfp, "\t%s", defaults[i - 1]);
                }
                else
                {
                    if (param[i][0] == '\0')
                        break;
                    else
                        fprintf(lfp, "\t%s", param[i]);
                }
            fprintf(lfp, "\n");
        }
    }
    else
    {
        if (flags & DFLT)
        {
            /* to allow -d to work at all scale factors */
            if (qnum == 11 && vnum == 2)
                fprintf(ofp, "%11.10f", Q11_FRACTION/flt_scale);
            else if (defaults[qnum - 1][vnum - 1])
                fprintf(ofp, "%s", defaults[qnum - 1][vnum - 1]);
            else
                fprintf(stderr,
                        "Bad default request (q: %d, p: %d)\n",
                        qnum, vnum);
        }
        else
        {
            if (param[vnum])
                fprintf(ofp, "%s", param[vnum]);
            else
                fprintf(stderr, "Bad parameter request (q: %d, p: %d)\n",
                        qnum, vnum);
        }
    }
    return;
}
コード例 #10
0
ファイル: gpusnowdv.cpp プロジェクト: dtarb/UEB
//this is for gpu; enables passing 'outside' forcing arrays
__host__ __device__ void uebCell::runUEB()
{ 
          // Variables to keep track of which time step we are in and which netcdf output file we are in
          istep = 0;  // time step initiated as 0        
          // map on to old UEB names
          Year = modelStartDate[0];
          Month = modelStartDate[1];
		  Day = modelStartDate[2];          
          sHour = modelStartHour;
          currentModelDateTime = julian(Year, Month, Day, sHour);
		  
		  int indx = uebCellY + uebCellX;     //blockIdx.x*blockDim.x + threadIdx.x;
          //++++++++++++++++++++This is the start of the main time loop++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                             
		  while (istep < numSimTimeSteps)						// && EJD >= currentModelDateTime)
		  {
			  //cout<<istep<<endl;             
	       //if(indx == 0)
		// printf(" time step: %d    ", istep);		
            if(sitev[9] != 3)
			{            
			   // UTC to local time conversion
			   calendardate(currentModelDateTime,Year, Month, Day, dHour);
			   UTCHour = dHour - UTCOffset;
			   OHour = UTCHour + lon/15.0;
			   UTCJulDat = julian(Year, Month, Day ,OHour);
			   calendardate(UTCJulDat, MYear, MMonth, MDay, MHour);
			   fHour = (float) MHour;
			   fModeldt = (float) modelDT;
			   
//      Map from wrapper input variables to UEB variables				
			   if ( inpDailyorSubdaily == 0)       //inputs are given for each time step (sub-daily time step)--in m/hr units 
			   {	
				   P = PrecArr[istep];                               // / 24000;   #12.19.14 --Daymet prcp in mm/day
				   V = WindspArr[istep];
				   Ta = TempArr[istep];

				   //get min max temp
				   Tmax = TempArr[istep];
				   Tmin = TempArr[istep];
				   Trange = 8;
				   //get max/min temperature during the day 
				   nb = (dHour - 0)/modelDT;		 //number of time steps before current time within same day
				   nf = (24 - dHour)/modelDT;      //no of time steps after current time within the same day
				   //#_TBC 9.13.13 look for better method for the following
				   if(dHour > 23)                  //to take care of hour 24, <=>0hr
				   {
					   nb = 0;
					   nf = 24/modelDT;
				   }
				   nbstart = findMax(istep - nb, 0);  //to guard against going out of lower bound near start time when the start time is not 0 hr (istep < nb )
				   nfend = findMin(istep + nf, numSimTimeSteps - 1); //don't go out of upper limit
				
				   for (int it = nbstart; it < nfend; ++it)
				   {
					   if (TempArr[it] <= Tmin)					
						   Tmin = TempArr[it];
					   if (TempArr[it] >= Tmax)					
						   Tmax = TempArr[it];
				   }
				   Trange = Tmax - Tmin;
				   //cout<<Trange<<endl;
				   if (Trange <= 0)
				   {
					   if (snowdgtvariteflag==1)	
					   {
						   cout<<"Input Diurnal temperature range is less than or equal to 0 which is unrealistic "<<endl;
						   cout<< "Diurnal temperature range is assumed as 8 degree celsius on "<<endl;
						   cout<< Year<<" "<< Month<<" "<<Day<<endl;
					   }
					   Trange = 8.0;
				   }
				   //		 Flag to control radiation (irad)
				   //!     0 is no measurements - radiation estimated from diurnal temperature range
				   //!     1 is incoming shortwave radiation read from file (measured), incoming longwave estimated
				   //!     2 is incoming shortwave and longwave radiation read from file (measured)
				   //!     3 is net radiation read from file (measured)
				   switch(irad)
				   {
				   case 0:
					   Qsiobs = infrContArr[8].infdefValue;
					   Qli = infrContArr[9].infdefValue;
					   Qnetob = infrContArr[10].infdefValue;
					   break;
				   case 1:
					   Qsiobs = SradArr[istep];                         // *3.6; // Daymet srad in W/m^2
					   Qli = infrContArr[9].infdefValue;
					   Qnetob = infrContArr[10].infdefValue;
					   break;
				   case 2:
					   Qsiobs = SradArr[istep];                         // *3.6; // Daymet srad in W/m^2
					   Qli = LradArr[istep];
					   Qnetob = infrContArr[10].infdefValue;
					   break;
				   case 3:
					   Qsiobs = infrContArr[8].infdefValue;
					   Qli = infrContArr[9].infdefValue;
					   Qnetob = NradArr[istep];
					   break;
				   default:
					   cout<<" The radiation flag is not the right number; must be between 0 and 3"<<endl;
					   getchar();
					   break;				
				   }
				   //atm. pressure from netcdf 10.30.13    //this needs revision 		//####TBC_6.20.13
				   if (infrContArr[7].infType == 2)
					   sitev[1] = infrContArr[7].infdefValue;
				   else
					   sitev[1] = ApresArr[istep];
				   //this needs revision 		//####TBC_6.20.13
				   if (infrContArr[11].infType == 2)
					   Qg = infrContArr[11].infdefValue;
				   else
					   Qg = QgArr[istep];
				   //!     Flag to control albedo (ireadalb)  				 
				   if (infrContArr[12].infType == 2)
					   Snowalb = infrContArr[12].infdefValue;
				   else
					   Snowalb = SnowalbArr[istep];
				   //12.18.14 Vapor pressure of air
				   if (infrContArr[6].infType == 2)
					   Vp = infrContArr[6].infdefValue;
				   else
					   Vp = VpArr[istep];
				   //relative humidity computed or read from file
				   //#12.18.14 needs revision
				   if (infrContArr[5].infType == 2)
				   {
					   RH = infrContArr[5].infdefValue;
				   }
				   else if (infrContArr[5].infType == -1)          //RH computed internally 
				   {
					   float eSat = 611 * exp(17.27*Ta / (Ta + 237.3)); //Pa
					   RH = Vp / eSat;
				   }
				   else
					   RH = RhArr[istep];
				   if (RH > 1)
				   {
					   //cout<<"relative humidity >= 1 at time step "<<istep<<endl;
					   RH = 0.99;
				   }
			   }   
			   else		//inputs are given as AVERAGE daily values, precip unit is always m/hr, Tmax and Tmin are required
			   {
				   //average daily value of precip in units of m/hr 4.22.14
				   P = PrecArr[istep / nstepinaDay];            // /24000 #12.19.14 Daymet prcp in mm/day           
				   V = WindspArr[istep / nstepinaDay];
				    
				   //get min max temp
				   Tmin = TaminArr[istep / nstepinaDay];
				   Tmax = TamaxArr[istep / nstepinaDay];
				   //cout << "Tmin = " << Tmin << "Tmax = " << Tmax << " ";
				   Trange = Tmax - Tmin;
				   //cout<<Trange<<endl;
				   if (Trange <= 0)
				   {
					   if (snowdgtvariteflag==1)	
					   {
						   cout<<"Input Diurnal temperature range is less than or equal to 0 which is unrealistic "<<endl;
						   cout<< "Diurnal temperature range is assumed as 8 degree celsius on "<<endl;
						   cout<< Year<<" "<< Month<<" "<<Day<<endl;
					   }
					   Trange = 8.0;
				   }
				   //sin curve describes the diel temperature fluctuations with max at 15 hrs and min at 3 hrs
				   Ta = Tmin + 0.5*Trange + 0.5*Trange*sin(2*P_i*(fHour + 15.0)/24);
				   //! Flag to control radiation (irad)
				   //!     0 is no measurements - radiation estimated from diurnal temperature range
				   //!     1 is incoming shortwave radiation read from file (measured), incoming longwave estimated
				   //!     2 is incoming shortwave and longwave radiation read from file (measured)
				   //!     3 is net radiation read from file (measured)
				   switch(irad)
				   {
				   case 0:
					   Qsiobs = infrContArr[8].infdefValue;
					   Qli = infrContArr[9].infdefValue;
					   Qnetob = infrContArr[10].infdefValue;
					   break;
				   case 1:
					   Qsiobs = SradArr[istep / nstepinaDay];                 // *3.6; // Daymet srad in W/m^2
					   Qli = infrContArr[9].infdefValue;
					   Qnetob = infrContArr[10].infdefValue;
					   break;
				   case 2:
					   Qsiobs = SradArr[istep / nstepinaDay];                 // *3.6; // Daymet srad in W/m^2
					   Qli = LradArr[istep / nstepinaDay];
					   Qnetob = infrContArr[10].infdefValue;
					   break;
				   case 3:
					   Qsiobs = infrContArr[8].infdefValue;
					   Qli = infrContArr[9].infdefValue;
					   Qnetob = NradArr[istep / nstepinaDay];
					   break;
				   default:
					   cout<<" The radiation flag is not the right number; must be between 0 and 3"<<endl;
					   getchar();
					   break;				
				   }
				   //atm. pressure from netcdf 10.30.13
				   //this needs revision 		//####TBC_6.20.13
				   if (infrContArr[7].infType == 2)
					   sitev[1] = infrContArr[7].infdefValue;
				   else
					   sitev[1] = ApresArr[istep / nstepinaDay];

				   //this needs revision 		//####TBC_6.20.13
				   if (infrContArr[11].infType == 2)
					   Qg = infrContArr[11].infdefValue;
				   else
					   Qg = QgArr[istep / nstepinaDay];
				   //!     Flag to control albedo (ireadalb)  
				   //!     0 is no measurements - albedo estimated internally
				   //!     1 is albedo read from file (provided: measured or obtained from another model)
				   //these need revision //####TBC_6.20.13
				   if (infrContArr[12].infType == 2)
					   Snowalb = infrContArr[12].infdefValue;
				   else
					   Snowalb = SnowalbArr[istep / nstepinaDay];
				   //12.18.14 Vapor pressure of air
				   if (infrContArr[6].infType == 2)
					   Vp = infrContArr[6].infdefValue;
				   else
					   Vp = VpArr[istep / nstepinaDay];
				   //relative humidity computed or read from file 			   //#12.18.14 
				   if (infrContArr[5].infType == 2)
				   {
					   RH = infrContArr[5].infdefValue;
				   }
				   else if (infrContArr[5].infType == -1)          //RH computed internally 
				   {
					   float eSat = 611 * exp(17.27*Ta / (Ta + 237.3)); //Pa
					   RH = Vp / eSat;
				   }
				   else
					   RH = RhArr[istep / nstepinaDay];
				   if (RH > 1)
				   {
					   //cout<<"relative humidity >= 1 at time step "<<istep<<endl;
					   RH = 0.99;
				   }
			   }	
        
		//  Below is code from point UEB 
				sitev[2]= Qg;   
				Inpt[0] =Ta;
				Inpt[1]=P;
				Inpt[2]=V;
				Inpt[3]=RH;
				Inpt[6] = Qnetob;         
			
			   //Radiation Input Parameterization  
			   hyri(MYear, MMonth, MDay, fHour, fModeldt,slope, azi, lat, HRI, cosZen); 
			   Inpt[7] = cosZen;                
			   if (irad <= 2)
			   {   
				   atf(atff,Trange, Month,dtbar,bca,bcc);      
		// We found that Model reanalysis and dowscaled data may produce some unreasonably negative solar radiation. this is simply bad data and it is generally better policy to try to give a model good data. 
		// If this is not possible, then the UEB checks will avoid the model doing anything too bad, it handles negative solar radiation in following way:
		// "no data in radiation would be to switch to the temperature method just for time steps when radiation is negative." 

				   if( irad ==0 || Qsiobs < 0)     //  For cases where input is strictly negative we calculate QSI from HRI and air temp range.  This covers the case of missing data being flagged with negative number, i.e. -9999.                 
				   {   
					   Inpt[4] = atff* Io *HRI;
					   cloud(as, bs, atff,cf);   // For cloudiness fraction
				   }
				   else   // Here incoming solar is input
				   {
			//      Need to call HYRI for horizontal surface to perform horizontal measurement adjustment
						hyri(MYear, MMonth, MDay, fHour, fModeldt, 0.0, azi, lat, HRI0, cosZen);
			//      If HRI0 is 0 the sun should have set so QSIOBS should be 0.  If it is
			//      not it indicates a potential measurement problem. i.e. moonshine
						if(HRI0 > 0) 
						{
							//cout<<Qsiobs;
							atfimplied =  findMin(Qsiobs/(HRI0*Io),0.9); // To avoid unreasonably large radiation when HRI0 is small
							Inpt[4] = atfimplied * HRI * Io;
						}
						else
						{
							Inpt[4] = Qsiobs; 
							if(Qsiobs != 0)
							{
								if (radwarnflag < 3)   //leave this warning only three times--enough to alert to non- -ve night time solar rad
							  {
									 cout<<"Warning: you have nonzero nightime incident radiation of "<<Qsiobs<<endl;
									 cout<<"at date "<<Year<<"   "<< Month<<"   "<< Day<<"     "<<dHour<<endl;
									 ++radwarnflag;
							  }
							}
						}
						cloud(as,bs,atff,cf);   // For cloudiness fraction  This is more theoretically correct
					}        
					if(irad < 2)
					{
						qlif(Ta, RH, T_k, SB_c, Ema,Eacl,cf,QLif);
						Inpt[5] = QLif;
					}
					else 
					{
						Ema = -9999;  //  These values are not evaluated but may need to be written out so are assigned for completeness
						Eacl = -9999;
						Inpt[5] = Qli;
					} 
					iradfl = 0;  
			   }   // Long wave or shortwave either measured and calculated
			   else
			   {
					  iradfl = 1;                    // This case is when given IRAD =3 (From Net Radiation)  
					  Inpt[6] = Qnetob;           
			   }        
	
		//      set control flags
				iflag[0] = iradfl;   // radiation [0=radiation is shortwave in col 5 and longwave in col 6, else = net radiation in column 7]
				//  In the code above radiation inputs were either computed or read from input files
				iflag[1] = 0;        // no 0 [/yes 1] printing
				//iflag[2] = outFile;        // Output unit to which to print
				if(ireadalb == 0)
				   iflag[3] = 1;        // Albedo Calculation [a value 1 means albedo is calculated, otherwise statev[3] is albedo
				else
				{
				   iflag[3]=0;
				   statev[2]=Snowalb;
				}  
				
			/*	if (istep >=48)
				{
					snowdgtvariteflag = 1;
					snowdgtvariteflag2 = 1;
					snowdgtvariteflag2 = 1;
					getchar();
				}*/

				//added 9.16.13
				iflag[4] = 4;
				mtime[0] = Year;
				mtime[1] = Month;
				mtime[2] = Day;
				mtime[3] = dHour;
				
				SNOWUEB2();     
		  
				dStorage = statev[1]-Ws1+ statev[3]-Wc1;
				errMB= cumP-cumMr-cumEs-cumEc -dStorage+cumGm - cumEg; 				
				
				OutVarValues[0][istep]= Year;
				OutVarValues[1][istep]=Month;
				OutVarValues[2][istep]=Day;
				OutVarValues[3][istep]=dHour;
				OutVarValues[4][istep]=atff;
				OutVarValues[5][istep]=HRI;
				OutVarValues[6][istep]=Eacl;
				OutVarValues[7][istep]=Ema;
				OutVarValues[8][istep]=Inpt[7]; //cosZen
				OutVarValues[9][istep]=Inpt[0];
				OutVarValues[10][istep]=Inpt[1];
				OutVarValues[11][istep]=Inpt[2];
				OutVarValues[12][istep]=Inpt[3];
				OutVarValues[13][istep]=Inpt[4];
				OutVarValues[14][istep]=Inpt[5];
				OutVarValues[15][istep]=Inpt[6];	
							
				for (int i=16;i<69;i++)
				{		   
					OutVarValues[i][istep] = OutArr[i-16];					
				}
				OutVarValues[69][istep] = errMB;

				if (snowdgt_outflag == 1 && indx ==0 )        //if debug mode 
				{
	            	printf(" time step: %d\n", istep);
					for (int uit = 0; uit<3; uit++)
						printf(" %d   ", (int) OutVarValues[uit][istep]);
					for(int uit = 3; uit< 70; uit++)
						printf(" %16.4f  ", OutVarValues[uit][istep]);
					printf(" \n");				
				}
           }
		   else //sitev[9] ==3 // this block entered only if sitev(10)= 3
		   {
                errMB = 0.0;
				for (int i=0;i<53;i++)
					OutArr[i] = 0.0;
				for (int i= 0;i <70;i++)
					OutVarValues[i][istep] = 0.0;              
		   }       
			istep++;				
			UPDATEtime(Year, Month, Day, dHour,modelDT);  			
            //ModHour=DBLE(Hour)
            currentModelDateTime = julian(Year, Month, Day, dHour); 
	   }  //End of the main time loop 
	   //copy next time step
	   modelStartDate[0] = Year;
	   modelStartDate[1] = Month;
	   modelStartDate[2] = Day;
	   modelStartHour = dHour;
	   //delete []tsprevday;
	   //delete []taveprevday;     
    
    return; 
}
コード例 #11
0
ファイル: samples.c プロジェクト: nerdalize/deltares-delft3d
/*----------------------------------------------------------------------
 * Open Samples file (skips comments in the process)
 *----------------------------------------------------------------------
 */
static FILE *
SamplesOpenFile ( TString fname   , TInt4 ftype   , TReal8 *t0 ,
                  TReal4  *scale  , TInt4 *ierror              )
{
   TChar  buffer[MAX_LINE_LENGTH] ;
   FILE  *infile                  ;
   TInt4  pos                     ;
   TInt4  err                     ;
   TInt4  iyear0                  ;
   TInt4  imonth0                 ;
   TInt4  iday0                   ;
   TInt4  ihour0                  ;
   TInt4  imin0                   ;
   TInt4  isec0                   ;

   *ierror = IEOK;

   if ( ftype != ODS_SAMPLES_2D   && ftype != ODS_SAMPLES_TABLE &&
        ftype != ODS_SAMPLES_TIME )
   {
      *ierror = IETYPE ;
      return NULL      ;
   }

/* Open the file and read the header
*/
   infile = fopen( fname , "r" ) ;
   if ( infile == NULL )
   {
      *ierror = IENOFI ;
      return NULL      ;
   }

   SamplesGetHeader( infile, ftype, buffer, scale, &err ) ;
   if ( err != 0 )
   {
      *ierror = IEUNKN ;
      return NULL      ;
   }

/* Now calculate the julian date and time: 1 jan 1900
*/
   iyear0  = 1900 ;
   imonth0 =    1 ;
   iday0   =    1 ;
   ihour0  =    0 ;
   imin0   =    0 ;
   isec0   =    0 ;
   julian( &iyear0 , &imonth0 , &iday0 , &ihour0 , &imin0 , &isec0 ,
           t0 );

/* Return the file pointer - if no error occurred
*/
   if ( err == 0 )
   {
      return infile ;
   }
   else
   {
      fclose( infile ) ;
      *ierror = IEUEOF ;
      return NULL      ;
   }
}
コード例 #12
0
ファイル: samples.c プロジェクト: nerdalize/deltares-delft3d
/*----------------------------------------------------------------------
 * Get the n-th value from a line
 * Returns 0 upon success, otherwise 1 to indicate an error.
 * If the value is "." or "?", the value is not set.
 * If the index idx is -1, return the number of values on the line
 *----------------------------------------------------------------------
 */
static TInt4
SamplesGetData( TString buffer, TInt4 ftype, TInt4 idx, TReal8 *value )
{
   TString ptoken     ;
   TInt4   i , number ;
   TInt4   jjjjmmdd   ;
   TInt4   hhmmss     ;
   TInt4   year       ;
   TInt4   month      ;
   TInt4   day        ;
   TInt4   hour       ;
   TInt4   min        ;
   TInt4   sec        ;

/* Let strtok() do the work
*/
   ptoken = strtok( buffer , " ,\t" ) ;

   if ( ptoken == NULL )
   {
      return 1 ; /* Empty line? */
   }

   if ( idx != -1 )
   {
      if ( ftype == ODS_SAMPLES_TIME && idx == 0 )
      {
         if ( strchr( ptoken, '/' ) != NULL )
         {
            sscanf( ptoken, "%d%*c%d%*c%d", &year, &month, &day ) ;
            ptoken = strtok( NULL , " ,\t" ) ;
            sscanf( ptoken, "%d%*c%d%*c%d", &hour, &min, &sec ) ;
         }
         else
         {
            sscanf( ptoken, "%d", &jjjjmmdd ) ;
            ptoken = strtok( NULL , " ,\t"  ) ;
            sscanf( ptoken, "%d", &hhmmss   ) ;
            year  =  jjjjmmdd                           / 10000 ;
            month = (jjjjmmdd - year*10000            ) /   100 ;
            day   = (jjjjmmdd - year*10000 - month*100)         ;
            hour  =  hhmmss                             / 10000 ;
            min   = (hhmmss   - hour*10000            ) /   100 ;
            sec   = (hhmmss   - hour*10000 - min*100  )         ;
         }
         julian( &year, &month, &day, &hour, &min, &sec, value );
         return 0 ;
      }

      /* First value has already been found. Now the next */
      for ( i = 1 ; i <= idx ; i ++ )
      {
         ptoken = strtok( NULL , " ,\t" ) ;
      }

      /* Check if it is a missing value */
      if ( ptoken == NULL )
      {
         return 0 ;
      }
      if ( ptoken[0] == '.' && strchr( ". ,\t" , ptoken[1] ) != NULL )
      {
         return 0 ;
      }
      if ( ptoken[0] == '?' )
      {
         return 0 ;
      }

      /* It seems a valid value
      */
      *value = (TReal4) atof( ptoken ) ;
   }
   else
   {
      number = 0 ;
      while ( ptoken != NULL )
      {
         ptoken = strtok( NULL , " ,\t" ) ;
         number ++ ;
      }
      return number ;
   }

   return 0 ;
}
コード例 #13
0
ファイル: ssb_build.cpp プロジェクト: sunyangkobe/db_research
long
mk_order(long index, order_t *o, long upd_num)
	{
	long      lcnt;
	long      rprice;
	long      ocnt;
	long      tmp_date;
	long      s_date;
	long      r_date;
	long      c_date;
	long      clk_num;
	long      supp_num;
	static char **asc_date = NULL;
	char tmp_str[2];
	char **mk_ascdate PROTO((void));
	int delta = 1;
	
	if (asc_date == NULL)
        asc_date = mk_ascdate();
	mk_sparse (index, o->okey,
		(upd_num == 0) ? 0 : 1 + upd_num / (10000 / refresh));
    RANDOM(o->custkey, O_CKEY_MIN, O_CKEY_MAX, O_CKEY_SD);
    while (o->custkey % CUST_MORTALITY == 0)
		{
		o->custkey += delta;
		o->custkey = MIN(o->custkey, O_CKEY_MAX);
		delta *= -1;
		}
	
	
    RANDOM(tmp_date, O_ODATE_MIN, O_ODATE_MAX, O_ODATE_SD);
    strcpy(o->odate, asc_date[tmp_date - STARTDATE]);
	
    pick_str(&o_priority_set, O_PRIO_SD, o->opriority);
	RANDOM(clk_num, 1, MAX((scale * O_CLRK_SCL), O_CLRK_SCL), O_CLRK_SD);
    sprintf(o->clerk, O_CLRK_FMT,
        O_CLRK_TAG,
        clk_num);
    o->clen = TEXT(O_CMNT_LEN, O_CMNT_SD, o->comment);
#ifdef DEBUG
	if (o->clen > O_CMNT_MAX) fprintf(stderr, "comment error: O%d\n", index);
#endif /* DEBUG */
    o->spriority = 0;
	
    o->totalprice = 0;
    o->orderstatus = 'O';
    ocnt = 0;
	
	RANDOM(o->lines, O_LCNT_MIN, O_LCNT_MAX, O_LCNT_SD);
    for (lcnt = 0; lcnt < o->lines; lcnt++)
		{
        HUGE_SET(o->okey, o->l[lcnt].okey);
        o->l[lcnt].lcnt = lcnt + 1;
	RANDOM(o->l[lcnt].quantity, L_QTY_MIN, L_QTY_MAX, L_QTY_SD);
	RANDOM(o->l[lcnt].discount, L_DCNT_MIN, L_DCNT_MAX, L_DCNT_SD);
        RANDOM(o->l[lcnt].tax, L_TAX_MIN, L_TAX_MAX, L_TAX_SD);
        pick_str(&l_instruct_set, L_SHIP_SD, o->l[lcnt].shipinstruct);
        pick_str(&l_smode_set, L_SMODE_SD, o->l[lcnt].shipmode);
        o->l[lcnt].clen = TEXT(L_CMNT_LEN, L_CMNT_SD, o->l[lcnt].comment);
        RANDOM(o->l[lcnt].partkey, L_PKEY_MIN, L_PKEY_MAX, L_PKEY_SD);
        RPRICE_BRIDGE( rprice, o->l[lcnt].partkey);
        RANDOM(supp_num, 0, 3, L_SKEY_SD);
        PART_SUPP_BRIDGE( o->l[lcnt].suppkey, o->l[lcnt].partkey, supp_num);
        o->l[lcnt].eprice = rprice * o->l[lcnt].quantity;
		
        o->totalprice +=
            ((o->l[lcnt].eprice * 
            ((long)100 - o->l[lcnt].discount)) / (long)PENNIES ) *
            ((long)100 + o->l[lcnt].tax)
            / (long)PENNIES;
		
		RANDOM(s_date, L_SDTE_MIN, L_SDTE_MAX, L_SDTE_SD);
        s_date += tmp_date;
		RANDOM(c_date, L_CDTE_MIN, L_CDTE_MAX, L_CDTE_SD);
        c_date += tmp_date;
		RANDOM(r_date, L_RDTE_MIN, L_RDTE_MAX, L_RDTE_SD);
        r_date += s_date;
		
        
        strcpy(o->l[lcnt].sdate, asc_date[s_date - STARTDATE]);
        strcpy(o->l[lcnt].cdate, asc_date[c_date - STARTDATE]);
        strcpy(o->l[lcnt].rdate, asc_date[r_date - STARTDATE]);
		
		
        if (julian(r_date) <= CURRENTDATE) 
			{
            pick_str(&l_rflag_set, L_RFLG_SD, tmp_str);
            o->l[lcnt].rflag[0] = *tmp_str;
			}
        else 
            o->l[lcnt].rflag[0] = 'N';
		
        if (julian(s_date) <= CURRENTDATE) 
			{
            ocnt++;
            o->l[lcnt].lstatus[0] = 'F';
			}
        else 
            o->l[lcnt].lstatus[0] = 'O';
		}
	
    if (ocnt > 0)
        o->orderstatus = 'P';
    if (ocnt == o->lines)
        o->orderstatus = 'F';
	
	return (0);
}
コード例 #14
0
ファイル: build.cpp プロジェクト: glycerine/shore-mt
long
mk_order(DSS_HUGE index, order_t *o, long upd_num)
{
  DSS_HUGE  lcnt;
  DSS_HUGE  rprice;
  long      ocnt;
  DSS_HUGE  tmp_date;
  DSS_HUGE  s_date;
  DSS_HUGE  r_date;
  DSS_HUGE  c_date;
  DSS_HUGE  clk_num;
  DSS_HUGE  supp_num;
  char **asc_date = NULL;
  char tmp_str[2];
  char **mk_ascdate PROTO((void));
  int delta = 1;
  static int bInit = 0;
  static char szFormat[100];
	
  while (!bInit) {
    TRACE( TRACE_ALWAYS, "Init mk_order ..\n");
    sprintf(szFormat, O_CLRK_FMT, 9, HUGE_FORMAT + 1);
    bInit = 1;
  }
	
  if (asc_date == NULL) {
    asc_date = mk_ascdate();
  }

  mk_sparse (index, &o->okey,
             (upd_num == 0) ? 0 : 1 + upd_num / (10000 / arefresh));
  if (scale >= 30000) {
    RANDOM64(o->custkey, O_CKEY_MIN, O_CKEY_MAX, O_CKEY_SD);
  }
  else {
    RANDOM(o->custkey, O_CKEY_MIN, O_CKEY_MAX, O_CKEY_SD);
  }

  while (o->custkey % CUST_MORTALITY == 0) {
    o->custkey += delta;
    o->custkey = MIN(o->custkey, O_CKEY_MAX);
    delta *= -1;
  }	
	
  RANDOM(tmp_date, O_ODATE_MIN, O_ODATE_MAX, O_ODATE_SD);
  strcpy(o->odate, asc_date[tmp_date - STARTDATE]);
	
  pick_str(&o_priority_set, O_PRIO_SD, o->opriority);
  RANDOM(clk_num, 1, MAX((scale * O_CLRK_SCL), O_CLRK_SCL), O_CLRK_SD);
  sprintf(o->clerk, szFormat, O_CLRK_TAG, clk_num);
  TEXT(O_CMNT_LEN, O_CMNT_SD, o->comment);
  o->clen = strlen(o->comment);
#ifdef DEBUG
  if (o->clen > O_CMNT_MAX) fprintf(stderr, "comment error: O%d\n", index);
#endif /* DEBUG */
  o->spriority = 0;
	
  o->totalprice = 0;
  o->orderstatus = 'O';
  ocnt = 0;
	
  RANDOM(o->lines, O_LCNT_MIN, O_LCNT_MAX, O_LCNT_SD);
  for (lcnt = 0; lcnt < o->lines; lcnt++) {
    o->l[lcnt].okey = o->okey;;
    o->l[lcnt].lcnt = lcnt + 1;
    RANDOM(o->l[lcnt].quantity, L_QTY_MIN, L_QTY_MAX, L_QTY_SD);
    RANDOM(o->l[lcnt].discount, L_DCNT_MIN, L_DCNT_MAX, L_DCNT_SD);
    RANDOM(o->l[lcnt].tax, L_TAX_MIN, L_TAX_MAX, L_TAX_SD);
    pick_str(&l_instruct_set, L_SHIP_SD, o->l[lcnt].shipinstruct);
    pick_str(&l_smode_set, L_SMODE_SD, o->l[lcnt].shipmode);
    TEXT(L_CMNT_LEN, L_CMNT_SD, o->l[lcnt].comment);
    o->l[lcnt].clen = strlen(o->l[lcnt].comment);
    if (scale >= 30000) {
      RANDOM64(o->l[lcnt].partkey, L_PKEY_MIN, L_PKEY_MAX, L_PKEY_SD);
    }
    else {
      RANDOM(o->l[lcnt].partkey, L_PKEY_MIN, L_PKEY_MAX, L_PKEY_SD);
    }

    rprice = rpb_routine(o->l[lcnt].partkey);
    RANDOM(supp_num, 0, 3, L_SKEY_SD);
    PART_SUPP_BRIDGE( o->l[lcnt].suppkey, o->l[lcnt].partkey, supp_num);
    o->l[lcnt].eprice = rprice * o->l[lcnt].quantity;
    
    o->totalprice +=
      ((o->l[lcnt].eprice * 
        ((long)100 - o->l[lcnt].discount)) / (long)PENNIES ) *
      ((long)100 + o->l[lcnt].tax)
      / (long)PENNIES;
		
    RANDOM(s_date, L_SDTE_MIN, L_SDTE_MAX, L_SDTE_SD);
    s_date += tmp_date;
    RANDOM(c_date, L_CDTE_MIN, L_CDTE_MAX, L_CDTE_SD);
    c_date += tmp_date;
    RANDOM(r_date, L_RDTE_MIN, L_RDTE_MAX, L_RDTE_SD);
    r_date += s_date;
		
    strcpy(o->l[lcnt].sdate, asc_date[s_date - STARTDATE]);
    strcpy(o->l[lcnt].cdate, asc_date[c_date - STARTDATE]);
    strcpy(o->l[lcnt].rdate, asc_date[r_date - STARTDATE]);
    
		
    if (julian(r_date) <= CURRENTDATE)  {
        pick_str(&l_rflag_set, L_RFLG_SD, tmp_str);
        //o->l[lcnt].rflag[0] = *tmp_str;
        o->l[lcnt].rflag = tmp_str[0];
    }
    else {
        //o->l[lcnt].rflag[0] = 'N';
        o->l[lcnt].rflag = 'N';
    }
		
    if (julian(s_date) <= CURRENTDATE)  {
        ocnt++;
        //o->l[lcnt].lstatus[0] = 'F';
        o->l[lcnt].lstatus = 'F';
    }
    else {
        //o->l[lcnt].lstatus[0] = 'O';
        o->l[lcnt].lstatus = 'O';
    }
  }
	
  if (ocnt > 0) {
    o->orderstatus = 'P';
  }

  if (ocnt == o->lines) {
    o->orderstatus = 'F';
  }

  
  for (uint i=0; i<TOTDATE; i++) {
      free (asc_date[i]);
  }
  free(asc_date);
	
  return (0);
}