source: branches/1.7/builder/scripts/templates/fortran77.tl @ 6307

Last change on this file since 6307 was 6307, checked in by ldelgass, 6 years ago

merge r6291 from 1.6 branch

File size: 6.4 KB
Line 
1# ----------------------------------------------------------------------
2#  LANGUAGE:  Fortran 77 API
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
6#
7#  See the file "license.terms" for information on usage and
8#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9# ======================================================================
10language "Fortran 77" {
11  extension ".f"
12
13  # use the convention with "f77" on the end of the program name
14  # so we can tell that this is a fortran program, not C language
15  command {@tool/@@FILEROOT@@f77 @driver}
16
17  main {c ----------------------------------------------------------------------
18c  MAIN PROGRAM - generated by the Rappture Builder
19c ----------------------------------------------------------------------
20      program main
21        IMPLICIT NONE
22
23c       stuff needed for Rappture:
24        integer rp_lib, rp_units_convert_dbl
25        integer io, ok
26        character*255 inFile, strVal
27
28@@DECLARATIONS@@
29
30c       open the XML file containing the run parameters
31        call getarg(1,inFile)
32        io = rp_lib(inFile)
33        if (io .eq. 0) then
34            write(6,*) "FAILED loading Rappture data from ",inFile
35            stop
36        endif
37
38c       ----------------------------------------------------------
39c       Get input values from Rappture
40c       ----------------------------------------------------------
41@@INPUTS@@
42
43c       ----------------------------------------------------------
44c          Add your code here for the main body of your program
45c       ----------------------------------------------------------
46
47c       spit out progress messages as you go along...
48        call rp_utils_progress (0, "Starting...")
49        call rp_utils_progress (5, "Loading data...")
50        call rp_utils_progress (50, "Half-way there")
51        call rp_utils_progress (100, "Done")
52
53c       ----------------------------------------------------------
54c       Save output values back to Rappture
55c       ----------------------------------------------------------
56@@OUTPUTS@@
57
58        call rp_result(io)
59      end program main
60}
61
62  input boolean {
63    decl "\nc       for $path"
64    decl "        logical $id"
65    code "\nc       get input value for $path"
66    code "        call rp_lib_get(io,\n     +    \"$path.current\", strVal)"
67    code "        $id = (strVal .eq. 'yes')"
68  }
69  input image {
70    code "\nc       get input value for $path"
71    code "c       returns base64-encoded image data"
72    code "        call rp_lib_get(io,\n     +    \"$path.current\", strVal)"
73  }
74  input integer {
75    decl "\nc       for $path"
76    decl "        integer $id"
77    code "\nc       get input value for $path"
78    code "        call rp_lib_get(io,\n     +    \"$path.current\", strVal)"
79    code "        read(strVal,*) $id"
80  }
81  input number {
82    set units [attr get units]
83    if {$units ne ""} {
84      decl "\nc       for $path"
85      decl "        double precision $id"
86      code "\nc       get input value for $path and convert to $units"
87      code "        call rp_lib_get(io,\n     +    \"$path.current\", strVal)"
88      code "        ok = rp_units_convert_dbl(strVal,\"$units\",$id)"
89      code "        if (ok .ne. 0) then"
90      code "          write(6,*) \"Error while loading \", \"$path\""
91      code "          stop"
92      code "        endif"
93    } else {
94      decl "\nc       for $path"
95      decl "        double precision $id"
96      code "\nc       get input value for $path"
97      code "        call rp_lib_get(io,\n     +    \"$path.current\", strVal)"
98      code "        read(strVal,*) $id"
99    }
100  }
101  input string {
102    decl "\nc       for $path"
103    decl "        character*255 $id"
104    code "\nc       get input value for $path"
105    code "        call rp_lib_get(io,\n     +    \"$path.current\", $id)"
106  }
107  input * {
108    code "\nc       get input value for $path"
109    code "        call rp_lib_get(io,\n     +    \"$path.current\", strVal)"
110  }
111
112  output boolean {
113    decl "\nc       for $path"
114    decl "        logical $id"
115    code "\nc       save output value for $path"
116    code "        if ($id) then"
117    code "          strVal = 'yes'"
118    code "        else"
119    code "          strVal = 'no'"
120    code "        endif"
121    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",strVal,0)"
122  }
123  output curve {
124    code "\nc       save output value for $path"
125    code "c       this shows just one (x,y) point -- modify as needed"
126    code "        write(strVal,'(E20.12,E20.12,A)') x, y, char(10)"
127    code "        call rp_lib_put_str(io,\n     +    \"$path.component.xy\",strVal,1)"
128  }
129  output histogram {
130    code "\nc       save output value for $path"
131    code "c       this shows just one point -- modify as needed"
132    code "c       (x,h,w) = x-coord, height of bar, and width of bar (optional)"
133    code "        write(strVal,'(E20.12,E20.12,E20.12,A)') x, h, w, char(10)"
134    code "        call rp_lib_put_str(io,\n     +    \"$path.component.xhw\",strVal,1)"
135  }
136  output image {
137    code "\nc       save output value for $path"
138    code "c       data should be base64-encoded image data"
139    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",$id,0)"
140  }
141  output integer {
142    decl "\nc       for $path"
143    decl "        integer $id"
144    code "\nc       save output value for $path"
145    code "        write(strVal,*) $id"
146    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",strVal,0)"
147  }
148  output number {
149    decl "\nc       for $path"
150    decl "        double precision $id"
151    code "\nc       save output value for $path"
152    code "        write(strVal,*) $id"
153    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",strVal,0)"
154  }
155  output string {
156    decl "\nc       for $path"
157    decl "        character*255 $id"
158    code "\nc       save output value for $path"
159    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",$id,0)"
160  }
161  output * {
162    code "\nc       save output value for $path"
163    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",$id,0)"
164  }
165
166  makefile {# simple makefile for a Rappture-based program
167
168FC              = gfortran
169FCFLAGS         = -g -Wall
170
171RAPPTURE_DIR    = @@RAPPTUREDIR@@
172INCLUDES        = -I$(RAPPTURE_DIR)/include
173LIBS            = -L$(RAPPTURE_DIR)/lib -lrappture -lm
174
175
176all: @@FILEROOT@@f77
177
178@@FILEROOT@@f77: @@FILENAME@@
179        $(FC) $(FCFLAGS) $(INCLUDES) $< -o $@ $(LIBS)
180
181install:
182
183clean:
184        $(RM) @@FILEROOT@@f77 run*.xml
185}
186}
Note: See TracBrowser for help on using the repository browser.