AutoMathText / data /code /fortran /0.85-0.90.jsonl
March07's picture
add batch 3/5 (200 files)
803451e verified
Raw
History Blame Contribute Delete
227 kB
{"text": "! e_taylor.f95\n! Calculates e^x via the Taylor Series approximation.\n! Contemplated not using a function for factorial, and just adding up pieces\n! along the way, but it got less accurate results.\n!\n! GRE, 2/26/10\n\nprogram e_taylor\n implicit none\n\n real :: x, true_soln, factorial\n ! Input x; true (according to fortran) solution; function factorial\n integer :: n, i\n ! Input n: number of terms to take; dummy counter i\n real :: approx = 1.0\n ! Output approx: our approximated solution\n\n write(*,*) \"I compute e^x via the Taylor Series approximation.\"\n\n write(*,*) \"What value for x?\"\n read(*,*) x\n true_soln = exp(x)\n\n write(*,*) \"How far out should we take the approximation?\"\n read(*,*) n\n\n do i = 1,n\n approx = approx + (x**i)/factorial(i)\n ! Add up terms of Taylor Series\n end do\n\n write(*,*) \"My approximation:\", approx ! Output approximate answer\n write(*,*) \"Actual answer:\", true_soln ! Output Fortran's solution\n write(*,*) \"Error:\", abs(true_soln - approx) ! Output |Error|\n\nend program e_taylor\n\nfunction factorial(k)\n! Computes k!\n implicit none\n\n real :: factorial ! Real to get more precision\n integer, intent(in) :: k ! Input\n integer :: j ! Counter\n factorial = 1.0\n do j = 2,k\n factorial = factorial * j\n end do\n return\nend function factorial\n", "meta": {"hexsha": "99c968b0c91aab92a5c0a83b760a3972a3494e3b", "size": 1469, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "workbench/e_taylor.f95", "max_stars_repo_name": "genos/Programming", "max_stars_repo_head_hexsha": "2c59cf9fda85bf2a89684b45f2dc275cacf897b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-08-03T13:29:55.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-03T13:29:55.000Z", "max_issues_repo_path": "workbench/e_taylor.f95", "max_issues_repo_name": "genos/Programming", "max_issues_repo_head_hexsha": "2c59cf9fda85bf2a89684b45f2dc275cacf897b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "workbench/e_taylor.f95", "max_forks_repo_name": "genos/Programming", "max_forks_repo_head_hexsha": "2c59cf9fda85bf2a89684b45f2dc275cacf897b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.8039215686, "max_line_length": 80, "alphanum_fraction": 0.59632403, "num_tokens": 378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741227833249, "lm_q2_score": 0.9416541552948503, "lm_q1q2_score": 0.8969953809452648}}
{"text": "! Math Algorithms\n!\n! Purpose: Function that calculates the factorial of a given number\n! Obs: The factorial is calculated in two ways: iterative and recursive\n! Language: Fortran 95\n! Author: José Cintra\n! Year: 2020\n! Web Site: https://github.com/JoseCintra/MathAlgorithms\n! License: Unlicense, described in http://unlicense.org\n! Online demo: https://onlinegdb.com/Syk6M8G8d\n\nMODULE math\n! Mathemathical functions\n\nCONTAINS\n\n ! Function to calculate the factorial in a iterative way\n INTEGER FUNCTION factorial(num)\n\n ! Variables\n IMPLICIT NONE\n INTEGER, INTENT(IN) :: num\n INTEGER :: i\n\n !Calculation\n factorial = 1\n DO i = 1,num\n factorial = factorial * i\n END DO\n RETURN\n\n END FUNCTION factorial\n\n ! Function to calculate the factorial in a recursive way\n RECURSIVE FUNCTION recFactorial (num) RESULT (res)\n\n ! Variables\n INTEGER, INTENT(IN) :: num\n INTEGER :: res\n\n !Calculation\n IF (num <= 1) THEN\n res = 1\n ELSE\n res = recFactorial(num-1) * num\n END IF\n\n END FUNCTION recFactorial\n\nEND MODULE\n\n\nPROGRAM factorialTest\n\n USE math\n\n ! Variables\n IMPLICIT NONE\n INTEGER :: num ! User's number to calculate factorial\n INTEGER :: fact ! Calculated factorial\n WRITE (*,'(a)') \"Factorial calculation\"\n\n ! Data entry\n PRINT *,\"\"\n \n ! Change this to test other input values \n num = 5 \n\n ! Output\n fact = factorial(num)\n WRITE (*, '(a,I0,a,I0)') \"The factorial of the number \", num, \" is \", fact\n fact = recFactorial(num)\n WRITE (*, '(a,I0,a,I0)') \"The recursive factorial of the number \", num, \" is \", fact\n\n PRINT *,\"\"\n WRITE (*, '(a)') \"END of execution\"\n\nEND PROGRAM factorialTest\n", "meta": {"hexsha": "3dda1eb792b7f14816071a0f094160ca80b66e0d", "size": 1771, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "Algorithms/Factorial.f95", "max_stars_repo_name": "JoseCintra/MathAlgorithms", "max_stars_repo_head_hexsha": "afa6b22f72890604083b54af8f741d51b26510b8", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-10-28T12:04:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-13T23:16:35.000Z", "max_issues_repo_path": "Algorithms/Factorial.f95", "max_issues_repo_name": "JoseCintra/MathAlgorithms", "max_issues_repo_head_hexsha": "afa6b22f72890604083b54af8f741d51b26510b8", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Algorithms/Factorial.f95", "max_forks_repo_name": "JoseCintra/MathAlgorithms", "max_forks_repo_head_hexsha": "afa6b22f72890604083b54af8f741d51b26510b8", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-10-29T09:20:17.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-29T09:20:17.000Z", "avg_line_length": 22.417721519, "max_line_length": 87, "alphanum_fraction": 0.6324110672, "num_tokens": 479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966732132748, "lm_q2_score": 0.9465966722716813, "lm_q1q2_score": 0.8960452608471301}}
{"text": "INTEGER FUNCTION euclid_sub(a, b)\n IMPLICIT NONE\n INTEGER, INTENT(INOUT) :: a, b\n\n a = ABS(a)\n b = ABS(b)\n\n DO WHILE (a /= b)\n \n IF (a > b) THEN\n a = a - b\n ELSE\n b = b - a\n END IF\n END DO\n\n euclid_sub = a\n\nEND FUNCTION euclid_sub \n\nINTEGER FUNCTION euclid_mod(a, b)\n IMPLICIT NONE\n INTEGER, INTENT(INOUT) :: a, b\n INTEGER :: temp\n\n DO WHILE (b > 0)\n temp = b\n b = MODULO(a,b)\n a = temp\n END DO\n\n euclid_mod = a\n\nEND FUNCTION euclid_mod\n\nPROGRAM euclidean\n\n IMPLICIT NONE\n INTEGER :: a, b, euclid_sub, euclid_mod\n \n a = 24\n b = 27\n WRITE(*,*) 'Subtraction method: GCD is: ', euclid_sub(a, b)\n \n a = 24\n b = 27\n WRITE(*,*) 'Modulus method: GCD is: ', euclid_mod(a, b)\n\nEND PROGRAM euclidean \n", "meta": {"hexsha": "3107e4de2d307439b74667a3e359f49f7b6b3076", "size": 846, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "contents/euclidean_algorithm/code/fortran/euclidean.f90", "max_stars_repo_name": "atocil/algorithm-archive", "max_stars_repo_head_hexsha": "2eb30cb103508c9efb91621564bd3114eb49d3af", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1975, "max_stars_repo_stars_event_min_datetime": "2018-04-28T13:46:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T13:14:47.000Z", "max_issues_repo_path": "contents/euclidean_algorithm/code/fortran/euclidean.f90", "max_issues_repo_name": "atocil/algorithm-archive", "max_issues_repo_head_hexsha": "2eb30cb103508c9efb91621564bd3114eb49d3af", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 632, "max_issues_repo_issues_event_min_datetime": "2018-04-28T10:27:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T20:38:53.000Z", "max_forks_repo_path": "contents/euclidean_algorithm/code/fortran/euclidean.f90", "max_forks_repo_name": "atocil/algorithm-archive", "max_forks_repo_head_hexsha": "2eb30cb103508c9efb91621564bd3114eb49d3af", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 433, "max_forks_repo_forks_event_min_datetime": "2018-04-27T22:50:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T06:16:03.000Z", "avg_line_length": 16.92, "max_line_length": 63, "alphanum_fraction": 0.5141843972, "num_tokens": 271, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9693241982893259, "lm_q2_score": 0.9241418267688302, "lm_q1q2_score": 0.8957930353383294}}
{"text": "program Prime_Number_Judgement\r\nimplicit none\r\n logical :: Judge = .false.\r\n integer :: n , i\r\n \r\n do n = 2 , 100\r\n do i = 2 , n-1\r\n if(mod(n,i) == 0) then\r\n Judge = .true.\r\n print*, n , '=', i, '*', n/i\r\n exit\r\n else\r\n continue\r\n end if\r\n Judge = .false.\r\n end do\r\n \r\n if (.not.Judge) then\r\n print*, n, 'is a prime number'\r\n end if\r\n end do\r\n\r\nend", "meta": {"hexsha": "ed687fd8d4d5b941ecffbfd5af3e463d61ae2f1a", "size": 513, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "GitHub_FortranHomework/Prime_Number.f90", "max_stars_repo_name": "MikasaMumei/Freshman_year", "max_stars_repo_head_hexsha": "c7b94d7726b170119fca40c6f87ebf79433444de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-12-02T13:32:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-02T13:32:17.000Z", "max_issues_repo_path": "GitHub_FortranHomework/Prime_Number.f90", "max_issues_repo_name": "MikasaMumei/Freshman_year", "max_issues_repo_head_hexsha": "c7b94d7726b170119fca40c6f87ebf79433444de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "GitHub_FortranHomework/Prime_Number.f90", "max_forks_repo_name": "MikasaMumei/Freshman_year", "max_forks_repo_head_hexsha": "c7b94d7726b170119fca40c6f87ebf79433444de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.3043478261, "max_line_length": 45, "alphanum_fraction": 0.3762183236, "num_tokens": 128, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. Yes\n2. Yes", "lm_q1_score": 0.9425067211996142, "lm_q2_score": 0.943347570909308, "lm_q1q2_score": 0.8891114260093524}}
{"text": "! \n! Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.\n!\n! NVIDIA CORPORATION and its licensors retain all intellectual property\n! and proprietary rights in and to this software, related documentation\n! and any modifications thereto.\n!\n!\n! These example codes are a portion of the code samples from the companion\n! website to the book \"CUDA Fortran for Scientists and Engineers\":\n!\n! http://store.elsevier.com/product.jsp?isbn=9780124169708\n!\n\nprogram sum_accuracy\n implicit none\n real, allocatable :: x(:)\n real :: sum_intrinsic,sum_cpu, sum_kahan, sum_pairwise, &\n comp, y, tmp\n double precision :: sum_cpu_dp\n integer :: i,inext,icurrent, N=10000000\n\n allocate (x(N))\n x=7.\n\n ! Summation using intrinsic\n sum_intrinsic=sum(x)\n\n ! Recursive summation \n sum_cpu=0.\n sum_cpu_dp=0.d0\n do i=1,N\n ! accumulator in single precision\n sum_cpu=sum_cpu+x(i)\n ! accumulator in double precision\n sum_cpu_dp=sum_cpu_dp+x(i)\n end do\n\n ! Kahan summation\n sum_kahan=0.\n comp=0. ! running compensation to recover lost low-order bits\n \n do i=1,N\n y = comp +x(i)\n tmp = sum_kahan + y ! low-order bits may be lost\n comp = (sum_kahan-tmp)+y ! (sum-tmp) recover low-order bits\n sum_kahan = tmp\n end do\n sum_kahan=sum_kahan +comp\n \n ! Pairwise summation\n icurrent=N\n inext=ceiling(real(N)/2)\n do while (inext >1)\n do i=1,inext\n if ( 2*i <= icurrent) x(i)=x(i)+x(i+inext)\n end do\n icurrent=inext\n inext=ceiling(real(inext)/2)\n end do\n sum_pairwise=x(1)+x(2)\n \n write(*, \"('Summming ',i10, &\n ' elements of magnitude ',f3.1)\") N,7.\n write(*, \"('Sum with intrinsic function =',f12.1, &\n ' Error=', f12.1)\") &\n sum_intrinsic, 7.*N-sum_intrinsic\n write(*, \"('Recursive sum with SP accumulator =',f12.1, &\n ' Error=', f12.1)\") sum_cpu, 7.*N-sum_cpu\n write(*, \"('Recursive sum with DP accumulator =',f12.1, &\n ' Error=', f12.1)\") sum_cpu_dp, 7.*N-sum_cpu_dp\n write(*, \"('Pairwise sum in SP =',f12.1, &\n ' Error=', f12.1)\") sum_pairwise, 7.*N-sum_pairwise\n write(*, \"('Compensated sum in SP =',f12.1, &\n ' Error=', f12.1)\") sum_kahan, 7.*N-sum_kahan\n \n deallocate(x)\nend program sum_accuracy\n", "meta": {"hexsha": "d7e69d90c25748ebd0a1d106b303b95c75879a54", "size": 2282, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "fortran-cuda/CUDA-Fortran-Book/chapter5/common/accuracy_sum.f90", "max_stars_repo_name": "aandrich3/fortran", "max_stars_repo_head_hexsha": "ed98e52679bee764b5ad9a1a0545a17d8ded3066", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "fortran-cuda/CUDA-Fortran-Book/chapter5/common/accuracy_sum.f90", "max_issues_repo_name": "aandrich3/fortran", "max_issues_repo_head_hexsha": "ed98e52679bee764b5ad9a1a0545a17d8ded3066", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-03-11T20:42:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-11T20:42:37.000Z", "max_forks_repo_path": "fortran-cuda/CUDA-Fortran-Book/chapter5/common/accuracy_sum.f90", "max_forks_repo_name": "aandrich3/fortran", "max_forks_repo_head_hexsha": "ed98e52679bee764b5ad9a1a0545a17d8ded3066", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-03-11T17:22:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-06T14:41:36.000Z", "avg_line_length": 28.8860759494, "max_line_length": 77, "alphanum_fraction": 0.6323400526, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9416541626630937, "lm_q2_score": 0.9407897529939848, "lm_q1q2_score": 0.8858985870975695}}
{"text": "module serial_subs\n\n implicit none\n\ncontains\n\n function calc_pi(n) result(pi)\n\n implicit none\n integer(8) :: accept\n real(8) :: r(2), pi\n integer(8), intent(in) :: n\n integer(8) :: i\n\n accept = 0\n\n do i = 1, n\n call random_number(r)\n if (r(1)**2 + r(2)**2 <= 1) then\n accept = accept + 1\n end if\n end do\n\n pi = 4.0d0 * dble(accept)/dble(n) ! dble(a) converts a to double precision real type. Pi/4 parts of a sphere circle\n\n end function calc_pi\n\nend module serial_subs\n\nprogram main\n\n use serial_subs\n\n implicit none\n integer(8) :: n\n real(8), parameter :: pi = 2.0d0*dacos(0.0d0)\n character (len=64) :: arg\n real(8) :: T1, T2, mypi\n ! 'How many samples you would like to take?'\n ! Usage of this program should be declare.\n call random_seed()\n\n if (command_argument_count() /= 1) then\n error stop \"One command line argument should be passed, which is the number of iterations to perform.\"\n end if\n\n call get_command_argument(1, arg)\n read(arg,*) n\n call cpu_time(T1)\n mypi = calc_pi(n)\n call cpu_time(T2)\n write(*,'(a,f12.6)') \"Calculated π = \", mypi\n write(*,'(a,f12.6)') \"Actual π = \", pi\n print *, 'The time usage is:', T2-T1\n\nend program main\n", "meta": {"hexsha": "21122010a360f9f6ef6ccfd7518c0aff13a6591e", "size": 1337, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "modern_fotran/ParrallelComputation/2acos0/serial.f90", "max_stars_repo_name": "ComplicatedPhenomenon/Fortran_Takeoff", "max_stars_repo_head_hexsha": "a13180050367e59a91973af96ab680c2b76097be", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modern_fotran/ParrallelComputation/2acos0/serial.f90", "max_issues_repo_name": "ComplicatedPhenomenon/Fortran_Takeoff", "max_issues_repo_head_hexsha": "a13180050367e59a91973af96ab680c2b76097be", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modern_fotran/ParrallelComputation/2acos0/serial.f90", "max_forks_repo_name": "ComplicatedPhenomenon/Fortran_Takeoff", "max_forks_repo_head_hexsha": "a13180050367e59a91973af96ab680c2b76097be", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.4561403509, "max_line_length": 124, "alphanum_fraction": 0.5736724009, "num_tokens": 406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741268224331, "lm_q2_score": 0.924141819456443, "lm_q1q2_score": 0.8803135867288159}}
{"text": "PROGRAM roots\r\n\r\n! Purpose:\r\n! This program solves for the roots of a quadratic equation of the \r\n! form a*x**2 + b*x + c = 0. It calculates the answers regardless\r\n! of the type of roots that the equation possesses.\r\n!\r\n! Record of revisions:\r\n! Date Programmer Description of change\r\n! ==== ========== =====================\r\n! 11/06/06 S. J. Chapman Original code\r\n!\r\nIMPLICIT NONE\r\n\r\n! Data dictionary: declare variable types, definitions, & units \r\nREAL :: a ! Coefficient of x**2 term of equation\r\nREAL :: b ! Coefficient of x term of equation\r\nREAL :: c ! Constant term of equation\r\nREAL :: discriminant ! Discriminant of the equation\r\nREAL :: imag_part ! Imaginary part of equation (for complex roots)\r\nREAL :: real_part ! Real part of equation (for complex roots)\r\nREAL :: x1 ! First solution of equation (for real roots)\r\nREAL :: x2 ! Second solution of equation (for real roots)\r\n\r\n! Prompt the user for the coefficients of the equation\r\nWRITE (*,*) 'This program solves for the roots of a quadratic '\r\nWRITE (*,*) 'equation of the form A * X**2 + B * X + C = 0. '\r\nWRITE (*,*) 'Enter the coefficients A, B, and C: '\r\nREAD (*,*) a, b, c\r\n\r\n! Echo back coefficients\r\nWRITE (*,*) 'The coefficients A, B, and C are: ', a, b, c \r\n\r\n! Calculate discriminant\r\ndiscriminant = b**2 - 4. * a * c \r\n\r\n! Solve for the roots, depending upon the value of the discriminant\r\nIF ( discriminant > 0. ) THEN ! there are two real roots, so...\r\n\r\n x1 = ( -b + sqrt(discriminant) ) / ( 2. * a )\r\n x2 = ( -b - sqrt(discriminant) ) / ( 2. * a )\r\n WRITE (*,*) 'This equation has two real roots:'\r\n WRITE (*,*) 'X1 = ', x1\r\n WRITE (*,*) 'X2 = ', x2\r\n\r\nELSE ( discriminant < 0. ) THEN ! there are complex roots, so ...\r\n\r\n real_part = ( -b ) / ( 2. * a )\r\n imag_part = sqrt ( abs ( discriminant ) ) / ( 2. * a )\r\n WRITE (*,*) 'This equation has complex roots:'\r\n WRITE (*,*) 'X1 = ', real_part, ' +i ', imag_part\r\n WRITE (*,*) 'X2 = ', real_part, ' -i ', imag_part\r\n\r\nELSE IF ( discriminant == 0. ) THEN ! there is one repeated root, so...\r\n\r\n x1 = ( -b ) / ( 2. * a )\r\n WRITE (*,*) 'This equation has two identical real roots:'\r\n WRITE (*,*) 'X1 = X2 = ', x1\r\n\r\nEND IF\r\n\r\nEND PROGRAM roots\r\n", "meta": {"hexsha": "9796ba7620b0bc6338f2e6293d56f237a60723f4", "size": 2349, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap3/roots.f90", "max_stars_repo_name": "yangyang14641/FortranLearning", "max_stars_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-03-12T02:18:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T07:58:56.000Z", "max_issues_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap3/roots.f90", "max_issues_repo_name": "yangyang14641/FortranLearning", "max_issues_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap3/roots.f90", "max_forks_repo_name": "yangyang14641/FortranLearning", "max_forks_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-05-11T02:36:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T06:36:55.000Z", "avg_line_length": 37.2857142857, "max_line_length": 72, "alphanum_fraction": 0.5683269476, "num_tokens": 660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9653811631528336, "lm_q2_score": 0.9111797009670495, "lm_q1q2_score": 0.8796357195608213}}
{"text": "PROGRAM ball\r\n!\r\n! Purpose:\r\n! To calculate distance traveled by a ball thrown at a specified\r\n! angle THETA and at a specified velocity VO from a point on the \r\n! surface of the earth, ignoring the effects of air friction and\r\n! the earth's curvature.\r\n!\r\n! Record of revisions:\r\n! Date Programmer Description of change\r\n! ==== ========== =====================\r\n! 11/14/06 S. J. Chapman Original code\r\n!\r\nIMPLICIT NONE\r\n\r\n! Data dictionary: declare constants\r\nREAL, PARAMETER :: DEGREES_2_RAD = 0.01745329 ! Deg ==> rad conv.\r\nREAL, PARAMETER :: GRAVITY = -9.81 ! Accel. due to gravity (m/s)\r\n\r\n! Data dictionary: declare variable types, definitions, & units \r\nINTEGER :: max_degrees ! angle at which the max rng occurs (degrees)\r\nREAL :: max_range ! Maximum range for the ball at vel v0 (meters)\r\nREAL :: range ! Range of the ball at a particular angle (meters)\r\nREAL :: radian ! Angle at which the ball was thrown (in radians)\r\nINTEGER :: theta ! Angle at which the ball was thrown (in degrees)\r\nREAL :: v0 ! Velocity of the ball (in m/s)\r\n \r\n! Initialize variables.\r\nmax_range = 0. \r\nmax_degrees = 0\r\nv0 = 20.\r\n\r\n! Loop over all specified angles.\r\n\r\nloop: DO theta = 0, 90\r\n\r\n ! Get angle in radians\r\n radian = real(theta) * DEGREES_2_RAD \r\n\r\n ! Calculate range in meters.\r\n range = (-2. * v0**2 / GRAVITY) * SIN(radian) * COS(radian)\r\n \r\n ! Write out the range for this angle.\r\n WRITE (*,*) 'Theta = ', theta, ' degrees; Range = ', range, &\r\n ' meters'\r\n\r\n ! Compare the range to the previous maximum range. If this\r\n ! range is larger, save it and the angle at which it occurred.\r\n IF ( range > max_range ) THEN\r\n max_range = range\r\n max_degrees = theta\r\n END IF\r\n \r\nEND DO loop\r\n \r\n! Skip a line, and then write out the maximum range and the angle\r\n! at which it occurred.\r\nWRITE (*,*) ' '\r\nWRITE (*,*) 'Max range = ', max_range, ' at ', max_degrees, ' degrees'\r\n \r\nEND PROGRAM ball\r\n", "meta": {"hexsha": "3f2f3ee31f912c3188a3c2d414b27d95c8d19cf2", "size": 2077, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap4/ball.f90", "max_stars_repo_name": "yangyang14641/FortranLearning", "max_stars_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-03-12T02:18:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T07:58:56.000Z", "max_issues_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap4/ball.f90", "max_issues_repo_name": "yangyang14641/FortranLearning", "max_issues_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap4/ball.f90", "max_forks_repo_name": "yangyang14641/FortranLearning", "max_forks_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-05-11T02:36:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T06:36:55.000Z", "avg_line_length": 33.5, "max_line_length": 76, "alphanum_fraction": 0.6027924892, "num_tokens": 533, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9817357253887768, "lm_q2_score": 0.8947894618940992, "lm_q1q2_score": 0.8784467814428368}}
{"text": "PROGRAM question5\n IMPLICIT NONE\n\n REAL, ALLOCATABLE, DIMENSION(:, :) :: A, B, C, D\n INTEGER:: L, M, N, i, j, k\n \n WRITE(*, *) \"A() is L by M .and. B() is M by N ==> So final result C() will be L by N\"\n WRITE(*, *) \"Please Enter L, M and N\" \n READ(*, *) L, M, N\n ALLOCATE(A(L, M))\n ALLOCATE(B(M, N))\n ALLOCATE(C(L, N))\n ALLOCATE(D(L, N)) \n\n WRITE(*, *) \"Enter Matrix A()\"\n DO i = 1, L\n READ(*, *) (A(i,j), j=1,M) ! A() is L-by-M\n ENDDO\n\n WRITE(*, *) \"Enter Matrix B()\"\n DO i = 1, M\n READ(*, *) (B(i,j), j=1, N) ! B() is M-by-N\n ENDDO\n\n DO i = 1, L\n DO j = 1, N\n C(i,j) = 0\n DO k = 1, M ! (row i of A)*(col j of B)\n C(i,j) = C(i,j) + A(i,k)*B(k,j)\n ENDDO\n ENDDO\n ENDDO\n\n WRITE(*, *)\n WRITE(*, *) \"Matrix C:\"\n DO i = 1, L\n Write(*, *) (C(i,j), j=1,N)\n ENDDO\n WRITE(*, *)\n\n D = matmul(a, b)\n WRITE(*, *) \"Matrix D: (calculated from matmul library)\"\n DO i = 1, L\n Write(*, *) (D(i,j), j=1,N)\n ENDDO\n\n WRITE(*, *) \n IF(All(C == D)) WRITE(*, *) \"C and D is same.\"\n \nEND", "meta": {"hexsha": "3b0836cc592c09aa1094fa4d07e757609314ae02", "size": 1172, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Practice-1/5.f90", "max_stars_repo_name": "arpitkekri/Code_With_FORTRAN", "max_stars_repo_head_hexsha": "fb731e6f8d8a47cfe38896fffd74a55d17efb2e3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2021-02-21T05:24:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-27T10:25:24.000Z", "max_issues_repo_path": "Practice-1/5.f90", "max_issues_repo_name": "akhil18soni/Code_With_FORTRAN", "max_issues_repo_head_hexsha": "92bb46ab5b340f070c229f27acb4806931879d02", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Practice-1/5.f90", "max_forks_repo_name": "akhil18soni/Code_With_FORTRAN", "max_forks_repo_head_hexsha": "92bb46ab5b340f070c229f27acb4806931879d02", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-27T12:14:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-19T23:30:55.000Z", "avg_line_length": 23.44, "max_line_length": 90, "alphanum_fraction": 0.4087030717, "num_tokens": 449, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966732132748, "lm_q2_score": 0.9230391584819669, "lm_q1q2_score": 0.8737457966646106}}
{"text": "! Created by EverLookNeverSee@GitHub on 5/25/20.\n! This program computes the product of two given matrices.\n\nprogram matrix_product\n implicit none\n ! declaring variables\n integer :: m, n, o, p, i, j, k\n ! declaring matrices\n real, allocatable, dimension(:,:) :: A, B, C\n\n print *, \"Matrix A:\"\n do\n print *, \"Enter number of rows and columns for matrix A:\"\n read *, m, n\n if (m <= 0 .or. n <= 0) then\n print *, \"number of rows and columns should be positive integers\"\n print *, \"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\"\n cycle\n end if\n exit\n end do\n\n print *, \"Matrix B:\"\n do\n print *, \"Enter number of rows and columns for matrix B:\"\n read *, o, p\n if (o <= 0 .or. p <= 0) then\n print *, \"number of rows and columns should be positive integers\"\n print *, \"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\"\n cycle\n end if\n if (n /= o) then\n print *, \"Number columns in matrix A should be equal to number of rows in matrix B.\"\n cycle\n end if\n exit\n end do\n\n ! Allocating memory space for matrices\n allocate(A(m, n))\n allocate(B(o, p))\n allocate(C(m, p))\n\n ! Getting elements of matrix A from user\n print *, \"Getting elements of matrix A:\"\n do i = 1, m\n do j = 1, n\n print *, \"A(\", i, j, \"):\"\n read*, A(i, j)\n end do\n end do\n ! Getting elements of matrix B from user\n print *, \"Getting elements of matrix B:\"\n do i = 1, o\n do j = 1, p\n print *, \"B(\", i, j, \"):\"\n read*, B(i, j)\n end do\n end do\n\n ! computing prodcut operation\n do i = 1, m\n do j = 1, p\n C(i, j) = 0.0\n do k = 1, n\n C(i, j) = C(i, j) + A(i, k) * B(k, j)\n end do\n end do\n end do\n\n ! printing result\n print *, \"Result -->\", ((C(i, j), j = 1, p), i = 1, m)\nend program matrix_product", "meta": {"hexsha": "c45173b36e1358d4f7ad1e212bf90b9168876932", "size": 2067, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/other/matrix_product.f90", "max_stars_repo_name": "EverLookNeverSee/FCS", "max_stars_repo_head_hexsha": "aa69d069d14e8dc20a9d176014c8a6a6b99322d4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-04-14T10:30:25.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-17T13:03:15.000Z", "max_issues_repo_path": "src/other/matrix_product.f90", "max_issues_repo_name": "EverLookNeverSee/FCS", "max_issues_repo_head_hexsha": "aa69d069d14e8dc20a9d176014c8a6a6b99322d4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-06-06T13:54:45.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-25T20:32:23.000Z", "max_forks_repo_path": "src/other/matrix_product.f90", "max_forks_repo_name": "EverLookNeverSee/FCS", "max_forks_repo_head_hexsha": "aa69d069d14e8dc20a9d176014c8a6a6b99322d4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-06-08T12:57:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-08T12:57:46.000Z", "avg_line_length": 28.3150684932, "max_line_length": 96, "alphanum_fraction": 0.4644412192, "num_tokens": 620, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.954647415574754, "lm_q2_score": 0.9149009480320036, "lm_q1q2_score": 0.8734078255456446}}
{"text": "!-----------------------------------------------------\n!PHY1038 Assignment 1 - Newton-Raphson root finding\n!URN 6309823 - Penguin Lab Group 1K\n!February 24th 2015\n!-----------------------------------------------------\n\nPROGRAM Newton_Raphson\nIMPLICIT NONE\nREAL :: x,x1,a,b,c,d,t\nINTEGER :: j,k\n\nWRITE(6,*) \" \"\nWRITE(6,*) \" \"\nWRITE(6,*) \"This program finds the roots of a cubic function using the Newton-Raphson method,\"\nWRITE(6,*) \" \"\nWRITE(6,*) \"i.e. it finds all possible values of x which satisfy the equation: f(x)=ax^3+bx^2+cx+d=0.\"\nWRITE(6,*) \" \"\nWRITE(6,*) \" \"\n\n!I had to change this so that the coeficients are defined individually. Then I an input them into the cubic equation.\n\nWRITE(6,*) \"Please input a value for a.\"\nREAD(5,*) a\nWRITE(6,*) \" \"\nWRITE(6,*) \"Please input a value for b.\"\nREAD(5,*) b\nWRITE(6,*) \" \"\nWRITE(6,*) \"Please input a value for c.\"\nREAD(5,*) c\nWRITE(6,*) \" \"\nWRITE(6,*) \"Please input a value for d.\"\nREAD(5,*) d\nWRITE(6,*) \" \"\nWRITE(6,*) \" \"\nWRITE(6,*) \"Make a guess as a first approximation to the root of the function (x); write down this value.\"\nREAD(5,*) x1\nWRITE(6,*) \" \"\nWRITE(6,*) \" \"\n\n!'t' remains as the initial guess so that it can be referenced later\n\nt=x1\nx=x1\n\n!This is a do loop which uses the formulat x1=x0-f(x0)/f'(x0) to find an estimate of a root of the cubic equation\n\n!-----------------------------------------------------\n\nk=1\n\nDO j=1,100\n x1=x-(a*x**3+b*x**2+c*x+d)/(3*a*x**2+2*b*x+c)\n IF (ABS(x1-x) <1E-6) EXIT \n x=x1\n k=k+1\nEND DO\n\n!------------------------------------------------------\nWRITE(6,*) \"The cubic equation in question is:\",a,\"x^3+\",b,\"x^2+\",c,\"x+\",d\nWRITE(6,*) \" \"\nWRITE(6,*) \"This is a root of the cubic equation to a tolerance of 10^-6:\", x1\nWRITE(6,*) \" \"\nWRITE(6,*) \"It took\",k,\"iterations to find this root\"\nWRITE(6,*) \" \"\nWRITE(6,*) \"The initial guess for a root of the cubic equation was:\",t\nWRITE(6,*) \" \"\nWRITE(6,*) \"Please repeat this program with different values for the initial guess until three roots of the cubic equation are found\"\n\nEND PROGRAM Newton_Raphson\n", "meta": {"hexsha": "5ac4ccc133cd86f871d36fda4e37281a806d54dc", "size": 2053, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "6309823-Newton-Raphson.f90", "max_stars_repo_name": "WilliamHoltam/computational-physics", "max_stars_repo_head_hexsha": "0c504766e356874e755971f5e82f76f6a367bc54", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "6309823-Newton-Raphson.f90", "max_issues_repo_name": "WilliamHoltam/computational-physics", "max_issues_repo_head_hexsha": "0c504766e356874e755971f5e82f76f6a367bc54", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "6309823-Newton-Raphson.f90", "max_forks_repo_name": "WilliamHoltam/computational-physics", "max_forks_repo_head_hexsha": "0c504766e356874e755971f5e82f76f6a367bc54", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.3285714286, "max_line_length": 133, "alphanum_fraction": 0.5859717487, "num_tokens": 644, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9572778073288128, "lm_q2_score": 0.9111797142327147, "lm_q1q2_score": 0.8722521189231874}}
{"text": "function derivs_1g(t, x)\n implicit none\n double precision :: derivs_1g\n double precision,intent(in) :: t, x\n double precision :: g = (50.d0), k = (0.1d0)\n \n derivs_1g = g - k * x\n \nend function derivs_1g\n\nsubroutine ode_1g_euler(x0,dt,nsteps,results)\n implicit none\n integer, intent(in) :: nsteps\n double precision, intent(in) :: x0, dt\n double precision, dimension(2, nsteps), intent(out) :: results\n double precision :: derivs_1g\n integer :: i, n\n double precision :: t, x\n \n t = 0.d0\n x = x0\n do i = 1, nsteps\n t = t + dt\n x = x + derivs_1g(t, x) * dt\n results(1,i) = t\n results(2,i) = x\n enddo\n \nend subroutine ode_1g_euler\n\nsubroutine ode_1g_rk2(x0,dt,nsteps,results)\n implicit none\n integer, intent(in) :: nsteps\n double precision, intent(in) :: x0, dt\n double precision, dimension(2, nsteps), intent(out) :: results\n double precision :: derivs_1g\n integer :: i, n\n double precision :: t, x, k1, k2\n \n t = 0.d0\n x = x0\n do i = 1, nsteps\n k1 = derivs_1g(t,x) * dt\n t = t + dt\n k2 = derivs_1g(t,x+k1) * dt\n x = x + (k1+k2)/2.d0\n results(1,i) = t\n results(2,i) = x\n enddo\nend subroutine ode_1g_rk2\n\nsubroutine ode_1g_rk4(x0,dt,nsteps,results)\n implicit none\n integer, intent(in) :: nsteps\n double precision, intent(in) :: x0, dt\n double precision, dimension(2, nsteps), intent(out) :: results\n double precision :: derivs_1g\n integer :: i, n\n double precision :: t, x, k1, k2, k3, k4, dt05\n \n dt05 = dt/2.d0\n t = 0.d0\n x = x0\n do i = 1, nsteps\n k1 = derivs_1g(t,x) * dt\n t = t + dt05\n k2 = derivs_1g(t,x+k1/2.d0) * dt\n k3 = derivs_1g(t,x+k2/2.d0) * dt\n t = t + dt05\n k4 = derivs_1g(t,x+k3) * dt\n x = x + (k1+2.d0*k2+2.d0*k3+k4)/6.d0\n results(1,i) = t\n results(2,i) = x\n enddo\nend subroutine ode_1g_rk4", "meta": {"hexsha": "86fd6e2eb0f9313f7f27bfca074f626c322b691e", "size": 1809, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "extra/src/sub_ode_1g.f90", "max_stars_repo_name": "lusystemsbio/numericalR", "max_stars_repo_head_hexsha": "014d849062d56181c0423e721c25383896d620bb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "extra/src/sub_ode_1g.f90", "max_issues_repo_name": "lusystemsbio/numericalR", "max_issues_repo_head_hexsha": "014d849062d56181c0423e721c25383896d620bb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "extra/src/sub_ode_1g.f90", "max_forks_repo_name": "lusystemsbio/numericalR", "max_forks_repo_head_hexsha": "014d849062d56181c0423e721c25383896d620bb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.12, "max_line_length": 64, "alphanum_fraction": 0.6135986733, "num_tokens": 734, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9441768620069626, "lm_q2_score": 0.9230391605990604, "lm_q1q2_score": 0.8715122181639616}}
{"text": "submodule (m_maths) sm_maths_d1d\n !! Implement math routines for double precision arrays\nimplicit none\n\ncontains\n !====================================================================!\n module function crossProduct_d1D(a,b) result(res)\n !! Interfaced with crossproduct()\n !====================================================================!\n real(r64),intent(in) :: a(3) !! 1D Array\n real(r64),intent(in) :: b(3) !! 1D Array\n real(r64) :: res(3) !! cross product\n res(1)=a(2)*b(3)-a(3)*b(2)\n res(2)=a(3)*b(1)-a(1)*b(3)\n res(3)=a(1)*b(2)-a(2)*b(1)\n end function\n !====================================================================!\n !====================================================================!\n module function cumprod_d1D(this) result(res)\n !! Interfaced with cumprod()\n !====================================================================!\n real(r64),intent(in) :: this(:) !! 1D array\n real(r64) :: res(size(this)) !! Cumulative product\n integer(i32) :: i\n integer(i32) :: N\n N=size(this)\n res(1) = this(1)\n do i=2,N\n res(i) = res(i-1) * this(i)\n end do\n end function\n !====================================================================!\n !====================================================================!\n module function cumsum_d1D(this) result(res)\n !! Interfaced with cumsum()\n !====================================================================!\n real(r64),intent(in) :: this(:) !! 1D array\n real(r64) :: res(size(this)) !! Cumulative sum\n integer(i32) :: i\n integer(i32) :: N\n N=size(this)\n res(1) = this(1)\n do i=2,N\n res(i) = res(i-1) + this(i) ! Round off error?\n end do\n end function\n !====================================================================!\n !====================================================================!\n module function geometricMean_d1D(this) result(res)\n !! Interfaced with geometricMean()\n !====================================================================!\n real(r64),intent(in) :: this(:)\n real(r64) :: res\n res=product(this)\n res=res**(dble(size(this)))\n end function\n !====================================================================!\n !====================================================================!\n module procedure Mean_d1D\n !! interface with mean()\n !====================================================================!\n !module function mean_d1D(this) result(res)\n !real(r64) :: this(:)\n !real(r64) :: res\n res=sum(this)/dble(size(this))\n end procedure\n !====================================================================!\n !====================================================================!\n module function median_d1D(this) result(res)\n !====================================================================!\n !! Interfaced with median()\n real(r64), intent(in) :: this(:) !! 1D array\n real(r64) :: res !! median\n integer(i32), allocatable :: i(:)\n integer(i32) :: iMed\n integer(i32) :: N\n\n integer(i32) :: iTmp\n\n N=size(this)\n call allocate(i,N)\n call arange(i,1,N)\n\n if (mod(N,2)==0) then\n iMed = N/2\n call argSelect(this, i, iMed, iTmp)\n res=this(iTmp)\n call arange(i,1,N)\n call argSelect(this, i, iMed+1, iTmp)\n res=0.5d0*(res+this(iTmp))\n else\n iMed=N/2 + 1\n call argSelect(this, i, iMed, iTmp)\n res = this(iTmp)\n end if\n\n deallocate(i)\n end function\n !====================================================================!\n !====================================================================!\n module procedure norm1_d1D\n !! interface with norm1()\n !====================================================================!\n !module function norm1_d1D(this) result(res)\n !real(r64) :: this(:)\n !real(r64) :: res\n res=sum(abs(this))\n end procedure\n !====================================================================!\n !====================================================================!\n module procedure normI_d1D\n !! interface with normI()\n !====================================================================!\n !module function normI_d1D(this) result(res)\n !real(r64) :: this(:)\n !real(r64) :: res\n res=maxval(abs(this))\n end procedure\n !====================================================================!\n! !====================================================================!\n! module procedure normP_d1D\n! !! Interfaced with normP\n! !====================================================================!\n! !module function normP_d1D(this, p) result(res)\n! !real(r64) :: this(:)\n! !real(r64) :: p\n! !real(r64) :: res\n!\n! end procedure\n! !====================================================================!\n !====================================================================!\n module function project_d1D(a,b) result(c)\n !====================================================================!\n !! Interfaced with project()\n real(r64),intent(in) :: a(:) !! 1D array\n real(r64),intent(in) :: b(size(a)) !! 1D array\n real(r64) :: c(size(a)) !! 1D array\n real(r64) :: c1\n ! Magnitude of b^2\n c1=norm2(b)**2.d0\n if (c1 == 0.0) then\n c=0.d0\n return\n end if\n c=b/c1\n ! Dot a onto b hat\n c1=dot_product(a,b)\n ! Multiply projected length by b hat\n c=c1*c\n end function\n !====================================================================!\n !====================================================================!\n module procedure trimmedmean_d1D\n !====================================================================!\n !function trimmedmean_d1D(this,alpha) result(res)\n !real(r64) :: this(:)\n !real(r64) :: alpha\n !real(r64) :: res\n integer(i32) :: istat\n integer(i32) :: j\n integer(i32) :: N\n integer(i32) :: tmp\n integer(i32), allocatable :: i(:)\n real(r64) :: alpha_\n\n real(r64), allocatable :: rTmp(:)\n\n N=size(this)\n alpha_=alpha*0.01d0\n ! Test the percentage\n if (alpha_ <= 0.d0) then\n res=Mean(this)\n return\n elseif (alpha_ >= 0.5d0) then\n call eMsg('trimmedmean:alpha >= 50% does not make sense')\n endif\n ! Calculate the number of integers that make up the trimmed percentage\n tmp=idnint(alpha_*dble(N))\n\n ! Set the indices into the vector\n call allocate(i, N)\n call arange(i, 1, N)\n\n ! Sort the vector\n call argSort(this,i)\n\n call allocate(rTmp, N-(2*tmp))\n rTmp =this(i(tmp+1:N-tmp))\n res=mean(rTmp)\n call deallocate(i)\n call deallocate(rTmp)\n end procedure\n !====================================================================!\n !====================================================================!\n module procedure std_d1D\n !! Interfaced with std()\n !====================================================================!\n !real(r64) :: this(:)\n !real(r64) :: res\n res=dsqrt(Variance(this))\n end procedure\n !====================================================================!\n !====================================================================!\n module procedure variance_d1D\n !! Interfaced with variance()\n !====================================================================!\n !real(r64) :: this(:)\n !real(r64) :: res\n real(r64) :: tmp\n real(r64), allocatable :: rTmp(:)\n tmp=Mean(this)\n call allocate(rTmp, size(this))\n rTmp = this - tmp\n rTmp = rTmp ** 2.d0\n res=sum(rTmp)/dble(size(this)-1)\n call deallocate(rTmp)\n end procedure\n !====================================================================!\nend submodule\n", "meta": {"hexsha": "dd12f647674c4ee4423950af51f8623c600e73dc", "size": 7433, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/maths/sm_maths_d1D.f90", "max_stars_repo_name": "leonfoks/coretran", "max_stars_repo_head_hexsha": "bf998d4353badc91d3a12d23c78781c8377b9578", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 72, "max_stars_repo_stars_event_min_datetime": "2017-10-20T15:19:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T11:17:43.000Z", "max_issues_repo_path": "src/maths/sm_maths_d1D.f90", "max_issues_repo_name": "leonfoks/coretran", "max_issues_repo_head_hexsha": "bf998d4353badc91d3a12d23c78781c8377b9578", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 25, "max_issues_repo_issues_event_min_datetime": "2017-10-20T15:54:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T09:45:01.000Z", "max_forks_repo_path": "src/maths/sm_maths_d1D.f90", "max_forks_repo_name": "leonfoks/coretran", "max_forks_repo_head_hexsha": "bf998d4353badc91d3a12d23c78781c8377b9578", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2018-02-20T15:07:38.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-10T17:58:00.000Z", "avg_line_length": 33.7863636364, "max_line_length": 73, "alphanum_fraction": 0.388133997, "num_tokens": 1798, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9621075711974104, "lm_q2_score": 0.9046505293168445, "lm_q1q2_score": 0.870371123543481}}
{"text": " program matrix02\n!\n! USAGE:\n! ./matrix02.exe <n>\n!\n! ABOUT:\n! This program reads a size n from the command line, fills two (n x n)\n! matrices with random numbers, and evaluates the matrix product using\n! explicit loops. The program tracks the time taken for the\n! multiplication steps and reports is at the end.\n!\n!\n! AUTHOR:\n! H. P. Hratchian, 2020.\n!\n!\n! Variable Declarations\n!\n implicit none\n integer::n,i,j,k\n integer,parameter::iOut=6\n real::tStart,tEnd\n real,dimension(:,:),allocatable::A,B,C\n character(len=256)::commandLineArg\n logical::fail=.false.\n!\n 1000 Format('Loop ',I1,': n = ',I10,' Job Time: ',F10.3,' s.')\n 9000 Format('Failure reading command line arguments...incorrect number.')\n 9999 Format('The program FAILED!')\n!\n! Read the user-specified matrix dimension, n, from the command line.\n!\n if(COMMAND_ARGUMENT_COUNT().ne.1) then\n write(iOut,9000)\n fail = .true.\n goto 999\n endIf\n call GET_COMMAND_ARGUMENT(1,commandLineArg)\n read(commandLineArg,*) n\n!\n! Allocate matrices A, B, and C. Then, fill A and B with random numbers.\n!\n Allocate(A(n,n),B(n,n),C(n,n))\n call random_number(A)\n call random_number(B)\n C = 0\n!\n! Carry out matrix multiplication using explicit nested loops.\n!\n call CPU_TIME(tStart)\n do i = 1,n\n do j = 1,n\n do k = 1,n\n C(i,j) = C(i,j) + A(i,k)*B(k,j)\n endDo\n endDo\n endDo\n call CPU_TIME(tEnd)\n write(iOut,1000) 1,n,tEnd-tStart\n!\n! Carry out matrix multiplication using explicit nested loops, using\n! approach 2.\n!\n C = 0\n call CPU_TIME(tStart)\n do k = 1,n\n do i = 1,n\n do j = 1,n\n C(i,j) = C(i,j) + A(i,k)*B(k,j)\n endDo\n endDo\n endDo\n call CPU_TIME(tEnd)\n write(iOut,1000) 2,n,tEnd-tStart\n!\n! Carry out matrix multiplication using explicit nested loops, using\n! approach 3.\n!\n C = 0\n call CPU_TIME(tStart)\n do k = 1,n\n do j = 1,n\n do i = 1,n\n C(i,j) = C(i,j) + A(i,k)*B(k,j)\n endDo\n endDo\n endDo\n call CPU_TIME(tEnd)\n write(iOut,1000) 3,n,tEnd-tStart\n!\n 999 if(fail) write(iOut,9999)\n end program matrix02\n", "meta": {"hexsha": "08188b386c273bae341ba02a33caf7fe661d0cb8", "size": 2340, "ext": "f03", "lang": "FORTRAN", "max_stars_repo_path": "Exercises_Workshop2/ProblemSet03-MatrixMultOpt/SolutionCodes/matrix02.f03", "max_stars_repo_name": "MQCPack/summerCodingWorkshop", "max_stars_repo_head_hexsha": "77989f555497c14711c4aa1817540fdc3131eee4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-06-29T16:24:28.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-29T16:24:28.000Z", "max_issues_repo_path": "Exercises_Workshop2/ProblemSet03-MatrixMultOpt/SolutionCodes/matrix02.f03", "max_issues_repo_name": "MQCPack/summerCodingWorkshop", "max_issues_repo_head_hexsha": "77989f555497c14711c4aa1817540fdc3131eee4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Exercises_Workshop2/ProblemSet03-MatrixMultOpt/SolutionCodes/matrix02.f03", "max_forks_repo_name": "MQCPack/summerCodingWorkshop", "max_forks_repo_head_hexsha": "77989f555497c14711c4aa1817540fdc3131eee4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-06-26T21:05:45.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-26T21:05:45.000Z", "avg_line_length": 25.1612903226, "max_line_length": 76, "alphanum_fraction": 0.5700854701, "num_tokens": 699, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465080392795, "lm_q2_score": 0.9304582569404568, "lm_q1q2_score": 0.8703008815055711}}
{"text": "module integrals\n !! module for computing integrals\n implicit none\ncontains\n\n function trapz(x,y) result(Int)\n !! Aproximates the integral of the function\n !! $$ y = f(x)$$\n !! given a set of points:\n !! $$(x_i,y_i)$$\n !! using the trapezoidal rule.\n !! The points do not need to be linearly spaced along the\n !! integration domain.\n real, intent(in) :: x(0:)\n !! Array containing the abscissas of the points\n real, intent(in) :: y(0:)\n !! Array containing the ordinates of the points\n real :: Int\n !! Numerical aproximation to the integral\n\n integer :: i, N\n\n N = ubound(x,1)\n Int = 0.\n do i = 1,N\n Int = Int + (y(i-1)+y(i))/2*(x(i)-x(i-1))\n end do\n end function\n\n\n\n\n function quad_trapz(f,a,b,h_in) result(Int)\n !! Approximates the integral:\n !! $$ \\int_{a}^{b}f\\left(x\\right)\\,\\mathrm{d}x$$\n !! using the trapezoidal rule on a linearly spaced\n !! set of points.\n interface\n function f(x) result(y)\n !! Function to be integrated\n real, intent(in) :: x\n !! independent variable\n real :: y\n !! dependent variable\n end function\n end interface\n real, intent(in) :: a\n !! Lower limit of integration\n real, intent(in) :: b\n !! Upper limit of integration\n real, intent(in) :: h_in\n !! Approximated size of the intervals used by the trapezoidal rule.\n real :: Int\n !! Numerical approximation to the integral\n\n integer :: i, N\n real :: h, x_l, x_r\n\n ! imposing that h must divide (b-a) in a whole number\n ! of intervals\n N = ceiling((b-a)/h_in)\n h = (b-a)/N\n\n Int = 0.\n do i=1,N\n x_l = (i-1)*h\n x_r = i*h\n Int = Int + (f(x_l)+f(x_r))/2\n end do\n Int = Int*h\n end function\n\n\nfunction quad_simpson(f,a,b,h_in) result(Int)\n !! Approximates the integral:\n !! $$ \\int_{a}^{b}f\\left(x\\right)\\,\\mathrm{d}x$$\n !! using Simpson's rule on a linearly spaced\n !! set of points.\n interface\n function f(x) result(y)\n !! Function to be integrated\n real, intent(in) :: x\n !! independent variable\n real :: y\n !! dependent variable\n end function\n end interface\n real, intent(in) :: a\n !! Lower limit of integration\n real, intent(in) :: b\n !! Upper limit of integration\n real, intent(in) :: h_in\n !! Approximated size of the intervals used by the trapezoidal rule.\n real :: Int\n !! Numerical approximation to the integral\n\n integer :: i, N\n real :: h, x_l, x_m, x_r\n\n ! imposing that h must divide (b-a) in an even number\n ! of intervals\n N = ceiling((b-a)/h_in)\n if(modulo(N,2)==1) N = N+1\n h = (b-a)/N\n\n Int = 0.\n do i=1,N,2\n x_l = (i-1)*h\n x_m = i*h\n x_r = (i+1)*h\n Int = Int + (f(x_l)+4*f(x_m)+f(x_r))/3\n end do\n Int = Int*h\nend function\n\n\nfunction quad(f,a,b,h_in,method) result(Int)\n !! Approximates the integral:\n !! $$ \\int_{a}^{b}f\\left(x\\right)\\,\\mathrm{d}x$$\n !! using some integration method on a linearly spaced\n !! set of points.\n interface\n function f(x) result(y)\n !! Function to be integrated\n real, intent(in) :: x\n !! independent variable\n real :: y\n !! dependent variable\n end function\n end interface\n real, intent(in) :: a\n !! Lower limit of integration\n real, intent(in) :: b\n !! Upper limit of integration\n real, intent(in) :: h_in\n !! Approximated size of the intervals used by the trapezoidal rule.\n character(*) :: method\n !! Method of integration to be used, can be either \"Trapezoidal\" or \"Simpson\"\n real :: Int\n !! Numerical approximation to the integral\n select case (method)\n case (\"Trapezoidal\")\n Int = quad_trapz(f,a,b,h_in)\n case (\"Simpson\")\n Int = quad_simpson(f,a,b,h_in)\n case default\n print*, 'Integration method \"'//method//'\"\" not recognised,'\n print*, 'please choose between \"Trapezoidal\" and \"Simpson\"'\n end select\nend function\nend module\n", "meta": {"hexsha": "7c0061638aa9da08b3a8fe5ee0639816cb2e2a26", "size": 3883, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/integrals.f90", "max_stars_repo_name": "MPenaR/NumericalMethods", "max_stars_repo_head_hexsha": "b3a46676d762d749c9d278efe4c98f41d3886a4b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-20T01:52:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-20T01:52:07.000Z", "max_issues_repo_path": "docs/src/integrals.f08", "max_issues_repo_name": "MPenaR/NumericalMethods", "max_issues_repo_head_hexsha": "b3a46676d762d749c9d278efe4c98f41d3886a4b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-03-19T22:17:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-07T17:57:58.000Z", "max_forks_repo_path": "src/integrals.f90", "max_forks_repo_name": "MPenaR/NumericalMethods", "max_forks_repo_head_hexsha": "b3a46676d762d749c9d278efe4c98f41d3886a4b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.5460526316, "max_line_length": 79, "alphanum_fraction": 0.6090651558, "num_tokens": 1187, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422227627597, "lm_q2_score": 0.914900957313305, "lm_q1q2_score": 0.8702009301467537}}
{"text": "SUBROUTINE matrix_inv3 (R1, Rinv)\r\n\r\n\r\n! ----------------------------------------------------------------------\r\n! SUBROUTINE: matrix_inv3.f90\r\n! ----------------------------------------------------------------------\r\n! Purpose:\r\n! 3x3 Matrix inversion\r\n! ----------------------------------------------------------------------\r\n! Input arguments:\r\n! - R1: \t\t\tArray 3x3\r\n!\r\n! Output arguments:\r\n! - Rinv : \t\t\tInverse matrix of input matrix 3x3\r\n! ----------------------------------------------------------------------\r\n! Thomas D. Papanikolaou, Geoscience Australia 30 June 2016\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n USE mdl_precision\r\n IMPLICIT NONE\r\n\r\n! ---------------------------------------------------------------------------\r\n! Dummy arguments declaration\r\n! ---------------------------------------------------------------------------\r\n! IN\r\n REAL (KIND = prec_q), INTENT(IN) :: R1(3,3)\r\n! OUT\r\n REAL (KIND = prec_q), INTENT(OUT) :: Rinv(3,3)\r\n! ---------------------------------------------------------------------------\r\n\r\n! ----------------------------------------------------------------------\r\n! Local variables declaration\r\n! ----------------------------------------------------------------------\r\n REAL (KIND = prec_q) :: Det_R\r\n REAL (KIND = prec_q) :: Cof_R(3,3), Adj_R(3,3)\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n! ----------------------------------------------------------------------\r\n! Determinant of R1\r\n Det_R = R1(1,1) * (R1(2,2)*R1(3,3) - R1(2,3)*R1(3,2)) & \r\n\t - R1(1,2) * (R1(2,1)*R1(3,3) - R1(2,3)*R1(3,1)) &\r\n\t + R1(1,3) * (R1(2,1)*R1(3,2) - R1(2,2)*R1(3,1))\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n! ----------------------------------------------------------------------\r\n! Cofactor matrix\r\n Cof_R(1,1) = ( R1(2,2)*R1(3,3) - R1(2,3)*R1(3,2) )\r\n Cof_R(1,2) = -1.0D0 * ( R1(2,1)*R1(3,3) - R1(2,3)*R1(3,1) )\r\n Cof_R(1,3) = ( R1(2,1)*R1(3,2) - R1(2,2)*R1(3,1) )\r\n\t \r\n Cof_R(2,1) = -1.0D0 * ( R1(1,2)*R1(3,3) - R1(1,3)*R1(3,2) )\r\n Cof_R(2,2) = ( R1(1,1)*R1(3,3) - R1(1,3)*R1(3,1) )\r\n Cof_R(2,3) = -1.0D0 * ( R1(1,1)*R1(3,2) - R1(1,2)*R1(3,1) )\r\n\r\n Cof_R(3,1) = ( R1(1,2)*R1(2,3) - R1(1,3)*R1(2,2) )\r\n Cof_R(3,2) = -1.0D0 * ( R1(1,1)*R1(2,3) - R1(1,3)*R1(2,1) )\r\n Cof_R(3,3) = ( R1(1,1)*R1(2,2) - R1(1,2)*R1(2,1) )\r\n! ----------------------------------------------------------------------\r\n\r\n\t \r\n! ----------------------------------------------------------------------\r\n! Adjoint matrix\r\n Adj_R = transpose (Cof_R)\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n! ----------------------------------------------------------------------\r\n! Inverse matrix\r\n Rinv = (1.0D0 / Det_R) * Adj_R\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n\r\nEND\r\n\r\n", "meta": {"hexsha": "18b2c75c6b57f423e1d7cd330a4f84d08c745813", "size": 3025, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/fortran/matrix_inv3.f90", "max_stars_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_stars_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 73, "max_stars_repo_stars_event_min_datetime": "2021-07-08T23:35:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T15:17:58.000Z", "max_issues_repo_path": "src/fortran/matrix_inv3.f90", "max_issues_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_issues_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-09-27T14:27:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T23:50:02.000Z", "max_forks_repo_path": "src/fortran/matrix_inv3.f90", "max_forks_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_forks_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2021-07-12T05:42:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T15:15:34.000Z", "avg_line_length": 38.2911392405, "max_line_length": 78, "alphanum_fraction": 0.2525619835, "num_tokens": 865, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9766692332287863, "lm_q2_score": 0.8902942144788076, "lm_q1q2_score": 0.8695229678030416}}
{"text": "program problem_21\n implicit none\n integer :: divisorsSum, i, total\n logical :: areAmicable\n\n total = 0\n do i = 1, 10000\n if (areAmicable(i, divisorsSum(i))) then\n total = total + i\n endif\n enddo\n\n print *, total\n\nend program problem_21\n\ninteger function divisorsSum(number) result(total)\n implicit none\n integer :: number, i\n total = 0\n\n do i = 1, number / 2\n if (modulo(number, i) .EQ. 0) then\n total = total + i\n endif\n enddo\nend function divisorsSum\n\nlogical function areAmicable(a, b) result(decision)\n implicit none\n integer :: a, b, divisorsSum\n \n if ((divisorsSum(a) .EQ. b) .AND. (divisorsSum(b) .EQ. a) .AND. (a .NE. b)) then\n decision = .TRUE.\n else\n decision = .FALSE.\n endif\nend function areAmicable\n", "meta": {"hexsha": "680a88e1b00aee3004440643ec3b8692a575b624", "size": 831, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "Problem_21/main.f95", "max_stars_repo_name": "jdalzatec/EulerProject", "max_stars_repo_head_hexsha": "2f2f4d9c009be7fd63bb229bb437ea75db77d891", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-03-28T05:32:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T05:32:58.000Z", "max_issues_repo_path": "Problem_21/main.f95", "max_issues_repo_name": "jdalzatec/EulerProject", "max_issues_repo_head_hexsha": "2f2f4d9c009be7fd63bb229bb437ea75db77d891", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Problem_21/main.f95", "max_forks_repo_name": "jdalzatec/EulerProject", "max_forks_repo_head_hexsha": "2f2f4d9c009be7fd63bb229bb437ea75db77d891", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.3076923077, "max_line_length": 84, "alphanum_fraction": 0.5944645006, "num_tokens": 250, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9566341975270266, "lm_q2_score": 0.9086179049750475, "lm_q1q2_score": 0.8692149603844926}}
{"text": "! Number F(46) is the highest allowed for integer(kind=4). The next number,\n! F(47) creates an integer overflow and produces a negative result.\n!\n! To test yourself, get the table of F(i) values from here:\n!\n! https://oeis.org/A000045/b000045.txt\n!\nprogram fibonacci_sequential\n implicit none\n integer :: i\n\n print '(a)', \"Enter index `i` for the Fibonacci sequence\"\n read *, i\n print '(2(a, i0))', \"F(\", i, \") = \", fib_seq(i)\ncontains\n function fib_seq(n)\n integer :: fib_seq\n integer, intent(in) :: n\n integer :: j, f_pp, f_p, f\n\n f_pp = 0\n f_p = 1\n do j = 2, n\n f = f_p + f_pp\n f_pp = f_p\n f_p = f\n end do\n fib_seq = f\n return\n end function fib_seq\nend program fibonacci_sequential\n", "meta": {"hexsha": "5bc5325e8dd0c05f6cfdb51b866ed623ebd22740", "size": 810, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Lecture_04/homework/fibonacci_sequental/fibonacci_sequental.f90", "max_stars_repo_name": "avsukhorukov/TdP2021-22", "max_stars_repo_head_hexsha": "dd3adf2ece93bcd685912614b848c5dddbcdf6de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture_04/homework/fibonacci_sequental/fibonacci_sequental.f90", "max_issues_repo_name": "avsukhorukov/TdP2021-22", "max_issues_repo_head_hexsha": "dd3adf2ece93bcd685912614b848c5dddbcdf6de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture_04/homework/fibonacci_sequental/fibonacci_sequental.f90", "max_forks_repo_name": "avsukhorukov/TdP2021-22", "max_forks_repo_head_hexsha": "dd3adf2ece93bcd685912614b848c5dddbcdf6de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3125, "max_line_length": 76, "alphanum_fraction": 0.5703703704, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067179697695, "lm_q2_score": 0.9219218396818157, "lm_q1q2_score": 0.8689175273431602}}
{"text": "program main_bisection\n implicit none\n real x1,x2,x,eps,xcosx \n external xcosx\n integer ind \n x1=0\n x2=3.14\n eps=1e-7\n call bisection(xcosx,x1,x2,x,eps,ind)\n if (ind>=0) then \n print *,'X= ',x,xcosx(x),ind\n else if (ind==-1) then \n print *,'f(x1)*f(x2) must be less than 0'\n else \n print *,'No Convergence'\n endif\nend program main_bisection\n\nfunction xcosx(x)\n real xcosx,x\n xcosx = x-cos(x)\nend function xcosx\n\nsubroutine bisection(func,x10,x20,x,eps,ind)\n implicit none\n real func,x10,x20,x,eps,x1,x2,y1,y2,xm,ym\n external func \n integer ind,it \n integer, parameter :: itmax=100000000\n\n x1=x10\n x2=x20 \n y1=func(x1)\n y2=func(x2)\n ind=0\n if(y1==0) then \n x=x1\n return \n else if (y2==0) then \n x=x2\n return \n else if(y1*y2>0) then \n ind=-1\n return \n endif \n\n do it = 1, itmax \n xm=(x1+x2)/2\n ym=func(xm)\n if(ym==0) then \n x=xm\n exit \n endif\n if(ym*y1<0) then\n x2=xm \n y2=ym \n else \n x1=xm\n y1=ym\n endif\n if(abs(x2-x1)<eps) then \n x=xm\n exit \n endif \n enddo\n\n if(it>itmax) then \n ind=-itmax \n else \n ind=it \n endif \n \nend subroutine bisection", "meta": {"hexsha": "3a4dcb3c946c0911d604739c751c224bfde16ec2", "size": 1371, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "90and95/solveNonLinear/xcosx/bisection.f90", "max_stars_repo_name": "terasakisatoshi/Fortran", "max_stars_repo_head_hexsha": "f2d7c94ad7a7efcd6545800b54674452d45a98f3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "90and95/solveNonLinear/xcosx/bisection.f90", "max_issues_repo_name": "terasakisatoshi/Fortran", "max_issues_repo_head_hexsha": "f2d7c94ad7a7efcd6545800b54674452d45a98f3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "90and95/solveNonLinear/xcosx/bisection.f90", "max_forks_repo_name": "terasakisatoshi/Fortran", "max_forks_repo_head_hexsha": "f2d7c94ad7a7efcd6545800b54674452d45a98f3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.7808219178, "max_line_length": 49, "alphanum_fraction": 0.5010940919, "num_tokens": 481, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9518632288833652, "lm_q2_score": 0.9124361682155117, "lm_q1q2_score": 0.8685144372275823}}
{"text": "module chebyshev_mod\n\nuse constants\n\ncontains\n function chebT (n,x)\n\n implicit none\n\n integer, intent(in) :: n\n real, intent(in) :: x\n real :: chebT\n \n if(abs(x)>1) then\n write(*,*) 'ERROR: chebT arg abs(x)>1', x\n endif\n\n if(x==1.0)then\n chebT = 1\n elseif(x==-1.0)then\n chebT = (-1)**n \n else\n !chebT = ( ( x - sqrt ( x**2 - 1 ) )**n &\n ! + ( x + sqrt ( x**2 - 1 ) )**n ) / 2d0\n chebT = cos ( n * acos(x) )\n endif\n\n\n end function chebT\n \n\n function chebU (n,x)\n \n implicit none\n\n integer, intent(in) :: n\n real, intent(in) :: x\n real(kind=dbl) :: chebU\n \n if(x==1.0) then\n chebU = n + 1\n elseif(x==-1.0) then\n chebU = (n+1) * (-1)**n\n else\n \n !chebU = ( ( x + sqrt ( x**2 - 1 ) )**(n+1) &\n ! - ( x - sqrt ( x**2 - 1 ) )**(n+1) ) &\n ! / ( 2d0 * sqrt ( x**2 - 1 ) )\n\n chebU = sin ( (n+1) * acos(x) ) / sin ( acos(x) )\n\n endif\n\n \n end function chebU\n\nend module chebyshev_mod\n", "meta": {"hexsha": "84cd736614a874c7e2f2220aa7c9dea18e81d2da", "size": 1179, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/chebyshev_mod.f90", "max_stars_repo_name": "efdazedo/aorsa2d", "max_stars_repo_head_hexsha": "ce0b8c930715277eeb4d23e60cc88434ffdaa583", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 5, "max_stars_repo_stars_event_min_datetime": "2018-02-13T21:57:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-10T16:47:51.000Z", "max_issues_repo_path": "src/chebyshev_mod.f90", "max_issues_repo_name": "efdazedo/aorsa2d", "max_issues_repo_head_hexsha": "ce0b8c930715277eeb4d23e60cc88434ffdaa583", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2018-02-23T20:33:30.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-23T20:34:31.000Z", "max_forks_repo_path": "src/chebyshev_mod.f90", "max_forks_repo_name": "efdazedo/aorsa2d", "max_forks_repo_head_hexsha": "ce0b8c930715277eeb4d23e60cc88434ffdaa583", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2018-02-15T16:50:58.000Z", "max_forks_repo_forks_event_max_datetime": "2018-06-23T14:07:59.000Z", "avg_line_length": 20.3275862069, "max_line_length": 63, "alphanum_fraction": 0.3893129771, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9566341999997378, "lm_q2_score": 0.9073122163480667, "lm_q1q2_score": 0.8679658962361217}}
{"text": "! =====================================================================\n! function FACTORIAL\n!\n! factorial is an function that recursively computes the value of the \n! factorial of integer n.\n! --------------------------------------------------------------------- \n INTEGER RECURSIVE FUNCTION factorial ( n ) RESULT ( nFactorial )\n\n IMPLICIT NONE\n\n INTEGER, INTENT ( IN ) :: n\n\n nFactorial = 0\n\n IF ( n == 0 ) THEN\n\n nFactorial = 1\n\n ELSE IF ( n >= 1 .AND. n <= 12 ) THEN\n\n nFactorial = n * factorial ( n - 1 )\n\n ELSE\n\n nFactorial = -1\n WRITE ( UNIT = 6 , FMT = * ) 'math : factorial :: &\n & ERROR - n must be an integer greater than or equal to 0, &\n & but less than or equal to 12 because KIND ( n ) may be a &\n & 32-bit integer.'\n STOP\n\n END IF\n\n RETURN\n END FUNCTION\n! =====================================================================\n", "meta": {"hexsha": "dd9efbdd78552625c103e0af3f90d5307cf13635", "size": 966, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "source/factorial.f", "max_stars_repo_name": "mkandes/itpprp", "max_stars_repo_head_hexsha": "d30f4fc0b05822a34fef187688ab12245cbbf93a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "source/factorial.f", "max_issues_repo_name": "mkandes/itpprp", "max_issues_repo_head_hexsha": "d30f4fc0b05822a34fef187688ab12245cbbf93a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/factorial.f", "max_forks_repo_name": "mkandes/itpprp", "max_forks_repo_head_hexsha": "d30f4fc0b05822a34fef187688ab12245cbbf93a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.1081081081, "max_line_length": 72, "alphanum_fraction": 0.4161490683, "num_tokens": 215, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9489172587090974, "lm_q2_score": 0.9136765287024915, "lm_q1q2_score": 0.8670034269632122}}
{"text": "program main\nuse calculates\nimplicit none\n\nreal(kind=8), dimension(3,3) :: A, A_work\nreal(kind=8), dimension(3) :: B, X, Y\nreal(kind=8) :: det_A, det_A_work, test, test2\ninteger :: i, j, k, l\n\n! assign values:\n\nA = reshape( (/2, 7, 2, 7, 3, 4, 3, 9, 6/) , (/3,3/))\nwrite(*,*) \"Matrix A:\"\ncall writes(A)\n\nB = (/10, 11, 6/)\n\nY = (/0.0495, 1.3465, 0.1584/)\nwrite(*,'(A12,3F8.3)') \"Vector B:\", B\nwrite(*,*)\n\ndet_A = determinant(A)\n\nwrite(*,*) \"det_A:\", det_A\nwrite(*,*)\n\n! Find x:\n \ndo i = 1, 3\n write(*,*) \"---------------------------------------------\"\n write(*,'(A15,I5)') \"iteration:\", i\n write(*,*) \"---------------------------------------------\"\n ! make A and A_work equal:\n do k = 1, 3\n do l = 1, 3\n A_work(k,l) = A(k,l)\n end do\n end do\n write(*,*) \"working array before column change\"\n call writes(A_work)\n !substitute the ith column of b in A_work:\n do j = 1, 3\n A_work(j,i) = B(j)\n end do\n write(*,*) \"working array after column change\"\n call writes(A_work)\n det_A_work = determinant(A_work)\n write(*,*) \"determinant of the working array:\", det_A_work\n write(*,*)\n X(i) = det_A_work/det_A\n write(*,'(A5,I1,A3,F8.3)') \" X(\",i,\") \", X(i)\n write(*,*)\nend do\n\nwrite(*,*) \"---------------------------------------------\"\nwrite(*,'(A15)') \"solution:\"\nwrite(*,*) \"---------------------------------------------\"\nwrite(*,*)\nwrite(*,'(A12,3F8.3)') \"Vector X:\", X\nwrite(*,*)\n\n! Check solution:\n\ndo i = 1, 3\n test = 0.0d0\n test2 = 0.0d0\n do j = 1, 3\n test = test + A(i,j)*X(j)\n test2 = test2 + A(i,j)*Y(j)\n end do\n write(*,'(A14,I1,A13,F6.3,A9,F6.3,A9,F6.3)') \"check for row \", i, \" => AX(i): \", test, \" B(i): \", B(i), \" AY(i): \", test2\nend do\n\nend program main\n", "meta": {"hexsha": "2eb5c35bf3a938351137cbfe6fb933d5d8e9673d", "size": 1745, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "ME_Numerical_Methods/HW2/ex4/main.f95", "max_stars_repo_name": "ElenaKusevska/Fortran_exercises", "max_stars_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ME_Numerical_Methods/HW2/ex4/main.f95", "max_issues_repo_name": "ElenaKusevska/Fortran_exercises", "max_issues_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ME_Numerical_Methods/HW2/ex4/main.f95", "max_forks_repo_name": "ElenaKusevska/Fortran_exercises", "max_forks_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.2666666667, "max_line_length": 129, "alphanum_fraction": 0.4790830946, "num_tokens": 651, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9621075766298657, "lm_q2_score": 0.9005297941266013, "lm_q1q2_score": 0.8664065379101362}}
{"text": "!*******************************************************\r\n!* LU decomposition routines used by test_lu.f90 *\r\n!* *\r\n!* F90 version by J-P Moreau, Paris *\r\n!* --------------------------------------------------- *\r\n!* Reference: *\r\n!* *\r\n!* \"Numerical Recipes By W.H. Press, B. P. Flannery, *\r\n!* S.A. Teukolsky and W.T. Vetterling, Cambridge *\r\n!* University Press, 1986\" [BIBLI 08]. *\r\n!* * \r\n!*******************************************************\r\nMODULE LU\r\n\r\nCONTAINS\r\n\r\n! ***************************************************************\r\n! * Given an N x N matrix A, this routine replaces it by the LU *\r\n! * decomposition of a rowwise permutation of itself. A and N *\r\n! * are input. INDX is an output vector which records the row *\r\n! * permutation effected by the partial pivoting; D is output *\r\n! * as -1 or 1, depending on whether the number of row inter- *\r\n! * changes was even or odd, respectively. This routine is used *\r\n! * in combination with LUBKSB to solve linear equations or to *\r\n! * invert a matrix. Return code is 1, if matrix is singular. *\r\n! ***************************************************************\r\n Subroutine LUDCMP(A,N,INDX,D,CODE)\r\n PARAMETER(NMAX=200)\r\n REAL*16 AMAX,DUM, SUM, VV(NMAX)\r\n real*16 A(N,N)\r\n INTEGER CODE, D, INDX(N)\r\n real*16 TINY\r\n TINY = 1.0q-40\r\n\r\n D=1; CODE=0\r\n\r\n DO I=1,N\r\n AMAX=0.q0\r\n DO J=1,N\r\n IF (ABS(A(I,J)).GT.AMAX) AMAX=ABS(A(I,J))\r\n END DO ! j loop\r\n IF(AMAX.LT.TINY) THEN\r\n CODE = 1\r\n RETURN\r\n END IF\r\n VV(I) = 1.q0 / AMAX\r\n END DO ! i loop\r\n\r\n DO J=1,N\r\n DO I=1,J-1\r\n SUM = A(I,J)\r\n DO K=1,I-1\r\n SUM = SUM - A(I,K)*A(K,J) \r\n END DO ! k loop\r\n A(I,J) = SUM\r\n END DO ! i loop\r\n AMAX = 0.q0\r\n DO I=J,N\r\n SUM = A(I,J)\r\n DO K=1,J-1\r\n SUM = SUM - A(I,K)*A(K,J) \r\n END DO ! k loop\r\n A(I,J) = SUM\r\n DUM = VV(I)*ABS(SUM)\r\n IF(DUM.GE.AMAX) THEN\r\n IMAX = I\r\n AMAX = DUM\r\n END IF\r\n END DO ! i loop \r\n \r\n IF(J.NE.IMAX) THEN\r\n DO K=1,N\r\n DUM = A(IMAX,K)\r\n A(IMAX,K) = A(J,K)\r\n A(J,K) = DUM\r\n END DO ! k loop\r\n D = -D\r\n VV(IMAX) = VV(J)\r\n END IF\r\n\r\n INDX(J) = IMAX\r\n IF(ABS(A(J,J)) < TINY) A(J,J) = TINY\r\n\r\n IF(J.NE.N) THEN\r\n DUM = 1.q0 / A(J,J)\r\n DO I=J+1,N\r\n A(I,J) = A(I,J)*DUM\r\n END DO ! i loop\r\n END IF \r\n END DO ! j loop\r\n\r\n RETURN\r\n END subroutine LUDCMP\r\n\r\n\r\n! ******************************************************************\r\n! * Solves the set of N linear equations A . X = B. Here A is *\r\n! * input, not as the matrix A but rather as its LU decomposition, *\r\n! * determined by the routine LUDCMP. INDX is input as the permuta-*\r\n! * tion vector returned by LUDCMP. B is input as the right-hand *\r\n! * side vector B, and returns with the solution vector X. A, N and*\r\n! * INDX are not modified by this routine and can be used for suc- *\r\n! * cessive calls with different right-hand sides. This routine is *\r\n! * also efficient for plain matrix inversion. *\r\n! ******************************************************************\r\n Subroutine LUBKSB(A,N,INDX,B)\r\n implicit none\r\n REAL*16 SUM\r\n real*16 A(N,N), B(N)\r\n INTEGER INDX(N)\r\n integer II, I, LL, J, N\r\n\r\n II = 0\r\n\r\n DO I=1,N\r\n LL = INDX(I)\r\n SUM = B(LL)\r\n B(LL) = B(I)\r\n IF(II.NE.0) THEN\r\n DO J=II,I-1\r\n SUM = SUM - A(I,J)*B(J)\r\n END DO ! j loop\r\n ELSE IF(SUM.NE.0.q0) THEN\r\n II = I\r\n END IF\r\n B(I) = SUM\r\n END DO ! i loop\r\n\r\n DO I=N,1,-1\r\n SUM = B(I)\r\n IF(I < N) THEN\r\n DO J=I+1,N\r\n SUM = SUM - A(I,J)*B(J)\r\n END DO ! j loop\r\n END IF\r\n B(I) = SUM / A(I,I)\r\n END DO ! i loop\r\n\r\n RETURN\r\n END subroutine LUBKSB\r\n\r\nEND MODULE LU\r\n\r\n! end of file lu.f90\r\n", "meta": {"hexsha": "ecb0fec8c9eca56bcba9834d338b356a838e7c95", "size": 4003, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "P-Wave/Short/lu.f90", "max_stars_repo_name": "DentonW/Ps-H-Scattering", "max_stars_repo_head_hexsha": "943846d1deadbe99a98d2c2e26bcebf55986d8e7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-08-02T03:50:06.000Z", "max_stars_repo_stars_event_max_datetime": "2017-08-02T03:50:06.000Z", "max_issues_repo_path": "P-Wave/Short/lu.f90", "max_issues_repo_name": "DentonW/Ps-H-Scattering", "max_issues_repo_head_hexsha": "943846d1deadbe99a98d2c2e26bcebf55986d8e7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "P-Wave/Short/lu.f90", "max_forks_repo_name": "DentonW/Ps-H-Scattering", "max_forks_repo_head_hexsha": "943846d1deadbe99a98d2c2e26bcebf55986d8e7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-09-28T22:09:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-28T22:09:05.000Z", "avg_line_length": 27.6068965517, "max_line_length": 70, "alphanum_fraction": 0.4499125656, "num_tokens": 1195, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9449947117065458, "lm_q2_score": 0.9161096055730491, "lm_q1q2_score": 0.8657187326101009}}
{"text": "! ****************************************************************************\n! ... Module for variable types\n! ... COSMO Project\n! ... Quim Ballabrera, March 2017\n! ****************************************************************************\n\nMODULE constants\n\nUSE types, ONLY: sp,dp\n\nIMPLICIT NONE\n\nPRIVATE\nPUBLIC pi,e_,nan,inf,deg2rad,rad2deg,i_,dpi,hpi\nPUBLIC zero,one,half,two,ten,hundred\nPUBLIC nan4,inf4\nPUBLIC grav,Rearth,Omega\n\n! ... Mathematical constants\n! ...\nREAL(dp), PARAMETER :: zero = 0.0_dp\nREAL(dp), PARAMETER :: one = 1.0_dp\nREAL(dp), PARAMETER :: two = 2.0_dp\nREAL(dp), PARAMETER :: half = 0.5_dp\nREAL(dp), PARAMETER :: ten = 10.0_dp\nREAL(dp), PARAMETER :: hundred = 100.0_dp\nREAL(dp), PARAMETER :: pi = 3.1415926535897932384626433832795_dp\nREAL(dp), PARAMETER :: dpi = 2.0_dp*pi\nREAL(dp), PARAMETER :: hpi = 0.5_dp*pi\nREAL(dp), PARAMETER :: e_ = 2.7182818284590452353602874713527_dp\nREAL(dp), PARAMETER :: nan = 0.0_dp/0.0_dp\nREAL(dp), PARAMETER :: inf = 1.0_dp/0.0_dp\nREAL(DP), PARAMETER :: deg2rad = pi/180.0_dp\nREAL(DP), PARAMETER :: rad2deg = 180.0_dp/pi\nCOMPLEX(dp), PARAMETER :: i_ = (0.0_dp, 1.0_dp)\n\nREAL(sp), PARAMETER :: nan4 = 0.0_sp/0.0_sp\nREAL(sp), PARAMETER :: inf4 = 1.0_sp/0.0_sp\n\n! ... Physical constants\n! ...\nREAL(DP), PARAMETER :: grav = 9.80665_dp ! m / s^2\nREAL(DP), PARAMETER :: Rearth = 6371229.0_dp ! m\nREAL(DP), PARAMETER :: Omega = 7.292E-5_dp ! 1/s\n\nEND MODULE constants\n\n", "meta": {"hexsha": "578b11af93391b4caf6ee8411a5798a020cfaf9f", "size": 1550, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/lib/constants.f90", "max_stars_repo_name": "quimbp/system_dynamics", "max_stars_repo_head_hexsha": "366339d9f6fea2e4242f8a73b700f8ea0af07797", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-11-22T13:23:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-22T13:23:22.000Z", "max_issues_repo_path": "src/lib/constants.f90", "max_issues_repo_name": "quimbp/system_dynamics", "max_issues_repo_head_hexsha": "366339d9f6fea2e4242f8a73b700f8ea0af07797", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/lib/constants.f90", "max_forks_repo_name": "quimbp/system_dynamics", "max_forks_repo_head_hexsha": "366339d9f6fea2e4242f8a73b700f8ea0af07797", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.2916666667, "max_line_length": 78, "alphanum_fraction": 0.56, "num_tokens": 519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422241476944, "lm_q2_score": 0.9086179037377831, "lm_q1q2_score": 0.8642248538615707}}
{"text": "! This program solves Newton's equation for a block\n! sliding on a horizontal frictionless surface. The block\n! is tied to a wall with a spring, and Newton's equation\n! takes the form\n! m d^2x/dt^2 =-kx\n! with k the spring tension and m the mass of the block.\n! The angular frequency is omega^2 = k/m and we set it equal\n! 1 in this example program. \n! Newton's equation is rewritten as two coupled differential\n! equations, one for the position x and one for the velocity v\n! dx/dt = v and\n! dv/dt = -x when we set k/m=1\n! We use therefore a two-dimensional array to represent x and v\n! as functions of t\n! y[0] == x\n! y[1] == v\n! dy[0]/dt = v\n! dy[1]/dt = -x\n! The derivatives are calculated by the user defined function \n! derivatives.\n! The user has to specify the initial velocity (usually v_0=0)\n! the number of steps and the initial position. In the programme\n! below we fix the time interval [a,b] to [0,2*pi].\n!\n!\n!\n!\n! this is the number of differential equations as a global parameter\n\nMODULE parameters\n INTEGER, PARAMETER, PUBLIC :: number_differential_eqs =2 \nEND MODULE parameters\n!\n! Main function begins here \n!\nPROGRAM diff_solver\n USE constants\n USE parameters\n IMPLICIT NONE\n REAL(DP), DIMENSION(number_differential_eqs) :: y, dydt, yout\n REAL(DP) :: t, h, tmax, E0, initial_x, initial_v\n INTEGER :: i, number_of_steps\n\n ! read in the initial position, velocity and number of steps \n CALL initialise (initial_x, initial_v, number_of_steps)\n ! setting initial values, step size and max time tmax \n h = 2.0_dp*acos(-1.0_dp)/FLOAT(number_of_steps) ! the step size \n tmax = h*number_of_steps ! the final time \n y(1) = initial_x ! initial position \n y(2) = initial_v ! initial velocity \n t=0.0_dp ! initial time \n E0 = 0.5_dp*(y(1)**2+y(2)**2) ! the initial total energy\n ! now we start solving the differential equations using the RK4 method \n OPEN(6,FILE='outf.dat')\n yout = 0.0_dp; dydt = 0.0_dp\n DO WHILE (t <= tmax)\n ! initial derivatives \n CALL derivatives(t, y, dydt) \n ! here we call the runge-kutta method and get the new y-value in yout \n CALL runge_kutta_4(y, t, h,yout,dydt)\n y = yout \n t = t + h\n ! writing time, x, v, the exact solution, and the energy difference \n WRITE(6,'(5(E12.6,1X))') t, y(1), y(2), cos(t),0.5*(y(1)**2+y(2)**2)-E0\n ENDDO\n CLOSE (6)\n\nEND PROGRAM diff_solver\n!\n! this function sets up the derivatives for this special case \n!\nSUBROUTINE derivatives(t, y, dydt)\n USE constants\n USE parameters\n IMPLICIT NONE\n REAL(DP), DIMENSION(number_differential_eqs) :: y, dydt\n REAL(DP) :: t\n\n dydt(1)=y(2); ! derivative of x \n dydt(2)=-y(1); ! derivative of v \n\nEND SUBROUTINE derivatives\n!\n! The function initialise\n! Reads in from screen the air temp, the number of steps\n! final time and the initial temperature\n!\nSUBROUTINE initialise(initial_x, initial_v, number_of_steps)\n USE constants\n IMPLICIT NONE\n INTEGER, INTENT(OUT) :: number_of_steps\n REAL(DP), INTENT(OUT) :: initial_x, initial_v\n\n WRITE(*,*) ' Read in from screen intial x, initial v, and number of steps'\n READ(*,*) initial_x, initial_v, number_of_steps\n\nEND SUBROUTINE initialise\n!\n! Runge-kutta procedure \n!\nSUBROUTINE runge_kutta_4(y,x,diff_eq_step,yout,dydx)\n USE constants\n USE parameters\n IMPLICIT NONE\n REAL(DP), DIMENSION(number_differential_eqs) :: yt, dyt, dym\n REAL(DP), DIMENSION(number_differential_eqs), INTENT(IN) :: y, dydx\n REAL(DP), DIMENSION(number_differential_eqs), INTENT(OUT) :: yout\n REAL(DP) :: hh, h6, xh\n REAL(DP), INTENT(IN) :: x, diff_eq_step \n\n hh=diff_eq_step*0.5; h6=diff_eq_step/6. ; xh=x+hh\n ! first rk-step\n yt=y+hh*dydx\n CALL derivatives(xh,yt,dyt)\n ! second rk-step\n yt=y+hh*dyt\n CALL derivatives(xh,yt,dym)\n ! third rk-step\n yt=y+diff_eq_step*dym; dym=dyt+dym\n CALL derivatives(x+diff_eq_step,yt,dyt)\n ! fourth rk-step\n yout=y+h6*(dydx+dyt+2.*dym)\n\nEND SUBROUTINE runge_kutta_4\n\n", "meta": {"hexsha": "03eb82f94b244e527102838c69a210dd4a3796d9", "size": 4268, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "doc/Programs/LecturePrograms/programs/ODE/Fortran/program1.f90", "max_stars_repo_name": "kimrojas/ComputationalPhysicsMSU", "max_stars_repo_head_hexsha": "a47cfc18b3ad6adb23045b3f49fab18c0333f556", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 220, "max_stars_repo_stars_event_min_datetime": "2016-08-25T09:18:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:09:16.000Z", "max_issues_repo_path": "doc/Programs/LecturePrograms/programs/ODE/Fortran/program1.f90", "max_issues_repo_name": "dnhdang94/ComputationalPhysicsMSU", "max_issues_repo_head_hexsha": "16990c74cf06eb5b933982137f0536d669567259", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-01-18T10:43:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T13:15:42.000Z", "max_forks_repo_path": "doc/Programs/LecturePrograms/programs/ODE/Fortran/program1.f90", "max_forks_repo_name": "dnhdang94/ComputationalPhysicsMSU", "max_forks_repo_head_hexsha": "16990c74cf06eb5b933982137f0536d669567259", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 136, "max_forks_repo_forks_event_min_datetime": "2016-08-25T09:04:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T09:54:21.000Z", "avg_line_length": 33.873015873, "max_line_length": 95, "alphanum_fraction": 0.6445641987, "num_tokens": 1298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966747198241, "lm_q2_score": 0.9111797136297299, "lm_q1q2_score": 0.862519686994064}}
{"text": "module procedures\nimplicit none\ncontains\n\n!----------------------------\n! Function to solve:\n!----------------------------\n\nreal(kind=8) function g (x)\n real(kind=8), intent (in) :: x\n real(kind=8) :: m, k, c, A\n\n m = 2000.0d0\n k = 500.0d0\n c = 38*(10**(3))\n A = 0.2\n\n g = A*A*k*k - A*A*k*m*x*x + A*A*x*x*c*c - m*c*x*x*x\nend function g\n\n!----------------------------\n! Bisection routine:\n!----------------------------\n\nsubroutine BisectionRoot (Fun, a, b, ToolMax, Xs)\n\n real(kind=8), intent(in) :: ToolMax\n real(kind=8), intent(inout) :: a, b\n real(kind=8), intent(out) :: Xs\n interface\n real(kind=8) function Fun(x)\n real(kind=8), intent (in) :: x\n end function\n end interface\n real(kind=8) :: n, ConvergenceTest\n integer :: i\n\n ! Determine n; check if a and b are positioned properly:\n\n n = nint( (log10(b-a) - log10(ToolMax)) / log10(2.0d0) )\n write(*,'(A6F7.3)') \" n >= \", n\n\n if (Fun(a)*Fun(b) > 0) then\n write(*,*) \"f(a) and f(b) are not on opposite sides of the root. Cannot apply the bisection method \"\n stop\n end if\n\n !Solve the function:\n \n write(*,'(6A15)') \" iteration: \", \" a \", &\n \" b \", \"(xNS) Solution\", \" f(xNS) \", \" Tolerance \"\n \n i = 0\n ConvergenceTest = 10\n do while (ConvergenceTest > ToolMax)\n \n i = i + 1\n if (i > n + 50) then\n write(*,*) \"convergence could not be reached in the number of intervals)\"\n stop\n end if\n \n Xs = (a+b)/2.0d0\n if (Fun(a)*Fun(Xs) < -0.00000000001) then\n b = Xs\n else if (Fun(a)*Fun(Xs) > 0.00000000001) then\n a = Xs\n else\n ConvergenceTest = abs(Fun(Xs))\n write(*,'(A6,I2,A7,3F15.11,F15.2,F15.11)') \" \", i, \" \", a, b, Xs, Fun(Xs), ConvergenceTest\n write(*,*) \"convergence reached\"\n exit\n end if\n \n ConvergenceTest = abs(Fun(Xs))\n write(*,'(A6,I2,A7,3F15.11,F15.2,F15.4)') \" \", i, \" \", a, b, Xs, Fun(Xs), ConvergenceTest\n\n end do\n\nend subroutine BisectionRoot\n\nend module procedures\n", "meta": {"hexsha": "cf0d4354e3a5384126109064484578a8f279a447", "size": 2088, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "ME_Numerical_Methods/HW3/ex3/mod.f95", "max_stars_repo_name": "ElenaKusevska/Fortran_exercises", "max_stars_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ME_Numerical_Methods/HW3/ex3/mod.f95", "max_issues_repo_name": "ElenaKusevska/Fortran_exercises", "max_issues_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ME_Numerical_Methods/HW3/ex3/mod.f95", "max_forks_repo_name": "ElenaKusevska/Fortran_exercises", "max_forks_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.156626506, "max_line_length": 106, "alphanum_fraction": 0.5052681992, "num_tokens": 717, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067179697695, "lm_q2_score": 0.9149009474519223, "lm_q1q2_score": 0.8623002892503439}}
{"text": "module PI\n\n \n implicit none\n\n contains\n\n function factorial(n) result (y)\n integer, intent(in) :: n\n integer :: y\n \n integer :: i\n\n y = 1\n do i = 2, n\n y = y*i\n end do\n end function\n\n ! n should be less than 17, or it will overflow.\n function sint(n, x) result (y)\n integer, intent(in) :: n\n real, intent(in) :: x\n real :: y\n\n integer :: i\n real :: coeff\n y = x\n coeff = x\n do i = 3, n, 2\n coeff = -coeff*x*x\n !print *, i, coeff, factorial(i)\n y = y + coeff/factorial(i)\n end do\n end function\nend module PI\n\nprogram test\n \n use PI\n\n implicit none\n real, parameter :: PIC = 4*atan(1d0)\n real, parameter :: EVAL_MAX = 2*PIC\n integer, parameter :: EVAL_SEGMENTS = 200\n\n call evalSine()\n call compareSine()\n\n contains\n\n subroutine evalSine()\n integer :: i\n real :: x\n\n10 format(F16.9, F16.9)\n\n open(unit=10, file=\"sinx_Taylor_5.txt\", status=\"replace\")\n open(unit=11, file=\"sinx_Taylor_10.txt\", status=\"replace\")\n do i = 0, EVAL_SEGMENTS\n x = EVAL_MAX/EVAL_SEGMENTS*i\n write (10, 10), x, sint(5, x)\n write (11, 10), x, sint(10, x)\n end do\n close(10)\n close(11)\n end subroutine\n\n subroutine compareSine()\n integer :: i\n real, dimension(EVAL_SEGMENTS + 1) :: x, y5, y10\n real :: dummy\n\n open(unit=10, file=\"sinx_Taylor_5.txt\", status=\"old\")\n open(unit=11, file=\"sinx_Taylor_10.txt\", status=\"old\")\n do i = 1, EVAL_SEGMENTS + 1\n read (10, *), x(i), y5(i)\n read (11, *), dummy, y10(i)\n end do\n close(10)\n close(11)\n\n open(unit=12, file=\"sinx_Taylor_5_10_error.txt\", status=\"replace\")\n do i = 1, EVAL_SEGMENTS + 1\n write (12, \"(F12.6, F12.6)\"), x(i), y10(i) - y5(i)\n end do\n close(12)\n\n end subroutine\n\nend program\n\n", "meta": {"hexsha": "da014909051a841d7dabcc8323ce1809b6664231", "size": 2158, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "pi2.f90", "max_stars_repo_name": "CXuesong/LearnFortran", "max_stars_repo_head_hexsha": "1bf355ba83f4da48b921a9a54c61bcc178422266", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pi2.f90", "max_issues_repo_name": "CXuesong/LearnFortran", "max_issues_repo_head_hexsha": "1bf355ba83f4da48b921a9a54c61bcc178422266", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pi2.f90", "max_forks_repo_name": "CXuesong/LearnFortran", "max_forks_repo_head_hexsha": "1bf355ba83f4da48b921a9a54c61bcc178422266", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.2043010753, "max_line_length": 74, "alphanum_fraction": 0.4791473587, "num_tokens": 625, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693674025231, "lm_q2_score": 0.9073122119620789, "lm_q1q2_score": 0.8616466143706114}}
{"text": "C$Procedure GCD ( Greatest Common Divisor )\n \n INTEGER FUNCTION GCD ( A, B )\n \nC$ Abstract\nC\nC Return the greatest common divisor of two integers.\nC\nC$ Disclaimer\nC\nC THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE\nC CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.\nC GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE\nC ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE\nC PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED \"AS-IS\"\nC TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY\nC WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A\nC PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC\nC SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE\nC SOFTWARE AND RELATED MATERIALS, HOWEVER USED.\nC\nC IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA\nC BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT\nC LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,\nC INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,\nC REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE\nC REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.\nC\nC RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF\nC THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY\nC CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE\nC ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.\nC\nC$ Required_Reading\nC\nC None.\nC\nC$ Keywords\nC\nC MATH, NUMBERS\nC\nC$ Declarations\n \n INTEGER A\n INTEGER B\n \nC$ Brief_I/O\nC\nC VARIABLE I/O DESCRIPTION\nC -------- --- --------------------------------------------------\nC A I Any integer\nC B I Any integer\nC GCD I The greatest common divisor of A and B.\nC\nC$ Detailed_Input\nC\nC A An integer\nC\nC B An integer\nC\nC$ Detailed_Output\nC\nC GCD The greatest common divisor of A and B.\nC\nC$ Parameters\nC\nC None.\nC\nC$ Exceptions\nC\nC Error free.\nC\nC 1) If both A and B are zero, we return 0 as the GCD.\nC\nC 2) If exactly one of A and B is zero, then the GCD is by\nC definition the maximum of the absolute values of A and B.\nC\nC$ Particulars\nC\nC This routine uses Euclid's Algorithm to find the greatest common\nC divisor (GCD) of the integers A and B. In other words the\nC largest integer, G, such that A = k*G for some k and B = j*G for\nC some G. Note if either A or B is zero, then we return the\nC maximum of the two integers ABS(A) and ABS(B). If one is\nC non-zero we have just what the definition says. If both are zero\nC the definition above does not give us a GCD, so we take the GCD\nC of 0 and 0 to be 0.\nC\nC\nC$ Examples\nC\nC A B GCD\nC ----- ----- -----\nC 8 4 4\nC 120 44 4\nC 15 135 15\nC 101 97 1\nC 119 221 17\nC 144 81 9\nC 0 111 111\nC 0 0 0\nC\nC$ Restrictions\nC\nC None.\nC\nC$ Files\nC\nC None.\nC\nC$ Author_and_Institution\nC\nC W.L. Taber (JPL)\nC\nC$ Literature_References\nC\nC The Art of Computer Programming Vol 1. \"Fundamental Algorithms\"\nC by Donald Knuth\nC\nC$ Version\nC\nC- SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)\nC\nC Comment section for permuted index source lines was added\nC following the header.\nC\nC- SPICELIB Version 1.0.0, 31-JAN-1990 (WLT)\nC\nC-&\n \nC$ Index_Entries\nC\nC greatest common divisor\nC\nC-&\n \n \nC$ Revisions\nC\nC- Beta Version 1.0.1, 29-DEC-1988 (WLT)\nC\nC This revision simply cleared up questions regarding the input of\nC zeros to the routine.\nC\nC-&\n \nC\nC Local variables\nC\n INTEGER REMNDR\n INTEGER ABSA\n INTEGER ABSB\n INTEGER P\n INTEGER Q\n \n ABSA = ABS(A)\n ABSB = ABS(B)\n \n IF ( ABSA .GT. ABSB ) THEN\n P = ABSA\n Q = ABSB\n ELSE\n P = ABSB\n Q = ABSA\n END IF\n \n REMNDR = 1\n \n \n IF ( Q .NE. 0 ) THEN\n \n DO WHILE (REMNDR .NE. 0 )\n GCD = Q\n REMNDR = P - (P/Q)*Q\n P = Q\n Q = REMNDR\n END DO\n \n ELSE\n \n GCD = P\n \n END IF\n \n RETURN\n \n END\n", "meta": {"hexsha": "adb272a28d01f3c7abeffc1ea97916feed73152e", "size": 4500, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "source/nasa_f/gcd.f", "max_stars_repo_name": "agforero/FTFramework", "max_stars_repo_head_hexsha": "6caf0bc7bae8dc54a62da62df37e852625f0427d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-08-19T21:43:50.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-20T02:57:25.000Z", "max_issues_repo_path": "source/nasa_f/gcd.f", "max_issues_repo_name": "agforero/fortran-testing-framework", "max_issues_repo_head_hexsha": "6caf0bc7bae8dc54a62da62df37e852625f0427d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-08-07T21:17:16.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-09T02:18:07.000Z", "max_forks_repo_path": "source/nasa_f/gcd.f", "max_forks_repo_name": "agforero/fortran-testing-framework", "max_forks_repo_head_hexsha": "6caf0bc7bae8dc54a62da62df37e852625f0427d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-03-31T08:41:53.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T08:41:53.000Z", "avg_line_length": 23.9361702128, "max_line_length": 72, "alphanum_fraction": 0.5911111111, "num_tokens": 1350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9674102524151826, "lm_q2_score": 0.8902942319436397, "lm_q1q2_score": 0.8612797676483775}}
{"text": "\tSUBROUTINE GDIGIT ( ival, ibase, ndig, idigs, iret )\nC************************************************************************\nC* GDIGIT \t\t\t\t\t\t\t\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* This subroutine computes the individual digits of a decimal input\t*\nC* number in any arbitrary base.\t\t\t\t\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* The digits are ordered beginning with the one's digit; so, IDIGS (1) *\nC* is multiplied by IBASE**0 = 1, IDIGS (2) by IBASE**1, and so on, in *\nC* recovering the value in the new base.\t\t\t\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* GDIGIT ( IVAL, IBASE, NDIG, IDIGS, IRET )\t\t\t\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* Input parameters:\t\t\t\t\t\t\t*\nC*\tIVAL\t\tINTEGER\t\tInput decimal value\t\t*\nC*\tIBASE\t\tINTEGER\t\tBase for the output digits\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* Input and output parameter:\t\t\t\t\t\t*\nC*\tNDIG\t\tINTEGER\t\tInput: max # of digits allowed\t*\nC*\t\t\t\t\tOutput: # of digits needed\t*\nC*\t\t\t\t\t\t\t\t\t*\nC* Output parameters:\t\t\t\t\t\t\t*\nC*\tIDIGS (NDIG)\tINTEGER\t\tOutput digits\t\t\t*\nC*\tIRET\t\tINTEGER\t\tReturn code\t\t\t*\nC*\t\t\t\t\t 0 = normal return\t\t*\nC*\t\t\t\t\t -1 = base cannot be < 2\t*\nC*\t\t\t\t\t -2 = not enough digits\t\t*\nC*\t\t\t\t\t -3 = input value < 0\t\t*\nC**\t\t\t\t\t\t\t\t\t*\nC* Log:\t\t\t\t\t\t\t\t\t*\nC* K. Brill/HPC\t\t 8/99\t\t\t\t\t\t*\nC************************************************************************\n\tINTEGER\t\tidigs (*)\nC*\n\tDOUBLE PRECISION\tv, b\nC------------------------------------------------------------------------\n\tIF ( ibase .lt. 2 ) THEN\n\t iret = -1\n\t RETURN\n\tEND IF\n\tIF ( ival .lt. 0 ) THEN\n\t iret = -3\n\t RETURN\n\tEND IF\n\tiret = 0\n\tnmax = ndig\n\tDO i = 1, nmax\n\t idigs (i) = 0\n\tEND DO\nC*\n\tv = DFLOAT ( ival )\n\tb = DFLOAT ( ibase )\n\tndig = INT ( DLOG ( v ) / DLOG ( b ) ) + 1\n\titest = ibase ** ndig\n\tIF ( itest .lt. ival ) ndig = ndig + 1\n\tIF ( ndig .gt. nmax ) THEN\n\t iret = -2\n\t RETURN\n\tEND IF\n\tiv = ival\n\tidig = ndig\n\tDO WHILE ( idig .gt. 0 )\n\t npwr = idig - 1\n\t id = ibase ** npwr\n\t idigs (idig) = iv / id\n\t iv = iv - idigs (idig) * id\n\t idig = idig - 1\n\tEND DO\nC*\n\tRETURN\n\tEND\n", "meta": {"hexsha": "e5e44c212fc24c56a9c77bd1e76c93399360482d", "size": 1923, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "gempak/source/programs/na/gd2ndfd/gdigit.f", "max_stars_repo_name": "oxelson/gempak", "max_stars_repo_head_hexsha": "e7c477814d7084c87d3313c94e192d13d8341fa1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 42, "max_stars_repo_stars_event_min_datetime": "2015-06-03T15:26:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T22:36:03.000Z", "max_issues_repo_path": "gempak/source/programs/na/gd2ndfd/gdigit.f", "max_issues_repo_name": "oxelson/gempak", "max_issues_repo_head_hexsha": "e7c477814d7084c87d3313c94e192d13d8341fa1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 60, "max_issues_repo_issues_event_min_datetime": "2015-05-11T21:36:08.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T16:22:42.000Z", "max_forks_repo_path": "gempak/source/programs/na/gd2ndfd/gdigit.f", "max_forks_repo_name": "oxelson/gempak", "max_forks_repo_head_hexsha": "e7c477814d7084c87d3313c94e192d13d8341fa1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 27, "max_forks_repo_forks_event_min_datetime": "2016-06-06T21:55:14.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-18T18:23:28.000Z", "avg_line_length": 26.7083333333, "max_line_length": 73, "alphanum_fraction": 0.4841393656, "num_tokens": 678, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9559813538993889, "lm_q2_score": 0.9005297921244243, "lm_q1q2_score": 0.8608896899018423}}
{"text": "program test_ode\n !! Program to test the ode module.\n !! The [Lorenz chaotic system](https://en.wikipedia.org/wiki/Lorenz_system) is solved:\n !! \\[\n !! \\frac{dx}{dt}= a\\left(y-x\\right)\\\\\n !! \\frac{dy}{dt}= x\\left(b-z\\right) - y \\\\\n !! \\frac{dz}{dt}= xy - cz\n !! \\]\n !! The system is integrated for \\(t\\in[0,10]\\) with \\(a=\\), \\(b=\\) and \\(c=\\).\n !! For initial conditions \\(\\left(x(0),y(0),z(0)\\right) = \\left(1,1,1\\right)\\), the solution is:\n !! ![Image of the trayectory](../../lorenz.png)\n use ode\n\n implicit none\n\n integer, parameter :: N = 1000;\n real :: Tf, dT\n real :: t(0:N), y(0:N,3)\n integer :: i, u\n\n Tf = 10\n dT = Tf/N\n\n do i =0, N\n t(i) = i*dT\n end do\n\n y = forward_euler(lorenz, t, [ 1.,1.,1.])\n\n open(file='datos.dat',newunit=u)\n do i = 0, N\n write(u,*) t(i), y(i,1), y(i,2), y(i,3)\n end do\n close(u)\n\n\ncontains\n\n function lorenz(U,t) result(dU)\n !! function for defining derivative in the \n !! [Lorenz system](https://en.wikipedia.org/wiki/Lorenz_system)\n !! written as:\n !! \\[\n !! \\frac{d\\mathbf{U}}{dt}=\\mathbf{F}\\left(\\mathbf{U},t\\right)\n !! \\]\n !! where:\n !! \\[\n !! \\mathbf{U}\\left(t\\right) = \n !! \\begin{pmatrix}\n !! x\\left(t\\right)\\\\\n !! y\\left(t\\right)\\\\\n !! z\\left(t\\right)\n !! \\end{pmatrix}\n !! \\]\n !! and\n !! \\[\n !! \\mathbf{F}\\left(\\mathbf{U},t\\right)=\n !! \\begin{pmatrix}\n !! a \\left( U_2 - U_1 \\right) \\\\\n !! U_1 \\left( b - U_3 \\right) - U_2 \\\\\n !! U_1 U_2 - cU_3\n !! \\end{pmatrix}\n !! \\]\n real, intent(in) :: U(:)\n real, intent(in) :: t\n real :: dU(size(U))\n real, parameter :: a = 10.\n real, parameter :: b = 28.\n real, parameter :: c = 8./3.\n dU(1) = a*(U(2)-U(1))\n dU(2) = U(1)*(b-U(3)) - U(2)\n dU(3) =U(1)*U(2) - c*U(3)\n end function\nend program\n", "meta": {"hexsha": "a0c4be890ea86b2b3fc53110aee36032bd48b19d", "size": 1766, "ext": "f08", "lang": "FORTRAN", "max_stars_repo_path": "docs/src/test_ode.f08", "max_stars_repo_name": "MPenaR/NumericalMethods", "max_stars_repo_head_hexsha": "b3a46676d762d749c9d278efe4c98f41d3886a4b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-10-20T01:52:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-20T01:52:07.000Z", "max_issues_repo_path": "docs/src/test_ode.f08", "max_issues_repo_name": "MPenaR/NumericalMethods", "max_issues_repo_head_hexsha": "b3a46676d762d749c9d278efe4c98f41d3886a4b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-03-19T22:17:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-07T17:57:58.000Z", "max_forks_repo_path": "docs/src/test_ode.f08", "max_forks_repo_name": "MPenaR/NumericalMethods", "max_forks_repo_head_hexsha": "b3a46676d762d749c9d278efe4c98f41d3886a4b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5466666667, "max_line_length": 98, "alphanum_fraction": 0.5243488109, "num_tokens": 729, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.961533812390815, "lm_q2_score": 0.894789457685656, "lm_q1q2_score": 0.8603703185355986}}
{"text": "function gcd(v, t)\n integer :: gcd\n integer, intent(in) :: v, t\n integer :: c, b, a\n\n b = t\n a = v\n do\n c = mod(a, b)\n if ( c == 0) exit\n a = b\n b = c\n end do\n gcd = b ! abs(b)\nend function gcd\n", "meta": {"hexsha": "1f3e3179599c905189986246f46042fa02f4a1c3", "size": 218, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "Task/Greatest-common-divisor/Fortran/greatest-common-divisor-3.f", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Greatest-common-divisor/Fortran/greatest-common-divisor-3.f", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Greatest-common-divisor/Fortran/greatest-common-divisor-3.f", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 13.625, "max_line_length": 29, "alphanum_fraction": 0.4633027523, "num_tokens": 88, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.972830768464319, "lm_q2_score": 0.8840392771633079, "lm_q1q2_score": 0.8600206093554219}}
{"text": "PROGRAM euler\n \n IMPLICIT NONE\n LOGICAL :: is_approx\n REAL(8), DIMENSION(:), ALLOCATABLE :: vec\n REAL(8) :: time_step, threshold\n INTEGER :: n\n\n time_step = 0.01d0\n n = 100\n threshold = 0.01d0\n \n ALLOCATE(vec(n))\n CALL forward_euler(time_step, n, vec)\n is_approx = check_result(vec, threshold, time_step)\n\n WRITE(*,*) is_approx\n\n DEALLOCATE(vec)\n \nCONTAINS\n\n SUBROUTINE forward_euler(time_step, n, vec)\n \n IMPLICIT NONE\n REAL(8), DIMENSION(:), INTENT(OUT) :: vec\n REAL(8), INTENT(IN) :: time_step\n INTEGER, INTENT(IN) :: n\n INTEGER :: i\n\n vec(1) = 1d0\n\n DO i=1, n-1\n \n vec(i+1) = vec(i) - 3d0 * vec(i) * time_step\n\n END DO\n END SUBROUTINE\n\n LOGICAL FUNCTION check_result(euler_result, threshold, time_step) \n \n IMPLICIT NONE\n REAL(8), DIMENSION(:), INTENT(IN) :: euler_result\n REAL(8), INTENT(IN) :: threshold, time_step \n REAL(8) :: time, solution\n INTEGER :: i\n\n check_result = .TRUE.\n\n DO i = 1, SIZE(euler_result)\n\n time = (i - 1) * time_step\n solution = EXP(-3d0 * time)\n \n IF (ABS(euler_result(i) - solution) > threshold) THEN\n \n WRITE(*,*) euler_result(i), solution\n check_result = .FALSE.\n\n END IF\n END DO\n END FUNCTION\nEND PROGRAM euler\n\n", "meta": {"hexsha": "5a7c8332ef24d44cf1396de8a99ff22ee36a8bbe", "size": 1668, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "contents/forward_euler_method/code/fortran/euler.f90", "max_stars_repo_name": "atocil/algorithm-archive", "max_stars_repo_head_hexsha": "2eb30cb103508c9efb91621564bd3114eb49d3af", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1975, "max_stars_repo_stars_event_min_datetime": "2018-04-28T13:46:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T13:14:47.000Z", "max_issues_repo_path": "contents/forward_euler_method/code/fortran/euler.f90", "max_issues_repo_name": "atocil/algorithm-archive", "max_issues_repo_head_hexsha": "2eb30cb103508c9efb91621564bd3114eb49d3af", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 632, "max_issues_repo_issues_event_min_datetime": "2018-04-28T10:27:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T20:38:53.000Z", "max_forks_repo_path": "contents/forward_euler_method/code/fortran/euler.f90", "max_forks_repo_name": "atocil/algorithm-archive", "max_forks_repo_head_hexsha": "2eb30cb103508c9efb91621564bd3114eb49d3af", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 433, "max_forks_repo_forks_event_min_datetime": "2018-04-27T22:50:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T06:16:03.000Z", "avg_line_length": 25.6615384615, "max_line_length": 70, "alphanum_fraction": 0.4628297362, "num_tokens": 417, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9230391685381606, "lm_q2_score": 0.9304582506732222, "lm_q1q2_score": 0.8588494100608824}}
{"text": "program testPositivDefinit\n implicit none\n integer , parameter:: columnRowLength = 4 ! Initialize how big the square matrix of the text file is\n ! also bigger or smaller matrices are possible\n integer, dimension(columnRowLength , columnRowLength) :: matrix\n logical :: isSymmetric = .TRUE.\n logical :: isPositivDefinit = .TRUE.\n INTEGER :: solutionDeterminat\n\n ! initialize the matrix from the text file\n\t\n\t! choose/uncomment one of the 3 matrix options\n ! open(10,file='CholeskyNotPossible.txt')\n\t\n open(10,file='CholeskyPossible.txt')\n\n ! -> Matrix columnRowLength have to be the same as in the text file -> here columnRowLength = 5\n ! open(10,file='5x5Matrix.txt')\n\n read (10,*) matrix\n\n ! first requirement for Cholesky: symmetry\n call checkSymmetry(columnRowLength, matrix, isSymmetric) ! returns all parameters (isSymmetric => True or False)\n\n ! second requirement for Cholesky: positiv determinat (here calculated by Laplace expansion)\n solutionDeterminat = determinatLaplace( matrix, columnRowLength )\n print *, ' '\n print *, 'The solution of Laplace expansion of the given Matrix is: '\n print *, solutionDeterminat\n call checkPositivDefiniteLaPlaceExpansion(columnRowLength, matrix, isPositivDefinit, isSymmetric)\n\n\n! If the matrix is symmetric and the determinat > 0 (with Laplace expansion) then the matrix is positiv definit => then there is a Cholesky decomposition\n IF (isPositivDefinit) THEN\n print *, ' '\n print *, 'calculate Cholesky decomposition'\n end if\n\ncontains\n\nsubroutine printMatrix(columnRowLength, matrix)\n !printing given matrices\n\n integer :: i,j, columnRowLength\n integer, dimension(columnRowLength , columnRowLength) :: matrix\n\n do i = 1,columnRowLength\n print*, (matrix(i, j), j=1,columnRowLength)\n end do\nend subroutine printMatrix\n\nsubroutine checkSymmetry(columnRowLength, matrix, isSymmetric)\n! checks if the matrix is symmetric\n\n integer :: columnRowLength\n integer, dimension(columnRowLength , columnRowLength) :: matrix, matrixTransposed ! create two quadratic matrices with given length\n integer :: i, j ! loop helpers\n logical :: isSymmetric ! setter for solution\n\n\n matrixTransposed = transpose(matrix)\t! function that transposes the matrix\n\n !printing both matrices\n print*,\"----------------matrix---------------\"\n call printMatrix(columnRowLength, matrix)\n\n print *, ' '\n\n print*,\"--------transpose of matrix ---------\"\n call printMatrix(columnRowLength, matrixTransposed)\n\n ! checking symmetric (compare tranpose and normal matrices)\n do i = 1, columnRowLength\n do j = 1, columnRowLength\n if(matrix(i,j) /= matrixTransposed(i,j)) then\n isSymmetric = .FALSE.\n exit\t\t! exit loop and set solution of the subroutine: isSymmetric = false\n end if\n end do\n end do\n\n\n if (isSymmetric) then\n print*, \"The matrix is equal to its transpose\"\n print*,\"Therfore, the matrix is symmetric\"\n else\n print*, \"The matrix is not equal to its transpose\"\n print*, \"Therefore, the matrix is antisymmetric\"\n end if\n end subroutine checkSymmetry\n\nsubroutine checkPositivDefiniteLaPlaceExpansion(columnRowLength, matrix, isPositivDefinit, isSymmetric)\n integer::columnRowLength\n Integer, dimension(columnRowLength, columnRowLength) :: matrix\n logical :: isPositivDefinit, isSymmetric\n\n IF(solutionDeterminat>0 .AND. isSymmetric) THEN\n isPositivDefinit = .TRUE.\n print *, 'The given matrix is symmetric and the solution of the the Laplace expansion is greater than 0'\n print *, 'Therefore the matrix is positive definit and there is a Cholesky decomposition '\n Else\n isPositivDefinit = .FALSE.\n print *, 'The given matrix is not symmetric or the solution of the the Laplace expansion is not greater than 0'\n print *, 'Therefore there is not a Cholesky decomposition'\n END IF\n\nend subroutine checkPositivDefiniteLaPlaceExpansion\n\nrecursive function determinatLaplace( matrix, n ) result( intermediateResult )\n integer :: n ! = columnRowLength (name here too long)\n integer:: matrix(n, n)\n integer:: submatrix(n-1, n-1), intermediateResult !intermediateResult\n integer :: i, sgn ! i=loop helper, sgn=sign for the change +/-\n\n if ( n == 1 ) then\n intermediateResult = matrix(1,1) ! The result of the determinats of a 1x1 matrix is its only element & calculates the recursion upwards again\n else\n intermediateResult = 0.0 ! reset for new tntermediateResult (last solution is safed in last recursion step)\n sgn = 1\n do i = 1, n ! go through first row //matrix(rows, columns)\n\n ! Sub-Array Manipulations\n ! Laplace expansion is made along the first row\n submatrix( 1:n-1, 1:i-1 ) = matrix( 2:n, 1:i-1 )! fill submatrix till i-1th column with matrix values that are between the first and i-1th column and not in the first row\n submatrix( 1:n-1, i:n-1 ) = matrix( 2:n, i+1:n )! fill submatrix from i column onwards with matrix values that are not in the first row and are between the i+1th column and n\n ! => skip first row & i-th column\n\n ! matrix(1,i) = value of first row elements -> alternately * +/- 1 (sgn)\n ! determinat method is called again with submatrix of the matrix with deleted 1st row and i-th column & the matrix columnRowlength-1\n ! the recursion calls end with the 1x1 matrices. After that the intermediateResult will get calculated up the recursion.\n ! one element of the first row fully calculated -> with do loop iterate through the hole row\n intermediateResult = intermediateResult + sgn * matrix(1, i) * determinatLaplace( submatrix, n-1 )\n sgn = - sgn ! change +/-\n enddo ! if do loop ends the intermediateResult is the solution\n endif\nend function\n\nend program testPositivDefinit\n\n\n", "meta": {"hexsha": "638dcf55a5c35ac9145fb880cc385ffd7dac85c0", "size": 6117, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "code.f90", "max_stars_repo_name": "JonasGreim/CholeskyDecompositionExistenceCheck", "max_stars_repo_head_hexsha": "83e7dd882d28af3d839b7b33750fa30d1fd95710", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "code.f90", "max_issues_repo_name": "JonasGreim/CholeskyDecompositionExistenceCheck", "max_issues_repo_head_hexsha": "83e7dd882d28af3d839b7b33750fa30d1fd95710", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code.f90", "max_forks_repo_name": "JonasGreim/CholeskyDecompositionExistenceCheck", "max_forks_repo_head_hexsha": "83e7dd882d28af3d839b7b33750fa30d1fd95710", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3829787234, "max_line_length": 186, "alphanum_fraction": 0.6803988883, "num_tokens": 1488, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.939913354875362, "lm_q2_score": 0.9136765187126079, "lm_q1q2_score": 0.8587767619740088}}
{"text": "! Power function using recursion\n!\n! An integer base \\( b > 0 \\) can be raised to an integer power \\( p > 0 \\)\n! using a simple recurrence relation,\n! \\[\n! b^p = b \\cdot b^{p - 1}.\n! \\]\n! The base case is \\( b^0 = 1 \\).\n!\n! TODO: try to incorporate case p < 0 with divisions for real numbers.\nprogram main\n implicit none\n integer :: n, m, ans\n print \"(a)\", \"Numbers n and m are \"\n read *, n, m\n print \"(a, i0)\", \"n^m is \", power_f(n, m)\n call power_s(n, m, ans)\n print \"(a, i0)\", \"n^m is \", ans\ncontains\n recursive function power_f(b, p) result(answer)\n integer :: answer\n integer, intent(in) :: b, p\n if (p == 0) then\n answer = 1\n else\n answer = b * power_f(b, p - 1)\n end if\n end function power_f\n\n recursive subroutine power_s(b, p, answer)\n integer, intent(in) :: b, p\n integer, intent(inout) :: answer\n if (p == 0) then\n answer = 1\n else\n call power_s(b, p - 1, answer)\n answer = b * answer\n end if\n end subroutine power_s\nend program main", "meta": {"hexsha": "81c6a2f6ac831cc2579737618969aca717db6c8f", "size": 1119, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Lecture_04/recursive_power/power.f90", "max_stars_repo_name": "avsukhorukov/TdP2021-22", "max_stars_repo_head_hexsha": "dd3adf2ece93bcd685912614b848c5dddbcdf6de", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Lecture_04/recursive_power/power.f90", "max_issues_repo_name": "avsukhorukov/TdP2021-22", "max_issues_repo_head_hexsha": "dd3adf2ece93bcd685912614b848c5dddbcdf6de", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lecture_04/recursive_power/power.f90", "max_forks_repo_name": "avsukhorukov/TdP2021-22", "max_forks_repo_head_hexsha": "dd3adf2ece93bcd685912614b848c5dddbcdf6de", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.975, "max_line_length": 75, "alphanum_fraction": 0.5317247542, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9579122684798184, "lm_q2_score": 0.8962513800615312, "lm_q1q2_score": 0.8585301926029092}}
{"text": "!-------------------------------------------------------------------\n subroutine make_array_logspace(a_start, a_end, dim, out)\n implicit none\n integer , intent(IN) :: dim\n double precision, intent(IN) :: a_start, a_end\n double precision, intent(out):: out(dim)\n integer :: i\n double precision :: du,u1,u2,exp\n if (dim.gt.1) then\n u1=log10(a_start)\n u2=log10(a_end) \n du=(u2-u1)/float(dim-1)\n exp=log10(a_start)\n do i=1, dim\n out(i)=10**exp\n exp=exp+du\n enddo\n else if(dim.eq.1) then\n out(1)=a_start\n else if(dim.lt.1) then\n write(*,'(A)',advance=\"no\") 'Error! It is impossible create' \n write(*,*) ' the log scaled array: dim is less than 1'\n stop\n endif\n return\n end subroutine make_array_logspace\n!-----------------------------------------------------------------\n\n!-------------------------------------------------------------------\n subroutine make_array_logspace_real(a_start, a_end, dim, out)\n implicit none\n integer :: i,dim\n real :: a_start,a_end,out(dim)\n real :: du,u1,u2,exp\n if (dim.gt.1) then\n u1=log10(a_start)\n u2=log10(a_end) \n du=(u2-u1)/float(dim-1)\n exp=log10(a_start)\n do i=1, dim\n out(i)=10**exp\n exp=exp+du\n enddo\n else if(dim.eq.1) then\n out(1)=a_start\n else if(dim.lt.1) then\n write(*,'(A)',advance=\"no\") 'Error! It is impossible create' \n write(*,*) ' the log scaled array: dim is less than 1'\n stop\n endif\n return\n end subroutine make_array_logspace_real\n!-----------------------------------------------------------------\n", "meta": {"hexsha": "2ba10b3c6801faebe0462ef44868ac5debb7d63e", "size": 1803, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "subroutines/make_array_logspace.f90", "max_stars_repo_name": "mgullik/data_analysis", "max_stars_repo_head_hexsha": "b91ae014bfa280ba7e7fa3a48600b18eeb74eafe", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "subroutines/make_array_logspace.f90", "max_issues_repo_name": "mgullik/data_analysis", "max_issues_repo_head_hexsha": "b91ae014bfa280ba7e7fa3a48600b18eeb74eafe", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "subroutines/make_array_logspace.f90", "max_forks_repo_name": "mgullik/data_analysis", "max_forks_repo_head_hexsha": "b91ae014bfa280ba7e7fa3a48600b18eeb74eafe", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.3888888889, "max_line_length": 68, "alphanum_fraction": 0.4520244038, "num_tokens": 448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741254760639, "lm_q2_score": 0.9005297834483234, "lm_q1q2_score": 0.8578213709334358}}
{"text": " !>@author\n !>Paul Connolly, The University of Manchester\n !>@brief\n !>code to solve a calculate the 1st derivative of a function\n !> richardson extrapolation: \n !> see https://www.researchgate.net/profile/Toshio_Fukushima/publication/320008726_Efficient_numerical_differentiation_by_Richardson_extrapolation_applied_to_forward_difference_formulas/links/59c73513a6fdccc7191edae2/Efficient-numerical-differentiation-by-Richardson-extrapolation-applied-to-forward-difference-formulas.pdf\n !>@param[in] x,h0,delta\n !>@param[inout] err\n !>@return dfsid1: gradient\n function dfsid1(func,x,h0,delta,err)\n\t use numerics_type\n implicit none\n real(wp), intent(in) :: x,h0,delta\n real(wp), intent(inout) :: err\n real(wp) :: dfsid1\n interface \n function func(x)\n use numerics_type\n real(wp), intent(in) :: x\n real(wp) :: func\n end function func \n end interface\n integer JMAX1; \n real(wp) :: BETA,ERRMIN,LOG2,fx\n parameter (JMAX1=8,BETA=8.e0_wp,ERRMIN=1.e-35_wp)\n parameter (LOG2=0.69314718055994530941723212145818e0_wp)\n integer j,kmin,k; \n real(wp),dimension(JMAX1,JMAX1) :: T\n real(wp) :: hj,errM,errP,factor,errT,errX \n \n fx=func(x)\n hj=2.e0_wp**(floor(log(abs(h0))/LOG2))\n if(h0.lt.0.e0_wp) then\n hj=-hj \n endif\n T(1,1)=(func(x+hj)-fx)/hj; dfsid1=T(1,1) \n errM=0.5e0_wp*delta*abs(dfsid1); errP=1.e-38_wp; err=1.e38_wp !e-66 and e99\n do j=2,JMAX1\n hj=hj/BETA; factor=BETA; kmin=1; T(1,j)=(func(x+hj)-fx)/hj \n do k=2,j\n T(k,j)=T(k-1,j)+(T(k-1,j)-T(k-1,j-1))/(factor-1.e0_wp) \n factor=BETA*factor \n errT=max(abs(T(k,j)-T(k-1,j)),abs(T(k,j)-T(k-1,j-1))) \n if(errT.le.err) then\n kmin=k; err=errT; dfsid1=T(k,j) \n endif\n enddo \n errX=err*err/errP \n if(errX.le.errM) then\n err=max(ERRMIN,errX); return\n endif\n if(err.le.errM) return \n if(kmin.eq.1) then\n err=errX; return \n endif\n errP=err \n enddo\n err=max(ERRMIN,errX) \n return; \n end function dfsid1", "meta": {"hexsha": "7972a08874b4931a1c929dcf85c4326af12ddf94", "size": 2369, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "dfsid1.f", "max_stars_repo_name": "UoM-maul1609/open-source-numerical-functions", "max_stars_repo_head_hexsha": "35201f021bbdcc41fcda8cccfd0639b8d1f6445f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dfsid1.f", "max_issues_repo_name": "UoM-maul1609/open-source-numerical-functions", "max_issues_repo_head_hexsha": "35201f021bbdcc41fcda8cccfd0639b8d1f6445f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dfsid1.f", "max_forks_repo_name": "UoM-maul1609/open-source-numerical-functions", "max_forks_repo_head_hexsha": "35201f021bbdcc41fcda8cccfd0639b8d1f6445f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.4833333333, "max_line_length": 329, "alphanum_fraction": 0.5555086534, "num_tokens": 736, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9579122720843812, "lm_q2_score": 0.894789454880027, "lm_q1q2_score": 0.8571297997612716}}
{"text": "SUBROUTINE arctan ( y,x , angle )\r\n\r\n\r\n! ----------------------------------------------------------------------\r\n! SUBROUTINE: arctan.f90\r\n! ----------------------------------------------------------------------\r\n! Purpose:\r\n! Angle computation based on the x,y Cartesian coordinates.\r\n! Test for identifying the angle quadrant.\r\n! ----------------------------------------------------------------------\r\n! Remarks:\r\n! Angles are considered counter-clockwise\r\n! The result is computed in radians. \r\n! ----------------------------------------------------------------------\r\n! Input arguments:\r\n! - x,y:\t\t\t2D Cartesian coordinates\r\n! Output arguments:\r\n! - angle:\t\t\tOrientation angle (counter-clockwise) starting from x axis (radians)\r\n! ----------------------------------------------------------------------\r\n! Dr. Thomas Papanikolaou, Geoscience Australia August 2015\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n USE mdl_precision\r\n USE mdl_num\r\n IMPLICIT NONE\r\n\r\n! ----------------------------------------------------------------------\r\n! Dummy arguments declaration\r\n! ----------------------------------------------------------------------\r\n REAL (KIND = prec_q), INTENT(IN) :: x,y\r\n REAL (KIND = prec_q), INTENT(OUT) :: angle\r\n! ----------------------------------------------------------------------\r\n\r\n! ----------------------------------------------------------------------\r\n! Local variables declaration\r\n! ----------------------------------------------------------------------\r\n REAL (KIND = prec_q) :: pi\r\n REAL (KIND = prec_q) :: a\r\n! ----------------------------------------------------------------------\r\n\r\n! ----------------------------------------------------------------------\r\n! Numerical Constants\r\n pi = PI_global\r\n! ----------------------------------------------------------------------\r\n\r\n\r\n! ----------------------------------------------------------------------\r\n if (x .ne. 0.d0) then\r\n a = atan( abs( y/x ) )\r\n if (x > 0.0D0) THEN\r\n if (y > 0.0D0) THEN\r\n angle = a\r\n else if (y < 0.0D0) THEN\r\n angle = 2.0D0 * pi - a\r\n else\r\n angle = 0.0D0\r\n end IF\r\n else if (x < 0.0D0) THEN\r\n if (y > 0.0D0) THEN\r\n angle = pi - a\r\n else if (y < 0.0D0) THEN\r\n angle = pi + a\r\n else\r\n angle = pi\r\n end IF\r\n end if\r\n else\r\n if (y > 0.0D0) THEN\r\n angle = pi / 2.0D0\r\n else if (y < 0.0D0) THEN\r\n angle = 3.0D0 * pi / 2.0D0\r\n else\r\n angle = 0.d0\r\n end IF\r\n end IF\r\n! ----------------------------------------------------------------------\r\n\r\nEND\r\n\t \r\n", "meta": {"hexsha": "c59442e66d4910f0bdd4a19c4af2a04ed1b71e61", "size": 2876, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/fortran/arctan.f90", "max_stars_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_stars_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 73, "max_stars_repo_stars_event_min_datetime": "2021-07-08T23:35:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T15:17:58.000Z", "max_issues_repo_path": "src/fortran/arctan.f90", "max_issues_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_issues_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2021-09-27T14:27:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T23:50:02.000Z", "max_forks_repo_path": "src/fortran/arctan.f90", "max_forks_repo_name": "RodrigoNaves/ginan-bitbucket-update-tests", "max_forks_repo_head_hexsha": "4bd5cc0a9dd0e94b1c2d8b35385e128404009b0c", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2021-07-12T05:42:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T15:15:34.000Z", "avg_line_length": 35.5061728395, "max_line_length": 82, "alphanum_fraction": 0.2844228095, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9643214460461698, "lm_q2_score": 0.8887588008585925, "lm_q1q2_score": 0.8570491720302177}}
{"text": "! In this module you can define for example global constants\n\nMODULE constants\n ! definition of variables for double precisions and complex variables \n INTEGER, PARAMETER :: dp = KIND(1.0D0)\n INTEGER, PARAMETER :: dpc = KIND((1.0D0,1.0D0))\n ! Global Truncation parameter\n REAL(DP), PARAMETER, PUBLIC :: truncation=1.0E-10\nEND MODULE constants\n\n! Here you can include specific functions which can be used by\n! many subroutines or functions\n\nMODULE functions\n\nCONTAINS\n REAL(DP) FUNCTION factorial(n)\n USE CONSTANTS \n INTEGER, INTENT(IN) :: n\n INTEGER :: loop\n\n factorial = 1.0_dp\n IF ( n > 1 ) THEN\n DO loop = 2, n\n factorial=factorial*loop\n ENDDO\n ENDIF\n\n END FUNCTION factorial\n\nEND MODULE functions\n\n\nPROGRAM exp_prog\n USE constants\n USE functions\n IMPLICIT NONE \n REAL (DP) :: x, term, final_sum\n INTEGER :: n, loop_over_x\n\n ! loop over x-values\n DO loop_over_x=0, 100, 10\n x=loop_over_x\n ! initialize the EXP sum\n final_sum= 0.0_dp; term = 1.0_dp; n = 0 \n DO WHILE ( ABS(term) > truncation)\n term = ((-1.0_dp)**n)*(x**n)/ factorial(n)\n final_sum=final_sum+term\n n=n+1\n ENDDO\n ! write the argument x, the exact value, the computed value and n\n WRITE(*,*) x ,EXP(-x), final_sum, n\n ENDDO\n\nEND PROGRAM exp_prog\n\n\n", "meta": {"hexsha": "9a44708789322d034b9e84805da5495e7cd01c28", "size": 1324, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "doc/Programs/LecturePrograms/programs/IntroProgramming/Fortran/program4.f90", "max_stars_repo_name": "kimrojas/ComputationalPhysicsMSU", "max_stars_repo_head_hexsha": "a47cfc18b3ad6adb23045b3f49fab18c0333f556", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 220, "max_stars_repo_stars_event_min_datetime": "2016-08-25T09:18:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:09:16.000Z", "max_issues_repo_path": "doc/Programs/LecturePrograms/programs/IntroProgramming/Fortran/program4.f90", "max_issues_repo_name": "dnhdang94/ComputationalPhysicsMSU", "max_issues_repo_head_hexsha": "16990c74cf06eb5b933982137f0536d669567259", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-01-18T10:43:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T13:15:42.000Z", "max_forks_repo_path": "doc/Programs/LecturePrograms/programs/IntroProgramming/Fortran/program4.f90", "max_forks_repo_name": "dnhdang94/ComputationalPhysicsMSU", "max_forks_repo_head_hexsha": "16990c74cf06eb5b933982137f0536d669567259", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 136, "max_forks_repo_forks_event_min_datetime": "2016-08-25T09:04:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T09:54:21.000Z", "avg_line_length": 22.8275862069, "max_line_length": 72, "alphanum_fraction": 0.6570996979, "num_tokens": 404, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067228145365, "lm_q2_score": 0.9086179031191509, "lm_q1q2_score": 0.856378482159447}}
{"text": "module procedures\nimplicit none\ncontains\n\nsubroutine writes2d (A)\n real(kind=8), allocatable, dimension(:,:), intent(in) :: A\n integer :: n, m, i, j\n\n n = size(A, 1)\n m = size(A, 2)\n\n do i = 1,n\n write(*,'(20F8.4)') (A(i,j), j = 1, m)\n end do\n write(*,*)\nend subroutine writes2d\n\nsubroutine writes1d (A)\n real(kind=8), allocatable, dimension(:), intent(in) :: A\n integer :: n, i\n \n n = size(A)\n\n write(*,'(20F8.4)') (A(i), i = 1, n)\n write(*,*)\nend subroutine writes1d\n\nreal(kind = 8) function MaxEig(A)\n real(kind=8), allocatable, dimension(:,:), intent(in) :: A\n real(kind=8), allocatable, dimension(:,:) :: Y, Y_old, Y_new\n real(kind=8) :: normalization_constant\n integer :: n, i, j\n\n !Initialize column vector:\n n = size(A,1)\n allocate (Y(n,1), Y_old(n,1))\n do i = 1, n\n Y(i,1) = 1.0d0\n Y_old(i,1) = 2.0d0 !initialize loop\n end do\n write(*,*) \"initial vector:\"\n call writes2d(Y)\n\n !perform calculation:\n i = 1\n do while (maxval(dabs(Y_old-Y)) .ge. 0.0001)\n do j = 1, n ! save old vector\n Y_old(j,1) = Y(j,1)\n end do\n Y = matmul(A,Y) !determine new vector\n MaxEig = maxval(Y)\n do j = 1, n\n Y(j,1) = Y(j,1)/MaxEig\n end do\n write(*,*) \"iteration:\", i\n write(*,'(A14,F10.6)') \" tolerance: \", maxval(dabs(Y_old-Y))\n write(*,'(A15,F8.4)') \" eigenvalue: \", MaxEig\n write(*,*) \"eigenvector:\"\n call writes2d(Y)\n i = i+1\n end do\n\n ! final normalization:\n normalization_constant = sqrt(Y(1,1)*Y(1,1) + Y(2,1)*Y(2,1) + Y(3,1)*Y(3,1))\n do i = 1, n\n Y(i,1) = Y(i,1)/normalization_constant\n end do\n write(*,*)\n write(*,'(A30)') \" -----------------------------\"\n write(*,'(A30)') \" final result \"\n write(*,'(A30)') \" -----------------------------\"\n write(*,*) \"eigenvalue:\", MaxEig\n write(*,*) \"eigenvector, normalized to length 1 for comparison with matlab result:\"\n call writes2d(Y)\n \n deallocate (Y, Y_old)\nend function MaxEig\n\nend module procedures\n", "meta": {"hexsha": "aecd063e4f0efaef9408003ed5e8074ce82a708b", "size": 2039, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "ME_Numerical_Methods/HW6/ex1/mod.f95", "max_stars_repo_name": "ElenaKusevska/Fortran_exercises", "max_stars_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ME_Numerical_Methods/HW6/ex1/mod.f95", "max_issues_repo_name": "ElenaKusevska/Fortran_exercises", "max_issues_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ME_Numerical_Methods/HW6/ex1/mod.f95", "max_forks_repo_name": "ElenaKusevska/Fortran_exercises", "max_forks_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.4875, "max_line_length": 86, "alphanum_fraction": 0.5380088279, "num_tokens": 730, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632856092016, "lm_q2_score": 0.9230391658917939, "lm_q1q2_score": 0.8559926336273909}}
{"text": "!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n!%\n!% Description:\n!% + Return the natural logarithm of an ndim-dimensional mixture of Standard Multivariate\n!% Normal (SMVN) density functions (PDF) with the mean and amplitude vectors as defined below.\n!% Reference: https://en.wikipedia.org/wiki/Multivariate_normal_distribution\n!% Input:\n!% + ndim: The number of dimensions of the domain of the objective function.\n!% + point: The input 64-bit real-valued vector of length ndim,\n!% at which the natural logarithm of objective function is computed.\n!% Output:\n!% + logFunc: A 64-bit real scalar number representing the natural logarithm of the objective function.\n!% Author:\n!% + Computational Data Science Lab, Monday 9:03 AM, May 16 2016, ICES, The University of Texas at Austin\n!% Visit:\n!% + https://www.cdslab.org/paramonte\n!%\n!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\nmodule LogFunc_mod\n\n use paramonte, only: IK, RK\n\n implicit none\n\n ! The number of dimensions of the domain of the objective function.\n\n integer(IK), parameter :: NDIM = 1_IK\n\n ! The number of mixtures of multivariate normal distributions.\n\n integer(IK), parameter :: NMIX = 3_IK\n\n ! The mean vectors of the SMVN mixtures.\n\n integer(IK) :: idim, imix\n real(RK), parameter :: MEAN(NDIM,NMIX) = reshape([((real(3*imix,RK), idim = 1, NDIM), imix = -NMIX/2, NMIX/2 + mod(NMIX,2) - 1)], shape = shape(MEAN))\n\n ! The log-amplitudes of the SMVN mixtures.\n\n real(RK), parameter :: LOG_AMPLITUDE(NMIX) = [(imix*log(2._RK), imix = 1, NMIX)]\n\ncontains\n\n function getLogFunc(ndim,Point) result(logFunc)\n ! Return the negative natural logarithm of SMVN mixture density evaluated at the input vector `Point` of length `ndim`.\n implicit none\n integer(IK), intent(in) :: ndim\n real(RK), intent(in) :: Point(ndim)\n real(RK) :: LogFuncMix(NMIX)\n real(RK) :: maxLogFuncMix\n real(RK) :: logFunc\n maxLogFuncMix = -huge(maxLogFuncMix)\n do imix = 1, NMIX\n LogFuncMix(imix) = LOG_AMPLITUDE(imix) - 0.5_RK * sum((Point - MEAN(:,imix))**2)\n if (maxLogFuncMix < LogFuncMix(imix)) maxLogFuncMix = LogFuncMix(imix)\n end do\n logFunc = maxLogFuncMix + log(sum(exp(LogFuncMix - maxLogFuncMix)))\n end function getLogFunc\n\nend module LogFunc_mod\n\n!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "meta": {"hexsha": "87e8979590532f320568609abd6f1a22807d7f31", "size": 2805, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "bin/example/sampler/mvn_mix/logfunc.f90", "max_stars_repo_name": "cdslaborg/paramonte-api-kernel", "max_stars_repo_head_hexsha": "b0aa0aae26b0c531b52b003dab3b89a6d1aeff87", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bin/example/sampler/mvn_mix/logfunc.f90", "max_issues_repo_name": "cdslaborg/paramonte-api-kernel", "max_issues_repo_head_hexsha": "b0aa0aae26b0c531b52b003dab3b89a6d1aeff87", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bin/example/sampler/mvn_mix/logfunc.f90", "max_forks_repo_name": "cdslaborg/paramonte-api-kernel", "max_forks_repo_head_hexsha": "b0aa0aae26b0c531b52b003dab3b89a6d1aeff87", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.828125, "max_line_length": 158, "alphanum_fraction": 0.5415329768, "num_tokens": 695, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9693241974031599, "lm_q2_score": 0.8824278618165526, "lm_q1q2_score": 0.8553586789215164}}
{"text": "! Truong Dang added this subroutine on 10-21-2016\n subroutine gauss_2(a,b,x,n)\n!===========================================================\n! Solutions to a system of linear equations A*x=b\n! Method: Gauss elimination (with scaling and pivoting)\n! Alex G. (November 2009)\n!-----------------------------------------------------------\n! input ...\n! a(n,n) - array of coefficients for matrix A\n! b(n) - array of the right hand coefficients b\n! n - number of equations (size of matrix A)\n! output ...\n! x(n) - solutions\n! coments ...\n! the original arrays a(n,n) and b(n) will be destroyed \n! during the calculation\n!===========================================================\nimplicit none \ninteger n\ndouble precision a(n,n), b(n), x(n)\ndouble precision s(n)\ndouble precision c, pivot, store\ninteger i, j, k, l\n\n! step 1: begin forward elimination\ndo k=1, n-1\n\n! step 2: \"scaling\"\n! s(i) will have the largest element from row i \n do i=k,n ! loop over rows\n s(i) = 0.0\n do j=k,n ! loop over elements of row i\n s(i) = max(s(i),abs(a(i,j)))\n end do\n end do\n\n! step 3: \"pivoting 1\" \n! find a row with the largest pivoting element\n pivot = abs(a(k,k)/s(k))\n l = k\n do j=k+1,n\n if(abs(a(j,k)/s(j)) > pivot) then\n pivot = abs(a(j,k)/s(j))\n l = j\n end if\n end do\n\n! Check if the system has a sigular matrix\n if(pivot == 0.0) then\n write(*,*) ' The matrix is sigular '\n return\n end if\n\n! step 4: \"pivoting 2\" interchange rows k and l (if needed)\nif (l /= k) then\n do j=k,n\n store = a(k,j)\n a(k,j) = a(l,j)\n a(l,j) = store\n end do\n store = b(k)\n b(k) = b(l)\n b(l) = store\nend if\n\n! step 5: the elimination (after scaling and pivoting)\n do i=k+1,n\n c=a(i,k)/a(k,k)\n a(i,k) = 0.0\n b(i)=b(i)- c*b(k)\n do j=k+1,n\n a(i,j) = a(i,j)-c*a(k,j)\n end do\n end do\nend do\n\n! step 6: back substiturion \nx(n) = b(n)/a(n,n)\ndo i=n-1,1,-1\n c=0.0\n do j=i+1,n\n c= c + a(i,j)*x(j)\n end do \n x(i) = (b(i)- c)/a(i,i)\nend do\n\nend subroutine gauss_2\n\n", "meta": {"hexsha": "33221fc6e734ba68e8ca9afb8251edc55a968507", "size": 2075, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "gauss_2.f90", "max_stars_repo_name": "truongd8593/Finite-volume-method-conventional-Laplace-equation-solver", "max_stars_repo_head_hexsha": "4b3011df8f95a87da9895724430f3fa3ebcb86c4", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-12T01:18:56.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-12T01:18:56.000Z", "max_issues_repo_path": "gauss_2.f90", "max_issues_repo_name": "truongd8593/FVM_LaplaceEq2D", "max_issues_repo_head_hexsha": "4b3011df8f95a87da9895724430f3fa3ebcb86c4", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gauss_2.f90", "max_forks_repo_name": "truongd8593/FVM_LaplaceEq2D", "max_forks_repo_head_hexsha": "4b3011df8f95a87da9895724430f3fa3ebcb86c4", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-12T01:18:56.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-12T01:18:56.000Z", "avg_line_length": 23.3146067416, "max_line_length": 61, "alphanum_fraction": 0.5209638554, "num_tokens": 676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9496693688269985, "lm_q2_score": 0.900529793459209, "lm_q1q2_score": 0.8552055605643143}}
{"text": "module procedures\nimplicit none\ncontains\n\n!----------------------------\n! Function to solve:\n!----------------------------\n\nreal(kind=8) function g (x)\n real(kind=8), intent (in) :: x\n\n g = 8.0d0 - 4.5d0*(x-sin(x))\nend function g\n\n!----------------------------\n! Bisection routine:\n!----------------------------\n\nsubroutine BisectionRoot (Fun, a, b, ToolMax, Xs)\n\n real(kind=8), intent(in) :: ToolMax\n real(kind=8), intent(inout) :: a, b\n real(kind=8), intent(out) :: Xs\n interface\n real(kind=8) function Fun(x)\n real(kind=8), intent (in) :: x\n end function\n end interface\n real(kind=8) :: n, ConvergenceTest\n integer :: i\n\n ! Determine n; check if a and b are positioned properly:\n\n n = nint( (log10(b-a) - log10(ToolMax)) / log10(2.0d0) )\n write(*,'(A6F7.3)') \" n >= \", n\n\n if (Fun(a)*Fun(b) > 0) then\n write(*,*) \"f(a) and f(b) are not on opposite sides of the root. Cannot apply the bisection method \"\n stop\n end if\n\n !Solve the function:\n \n write(*,'(6A15)') \" iteration: \", \" a \", &\n \" b \", \"(xNS) Solution\", \" f(xNS) \", \" Tolerance \"\n \n i = 0\n ConvergenceTest = 10\n do while (ConvergenceTest > ToolMax)\n \n i = i + 1\n if (i > n + 10) then\n write(*,*) \"convergence could not be reached in the number of intervals)\"\n stop\n end if\n \n Xs = (a+b)/2.0d0\n if (Fun(a)*Fun(Xs) < -0.00000000001) then\n b = Xs\n else if (Fun(a)*Fun(Xs) > 0.00000000001) then\n a = Xs\n else\n ConvergenceTest = abs(Fun(Xs))\n write(*,'(A6,I2,A7,5F15.11)') \" \", i, \" \", a, b, Xs, Fun(Xs), ConvergenceTest\n write(*,*) \"convergence reached\"\n exit\n end if\n \n ConvergenceTest = abs(Fun(Xs))\n write(*,'(A6,I2,A7,5F15.11)') \" \", i, \" \", a, b, Xs, Fun(Xs), ConvergenceTest\n\n end do\n\nend subroutine BisectionRoot\n\nend module procedures\n", "meta": {"hexsha": "1484af096bfa7a51e9867a0fd57afddccebeeb94", "size": 1947, "ext": "f95", "lang": "FORTRAN", "max_stars_repo_path": "ME_Numerical_Methods/HW3/ex2/mod.f95", "max_stars_repo_name": "ElenaKusevska/Fortran_exercises", "max_stars_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ME_Numerical_Methods/HW3/ex2/mod.f95", "max_issues_repo_name": "ElenaKusevska/Fortran_exercises", "max_issues_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ME_Numerical_Methods/HW3/ex2/mod.f95", "max_forks_repo_name": "ElenaKusevska/Fortran_exercises", "max_forks_repo_head_hexsha": "69bab3c2ac6a17612e28e71e8a7bd322f4260153", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.2857142857, "max_line_length": 106, "alphanum_fraction": 0.5100154083, "num_tokens": 641, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308073258007, "lm_q2_score": 0.9149009607937928, "lm_q1q2_score": 0.8539967424569008}}
{"text": "\n! $UWHPSC/codes/fortran/taylor_converge.f90\n\nprogram taylor_converge\n\n implicit none \n real (kind=8) :: x, exp_true, y, relative_error\n integer :: nmax, nterms, j\n\n nmax = 100\n\n print *, \" x true approximate error nterms\"\n do j = -20,20,4\n x = float(j) ! convert to a real\n call exptaylor(x,nmax,y,nterms) ! defined below\n exp_true = exp(x)\n relative_error = abs(y-exp_true) / exp_true\n print '(f10.3,3d19.10,i6)', x, exp_true, y, relative_error, nterms\n enddo\n\nend program taylor_converge\n\n!====================================\nsubroutine exptaylor(x,nmax,y,nterms)\n!====================================\n implicit none\n\n ! subroutine arguments:\n real (kind=8), intent(in) :: x\n integer, intent(in) :: nmax\n real (kind=8), intent(out) :: y\n integer, intent(out) :: nterms\n\n ! local variables:\n real (kind=8) :: term, partial_sum\n integer :: j\n\n term = 1.\n partial_sum = term\n\n do j=1,nmax\n ! j'th term is x**j / j! which is the previous term times x/j:\n term = term*x/j \n ! add this term to the partial sum:\n partial_sum = partial_sum + term \n if (abs(term) < 1.d-16*partial_sum) exit\n enddo\n nterms = j ! number of terms used\n y = partial_sum ! this is the value returned\nend subroutine exptaylor\n\n", "meta": {"hexsha": "9c420f1181179f2aeba1045813ca760f169d61a3", "size": 1435, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "uwhpsc/codes/fortran/taylor_converge.f90", "max_stars_repo_name": "philipwangdk/HPC", "max_stars_repo_head_hexsha": "e2937016821701adb80ece5bf65d43d1860640c0", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "uwhpsc/codes/fortran/taylor_converge.f90", "max_issues_repo_name": "philipwangdk/HPC", "max_issues_repo_head_hexsha": "e2937016821701adb80ece5bf65d43d1860640c0", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "uwhpsc/codes/fortran/taylor_converge.f90", "max_forks_repo_name": "philipwangdk/HPC", "max_forks_repo_head_hexsha": "e2937016821701adb80ece5bf65d43d1860640c0", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.5961538462, "max_line_length": 89, "alphanum_fraction": 0.5428571429, "num_tokens": 408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966641739774, "lm_q2_score": 0.9019206679615432, "lm_q1q2_score": 0.8537550956419623}}
{"text": "!> Module to calculate the CFL number\nmodule CFL_mod\n use types_mod, only: DP, SI\n\n implicit none\n\n private\n\n public :: fd1d_heat_explicit_cfl \n\ncontains\n !> calculate the CFL number\n !> \\( \\text{CFL} = \\kappa\\frac{\\Delta t}{\\Delta x^2} \\)\n subroutine fd1d_heat_explicit_cfl(k, T_NUM, t_min, t_max, X_NUM, x_min, &\n x_max, cfl)\n\n implicit none\n\n !> number of intervals in t-axis\n integer(kind=SI), intent (in) :: T_NUM\n !> number of intervals in x-axis\n integer(kind=SI), intent (in) :: X_NUM\n !> the heat constant \\( \\kappa \\)\n real (kind=DP), intent (in) :: k\n !> upper bound of t-axis\n real (kind=DP), intent (in) :: t_max\n !> lower bound of t-axis\n real (kind=DP), intent (in) :: t_min\n !> upper bound of x-axis\n real (kind=DP), intent (in) :: x_max\n !> lower bound of x-axis\n real (kind=DP), intent (in) :: x_min\n !> the CFL number\n real (kind=DP), intent (out) :: cfl\n real (kind=DP) :: dx\n real (kind=DP) :: dt\n\n dx = (x_max-x_min)/real(X_NUM-1, kind=DP)\n dt = (t_max-t_min)/real(T_NUM-1, kind=DP)\n\n cfl = k*dt/dx/dx\n\n write (*, '(a)') ' '\n write (*, '(a,g14.6)') ' CFL stability criterion value = ', cfl\n\n end subroutine\n\nend module CFL_mod\n", "meta": {"hexsha": "8b5f589e740efdcac15a892dc3e4245b7e8462ba", "size": 1233, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/CFL_mod.f90", "max_stars_repo_name": "dennissergeev/fortran-workshop", "max_stars_repo_head_hexsha": "aa9a519ee0b1a70144327ce3066b34e0f5bf15a6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/CFL_mod.f90", "max_issues_repo_name": "dennissergeev/fortran-workshop", "max_issues_repo_head_hexsha": "aa9a519ee0b1a70144327ce3066b34e0f5bf15a6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/CFL_mod.f90", "max_forks_repo_name": "dennissergeev/fortran-workshop", "max_forks_repo_head_hexsha": "aa9a519ee0b1a70144327ce3066b34e0f5bf15a6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1632653061, "max_line_length": 75, "alphanum_fraction": 0.601784266, "num_tokens": 423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9546474194456936, "lm_q2_score": 0.8933094060543487, "lm_q1q2_score": 0.8527955192563493}}
{"text": "MODULE m_grule\nCONTAINS\n SUBROUTINE grule(n, x, w)\n!***********************************************************************\n! determines the (n+1)/2 nonnegative points x(i) and\n! the corresponding weights w(i) of the n-point\n! gauss-legendre integration rule, normalized to the\n! interval (-1,1). the x(i) appear in descending order.\n! this routine is from 'methods of numerical integration',\n! p.j. davis and p. rabinowitz, page 369.\n! m.w.\n!***********************************************************************\n\n USE m_constants\n IMPLICIT NONE\n! ..\n! .. Arguments ..\n INTEGER, INTENT(IN) :: n\n REAL, INTENT(OUT) :: w(n/2), x(n/2)\n! ..\n! .. Locals ..\n INTEGER :: i, it, k, m\n REAL :: d1, d2pn, d3pn, d4pn, den, dp, dpn, e1, fx, h\n REAL :: p, pk, pkm1, pkp1, t, t1, u, v, x0\n! ..\n! ..\n m = (n + 1)/2\n e1 = n*(n + 1)\n\n DO i = 1, m\n t = (4*i - 1)*pi_const/(4*n + 2)\n x0 = (1.-(1.-1./n)/(8.*n*n))*cos(t)\n !---> iterate on the value (m.w. jan. 1982)\n DO it = 1, 2\n pkm1 = 1.\n pk = x0\n DO k = 2, n\n t1 = x0*pk\n pkp1 = t1 - pkm1 - (t1 - pkm1)/k + t1\n pkm1 = pk\n pk = pkp1\n ENDDO\n den = 1.-x0*x0\n d1 = n*(pkm1 - x0*pk)\n dpn = d1/den\n d2pn = (2.*x0*dpn - e1*pk)/den\n d3pn = (4.*x0*d2pn + (2.-e1)*dpn)/den\n d4pn = (6.*x0*d3pn + (6.-e1)*d2pn)/den\n u = pk/dpn\n v = d2pn/dpn\n h = -u*(1.+.5*u*(v + u*(v*v - u*d3pn/(3.*dpn))))\n p = pk + h*(dpn + .5*h*(d2pn + h/3.*(d3pn + .25*h*d4pn)))\n dp = dpn + h*(d2pn + .5*h*(d3pn + h*d4pn/3.))\n h = h - p/dp\n x0 = x0 + h\n ENDDO\n x(i) = x0\n fx = d1 - h*e1*(pk + .5*h*(dpn + h/3.*(d2pn + .25*h*(d3pn + &\n .2*h*d4pn))))\n w(i) = 2.*(1.-x(i)*x(i))/(fx*fx)\n ENDDO\n\n IF (m + m > n) x(m) = 0.\n END SUBROUTINE grule\nEND MODULE m_grule\n", "meta": {"hexsha": "7e4c1243e73495cb18a397e24dd648dbb04416d4", "size": 2196, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "math/grule.f90", "max_stars_repo_name": "MRedies/FLEUR", "max_stars_repo_head_hexsha": "84234831c55459a7539e78600e764ff4ca2ec4b6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "math/grule.f90", "max_issues_repo_name": "MRedies/FLEUR", "max_issues_repo_head_hexsha": "84234831c55459a7539e78600e764ff4ca2ec4b6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "math/grule.f90", "max_forks_repo_name": "MRedies/FLEUR", "max_forks_repo_head_hexsha": "84234831c55459a7539e78600e764ff4ca2ec4b6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.2727272727, "max_line_length": 75, "alphanum_fraction": 0.3720400729, "num_tokens": 776, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9572778012346834, "lm_q2_score": 0.8902942159342104, "lm_q1q2_score": 0.8522588894814574}}
{"text": "PROGRAM A10Q2\r\n!--\r\n! A program to implement the `Sieve of Eratosthenes` algorithm\r\n!--\r\nIMPLICIT NONE\r\nINTEGER, DIMENSION(1:4999) :: S, Sfinal\r\nINTEGER :: i, j, jprev, p, pnew\r\nREAL :: size\r\n\r\nPRINT *, \"Determines the list of prime numbers from 0-5000 using the 'Sieve of Eratosthenes' method\"\r\n!- initialize the arrays\r\nDO i = 2,5000\r\n\tS(i - 1) = i \r\n Sfinal(i-1) = 0 \r\nEND DO\r\n!- implement the algorithm\r\np = 2\r\npnew = 2\r\nsize = 5000\r\nDO WHILE (SQRT(size) .ge. p)\r\n\tDO i= 1,4999\r\n\t\tIF (MOD(S(i),p) .eq. 0 .and. S(i) .ne. p) S(i) = 0\r\n \tEND DO\r\n\tDO WHILE (pnew .eq. p)\r\n\t\tDO i = 1,4999\r\n\t\t\tIF (S(i) .ne. 0 .and. S(i) .gt. p .and. p .eq. pnew) pnew = S(i)\r\n END DO\r\n END DO\r\n p = pnew\r\nEND DO\r\n!- isolate the non zeros\r\nj = 1\r\nDO i=1,4999\r\n \tIF (S(i) .ne. 0) THEN\r\n \t\tSfinal(j) = S(i)\r\n j = j + 1\r\n END IF\r\nEND DO\r\n!- print the final result\r\nj = 0\r\njprev = 1\r\nDO i = 1,334\r\n \tIF (j + 15 > 334) THEN\r\n \tj = 4999\r\n ELSE \r\n \t\tj = j + 15\r\n END IF\r\n\tPRINT '(15I5)', PACK(Sfinal(jprev:j), Sfinal(jprev:j)/=0)\r\n jprev = j +1\r\nEND DO\r\n\r\nEND PROGRAM A10Q2", "meta": {"hexsha": "dc39dc4d61ef8d647ccd4d4c5547511689a26747", "size": 1090, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Assignment 10/A10Q2.f90", "max_stars_repo_name": "Chris-Drury/COMP3731", "max_stars_repo_head_hexsha": "59d70f4fe8354b7b50fd2911ec2d8e7aad8401bc", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assignment 10/A10Q2.f90", "max_issues_repo_name": "Chris-Drury/COMP3731", "max_issues_repo_head_hexsha": "59d70f4fe8354b7b50fd2911ec2d8e7aad8401bc", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assignment 10/A10Q2.f90", "max_forks_repo_name": "Chris-Drury/COMP3731", "max_forks_repo_head_hexsha": "59d70f4fe8354b7b50fd2911ec2d8e7aad8401bc", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.9615384615, "max_line_length": 101, "alphanum_fraction": 0.5541284404, "num_tokens": 455, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9585377296574669, "lm_q2_score": 0.8887587920192298, "lm_q1q2_score": 0.8519088347152253}}
{"text": "!11. Write a program that computes\n! 4\\cdot \\sum_{k=1}^{10^6} \\frac{(-1)^{k+1}}{2k-1} = 4\\cdot(1-1/3+1/5-1/7+1/9-1/11\\ldots).\n \n program Exercises \n \n ! Recommendation: use Wolfram Alpha for something that resembles human legibility for the above thing\n implicit none\n integer :: k\n integer :: denominator\n real :: fraction\n real :: acc\n \n acc = 0\n \n do k=1,1000000 ! 10^6\n \n denominator = (2 * k) - 1\n fraction = 1.0 / real(denominator)\n \n ! Rather than mess around with exponents, it's easier to express multiplying by (-1)^(some function of k) this way. \n if (mod(k, 2) .ne. 0) then\n acc = acc + fraction\n else\n acc = acc - fraction\n end if\n \n end do\n \n acc = acc * 4\n \n print *, acc \n \n end program Exercises", "meta": {"hexsha": "dba00be204c7acfa032991ec8863db32cf07cb7e", "size": 867, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "E11.f90", "max_stars_repo_name": "clandrew/problemsf90", "max_stars_repo_head_hexsha": "8dd561f9ab4cb7a880efda5d3c4a32bc458cac24", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "E11.f90", "max_issues_repo_name": "clandrew/problemsf90", "max_issues_repo_head_hexsha": "8dd561f9ab4cb7a880efda5d3c4a32bc458cac24", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "E11.f90", "max_forks_repo_name": "clandrew/problemsf90", "max_forks_repo_head_hexsha": "8dd561f9ab4cb7a880efda5d3c4a32bc458cac24", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.2727272727, "max_line_length": 124, "alphanum_fraction": 0.5363321799, "num_tokens": 259, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.970687766704745, "lm_q2_score": 0.8774767794716264, "lm_q1q2_score": 0.851755975400585}}
{"text": "program roots\nuse M_escape, only : color,color_mode, bg_blue, fg_white, reset, fg_yellow, bold, clear\n! Calculate and print the roots of a quadratic formula even if they are complex\nimplicit none\ninteger,parameter :: dp=kind(0.0d0)\nreal(kind=dp) :: a, b, c, discriminant\nreal(kind=dp) :: x1, x2, x ! Real roots of the equation\nreal(kind=dp) :: x_real ! Real part of complex root of the equation\nREAL(kind=dp) :: x_complex ! Imaginary part of complex root of the equation\ncharacter(len=:),allocatable :: line\ncharacter(len=256) :: message\ninteger :: ios\ncharacter(len=1) :: paws\n !call color_mode(isatty(stdout)) ! ISATTY() is an extension, but found in Intel, GNU, PGI, ... compiler\n INFINITE: do\n ! clear screen, set attributes and print messages\n line=\"Enter the quadratic equation coefficients a, b and c\"\n write(*,'(*(a))') color(line,bg=bg_blue,fg=fg_white,style=clear//bold)\n write(*,'(*(a))',advance='no') bg_blue,fg_white,repeat('_',len(line)),fg_yellow,bold, char(13),' ENTER>'\n read(*,*,iostat=ios,iomsg=message)a,b,c\n write(*,'(a)',advance='no') reset\n if(ios.ne.0)then\n write(*,'(*(g0))')ios,' ',trim(message)\n else\n ! Given the equation \"A*x**2 + B*x + C = 0\"\n ! Use the quadratic formula to determine the root values of the equation.\n ! prompt for new value\n \n WRITE(*,'(*(g0))') 'for ',a,'*x**2 + ',b,'*x + ',c,' = 0'\n discriminant = b**2 - 4*a*c\n \n IF ( discriminant>0 ) THEN\n write(*,*) 'the roots (ie. \"x intercepts\") are real so the parabola crosses the x-axis at two points:'\n x1 = ( -b + sqrt(discriminant)) / (2 * a)\n x2 = ( -b - sqrt(discriminant)) / (2 * a)\n PRINT *, \"Real roots:\", x1, x2\n ELSEIF ( discriminant==0 ) THEN\n PRINT *,'the roots (ie. \"x intercepts\") are repeated (real and equal) so the parabola just touches the x-axis at:'\n x = (-b) / (2 * a)\n PRINT *, \"Two identical Real roots\", x\n ELSE\n PRINT *, 'the roots(ie. \"x intercepts\") are complex:'\n x_real = (-b)/(2 * a)\n x_complex = sqrt (abs(discriminant)) / (2 * a)\n PRINT *, x_real, \"+i\",x_complex , x_real, \"-i\",x_complex\n ENDIF\n PRINT *, \"discriminant =\", discriminant\n endif\n write(*,'(*(g0))')'press <return> to continue, <q> to quit'\n read(*,advance='yes',iostat=ios,fmt='(a)',iomsg=message)paws\n if(paws.ne.'')exit INFINITE\n enddo INFINITE\nEND PROGRAM roots\n", "meta": {"hexsha": "cfdbee305c425a433012dfc3d6612e6878441c9d", "size": 2712, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "app/roots.f90", "max_stars_repo_name": "urbanjost/M_escape", "max_stars_repo_head_hexsha": "ae09d251d62f1fa3887f0575562801a8195c770e", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-09-14T08:30:47.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-20T16:39:07.000Z", "max_issues_repo_path": "app/roots.f90", "max_issues_repo_name": "urbanjost/M_escape", "max_issues_repo_head_hexsha": "ae09d251d62f1fa3887f0575562801a8195c770e", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/roots.f90", "max_forks_repo_name": "urbanjost/M_escape", "max_forks_repo_head_hexsha": "ae09d251d62f1fa3887f0575562801a8195c770e", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-10T01:12:02.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-10T01:12:02.000Z", "avg_line_length": 50.2222222222, "max_line_length": 126, "alphanum_fraction": 0.5538348083, "num_tokens": 760, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582535657919, "lm_q2_score": 0.9149009636941993, "lm_q1q2_score": 0.8512771528645646}}
{"text": "MODULE precision\n ! dp = double precision\n INTEGER, PARAMETER:: dp = SELECTED_REAL_KIND(12)\nEND MODULE precision\n\nPROGRAM Newton_Raphson_Method\n USE precision\n IMPLICIT NONE\n\n REAL(KIND = dp):: x0, x1, f1, fun, fprime, error, root\n WRITE(*, fmt = '(/A)', ADVANCE = 'NO') \"Enter value of x0 : \"\n ! For this question enter x0\n READ *, x0\n\n error = 1e-6\n\n DO\n fun = Func(x0)\n fprime = FuncPrime(x0)\n x1 = x0 - fun / fprime\n f1 = Func(x0)\n \n IF (f1 .EQ. 0.0) THEN\n root = x0\n WRITE(*, *) \"Root is: \", root\n RETURN\n ENDIF\n\n IF (abs((x1 - x0)/x1) .LT. error) THEN \n root = x1\n WRITE(*, *) \"Root is: \", root\n RETURN\n ELSE \n x0 = x1\n ENDIF\n\n ENDDO \n\n CONTAINS\n REAL(KIND = dp) FUNCTION Func(x)\n USE precision\n IMPLICIT NONE \n REAL(KIND = dp):: x\n Func = x**2 - 3*x + 2\n RETURN \n END FUNCTION Func\n\n REAL(KIND = dp) FUNCTION FuncPrime(x)\n USE precision\n IMPLICIT NONE \n REAL(KIND = dp):: x\n FuncPrime = 2*x - 3\n RETURN \n END FUNCTION FuncPrime\n\nEND PROGRAM Newton_Raphson_Method\n", "meta": {"hexsha": "fb8a25d861d3b7071130bcd39eea1eaefe63158b", "size": 1235, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Roots of Nonlinear Equation/Newton Raphson Method.f90", "max_stars_repo_name": "arpitkekri/Code_With_FORTRAN", "max_stars_repo_head_hexsha": "fb731e6f8d8a47cfe38896fffd74a55d17efb2e3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2021-02-21T05:24:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-27T10:25:24.000Z", "max_issues_repo_path": "Roots of Nonlinear Equation/Newton Raphson Method.f90", "max_issues_repo_name": "akhil18soni/Code_With_FORTRAN", "max_issues_repo_head_hexsha": "92bb46ab5b340f070c229f27acb4806931879d02", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Roots of Nonlinear Equation/Newton Raphson Method.f90", "max_forks_repo_name": "akhil18soni/Code_With_FORTRAN", "max_forks_repo_head_hexsha": "92bb46ab5b340f070c229f27acb4806931879d02", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-02-27T12:14:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-19T23:30:55.000Z", "avg_line_length": 21.6666666667, "max_line_length": 65, "alphanum_fraction": 0.5101214575, "num_tokens": 372, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.95598134762883, "lm_q2_score": 0.8902942195727173, "lm_q1q2_score": 0.8511046678132838}}
{"text": "\nC***********************************************************************\nC> \\brief Advance one time step using fourth order (real) Runge-Kutta\nC> \\param[in] neq number of equations\nC> \\param[in] yo initial value\nC> \\param[out] yf final value\nC> \\param[in] to intial time\nC> \\param[in] h time step\nC> \\param[in] FUNC function to integrate\nC***********************************************************************\n subroutine SRK4(neq, yo, yf, to, h, FUNC)\nC***********************************************************************\nC\nC Advance one time step using fourth order (real) Runge-Kutta\nC\nC***********************************************************************\n external FUNC\n integer neq\n real to, h\n real yo(neq), yf(neq)\n real f(neq), k1(neq), k2(neq), k3(neq), k4(neq), q(neq)\n \n call FUNC(neq, yo, to, f)\n do j = 1 , neq\n k1(j) = h*f(j)\n q(j) = yo(j) + 0.5*k1(j)\n end do\n call FUNC(neq, q, to+0.5*h, f)\n do j = 1 , neq\n k2(j) = h*f(j)\n q(j) = yo(j) + 0.5*k2(j)\n end do\n call FUNC(neq, q, to+0.5*h, f)\n do j = 1 , neq\n k3(j) = h*f(j)\n q(j) = yo(j) + k3(j)\n end do\n call FUNC(neq, q, to+h, f)\n do j = 1 , neq\n k4(j) = h*f(j)\n yf(j) = yo(j)+k1(j)/6.+(k2(j)+k3(j))/3.+k4(j)/6.\n end do\n\n return\n end\n\nC***********************************************************************\nC> \\brief Advance one time step using fourth order (real) Runge-Kutta\nC> \\param[in] neq number of equations\nC> \\param[in] yo initial value\nC> \\param[out] yf final value\nC> \\param[in] to intial time\nC> \\param[in] h time step\nC> \\param[in] FUNC function to integrate\nC***********************************************************************\n subroutine CRK4(neq, yo, yf, to, h, FUNC)\nC***********************************************************************\nC\nC Advance one time step using fourth order (complex) Runge-Kutta\nC\nc***********************************************************************\n external FUNC\n integer neq\n real to, h\n complex yo(neq), yf(neq)\n complex f(neq), k1(neq), k2(neq), k3(neq), k4(neq), q(neq)\n \n call FUNC(neq, yo, to, f)\n do j = 1 , neq\n k1(j) = h*f(j)\n q(j) = yo(j) + 0.5*k1(j)\n end do\n call FUNC(neq, q, to+0.5*h, f)\n do j = 1 , neq\n k2(j) = h*f(j)\n q(j) = yo(j) + 0.5*k2(j)\n end do\n call FUNC(neq, q, to+0.5*h, f)\n do j = 1 , neq\n k3(j) = h*f(j)\n q(j) = yo(j) + k3(j)\n end do\n call FUNC(neq, q, to+h, f)\n do j = 1 , neq\n k4(j) = h*f(j)\n yf(j) = yo(j)+k1(j)/6.+(k2(j)+k3(j))/3.+k4(j)/6.\n end do\n\n return\n end\n\nC***********************************************************************\n SUBROUTINE SPLINE (N,X,Y,FDP) \nC***********************************************************************\nC\nC.... Note: this routine is in the public domain and available\nC at https://web.stanford.edu/class/me200c/\nC\nC-----THIS SUBROUTINE COMPUTES THE SECOND DERIVATIVES NEEDED \nC-----IN CUBIC SPLINE INTERPOLATION. THE INPUT DATA ARE: \nC-----N = NUMBER OF DATA POINTS \nC-----X = ARRAY CONTAINING THE VALUES OF THE INDEPENDENT VARIABLE \nC----- (ASSUMED TO BE IN ASCENDING ORDER) \nC-----Y = ARRAY CONTAINING THE VALUES OF THE FUNCTION AT THE \nC----- DATA POINTS GIVEN IN THE X ARRAY \nC-----THE OUTPUT IS THE ARRAY FDP WHICH CONTAINS THE SECOND \nC-----DERIVATIVES OF THE INTERPOLATING CUBIC SPLINE. \n DIMENSION X(N),Y(N),A(N),B(N),C(N),R(N),FDP(N) \nC-----COMPUTE THE COEFFICIENTS AND THE RHS OF THE EQUATIONS. \nC-----THIS ROUTINE USES THE CANTILEVER CONDITION. THE PARAMETER \nC-----ALAMDA (LAMBDA) IS SET TO 1. BUT THIS CAN BE USER-MODIFIED. \nC-----A,B,C ARE THE THREE DIAGONALS OF THE TRIDIAGONAL SYSTEM; \nC-----R IS THE RIGHT HAND SIDE. THESE ARE NOW ASSEMBLED. \n ALAMDA = 1. \n NM2 = N - 2 \n NM1 = N - 1 \n C(1) = X(2) - X(1) \n DO 1 I=2,NM1 \n C(I) = X(I+1) - X(I) \n A(I) = C(I-1) \n B(I) = 2.*(A(I) + C(I)) \n R(I) = 6.*((Y(I+1) - Y(I))/C(I) - (Y(I) - Y(I-1))/C(I-1)) \n 1 CONTINUE \n B(2) = B(2) + ALAMDA * C(1) \n B(NM1) = B(NM1) + ALAMDA * C(NM1) \nC-----AT THIS POINT WE COULD CALL A TRIDIAGONAL SOLVER SUBROUTINE \nC-----BUT THE NOTATION IS CLUMSY SO WE WILL SOLVE DIRECTLY. THE \nC-----NEXT SECTION SOLVES THE SYSTEM WE HAVE JUST SET UP. \n DO 2 I=3,NM1 \n T = A(I)/B(I-1) \n B(I) = B(I) - T * C(I-1) \n R(I) = R(I) - T * R(I-1) \n 2 CONTINUE \n FDP(NM1) = R(NM1)/B(NM1) \n DO 3 I=2,NM2 \n NMI = N - I \n FDP(NMI) = (R(NMI) - C(NMI)*FDP(NMI+1))/B(NMI) \n 3 CONTINUE \n FDP(1) = ALAMDA * FDP(2) \n FDP(N) = ALAMDA * FDP(NM1) \nC-----WE NOW HAVE THE DESIRED DERIVATIVES SO WE RETURN TO THE \nC-----MAIN PROGRAM. \n RETURN \n END \n\nC***********************************************************************\n SUBROUTINE SPEVAL (N,X,Y,FDP,XX,F) \nC***********************************************************************\nC\nC.... Note: this routine is in the public domain and available\nC at https://web.stanford.edu/class/me200c/\nC\nC-----THIS SUBROUTINE EVALUATES THE CUBIC SPLINE GIVEN \nC-----THE 2ND DERIVATIVE COMPUTED BY SUBROUTINE SPLINE. \nC-----THE INPUT PARAMETERS N,X,Y,FDP HAVE THE SAME \nC-----MEANING AS IN SPLINE. \nC-----XX = VALUE OF INDEPENDENT VARIABLE FOR WHICH \nC----- AN INTERPOLATED VALUE IS REQUESTED \nC-----F = THE INTERPOLATED RESULT \n DIMENSION X(N),Y(N),FDP(N) \nC-----THE FIRST JOB IS TO FIND THE PROPER INTERVAL. \n#if USE_NR_HUNT\nc\nc Search using bisection with a good guess\nc\n I = IOLD\n IF (XX.EQ.X(1)) THEN\n I = 1\n ELSE IF (XX.EQ.X(N)) THEN\n I = N\n ELSE\n call HUNT (X,N,XX,I)\n END IF\n IOLD = I\n#elif 1\n I = IOLD\n IF (XX.EQ.X(1)) THEN\n I = 1\n ELSE IF (XX.EQ.X(N)) THEN\n I = N\n ELSE\n call BISECT (X,N,XX,I)\n ENDiF\n IOLD = I\n#else\nc\nc This is really a slow way of searching\nc\n NM1 = N - 1\n DO 1 I=1,NM1\n IF (XX.LE.X(I+1)) GO TO 10\n 1 CONTINUE \n#endif\nC-----NOW EVALUATE THE CUBIC \n 10 DXM = XX - X(I) \n DXP = X(I+1) - XX \n DEL = X(I+1) - X(I) \n F = FDP(I)*DXP*(DXP*DXP/DEL - DEL)/6. \n 1 +FDP(I+1)*DXM*(DXM*DXM/DEL - DEL)/6. \n 2 +Y(I)*DXP/DEL + Y(I+1)*DXM/DEL \n RETURN \n END \n\nC***********************************************************************\n subroutine BISECT(X,N,XX,I)\nC***********************************************************************\n dimension X(N)\nC***********************************************************************\n il = I-1\n ir = N-1\n do while (ir-il .gt. 1) \n im = ISHFT(ir+il,-1) \n if ( X(im+1) > xx ) then\n ir = im\n else\n il = im\n end if\n end do\n I = il+1\n return\n end\n\nC***********************************************************************\n SUBROUTINE SPDER(N,X,Y,FDP,XX,F,FP,FPP)\nC***********************************************************************\nC\nC.... Note: this routine is in the public domain and available\nC at https://web.stanford.edu/class/me200c/\nC\nC-----THIS SUBROUTINE EVALUATES THE CUBIC SPLINE GIVEN \nC-----THE 2ND DERIVATIVE COMPUTED BY SUBROUTINE SPLINE. \nC-----THE INPUT PARAMETERS N,X,Y,FDP HAVE THE SAME \nC-----MEANING AS IN SPLINE. \nC-----XX = VALUE OF INDEPENDENT VARIABLE FOR WHICH \nC----- AN INTERPOLATED VALUE IS REQUESTED \nC-----F = THE INTERPOLATED RESULT \nC-----FP = THE INTERPOLATED DERIVATIVE RESULT \n INTEGER N\n DIMENSION X(N),Y(N),FDP(N)\n REAL XX, F, FP, FPP\nC-----THE FIRST JOB IS TO FIND THE PROPER INTERVAL. \n#if USE_NR_HUNT\nc\nc Search using bisection with a good guess\nc\n I = IOLD\n IF (XX.EQ.X(1)) THEN\n I = 1\n ELSE IF (XX.EQ.X(N)) THEN\n I = N\n ELSE\n call HUNT (X,N,XX,I)\n END IF\n IOLD = I\n#elif 1\n I = IOLD\n IF (XX.EQ.X(1)) THEN\n I = 1\n ELSE IF (XX.EQ.X(N)) THEN\n I = N\n ELSE\n call BISECT (X,N,XX,I)\n ENDiF\n IOLD = I\n#else\nc\nc This is really a slow way of searching\nc\n NM1 = N - 1\n DO 1 I=1,NM1\n IF (XX.LE.X(I+1)) GO TO 10\n 1 CONTINUE \n#endif\nC-----NOW EVALUATE THE CUBIC \n 10 continue\nC write(*,*) I, X(I), XX, X(I+1)\n DXM = XX - X(I)\n DXP = X(I+1) - XX\n DEL = X(I+1) - X(I)\n F = FDP(I)*DXP*(DXP*DXP/DEL - DEL)/6.0\n 1 +FDP(I+1)*DXM*(DXM*DXM/DEL - DEL)/6.0\n 2 +Y(I)*DXP/DEL + Y(I+1)*DXM/DEL\n FP= FDP(I)*(-3.0*DXP*DXP/DEL + DEL)/6.0\n 1 +FDP(I+1)*(3.0*DXM*DXM/DEL - DEL)/6.0\n 2 -Y(I)/DEL + Y(I+1)/DEL\n FPP=FDP(I)*DXP/DEL+FDP(I+1)*DXM/DEL\n RETURN \n END\n\nC***********************************************************************\n subroutine SLSRK14(neq, yo, yf, to, h, FUNC)\nC***********************************************************************\nC\nC Advance one time step with low-storage Runge Kutta 14\nC\nC***********************************************************************\n external FUNC\n integer neq\n real to, h\n real yo(neq), yf(neq)\n real f(neq), yt(neq)\nC***********************************************************************\n parameter (nsubstep=14)\n real A(0:14), B(0:13), c(0:13), w(0:14)\n data A / 0.0, \n & -0.7188012108672410, \n & -0.7785331173421570,\n & -0.0053282796654044, \n & -0.8552979934029281, \n & -3.9564138245774565, \n & -1.5780575380587385,\n & -2.0837094552574054, \n & -0.7483334182761610,\n & -0.7032861106563359, \n & 0.0013917096117681,\n & -0.0932075369637460, \n & -0.9514200470875948,\n & -7.1151571693922548, \n & 0.0/\n data B / 0.0367762454319673,\n & 0.3136296607553959,\n & 0.1531848691869027,\n & 0.0030097086818182,\n & 0.3326293790646110,\n & 0.2440251405350864,\n & 0.3718879239592277,\n & 0.6204126221582444,\n & 0.1524043173028741,\n & 0.0760894927419266,\n & 0.0077604214040978,\n & 0.0024647284755382,\n & 0.0780348340049386,\n & 5.5059777270269628 /\n data c / 0.0,\n & 0.0367762454319673,\n & 0.1249685262725025,\n & 0.2446177702277698,\n & 0.2476149531070420,\n & 0.2969311120382472,\n & 0.3978149645802642,\n & 0.5270854589440328,\n & 0.6981269994175695,\n & 0.8190890835352128,\n & 0.8527059887098624,\n & 0.8604711817462826,\n & 0.8627060376969976,\n & 0.8734213127600976 /\n data w / -0.116683473041717417,\n & 0.213493962104674251,\n & 0.128620987881127052,\n & 4.610096100109887907,\n & -5.386527768056724064,\n & 1.445540684241274576,\n & -0.761388932107154526,\n & 0.543874700576422732,\n & 0.102277834602298279,\n & 0.07127466608688701188,\n & -3.459648919807762457,\n & 37.20095449534884580,\n & -39.09786206496502814,\n & 5.505977727026962754,\n & 0.0 /\n do j = 1, neq\n yf(j) = yo(j)\n end do\n do i = 0, nsubstep-1\n t = to + c(i)*h\n call FUNC(neq, yf, t, f)\n do j = 1, neq\n yt(j) = A(i)*yt(j) + h*f(j)\n end do\n do j = 1, neq\n yf(j) = yf(j) + B(i)*yt(j)\n end do\n if (i+1 .lt. nsubstep) then\n t = to + c(i+1)*h\n else\n t = to + h\n end if\n end do\n return\n end\n\nC***********************************************************************\n subroutine CLSRK14(neq, yo, yf, to, h, FUNC)\nC***********************************************************************\nC\nC Advance one time step with low-storage Runge Kutta 14\nC\nC***********************************************************************\n external FUNC\n integer neq\n real to, h\n complex yo(neq), yf(neq)\n complex f(neq), yt(neq)\nC***********************************************************************\n parameter (nsubstep=14)\n real A(0:14), B(0:13), c(0:13), w(0:14)\n data A / 0.0, \n & -0.7188012108672410, \n & -0.7785331173421570,\n & -0.0053282796654044, \n & -0.8552979934029281, \n & -3.9564138245774565, \n & -1.5780575380587385,\n & -2.0837094552574054, \n & -0.7483334182761610,\n & -0.7032861106563359, \n & 0.0013917096117681,\n & -0.0932075369637460, \n & -0.9514200470875948,\n & -7.1151571693922548, \n & 0.0/\n data B / 0.0367762454319673,\n & 0.3136296607553959,\n & 0.1531848691869027,\n & 0.0030097086818182,\n & 0.3326293790646110,\n & 0.2440251405350864,\n & 0.3718879239592277,\n & 0.6204126221582444,\n & 0.1524043173028741,\n & 0.0760894927419266,\n & 0.0077604214040978,\n & 0.0024647284755382,\n & 0.0780348340049386,\n & 5.5059777270269628 /\n data c / 0.0,\n & 0.0367762454319673,\n & 0.1249685262725025,\n & 0.2446177702277698,\n & 0.2476149531070420,\n & 0.2969311120382472,\n & 0.3978149645802642,\n & 0.5270854589440328,\n & 0.6981269994175695,\n & 0.8190890835352128,\n & 0.8527059887098624,\n & 0.8604711817462826,\n & 0.8627060376969976,\n & 0.8734213127600976 /\n data w / -0.116683473041717417,\n & 0.213493962104674251,\n & 0.128620987881127052,\n & 4.610096100109887907,\n & -5.386527768056724064,\n & 1.445540684241274576,\n & -0.761388932107154526,\n & 0.543874700576422732,\n & 0.102277834602298279,\n & 0.07127466608688701188,\n & -3.459648919807762457,\n & 37.20095449534884580,\n & -39.09786206496502814,\n & 5.505977727026962754,\n & 0.0 /\n do j = 1, neq\n yf(j) = yo(j)\n end do\n do i = 0, nsubstep-1\n t = to + c(i)*h\n call FUNC(neq, yf, t, f)\n do j = 1, neq\n yt(j) = A(i)*yt(j) + h*f(j)\n end do\n do j = 1, neq\n yf(j) = yf(j) + B(i)*yt(j)\n end do\n if (i+1 .lt. nsubstep) then\n t = to + c(i+1)*h\n else\n t = to + h\n end if\n end do\n return\n end\n\nC***********************************************************************\n subroutine advance(FUNC, neq, t1, t2, nstep, t, x)\nC***********************************************************************\nC\nC Advance from t1 to t2\nC\nC***********************************************************************\n external FUNC\n real t(nstep+1), x(neq,nstep+1)\n real dt\nC***********************************************************************\n dt = (t2 - t1)/nstep\n t(1) = t1\n do i = 1, nstep\n call srkck45(neq, x(1,i), x(1,i+1), t(i), dt, FUNC)\n t(i+1) = t(i) + dt\n end do\n return\n end\n\nC***********************************************************************\n subroutine SRKCK45(neq, yo, yf, to, h, FUNC)\nC***********************************************************************\nC\nC Advance one time step Runge-Kutta Cash-Karp method\nC\nC***********************************************************************\n external FUNC\n integer neq\n real to, h, t\n real yo(neq), yf(neq), yt(neq)\n real yk(neq,6), ye(neq)\nC***********************************************************************\n real b(6,5)\n real a(6), c(6), d(6)\n data a / 0.0, 0.2, 0.3, 0.6, 1.0, 0.875 /\n data b / 0.0, 0.2, 0.075, 0.3, -0.2037037037037037,\n & 0.029495804398148147,\n & 0.0, 0.0, 0.225, -0.9, 2.5, 0.341796875,\n & 0.0, 0.0, 0.0, 1.2, -2.5925925925925926,\n & 0.041594328703703706,\n & 0.0, 0.0, 0.0, 0.0, 1.2962962962962963,\n & 0.40034541377314814,\n & 0.0, 0.0, 0.0, 0.0, 0.0, 0.061767578125 /\n data c / 0.09788359788359788, 0.0, 0.4025764895330113,\n & 0.21043771043771045, 0.0, 0.2891022021456804 /\n data d / -0.004293774801587311, 0.0, 0.018668586093857853,\n & -0.034155026830808066, -0.019321986607142856,\n & 0.03910220214568039 /\nc\nc Test data\nc\n#ifdef FSC_DEBUG\n do i = 1, 6\n do j = 1, 5\n write(*,*) i, j, b(i,j)\n end do\n end do\n stop\n#endif\nc\nc Stage 1 - 6\nc\n do m = 1, 6\n t = to + a(m)*h\n do n = 1, neq\n yt(n) = yo(n)\n end do\n do k = 1, m-1\n do n = 1, neq\n yt(n) = yt(n) + b(m,k)*yk(n,k)\n end do\n end do\n call FUNC(neq, yt, t, yk(1,m))\n do n = 1, neq\n yk(n,m) = h * yk(n,m)\n end do\n end do\nc\nc Final solution and error\nc\n do n = 1, neq\n yf(n) = yo(n)\n ye(n) = 0.0\n end do\n do k = 1, 6\n do n = 1, neq\n yf(n) = yf(n) + c(k)*yk(n,k)\n ye(n) = ye(n) + d(k)*yk(n,k)\n end do\n end do\n\n return\n end\n\nC***********************************************************************\n subroutine CRKCK45(neq, yo, yf, to, h, FUNC)\nC***********************************************************************\nC\nC Advance one time step Runge-Kutta Cash-Karp method\nC\nC***********************************************************************\n external FUNC\n integer neq\n real to, h, t\n complex yo(neq), yf(neq), yt(neq)\n complex yk(neq,6), ye(neq)\nC***********************************************************************\n real b(6,5)\n real a(6), c(6), d(6)\n data a / 0.0, 0.2, 0.3, 0.6, 1.0, 0.875 /\n data b / 0.0, 0.2, 0.075, 0.3, -0.2037037037037037, \n & 0.029495804398148147,\n & 0.0, 0.0, 0.225, -0.9, 2.5, 0.341796875,\n & 0.0, 0.0, 0.0, 1.2, -2.5925925925925926, \n & 0.041594328703703706,\n & 0.0, 0.0, 0.0, 0.0, 1.2962962962962963,\n & 0.40034541377314814,\n & 0.0, 0.0, 0.0, 0.0, 0.0, 0.061767578125 /\n data c / 0.09788359788359788, 0.0, 0.4025764895330113,\n & 0.21043771043771045, 0.0, 0.2891022021456804 /\n data d / -0.004293774801587311, 0.0, 0.018668586093857853,\n & -0.034155026830808066, -0.019321986607142856,\n & 0.03910220214568039 / \nc\nc Test data\nc\n#ifdef FSC_DEBUG\n do i = 1, 6\n do j = 1, 5\n write(*,*) i, j, b(i,j)\n end do\n end do\n stop\n#endif\nc\nc Stage 1 - 6\nc\n do m = 1, 6 \n t = to + a(m)*h\n do n = 1, neq\n yt(n) = yo(n)\n end do\n do k = 1, m-1\n do n = 1, neq\n yt(n) = yt(n) + b(m,k)*yk(n,k)\n end do\n end do \n call FUNC(neq, yt, t, yk(1,m))\n do n = 1, neq\n yk(n,m) = h * yk(n,m)\n end do\n end do\nc\nc Final solution and error\nc\n do n = 1, neq\n yf(n) = yo(n)\n ye(n) = 0.0\n end do\n do k = 1, 6\n do n = 1, neq\n yf(n) = yf(n) + c(k)*yk(n,k)\n ye(n) = ye(n) + d(k)*yk(n,k)\n end do\n end do\n\n return\n end \n", "meta": {"hexsha": "0dad4419f19da03df6457ca36280a0f99f5b2292", "size": 20268, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "util.f", "max_stars_repo_name": "sscollis/fsc", "max_stars_repo_head_hexsha": "84560a0916ae7cf4fee42428509bf06e26bb640c", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "util.f", "max_issues_repo_name": "sscollis/fsc", "max_issues_repo_head_hexsha": "84560a0916ae7cf4fee42428509bf06e26bb640c", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "util.f", "max_forks_repo_name": "sscollis/fsc", "max_forks_repo_head_hexsha": "84560a0916ae7cf4fee42428509bf06e26bb640c", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.3261205564, "max_line_length": 72, "alphanum_fraction": 0.4207124531, "num_tokens": 6825, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9511422213778251, "lm_q2_score": 0.8947894675053568, "lm_q1q2_score": 0.8510720417885264}}
{"text": " program numintgrl2\r\n implicit none\r\n integer, parameter :: rp = Selected_real_kind(15)\r\n integer :: i, n\r\n real (kind = rp) :: a, b, x_i, deltaX, sum, f\r\n sum = 0.0_rp\r\n print *, \"input the lower bound\"\r\n read *, a\r\n print *, \"input the upper bound\"\r\n read *, b\r\n print *, \"input the number of sections\"\r\n read *, n\r\n deltaX = (b-a)/n\r\n\r\n do i = 0, n-1, 1 !left riemann sum\r\n x_i = a + (i * deltaX)\r\n sum = sum + (deltaX * f(x_i))\r\n end do\r\n write (*,*) sum\r\n end program numintgrl2\r\n\r\n\r\n\r\n function f(x1) \r\n integer, parameter :: rp = Selected_real_kind(15)\r\n real ( kind = rp) ,intent (in) :: x1\r\n real (kind = rp) :: f \r\n f = (x1 ** 2 )/3\r\n return\r\n end function f\r\n!edit f to (approx) integrate a different function\r\n", "meta": {"hexsha": "26a9a79cf9f9dece941721de29d5e8ff4ac5998a", "size": 858, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "practiceNumIntegral2-09-12-18.f", "max_stars_repo_name": "DU-ds/Fortran", "max_stars_repo_head_hexsha": "7145bb0fa1a863e3c0800355767896ee6dc54e19", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "practiceNumIntegral2-09-12-18.f", "max_issues_repo_name": "DU-ds/Fortran", "max_issues_repo_head_hexsha": "7145bb0fa1a863e3c0800355767896ee6dc54e19", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "practiceNumIntegral2-09-12-18.f", "max_forks_repo_name": "DU-ds/Fortran", "max_forks_repo_head_hexsha": "7145bb0fa1a863e3c0800355767896ee6dc54e19", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.8125, "max_line_length": 57, "alphanum_fraction": 0.5034965035, "num_tokens": 258, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9643214532237354, "lm_q2_score": 0.8824278695464501, "lm_q1q2_score": 0.8509441255261576}}
{"text": "!> Author: Jabir Ali Ouassou\n!> Category: Foundation\n!>\n!> This file defines functions that perform some common matrix operations.\n\nmodule matrix_m\n use :: basic_m\ncontains\n pure function identity(n) result(R)\n !! Constructs an n×n identity matrix.\n integer, intent(in) :: n !! Matrix dimension\n real(wp), dimension(n,n) :: R !! Identity matrix [n×n]\n integer :: i, j\n\n ! Initialize by exploiting integer arithmetic to avoid multiple passes\n do i=1,n\n do j=1,n\n R(j,i) = (i/j)*(j/i)\n end do\n end do\n end function\n\n pure function matrix_inverse_re(A) result(R)\n !! Wrapper for matrix_inverse_cx that allows the procedure to be used for real matrices.\n real(wp), dimension(:,:), intent(in) :: A !! Matrix A [n×n]\n real(wp), dimension(size(A,1),size(A,1)) :: R !! Matrix R=A¯¹\n\n R = re(matrix_inverse_cx(cx(A)))\n end function\n\n pure function matrix_inverse_cx(A) result(R)\n !! Invert a square n×n matrix using Gauss-Jordan elimination with partial pivoting.\n !! In the special case n=2, the inverse is evaluated using a cofactoring algorithm.\n !! [This implementation is based on Algorithm #2 in \"Efficient matrix inversion via \n !! Gauss-Jordan elimination and its parallelization\" by E.S. Quintana et al. (1998)]\n complex(wp), dimension(:,:), intent(in) :: A !! Matrix A [n×n]\n complex(wp), dimension(size(A,1),size(A,1)) :: R !! Matrix R=A¯¹\n integer, dimension(size(A,1)) :: P\n complex(wp) :: Q\n integer :: i, j\n\n select case (size(A,1))\n case (1)\n ! Trivial case\n R(1,1) = 1/A(1,1)\n\n case (2)\n ! Inverse determinant\n Q = 1/(A(1,1)*A(2,2) - A(1,2)*A(2,1))\n\n ! Inverse matrix\n R(1,1) = +Q * A(2,2)\n R(2,1) = -Q * A(2,1)\n R(1,2) = -Q * A(1,2)\n R(2,2) = +Q * A(1,1)\n\n case default\n ! Permutation array\n P = [ ( i, i=1,size(A,1) ) ]\n\n ! Matrix copy\n R = A\n\n ! Matrix inversion\n do i=1,size(A,1)\n ! Pivoting procedure\n j = (i-1) + maxloc(abs(A(i:,i)),1)\n P([i,j]) = P([j,i])\n R([i,j],:) = R([j,i],:)\n\n ! Jordan transformation\n Q = R(i,i)\n R(:,i) = [R(:i-1,i), (0.0_wp,0.0_wp), R(i+1:,i)] / (-Q)\n R = R + matmul(R(:,[i]), R([i],:))\n R(i,:) = [R(i,:i-1), (1.0_wp,0.0_wp), R(i,i+1:)] / (+Q)\n end do\n\n ! Pivot inversion\n R(:,P) = R\n end select\n end function\n\n pure function matrix_trace(A) result(r)\n !! Calculate the trace of a general complex matrix.\n complex(wp), dimension(:,:), intent(in) :: A !! Matrix [n×m]\n complex(wp) :: r !! r = Tr(A)\n integer :: n\n\n r = 0\n do n = 1,min(size(A,1),size(A,2))\n r = r + A(n,n)\n end do\n end function\n\n pure function commutator(A, B) result(R)\n !! Calculate the commutator between two complex square matrices.\n complex(wp), dimension(:,:), intent(in) :: A !! Left matrix [n×n]\n complex(wp), dimension(size(A,1),size(A,1)), intent(in) :: B !! Right matrix [n×n]\n complex(wp), dimension(size(A,1),size(A,1)) :: R !! Commutator R = [A,B]\n\n R = matmul(A,B) - matmul(B,A)\n end function\n\n pure function anticommutator(A, B) result(R)\n !! Calculate the anticommutator between two complex square matrices.\n complex(wp), dimension(:,:), intent(in) :: A !! Left matrix [n×n]\n complex(wp), dimension(size(A,1),size(A,1)), intent(in) :: B !! Right matrix [n×n]\n complex(wp), dimension(size(A,1),size(A,1)) :: R !! Anticommutator R = {A,B}\n\n R = matmul(A,B) + matmul(B,A)\n end function\n\n pure function vector_diag(A) result(r)\n !! Extract the diagonal of a general complex matrix.\n complex(wp), dimension(:,:), intent(in) :: A !! Matrix [n×m]\n complex(wp), dimension(min(size(A,1),size(A,2))) :: r !! r = Diag(A)\n integer :: n\n\n do n = 1,size(r)\n r(n) = A(n,n)\n end do\n end function\n\n pure function matrix_diag(A,B) result(R)\n !! Construct a block-diagonal matrix R from two general matrices A and B.\n complex(wp), dimension(:,:), intent(in) :: A !! Left matrix [n×m]\n complex(wp), dimension(:,:), intent(in) :: B !! Right matrix [p×q]\n complex(wp), dimension(size(A,1)+size(B,1), size(A,2)+size(B,2)) :: R !! R = Diag(A,B)\n\n R = 0.0_wp\n R(:size(A,1), :size(A,2) ) = A\n R( size(A,1)+1:, size(A,2)+1:) = B\n end function\nend module\n", "meta": {"hexsha": "63999035d15c42ef6215f73694874c5dcdacfc19", "size": 4802, "ext": "f", "lang": "FORTRAN", "max_stars_repo_path": "src/foundation/matrix.f", "max_stars_repo_name": "jabirali/NEUS", "max_stars_repo_head_hexsha": "f9e3f18a45c84272ebaafcb7b834eebf47acb9b8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-04-22T02:20:48.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-11T08:43:07.000Z", "max_issues_repo_path": "src/foundation/matrix.f", "max_issues_repo_name": "jabirali/NEUS", "max_issues_repo_head_hexsha": "f9e3f18a45c84272ebaafcb7b834eebf47acb9b8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/foundation/matrix.f", "max_forks_repo_name": "jabirali/NEUS", "max_forks_repo_head_hexsha": "f9e3f18a45c84272ebaafcb7b834eebf47acb9b8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-07-11T03:24:08.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-11T03:24:08.000Z", "avg_line_length": 35.5703703704, "max_line_length": 97, "alphanum_fraction": 0.5166597251, "num_tokens": 1432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9678992942089575, "lm_q2_score": 0.8791467690927438, "lm_q1q2_score": 0.850925537310952}}
{"text": "program multi_dimensional_bruteforce_mc\n\n !Author : Anantha Rao\n ! Reg no : 20181044\n ! 6D (x1,x2,x3,x4,x5,x6) Integral\n implicit none\n integer:: n,i,j\n real*8 :: x(6), y, func, int_mc, var, sigma, p(2)\n ! p : Dummy argument for random number generator (2 values)\n real*8 :: length, volume, sqrt2, gauss_dev\n\n length=5.0d0 ! use one side of each dimension (0,5)\n volume=acos(-1.0d0)**3 ! volume of 6D space\n sqrt2=1.0d0/sqrt(2.0d0)\n\n open(unit=1, file=\"20181044_multi_impsampling_mc.dat\")\n n=1\n\n ! Initiate variables\n\n\nprint *,\"Welcome to this program.& \n& This program solves mutidimensional integral using Monte-Carlo rule with sampling\"\n\n 7 int_mc=0.0d0\n var=0.0d0\n sigma=0.0d0\n write(*,10) n\n 10 format(\"Computig for n=\",i10)\n\n do i=1,n\n do j=1,6\n call random_number(p)\n x(j) = gauss_dev(p)*sqrt2\n end do\n int_mc=int_mc+func(x)\n sigma=sigma+func(x)*func(x)\n end do\n\n int_mc = int_mc/real(n)\n sigma=sigma/real(n)\n var=sigma-int_mc*int_mc\n\n int_mc = volume*int_mc\n sigma=volume*sqrt(var/real(n))\n\n write(1,*) n, \"\", int_mc, \"\", sigma\n\n ! begin automation\n n=n*10\n if (n .lt. 1000000000 ) goto 7\n print*,\"Done! Output stored in file 20181044_multi_impsampling_mc.dat\"\n ! end automation\n\n\nend program\n\n\nreal*8 function func(x)\n implicit none\n real*8::x(6), xy, a\n a=0.5d0\n\n xy= (x(1)-x(4))**2 + (x(2)-x(5))**2 + (x(3)-x(6))**2\n func=exp(- a*xy)\n\nend function\n\nreal*8 function gauss_dev(x)\n implicit none\n real*8:: fact, sqr, p, x1, x2, x(2)\n\n 7 call random_number(p)\n x1 = 2.0d0*p - 1.0d0\n call random_number(p)\n x2 = 2.0d0*p - 1.0d0\n sqr = x1*x1 + x2*x2\n\n if (sqr .ge. 1.0d0 .or. sqr .eq. 0.0d0) goto 7\n\n fact=sqrt(-2.0d0*log(sqr)/sqr)\n gauss_dev=x2*fact\n end function\n", "meta": {"hexsha": "a10f4346589fb7021d84200d0c327ecfe22581d1", "size": 1937, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Solutions/assgn02_solns/Assgn02_p3_mc_sampling.f90", "max_stars_repo_name": "Anantha-Rao12/ComPhys", "max_stars_repo_head_hexsha": "235bbebcff0a0ba8b20380d4749a039bca060771", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Solutions/assgn02_solns/Assgn02_p3_mc_sampling.f90", "max_issues_repo_name": "Anantha-Rao12/ComPhys", "max_issues_repo_head_hexsha": "235bbebcff0a0ba8b20380d4749a039bca060771", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Solutions/assgn02_solns/Assgn02_p3_mc_sampling.f90", "max_forks_repo_name": "Anantha-Rao12/ComPhys", "max_forks_repo_head_hexsha": "235bbebcff0a0ba8b20380d4749a039bca060771", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.0595238095, "max_line_length": 84, "alphanum_fraction": 0.5792462571, "num_tokens": 701, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9539661002182845, "lm_q2_score": 0.8918110375304409, "lm_q1q2_score": 0.8507574976045369}}
{"text": "! Simple test program for numerical integration which\n! calls three methods in the program library (you must link\n! the library as well).\n\n\nPROGRAM int_test\n USE constants\n USE F90library\n IMPLICIT NONE\n INTEGER :: i, n\n REAL(DP) :: a, b, int_trapez, int_gauss, int_simpson\n REAL(DP), ALLOCATABLE, DIMENSION(:) :: x, w\n\n INTERFACE\n DOUBLE PRECISION FUNCTION func(x)\n USE constants\n IMPLICIT NONE\n REAL(DP), INTENT(IN) :: x\n\n END FUNCTION func\n END INTERFACE\n\n WRITE(*,*) ' Read in number of mesh points'\n READ(*,*) n\n WRITE(*,*) ' Read in integration limits [a,b]'\n READ(*,*) a, b\n\n ! reserve space in memory for vectors containing the mesh points\n ! weights and function values for the use of the Gauss-Legendre\n ! method\n\n ALLOCATE ( x(n), w(n) )\n\n ! Set up the mesh points and weights for Gauss Legendre\n\n CALL gauleg(a,b,x,w,n)\n\n ! Integrate using the trapezoidal rule and simpson's method\n ! Note the transfer of a function name to the methods\n CALL trapezoidal_rule(a,b,int_trapez,n,func)\n CALL simpson(a,b,int_simpson,n,func)\n ! Gaussian quadrature\n\n int_gauss=0.\n DO i=1,n\n int_gauss=int_gauss+w(i)*func(x(i))\n ENDDO\n\n ! final output\n WRITE (*, *) n, int_trapez, int_simpson, int_gauss\n DEALLOCATE ( x, w)\n\nEND PROGRAM int_test\n\n! The explicit function to be evaluated\n\nDOUBLE PRECISION FUNCTION func(x)\n USE constants\n IMPLICIT NONE\n REAL(DP), INTENT(IN) :: x\n func=exp(-x)/x\n\nEND FUNCTION func\n", "meta": {"hexsha": "cb6b02c2e995b0bb44f633a8a4ab9a65d07afcea", "size": 1499, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "doc/Programs/LecturePrograms/programs/NumericalIntegration/Fortran/program1.f90", "max_stars_repo_name": "kimrojas/ComputationalPhysicsMSU", "max_stars_repo_head_hexsha": "a47cfc18b3ad6adb23045b3f49fab18c0333f556", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 220, "max_stars_repo_stars_event_min_datetime": "2016-08-25T09:18:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T14:09:16.000Z", "max_issues_repo_path": "doc/Programs/LecturePrograms/programs/NumericalIntegration/Fortran/program1.f90", "max_issues_repo_name": "dnhdang94/ComputationalPhysicsMSU", "max_issues_repo_head_hexsha": "16990c74cf06eb5b933982137f0536d669567259", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-01-18T10:43:38.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-08T13:15:42.000Z", "max_forks_repo_path": "doc/Programs/LecturePrograms/programs/NumericalIntegration/Fortran/program1.f90", "max_forks_repo_name": "dnhdang94/ComputationalPhysicsMSU", "max_forks_repo_head_hexsha": "16990c74cf06eb5b933982137f0536d669567259", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 136, "max_forks_repo_forks_event_min_datetime": "2016-08-25T09:04:56.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T09:54:21.000Z", "avg_line_length": 23.421875, "max_line_length": 69, "alphanum_fraction": 0.6737825217, "num_tokens": 454, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248157222396, "lm_q2_score": 0.9059898153067649, "lm_q1q2_score": 0.8507469193646608}}
{"text": "RECURSIVE SUBROUTINE factorial ( n, result )\r\n!\r\n! Purpose:\r\n! To calculate the factorial function\r\n! | n(n-1)! n >= 1 \r\n! n ! = |\r\n! | 1 n = 0\r\n!\r\n! Record of revisions:\r\n! Date Programmer Description of change\r\n! ==== ========== =====================\r\n! 12/07/06 S. J. Chapman Original code\r\n!\r\nIMPLICIT NONE\r\n\r\n! Data dictionary: declare calling parameter types & definitions\r\nINTEGER, INTENT(IN) :: n ! Value to calculate\r\nINTEGER, INTENT(OUT) :: result ! Result\r\n\r\n! Data dictionary: declare local variable types & definitions\r\nINTEGER :: temp ! Temporary variable\r\n\r\nIF ( n >= 1 ) THEN\r\n CALL factorial ( n-1, temp )\r\n result = n * temp\r\nELSE\r\n result = 1\r\nEND IF\r\n\r\nEND SUBROUTINE factorial\r\n", "meta": {"hexsha": "6dd3eb7ad93c46e84f56d8c3422418a8d71aee0c", "size": 832, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap13/factorial.f90", "max_stars_repo_name": "yangyang14641/FortranLearning", "max_stars_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_stars_repo_licenses": ["AFL-3.0"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-03-12T02:18:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-05T07:58:56.000Z", "max_issues_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap13/factorial.f90", "max_issues_repo_name": "yangyang14641/FortranLearning", "max_issues_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_issues_repo_licenses": ["AFL-3.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Fortran952003ForScientistsandEngineers3rdStephenJChapman/chap13/factorial.f90", "max_forks_repo_name": "yangyang14641/FortranLearning", "max_forks_repo_head_hexsha": "3d4a91aacd957361aff5873054edf35c586e8a55", "max_forks_repo_licenses": ["AFL-3.0"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2018-05-11T02:36:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-05T06:36:55.000Z", "avg_line_length": 26.8387096774, "max_line_length": 65, "alphanum_fraction": 0.5264423077, "num_tokens": 206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9603611608990299, "lm_q2_score": 0.8856314677809304, "lm_q1q2_score": 0.8505260645268061}}
{"text": "!------------------------------------------------------------------------------------------------------------------------\n! Description : This is a Fortran program to demonstrate factorial calculation. This fortran function returns the factorial for the non negative number. It returns -1, if the number is negative.\n! Author: Rajesh Prashanth <rajeshprasanth@rediffmail.com>\n! Created on Thu Jan 23 03:05:00 IST 2020\n!------------------------------------------------------------------------------------------------------------------------\n! Use any fortran compiler for compilation\n! \n! For an instance,\n!\n! $ gfortran factorial1.f90 -o factorial1\n!\n!------------------------------------------------------------------------------------------------------------------------\nfunction factorial1(num_in) result (fac_out)\n\tinteger, intent(in) :: num_in\n\tinteger :: fac = 1, counter,fac_out\n\t\n\tcounter=num_in\n\t\n\tif (num > 0) then\n\t\tdo while (counter > 1) \n\t\t\tfac = fac * counter\n\t\t\tcounter = counter - 1 \n\t\tend do\n\t\tfac_out = fac\n\telse \n\t\tfac_out = -1\n\tend if \nend function factorial1\n\nprogram factorial_driver\n\tinteger:: input,factorial1\n\twrite(*,*)'Enter the number >>> '\n\tread(*,*)input\n\tif (factorial1(input) < -1 ) then\n\t\twrite(*,*) 'Invalid Number in input !!!'\n\telse\n\t\twrite(*,*) 'Factorial for',input, ' is ', factorial1(input)\n\tend if\nend program factorial_driver\n", "meta": {"hexsha": "21990fc59d07cb67fd8cdd79c3b2ff6a1d5a49e3", "size": 1368, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "factorial1.f90", "max_stars_repo_name": "rajeshprasanth/Factorials", "max_stars_repo_head_hexsha": "fba1bc37d2140ecfb0c1e68b180207200b29f341", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-02-25T04:01:32.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-25T04:01:32.000Z", "max_issues_repo_path": "factorial1.f90", "max_issues_repo_name": "rajeshprasanth/Factorials", "max_issues_repo_head_hexsha": "fba1bc37d2140ecfb0c1e68b180207200b29f341", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 25, "max_issues_repo_issues_event_min_datetime": "2019-08-08T21:59:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-06T02:42:23.000Z", "max_forks_repo_path": "factorial1.f90", "max_forks_repo_name": "rajeshprasanth/Factorials", "max_forks_repo_head_hexsha": "fba1bc37d2140ecfb0c1e68b180207200b29f341", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-01-22T21:33:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-05T20:33:38.000Z", "avg_line_length": 34.2, "max_line_length": 194, "alphanum_fraction": 0.5197368421, "num_tokens": 304, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9334308147331957, "lm_q2_score": 0.9111797051879431, "lm_q1q2_score": 0.8505232145819348}}
{"text": "PROGRAM carbon_date\nIMPLICIT NONE\n REAL, PARAMETER :: DECAY_CONSTANT = 0.00012097 ! The known decay constant for carbon 14\n REAL :: carbon14_final ! Percentage of carbon 14 remaining\n REAL :: age ! Age in years\n WRITE(*, *) \"Enter the percent of carbon 14 remaining.\"\n READ(*, *) carbon14_final\n age = (-1.0 / DECAY_CONSTANT) * LOG(carbon14_final / 100)\n WRITE(*, *) carbon14_final, \"% carbon 14 remaining. Age: \", age, \" years.\"\nEND PROGRAM carbon_date\n", "meta": {"hexsha": "651c191774cd617a961082afa1b890cdfe0e7096", "size": 474, "ext": "f90", "lang": "FORTRAN", "max_stars_repo_path": "src/chap2/carbon_date.f90", "max_stars_repo_name": "evanmacbride/fortran-practice", "max_stars_repo_head_hexsha": "1d9d851c35baedf52444db65157bd9a987dec60d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/chap2/carbon_date.f90", "max_issues_repo_name": "evanmacbride/fortran-practice", "max_issues_repo_head_hexsha": "1d9d851c35baedf52444db65157bd9a987dec60d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/chap2/carbon_date.f90", "max_forks_repo_name": "evanmacbride/fortran-practice", "max_forks_repo_head_hexsha": "1d9d851c35baedf52444db65157bd9a987dec60d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.0909090909, "max_line_length": 89, "alphanum_fraction": 0.6877637131, "num_tokens": 133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9532750400464605, "lm_q2_score": 0.8918110562208682, "lm_q1q2_score": 0.8501412203328244}}