source: trunk/examples/app-fermi/fortran/fermi.f

Last change on this file was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 2.8 KB
Line 
1c ----------------------------------------------------------------------
2c  EXAMPLE: Fermi-Dirac function in Fortran.
3c
4c  This simple example shows how to use Rappture within a simulator
5c  written in Fortran.
6c
7c ======================================================================
8c  AUTHOR:  Michael McLennan, Purdue University
9c  AUTHOR:  Derrick Kearney, Purdue University
10c  Copyright (c) 2004-2012  HUBzero Foundation, LLC
11c
12c  See the file "license.terms" for information on usage and
13c  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14c ======================================================================
15
16      program fermi
17        IMPLICIT NONE
18
19        integer rp_lib, rp_units_convert_dbl
20
21        integer driver, ok, progress
22        double precision T, Ef, kT, Emin, Emax, dE, f, E
23        CHARACTER*100 inFile, strVal
24        character*40 xy
25
26        call getarg(1,inFile)
27        driver = rp_lib(inFile)
28        if (driver .eq. 0) then
29            write(0,*) "Error while opening ",inFile
30            stop
31        endif
32
33        call rp_lib_get(driver,
34     +        "input.number(temperature).current", strVal)
35        ok = rp_units_convert_dbl(strVal,"K",T)
36        if (ok .ne. 0) then
37            write(strVal,*) "Error while converting temperature"
38            write(0,*) strVal
39            call rp_lib_put_str (driver,"output.log",strVal,0)
40            call rp_result(driver)
41            stop
42        endif
43
44        call rp_lib_get(driver,
45     +        "input.number(Ef).current", strVal)
46        ok = rp_units_convert_dbl(strVal,"eV",Ef)
47        if (ok .ne. 0) then
48            write(strVal,*) "Error while converting Ef"
49            write(0,*) strVal
50            call rp_lib_put_str (driver,"output.log",strVal,0)
51            call rp_result(driver)
52            stop
53        endif
54
55        kT = 8.61734e-5 * T
56        Emin = Ef - 10*kT
57        Emax = Ef + 10*kT
58
59        dE = 0.005*(Emax - Emin)
60
61c       Label out graph with a title, x-axis label,
62c       y-axis label and y-axis units
63
64        call rp_lib_put_str (driver,"output.curve(f12).about.label",
65     +          "Fermi-Dirac Factor",0)
66        call rp_lib_put_str (driver,"output.curve(f12).xaxis.label",
67     +          "Fermi-Dirac Factor",0)
68        call rp_lib_put_str (driver,"output.curve(f12).yaxis.label",
69     +          "Energy",0)
70        call rp_lib_put_str (driver,"output.curve(f12).yaxis.units",
71     +          "eV",0)
72
73        do 10 E=Emin,Emax,dE
74          f = 1.0/(1.0+exp((E-Ef)/kT))
75          progress = nint((E-Emin)/(Emax-Emin)*100)
76          call rp_utils_progress (progress,"Iterating")
77          write(xy,'(E20.12,F13.9,A)') f, E, char(10)
78          call rp_lib_put_str (driver,
79     +          "output.curve(f12).component.xy", xy, 1)
80 10     continue
81
82        call rp_result(driver)
83      end program fermi
Note: See TracBrowser for help on using the repository browser.