Hi all,
I would like to know how I can get a Fortran function to return one or two values. More specifically the f_b_check and f_c_check values.
Thanks
module reaction_calculation
use OMP_LIB
implicit none
real :: q_check, f_b_check, f_c_check, l_b_check, l_c_check,l, dist_deflection_b,dist_deflection_c,reactionb_deflection,reactionc_deflection,total_deflection_b, total_deflection_c
real,allocatable :: f_b_check_array(:),f_c_check_array(:)
integer :: i, j
contains
function reaction_b_c(f_b_check,f_c_check,l_b_check,l_c_check,l,q_check)
allocate(f_b_check_array(4*q_check*l))
allocate(f_c_check_array(4*q_check*l))
!$OMP PARALLEL
!$OMP DO
do i = 1:4*q_check*l
f_b_check_array(i) = (i/4.0)
f_c_check_array(i) = (i/4.0)
end do
!$OMP END DO
!$OMP END PARALLEL
dist_deflection_b = -((q_check*(l_b_check**2))/24)*((6*(l**2))-(4*l*l_b_check)-(l_b_check**2))
dist_deflection_c = -((q_check*(l_c_check**2))/24)*((6*(l**2))-(4*l*l_c_check)-(l_c_check**2))
!$OMP PARALLEL
!$OMP DO
do i = 1:4*q_check*l
do j = 1:4*q_check*l
reactionb_deflection = (((f_b_check_array(i)*(l_b_check**2))*((3*l_b_check)-l_b_check))/6) + (((f_c_check_array(j)*(l_b_check**2))*((3*l_c_check)-l_b_check))/6)
reactionc_deflection = (((f_b_check_array(i)*(l_b_check**2))*((3*l_c_check)-l_b_check))/6) + (((f_c_check_array(j)*(l_c_check**2))*((3*l_c_check)-l_c_check))/6)
total_deflection_b = dist_deflection_b + reactionb_deflection
total_deflection_c = dist_deflection_c + reactionc_deflection
!$OMP CRITICAL
if (total_deflection_b == 0 .and. total_deflection_c == 0) then
f_b_check = f_b_check_array(i)
f_c_check = f_c_check_array(j)
end if
!$OMP END CRITICAL
end do
end do
!$OMP END DO
!$OMP END PARALLEL
deallocate(f_b_check_array)
deallocate(f_c_check_array)
end function reaction_b_c
end module reaction_calculation