| | 36 | |
| | 37 | == Console2/Console2/Console2.f90 == |
| | 38 | {{{ |
| | 39 | #!fortran |
| | 40 | real x,dx,s |
| | 41 | !open(1,file='y1.dat', status='unknown') |
| | 42 | a=0 |
| | 43 | b=1.57 |
| | 44 | n=100 |
| | 45 | dx=(b-a)/n |
| | 46 | S=0 |
| | 47 | do i=0,n |
| | 48 | if(mod(i,2)==0) then |
| | 49 | S=S+dx/3*2*f(i*dx+a) |
| | 50 | else |
| | 51 | S=S+dx/3*4*f(i*dx+a) |
| | 52 | end if |
| | 53 | end do |
| | 54 | |
| | 55 | print *, 'Sim = ', S |
| | 56 | pause |
| | 57 | |
| | 58 | contains |
| | 59 | |
| | 60 | function f(x) |
| | 61 | f=sin(x)*sin(2*x)*sin(3*x) |
| | 62 | end function f |
| | 63 | end |
| | 64 | }}} |
| | 65 | |
| | 66 | == Console3/Console3/Console3.f90 == |
| | 67 | {{{ |
| | 68 | #!fortran |
| | 69 | real x,dx, a, b |
| | 70 | open(1,file='y2.dat', status='unknown') |
| | 71 | a=-0.5 |
| | 72 | b=0.5 |
| | 73 | n=100 |
| | 74 | dx=(b-a)/n |
| | 75 | do i=1,n |
| | 76 | write(1,*) i*dx + a, 1/sqrt(1-(i*dx+a)**2) |
| | 77 | end do |
| | 78 | end |
| | 79 | }}} |
| | 80 | |
| | 81 | == Console4/Console4/Console4.f90 == |
| | 82 | {{{ |
| | 83 | #!fortran |
| | 84 | real x,dx, a, b |
| | 85 | open(1,file='y2.dat', status='unknown') |
| | 86 | a=0 |
| | 87 | b=1.14 |
| | 88 | n=100 |
| | 89 | dx=(b-a)/n |
| | 90 | do i=1,n |
| | 91 | write(1,*) i*dx + a, sin(i*dx+a)*sin(2*i*dx+a)*sin(3*i*dx+a) |
| | 92 | end do |
| | 93 | end |
| | 94 | }}} |
| | 95 | |
| | 96 | == Console5/Console5/Console5.f90 == |
| | 97 | {{{ |
| | 98 | #!fortran |
| | 99 | program Simp |
| | 100 | |
| | 101 | integer n |
| | 102 | real y1, y2, y3, x, h, a, s |
| | 103 | n=100 |
| | 104 | h=2/n |
| | 105 | do i=1,n |
| | 106 | |
| | 107 | x(i)=-1+h(i-1) |
| | 108 | |
| | 109 | y1(i)=f1(x(i)) |
| | 110 | y2(i)=f2(x(i),h) |
| | 111 | y3(i)=f3(x(i),h) |
| | 112 | |
| | 113 | a=h/6*(y1+4*y2+y3) |
| | 114 | s=sum(a) |
| | 115 | end do |
| | 116 | |
| | 117 | contains |
| | 118 | real function f1(x) |
| | 119 | real x |
| | 120 | f1=x*(5-4*x)**(-0.5) |
| | 121 | end function |
| | 122 | real function f2(x,h) |
| | 123 | real x, h |
| | 124 | f2=(x+h/2)*(5-4*(x+h/2))**(-0.5) |
| | 125 | end function |
| | 126 | real function f3(x,h) |
| | 127 | real x, h |
| | 128 | f3=(x+h)*(5-4*(x+h))**(-0.5) |
| | 129 | |
| | 130 | end function |
| | 131 | print *, s |
| | 132 | end program |
| | 133 | }}} |
| | 134 | |
| | 135 | == Console6/Console6/Console6.f90 == |
| | 136 | {{{ |
| | 137 | #!fortran |
| | 138 | program kolco |
| | 139 | |
| | 140 | integer :: n=1000 |
| | 141 | real :: r1=1.0, r2=2.0, q=3.0, d=5.0, eq=-4.8e-10, m=9.1e-28 ! ������� ��������� � ���-������� |
| | 142 | real :: dt, t, x, vx |
| | 143 | |
| | 144 | t=1.0e-9 |
| | 145 | dt=t/float(n) |
| | 146 | vx=0 |
| | 147 | x=2.5 |
| | 148 | |
| | 149 | |
| | 150 | open (1,file='kolco',status='unknown') |
| | 151 | |
| | 152 | do i=1,n |
| | 153 | E=q*x/(x**2+r1**2)**(1.5)- q*(5-x)/((5-x)**2+r2**2)**(1.5) |
| | 154 | vx=vx+(eq*E/m)*dt |
| | 155 | x=x+vx*dt |
| | 156 | write(1,*) vx, x, i*dt |
| | 157 | end do |
| | 158 | |
| | 159 | end program |
| | 160 | }}} |
| | 161 | |
| | 162 | == Console7/Console7/Console7.f90 == |
| | 163 | {{{ |
| | 164 | #!fortran |
| | 165 | program kolco |
| | 166 | |
| | 167 | integer :: n=10000 |
| | 168 | real(8) :: r1=1.0, r2=2.0, q=3.0, d=5.0, eq=4.8e-10, m=9.1e-28 ! ������� ��������� � ���-������� |
| | 169 | real(8) :: dt, t, x, vx |
| | 170 | |
| | 171 | t=1.0e-6 |
| | 172 | dt=t/float(n) |
| | 173 | vx=0 |
| | 174 | x=2.5 |
| | 175 | |
| | 176 | |
| | 177 | open (1,file='kolco',status='unknown') |
| | 178 | |
| | 179 | do i=1,n |
| | 180 | E=q*x/sqrt((x**2+r1**2)**3)- q*(5-x)/sqrt(((5-x)**2+r2**2)**3) |
| | 181 | vx=vx+(eq*E/m)*dt |
| | 182 | x=x+vx*dt |
| | 183 | write(1,*) x, i*dt, vx |
| | 184 | end do |
| | 185 | |
| | 186 | end program |
| | 187 | }}} |
| | 188 | |
| | 189 | == Console8/Console8/Console8.f90 == |
| | 190 | {{{ |
| | 191 | #!fortran |
| | 192 | external fct, out |
| | 193 | real aux(8,2) |
| | 194 | common /a/ dt, k, n, A, Vm, om |
| | 195 | real :: pr(5) = (/0.,2*3.14159*10., 2*3.14159/50, .0001, .0/) |
| | 196 | real :: du(2) = (/0.5, 0.5/) |
| | 197 | integer :: nd = 2 |
| | 198 | real :: dt=2*3.14159265 |
| | 199 | real :: t |
| | 200 | A = 2.0 |
| | 201 | om = 1.0 |
| | 202 | Vm = A*om |
| | 203 | u(1) = Vm/Vm |
| | 204 | u(2) = 0 |
| | 205 | k = 1 |
| | 206 | n=1 |
| | 207 | |
| | 208 | open (unit=2, file = 'osc_rk0.dat' ,status='unknown') |
| | 209 | write(*,*) 'x=' , u(1), 'v=', u(2) |
| | 210 | pause |
| | 211 | call rkgs(pr, u, du, nd, ih, fct, out, aux) |
| | 212 | write(2,*) 'ih=', ih |
| | 213 | stop |
| | 214 | end |
| | 215 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| | 216 | |
| | 217 | subroutine fct (t, u, du) |
| | 218 | real u(2), du(2) |
| | 219 | common /a/ dt, k, n, A, Vm, om |
| | 220 | du(1) = -u(2)/(1+0.1*sin(om*dt)) |
| | 221 | du(2) = u(1) |
| | 222 | return |
| | 223 | end |
| | 224 | |
| | 225 | |
| | 226 | subroutine out (t, u, du, ih, nd, pr) |
| | 227 | real u(2), du(2), pr(5) |
| | 228 | common /a/ dt, k, n, A, Vm, om |
| | 229 | |
| | 230 | if(t.ge.k*(dt/50.)) then |
| | 231 | write (2,1) t/om, u(1)*Vm, u(2)*A |
| | 232 | k=k+1 |
| | 233 | else |
| | 234 | end if |
| | 235 | |
| | 236 | 1 format (f8.3, f8.3, f8.3) |
| | 237 | return |
| | 238 | end |
| | 239 | |
| | 240 | |
| | 241 | |
| | 242 | }}} |
| | 243 | |
| | 244 | == Console9/Console9/Console9.f90 == |
| | 245 | {{{ |
| | 246 | #!fortran |
| | 247 | ! Console9.f90 |
| | 248 | ! |
| | 249 | ! FUNCTIONS: |
| | 250 | ! Console9 - Entry point of console application. |
| | 251 | ! |
| | 252 | |
| | 253 | !**************************************************************************** |
| | 254 | ! |
| | 255 | ! PROGRAM: Console9 |
| | 256 | ! |
| | 257 | ! PURPOSE: Entry point for the console application. |
| | 258 | ! |
| | 259 | !**************************************************************************** |
| | 260 | |
| | 261 | program Console9 |
| | 262 | |
| | 263 | implicit none |
| | 264 | |
| | 265 | ! Variables |
| | 266 | |
| | 267 | ! Body of Console9 |
| | 268 | print *, 'Hello World' |
| | 269 | |
| | 270 | end program Console9 |
| | 271 | |
| | 272 | }}} |
| | 273 | |
| 2555 | | == Console4/Console4/Console4.f90 == |
| 2556 | | {{{ |
| 2557 | | #!fortran |
| 2558 | | real x,dx, a, b |
| 2559 | | open(1,file='y2.dat', status='unknown') |
| 2560 | | a=0 |
| 2561 | | b=1.14 |
| 2562 | | n=100 |
| 2563 | | dx=(b-a)/n |
| 2564 | | do i=1,n |
| 2565 | | write(1,*) i*dx + a, sin(i*dx+a)*sin(2*i*dx+a)*sin(3*i*dx+a) |
| 2566 | | end do |
| 2567 | | end |
| 2568 | | }}} |
| 2569 | | |
| 2570 | | == Console5/Console5/Console5.f90 == |
| 2571 | | {{{ |
| 2572 | | #!fortran |
| 2573 | | program Simp |
| 2574 | | |
| 2575 | | integer n |
| 2576 | | real y1, y2, y3, x, h, a, s |
| 2577 | | n=100 |
| 2578 | | h=2/n |
| 2579 | | do i=1,n |
| 2580 | | |
| 2581 | | x(i)=-1+h(i-1) |
| 2582 | | |
| 2583 | | y1(i)=f1(x(i)) |
| 2584 | | y2(i)=f2(x(i),h) |
| 2585 | | y3(i)=f3(x(i),h) |
| 2586 | | |
| 2587 | | a=h/6*(y1+4*y2+y3) |
| 2588 | | s=sum(a) |
| 2589 | | end do |
| 2590 | | |
| 2591 | | contains |
| 2592 | | real function f1(x) |
| 2593 | | real x |
| 2594 | | f1=x*(5-4*x)**(-0.5) |
| 2595 | | end function |
| 2596 | | real function f2(x,h) |
| 2597 | | real x, h |
| 2598 | | f2=(x+h/2)*(5-4*(x+h/2))**(-0.5) |
| 2599 | | end function |
| 2600 | | real function f3(x,h) |
| 2601 | | real x, h |
| 2602 | | f3=(x+h)*(5-4*(x+h))**(-0.5) |
| 2603 | | |
| 2604 | | end function |
| 2605 | | print *, s |
| 2606 | | end program |
| 2607 | | }}} |
| 2608 | | |
| 2609 | | == Console6/Console6/Console6.f90 == |
| 2610 | | {{{ |
| 2611 | | #!fortran |
| 2612 | | program kolco |
| 2613 | | |
| 2614 | | integer :: n=1000 |
| 2615 | | real :: r1=1.0, r2=2.0, q=3.0, d=5.0, eq=-4.8e-10, m=9.1e-28 ! ������� ��������� � ���-������� |
| 2616 | | real :: dt, t, x, vx |
| 2617 | | |
| 2618 | | t=1.0e-9 |
| 2619 | | dt=t/float(n) |
| 2620 | | vx=0 |
| 2621 | | x=2.5 |
| 2622 | | |
| 2623 | | |
| 2624 | | open (1,file='kolco',status='unknown') |
| 2625 | | |
| 2626 | | do i=1,n |
| 2627 | | E=q*x/(x**2+r1**2)**(1.5)- q*(5-x)/((5-x)**2+r2**2)**(1.5) |
| 2628 | | vx=vx+(eq*E/m)*dt |
| 2629 | | x=x+vx*dt |
| 2630 | | write(1,*) vx, x, i*dt |
| 2631 | | end do |
| 2632 | | |
| 2633 | | end program |
| 2634 | | }}} |
| 2635 | | |
| 2636 | | == Console7/Console7/Console7.f90 == |
| 2637 | | {{{ |
| 2638 | | #!fortran |
| 2639 | | program kolco |
| 2640 | | |
| 2641 | | integer :: n=10000 |
| 2642 | | real(8) :: r1=1.0, r2=2.0, q=3.0, d=5.0, eq=4.8e-10, m=9.1e-28 ! ������� ��������� � ���-������� |
| 2643 | | real(8) :: dt, t, x, vx |
| 2644 | | |
| 2645 | | t=1.0e-6 |
| 2646 | | dt=t/float(n) |
| 2647 | | vx=0 |
| 2648 | | x=2.5 |
| 2649 | | |
| 2650 | | |
| 2651 | | open (1,file='kolco',status='unknown') |
| 2652 | | |
| 2653 | | do i=1,n |
| 2654 | | E=q*x/sqrt((x**2+r1**2)**3)- q*(5-x)/sqrt(((5-x)**2+r2**2)**3) |
| 2655 | | vx=vx+(eq*E/m)*dt |
| 2656 | | x=x+vx*dt |
| 2657 | | write(1,*) x, i*dt, vx |
| 2658 | | end do |
| 2659 | | |
| 2660 | | end program |
| 2661 | | }}} |
| 2662 | | |
| 2663 | | == Console8/Console8/Console8.f90 == |
| 2664 | | {{{ |
| 2665 | | #!fortran |
| 2666 | | external fct, out |
| 2667 | | real aux(8,2) |
| 2668 | | common /a/ dt, k, n, A, Vm, om |
| 2669 | | real :: pr(5) = (/0.,2*3.14159*10., 2*3.14159/50, .0001, .0/) |
| 2670 | | real :: du(2) = (/0.5, 0.5/) |
| 2671 | | integer :: nd = 2 |
| 2672 | | real :: dt=2*3.14159265 |
| 2673 | | real :: t |
| 2674 | | A = 2.0 |
| 2675 | | om = 1.0 |
| 2676 | | Vm = A*om |
| 2677 | | u(1) = Vm/Vm |
| 2678 | | u(2) = 0 |
| 2679 | | k = 1 |
| 2680 | | n=1 |
| 2681 | | |
| 2682 | | open (unit=2, file = 'osc_rk0.dat' ,status='unknown') |
| 2683 | | write(*,*) 'x=' , u(1), 'v=', u(2) |
| 2684 | | pause |
| 2685 | | call rkgs(pr, u, du, nd, ih, fct, out, aux) |
| 2686 | | write(2,*) 'ih=', ih |
| 2687 | | stop |
| 2688 | | end |
| 2689 | | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2690 | | |
| 2691 | | subroutine fct (t, u, du) |
| 2692 | | real u(2), du(2) |
| 2693 | | common /a/ dt, k, n, A, Vm, om |
| 2694 | | du(1) = -u(2)/(1+0.1*sin(om*dt)) |
| 2695 | | du(2) = u(1) |
| 2696 | | return |
| 2697 | | end |
| 2698 | | |
| 2699 | | |
| 2700 | | subroutine out (t, u, du, ih, nd, pr) |
| 2701 | | real u(2), du(2), pr(5) |
| 2702 | | common /a/ dt, k, n, A, Vm, om |
| 2703 | | |
| 2704 | | if(t.ge.k*(dt/50.)) then |
| 2705 | | write (2,1) t/om, u(1)*Vm, u(2)*A |
| 2706 | | k=k+1 |
| 2707 | | else |
| 2708 | | end if |
| 2709 | | |
| 2710 | | 1 format (f8.3, f8.3, f8.3) |
| 2711 | | return |
| 2712 | | end |
| 2713 | | |
| 2714 | | |
| 2715 | | |
| 2716 | | }}} |
| 2717 | | |
| 2718 | | == Console9/Console9/Console9.f90 == |
| 2719 | | {{{ |
| 2720 | | #!fortran |
| 2721 | | ! Console9.f90 |
| 2722 | | ! |
| 2723 | | ! FUNCTIONS: |
| 2724 | | ! Console9 - Entry point of console application. |
| 2725 | | ! |
| 2726 | | |
| 2727 | | !**************************************************************************** |
| 2728 | | ! |
| 2729 | | ! PROGRAM: Console9 |
| 2730 | | ! |
| 2731 | | ! PURPOSE: Entry point for the console application. |
| 2732 | | ! |
| 2733 | | !**************************************************************************** |
| 2734 | | |
| 2735 | | program Console9 |
| 2736 | | |
| 2737 | | implicit none |
| 2738 | | |
| 2739 | | ! Variables |
| 2740 | | |
| 2741 | | ! Body of Console9 |
| 2742 | | print *, 'Hello World' |
| 2743 | | |
| 2744 | | end program Console9 |
| 2745 | | |
| 2746 | | }}} |
| 2747 | | |
| 2748 | | == Eyler/Eyler/Eyler.f90 == |
| 2749 | | {{{ |
| 2750 | | #!fortran |
| 2751 | | real v,x,dt,t,dv,Fm |
| 2752 | | open(2,file='y2.dat', status='unknown') |
| 2753 | | q1=1.0e-9 |
| 2754 | | q2=1.0e-9 |
| 2755 | | r1=0.1 |
| 2756 | | r2=0.2 |
| 2757 | | d=0.5 |
| 2758 | | t0=d/v0 |
| 2759 | | n=100 |
| 2760 | | pi=3.141593 |
| 2761 | | E0=0.0 |
| 2762 | | v0=0.0 |
| 2763 | | dt=t0/n |
| 2764 | | x=x/d |
| 2765 | | write(*,*) dt |
| 2766 | | open(1,file='xv.dat', status='unknown') |
| 2767 | | Fm=q1/me/(vo**2) |
| 2768 | | print*, Fm |
| 2769 | | do k=1,n |
| 2770 | | t=k*dt |
| 2771 | | v=v+Fm*sin(2.0*pi*x)*dt |
| 2772 | | x=x+v*dt |
| 2773 | | |
| 2774 | | write(1,*) t*t0/1.0e-9, v*v0, x*d, sin(2.0*pi*x) |
| 2775 | | if(x.ge.1.0) then |
| 2776 | | write(1,*) t*t0/1.0e-9, v*vo, x*d |
| 2777 | | stop |
| 2778 | | else |
| 2779 | | end if |
| 2780 | | end do |
| 2781 | | end |
| 2782 | | }}} |