Changeset 2210 in lmdz_wrf for trunk/tools
- Timestamp:
- Nov 2, 2018, 4:04:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r1913 r2210 41 41 ! reconstruct_matrix: Subroutine to reconstruct a 2D matrix from a pair of syncronized vectors with the positions on x 42 42 ! and y coordinates 43 ! runmean_F1D: Subroutine fo computing the running mean of a given set of float 1D values 43 44 ! SortR_K*: Subroutine receives an array x() r_K and sorts it into ascending order. 44 45 ! StatsR_K: Subroutine to provide the minmum, maximum, mean, the quadratic mean, and the standard deviation of a … … 3611 3612 END SUBROUTINE NcountR 3612 3613 3614 SUBROUTINE runmean_F1D(d1, values, Nmean, headertail, runmean) 3615 ! Subroutine fo computing the running mean of a given set of float 1D values 3616 3617 IMPLICIT NONE 3618 3619 INTEGER, INTENT(in) :: d1, Nmean 3620 REAL(r_k), DIMENSION(d1), INTENT(in) :: values 3621 CHARACTER(len=*), INTENT(in) :: headertail 3622 REAL(r_k), DIMENSION(d1), INTENT(out) :: runmean 3623 3624 ! Local 3625 INTEGER :: i, j, Nmean2 3626 CHARACTER(len=5) :: NmeanS 3627 3628 !!!!!!! Variables 3629 ! values: values to compute the running mean 3630 ! Nmean: number of odd points to use for the running mean 3631 ! headertail: How to proceed for the grid points at the beginning of the values which are not 3632 ! encompassed by the Nmean 3633 ! 'miss': set as missing values (1.d20) 3634 ! 'original': keep the original values 3635 ! 'progressfill': mean the values as a progressive running filter (e.g. for Nmean=5): 3636 ! runmean[values(1)] = values(1) 3637 ! runmean[values(2)] = MEAN(values(1:3)) 3638 ! runmean[values(3)] = MEAN(values(1:5)) 3639 ! runmean[values(4)] = MEAN(values(2:6)) 3640 ! (...) 3641 ! runmean[values(d1-2)] = MEAN(values(d1-5:d1)) 3642 ! runmean[values(d1-1)] = MEAN(values(d1-2:d1)) 3643 ! runmean[values(d1)] = MEAN(values(dd1)) 3644 ! 'zero': set as zero values 3645 ! runmean: runnig mean values 3646 3647 fname = 'runmean_F1D' 3648 3649 IF (MOD(Nmean,2) == 0) THEN 3650 WRITE(NmeanS,'(I5)')Nmean 3651 msg="Nmean has to be odd!! value provided: "// NmeanS 3652 CALL ErrMsg(msg, fname, -1) 3653 END IF 3654 Nmean2 = Nmean/2 3655 3656 SELECT CASE (TRIM(headertail)) 3657 CASE ('missing') 3658 runmean = fillval64 3659 CASE ('original') 3660 runmean = values 3661 CASE ('progressfill') 3662 DO i=1, Nmean2 3663 runmean(i) = SUM(values(1:2*(i-1)+1))/(2*(i-1)+1) 3664 END DO 3665 runmean(d1) = values(d1) 3666 DO i=2, Nmean2 3667 j = d1-(2*(i-1)) 3668 runmean(d1-(i-1)) = SUM(values(j:d1))/(2*(i-1)+1) 3669 END DO 3670 CASE ('zero') 3671 runmean = zeroRK 3672 CASE DEFAULT 3673 msg = "'" // TRIM(headertail) // "' not available !!" //CHAR(44) // " available ones: " // & 3674 "'missing', 'original', 'progressfill', 'zero'" 3675 CALL ErrMsg(msg, fname, -1) 3676 END SELECT 3677 3678 DO i= 1+Nmean2, d1 - Nmean2 3679 runmean(i) = SUM(values(i-Nmean2:i+Nmean2))/Nmean 3680 END DO 3681 3682 END SUBROUTINE runmean_F1D 3683 3613 3684 END MODULE module_scientific
Note: See TracChangeset
for help on using the changeset viewer.