module CScaleRange
    implicit none
    public
    contains
    
    real function ScaleRange(x, toMin, toMax, fromMin, fromMax)
        implicit none
	    real, intent(in) :: x
	    real, intent(in) :: toMin
	    real, intent(in) :: toMax
	    real, intent(in) :: fromMin
	    real, intent(in) :: fromMax
        ScaleRange = ((toMax - toMin)*(x - fromMin)/(fromMax - fromMin)) + toMin   
    end function 
    
end module CScaleRange
