online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
module Distribution implicit none real, parameter :: PI = 3.14159 contains subroutine standardNormal( Z ) ! Uses Box-Muller method real, intent(out) :: Z real u(2) call random_number( u ) ! 2 variables uniformly distributed on (0,1) u(1) = max( u(1), 1.0e-30 ) ! paranoia Z = sqrt( -2.0 * log( u(1) ) ) * cos( 2.0 * PI * u(2) ) end subroutine standardNormal real function truncatedNormal( mean, sigma, lower, upper ) real,intent(in) :: mean, sigma, lower, upper real Z do call standardNormal( Z ) truncatedNormal = mean + sigma * Z if ( truncatedNormal >= lower .and. truncatedNormal <= upper ) return end do end function truncatedNormal end module Distribution program main use Distribution ! access module implicit none integer :: N = 10 real :: mean = 100, sigma = 10, lower = 95, upper = 115; integer i call random_seed write( *, "( f6.2 )" ) ( truncatedNormal( mean, sigma, lower, upper ), i = 1, N ) end program main
GFORTRAN module version '10' created from main.f95 MD5:d65c01ccf831b48e0bc0b21dda45740f -- If you edit this, you'll get what you deserve. (() () () () () () () () () () () () () () () () () () () () () () () () () () ()) () () () () () (2 'distribution' 'distribution' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0) 3 'pi' 'distribution' '' 1 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0) (REAL 4 0 0 0 REAL ()) 0 0 () (CONSTANT ( REAL 4 0 0 0 REAL ()) 0 '0.3243f40@1') () 0 () () () 0 0) 4 'standardnormal' 'distribution' '' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL UNKNOWN 0 0 SUBROUTINE) (UNKNOWN 0 0 0 0 UNKNOWN ()) 5 0 (6) () 0 () () () 0 0) 7 'truncatednormal' 'distribution' '' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL UNKNOWN 0 0 FUNCTION) (REAL 4 0 0 0 REAL ()) 8 0 (9 10 11 12) () 7 () () () 0 0) 6 'z' '' '' 5 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) ( REAL 4 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0) 9 'mean' '' '' 8 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) ( REAL 4 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0) 10 'sigma' '' '' 8 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (REAL 4 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0) 11 'lower' '' '' 8 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (REAL 4 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0) 12 'upper' '' '' 8 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (REAL 4 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0) ) ('distribution' 0 2 'pi' 0 3 'standardnormal' 0 4 'truncatednormal' 0 7)

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue