[Dart-dev] [4723] DART/trunk/system_simulation/full_error.f90: Reduce precision in fortran write statement from 16 to 14 significant

nancy at ucar.edu nancy at ucar.edu
Wed Feb 16 09:23:23 MST 2011


Revision: 4723
Author:   nancy
Date:     2011-02-16 09:23:23 -0700 (Wed, 16 Feb 2011)
Log Message:
-----------
Reduce precision in fortran write statement from 16 to 14 significant
digits.  Tested on gfortran and ifort on mac, xlf on ibm, and ifort on
linux cluster. With 14 sig digits only a handful (< 30) of the 200 means 
and alphas differed across the platforms and compilers.  All differences
were in the last digit and varied by no more than 1.
Also moved the 2 subroutines into the program block following 
a 'contains' line.  that keeps us from having to set 
'implicit none' and add 'use' statements in each subroutine.

Modified Paths:
--------------
    DART/trunk/system_simulation/full_error.f90

-------------- next part --------------
Modified: DART/trunk/system_simulation/full_error.f90
===================================================================
--- DART/trunk/system_simulation/full_error.f90	2011-02-15 22:56:44 UTC (rev 4722)
+++ DART/trunk/system_simulation/full_error.f90	2011-02-16 16:23:23 UTC (rev 4723)
@@ -187,7 +187,7 @@
    write(iunit, 10)   i, bin_count(i), true_correl_mean, alpha
 end do
 
-10 format (I4,I9,2G25.16)
+10 format (I4,I9,2G25.14)
 
 call close_file(iunit)
 
@@ -198,26 +198,23 @@
 
 call finalize_utilities()
 
-end program full_error
+! end of main program
 
+contains
 
-
 !-----------------------------------------------------
 
 subroutine comp_correl(ens, n, correl)
 
-use types_mod, only : r8
-
-implicit none
-
-integer, intent(in) :: n
-real(r8), intent(in) :: ens(2, n)
+integer,  intent(in)  :: n
+real(r8), intent(in)  :: ens(2, n)
 real(r8), intent(out) :: correl
+
 real(r8) :: sum_x, sum_y, sum_xy, sum_x2, sum_y2
 
 
-sum_x = sum(ens(2, :))
-sum_y = sum(ens(1, :))
+sum_x  = sum(ens(2, :))
+sum_y  = sum(ens(1, :))
 sum_xy = sum(ens(2, :) * ens(1, :))
 sum_x2 = sum(ens(2, :) * ens(2, :))
 
@@ -233,21 +230,18 @@
 
 subroutine sample_mean_var(x, n, mean, var)
 
-use types_mod, only : r8
-
-implicit none
-
-integer, intent(in) :: n
-real(r8), intent(in) :: x(n)
+integer,  intent(in)  :: n
+real(r8), intent(in)  :: x(n)
 real(r8), intent(out) :: mean, var
 
 real(r8) :: sx, s_x2
 
-sx = sum(x)
+sx   = sum(x)
 s_x2 = sum(x * x)
 mean = sx / n
-var = (s_x2 - sx**2 / n) / (n - 1)
+var  = (s_x2 - sx**2 / n) / (n - 1)
 
 end subroutine sample_mean_var
 
 
+end program full_error


More information about the Dart-dev mailing list