This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [testsuite gfortran] partial fix for secnds*.f


On Fri, May 11, 2007 at 04:50:39PM +0200, Dominique Dhumieres wrote:
> ...
> extern GFC_REAL_4 secnds (GFC_REAL_4 *);
> export_proto(secnds);
> 
> GFC_REAL_4

GFC_REAL_4 is equivalent to C's float type.  I wonder if we're
seeing a rounding problem due to the mixed mode math.

> secnds (GFC_REAL_4 *x)
> {
>   GFC_INTEGER_4 values[VALUES_SIZE];
>   GFC_REAL_4 temp1, temp2;
> 
>   /* Make the INTEGER*4 array for passing to date_and_time.  */
>   gfc_array_i4 *avalues = internal_malloc_size (sizeof (gfc_array_i4));
>   avalues->data = &values[0];
>   GFC_DESCRIPTOR_DTYPE (avalues) = ((GFC_DTYPE_REAL << GFC_DTYPE_TYPE_SHIFT)
> 					& GFC_DTYPE_TYPE_MASK) +
> 				    (4 << GFC_DTYPE_SIZE_SHIFT);
> 
>   avalues->dim[0].ubound = 7;
>   avalues->dim[0].lbound = 0;
>   avalues->dim[0].stride = 1;
> 
>   date_and_time (NULL, NULL, NULL, avalues, 0, 0, 0);
> 
>   free_mem (avalues);
> 
>   temp1 = 3600.0 * (GFC_REAL_4)values[4] +
> 	    60.0 * (GFC_REAL_4)values[5] +
> 		   (GFC_REAL_4)values[6] +
> 	   0.001 * (GFC_REAL_4)values[7];

These constants should be 3600.f, 60.f and 0.001f.

>   temp2 = fmod (*x, 86400.0);

This should be fmodf (*x,86400.f)

>   temp2 = (temp1 - temp2 >= 0.0) ? temp2 : (temp2 - 86400.0);

86400.f

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]