From 1a30968dcaa464840aa440b8ecbbd10777c2e921 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Wed, 4 Mar 2020 21:04:39 -0500 Subject: [PATCH] Added the rand element code --- src/elements.f90 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/elements.f90 b/src/elements.f90 index fed369f..f63b6b2 100644 --- a/src/elements.f90 +++ b/src/elements.f90 @@ -497,7 +497,7 @@ module elements character(len=100), intent(in) :: pos_string !The position string real(kind=dp), intent(out) :: pos !The output parsed position value - integer :: iospara, face, ele + integer :: iospara, face, ele, randsize real(kind=dp) :: rand, rone, rtwo, rand_ele_pos(3) character(len=100) :: cone, ctwo @@ -520,6 +520,18 @@ module elements !Now read the rest of the command which specifies the face we need and check !to make sure it's an accepted face number cone = pos_string(index(pos_string, '[')+1:index(pos_string, '[')+1) + + !Check to see if we also pass an element size, if it was passed then make sure our + !random element is the right size + if(index(pos_string,':') > 0) then + ctwo = pos_string(index(pos_string, ':')+1:index(pos_string,']')-1) + read(ctwo, *) randsize + do while(randsize /= size_ele(ele)) + call random_number(rand) + ele= 1 + floor(ele_num*rand) + end do + end if + read(cone, *) face if ((face < 1).or.(face > 6)) stop "Current face number must be 1,2,3,4,5,6. Please check documentation" !Now get the position