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

Last change on this file since 555 was 555, checked in by dkearney, 18 years ago

updated examples removing output sections from tool.xml files and making the example code generate the output section using the rappture library put command. this change is made in the example files to help curb people from defining output sections in their tool.xml files. the output sections should really be created inside the program when the output data is ready to be entered.

File size: 2.1 KB
RevLine 
[66]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.
[115]6c
[66]7c ======================================================================
8c  AUTHOR:  Michael McLennan, Purdue University
9c  AUTHOR:  Derrick Kearney, Purdue University
[115]10c  Copyright (c) 2004-2005  Purdue Research Foundation
11c
12c  See the file "license.terms" for information on usage and
13c  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
[66]14c ======================================================================
[115]15
[66]16      program fermi
17        IMPLICIT NONE
18
[119]19        integer rp_lib, rp_units_convert_dbl
[66]20
[83]21        integer driver, ok
[66]22        double precision T, Ef, kT, Emin, Emax, dE, f, E
[83]23        CHARACTER*100 inFile, strVal
[66]24        character*40 xy
25
26        call getarg(1,inFile)
27        driver = rp_lib(inFile)
28
[83]29        call rp_lib_get(driver,
30     +        "input.number(temperature).current", strVal)
31        ok = rp_units_convert_dbl(strVal,"K",T)
32
33        call rp_lib_get(driver,
34     +        "input.number(Ef).current", strVal)
35        ok = rp_units_convert_dbl(strVal,"K",Ef)
36
[66]37        kT = 8.61734e-5 * T
38        Emin = Ef - 10*kT
39        Emax = Ef + 10*kT
40
41        dE = 0.005*(Emax - Emin)
42
[555]43c       Label out graph with a title, x-axis label,
44c       y-axis label and y-axis units
45
46        call rp_lib_put_str (driver,"output.curve(f12).about.label",
47     +          "Fermi-Dirac Factor",0)
48        call rp_lib_put_str (driver,"output.curve(f12).xaxis.label",
49     +          "Fermi-Dirac Factor",0)
50        call rp_lib_put_str (driver,"output.curve(f12).yaxis.label",
51     +          "Energy",0)
52        call rp_lib_put_str (driver,"output.curve(f12).yaxis.units",
53     +          "eV",0)
54
[66]55        do 10 E=Emin,Emax,dE
56          f = 1.0/(1.0+exp((E-Ef)/kT))
57          write(xy,'(E20.12,F13.9,A)') f, E, char(10)
[555]58          call rp_lib_put_str (driver,
59     +          "output.curve(f12).component.xy", xy, 1)
[66]60 10     continue
61
62        call rp_result(driver)
63      end program fermi
Note: See TracBrowser for help on using the repository browser.