# ---------------------------------------------------------------------- # LANGUAGE: Fortran 77 API # ====================================================================== # AUTHOR: Michael McLennan, Purdue University # Copyright (c) 2004-2012 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ====================================================================== language "Fortran 77" { extension ".f" # use the convention with "f77" on the end of the program name # so we can tell that this is a fortran program, not C language command {@tool/@@FILEROOT@@f77 @driver} main {c ---------------------------------------------------------------------- c MAIN PROGRAM - generated by the Rappture Builder c ---------------------------------------------------------------------- program main IMPLICIT NONE c stuff needed for Rappture: integer rp_lib, rp_units_convert_dbl integer io, ok character*255 inFile, strVal @@DECLARATIONS@@ c open the XML file containing the run parameters call getarg(1,inFile) io = rp_lib(inFile) if (io .eq. 0) then write(6,*) "FAILED loading Rappture data from ",inFile stop endif c ---------------------------------------------------------- c Get input values from Rappture c ---------------------------------------------------------- @@INPUTS@@ c ---------------------------------------------------------- c Add your code here for the main body of your program c ---------------------------------------------------------- c spit out progress messages as you go along... call rp_utils_progress (0, "Starting...") call rp_utils_progress (5, "Loading data...") call rp_utils_progress (50, "Half-way there") call rp_utils_progress (100, "Done") c ---------------------------------------------------------- c Save output values back to Rappture c ---------------------------------------------------------- @@OUTPUTS@@ call rp_result(io) end program main } input boolean { decl "\nc for $path" decl " logical $id" code "\nc get input value for $path" code " call rp_lib_get(io,\n + \"$path.current\", strVal)" code " $id = (strVal .eq. 'yes')" } input image { code "\nc get input value for $path" code "c returns base64-encoded image data" code " call rp_lib_get(io,\n + \"$path.current\", strVal)" } input integer { decl "\nc for $path" decl " integer $id" code "\nc get input value for $path" code " call rp_lib_get(io,\n + \"$path.current\", strVal)" code " read(strVal,*) $id" } input number { set units [attr get units] if {$units ne ""} { decl "\nc for $path" decl " double precision $id" code "\nc get input value for $path and convert to $units" code " call rp_lib_get(io,\n + \"$path.current\", strVal)" code " ok = rp_units_convert_dbl(strVal,\"$units\",$id)" code " if (ok .ne. 0) then" code " write(6,*) \"Error while loading \", \"$path\"" code " stop" code " endif" } else { decl "\nc for $path" decl " double precision $id" code "\nc get input value for $path" code " call rp_lib_get(io,\n + \"$path.current\", strVal)" code " read(strVal,*) $id" } } input string { decl "\nc for $path" decl " character*255 $id" code "\nc get input value for $path" code " call rp_lib_get(io,\n + \"$path.current\", $id)" } input * { code "\nc get input value for $path" code " call rp_lib_get(io,\n + \"$path.current\", strVal)" } output boolean { decl "\nc for $path" decl " logical $id" code "\nc save output value for $path" code " if ($id) then" code " strVal = 'yes'" code " else" code " strVal = 'no'" code " endif" code " call rp_lib_put_str(io,\n + \"$path.current\",strVal,0)" } output curve { code "\nc save output value for $path" code "c this shows just one (x,y) point -- modify as needed" code " write(strVal,'(E20.12,E20.12,A)') x, y, char(10)" code " call rp_lib_put_str(io,\n + \"$path.component.xy\",strVal,1)" } output histogram { code "\nc save output value for $path" code "c this shows just one point -- modify as needed" code "c (x,h,w) = x-coord, height of bar, and width of bar (optional)" code " write(strVal,'(E20.12,E20.12,E20.12,A)') x, h, w, char(10)" code " call rp_lib_put_str(io,\n + \"$path.component.xhw\",strVal,1)" } output image { code "\nc save output value for $path" code "c data should be base64-encoded image data" code " call rp_lib_put_str(io,\n + \"$path.current\",$id,0)" } output integer { decl "\nc for $path" decl " integer $id" code "\nc save output value for $path" code " write(strVal,*) $id" code " call rp_lib_put_str(io,\n + \"$path.current\",strVal,0)" } output number { decl "\nc for $path" decl " double precision $id" code "\nc save output value for $path" code " write(strVal,*) $id" code " call rp_lib_put_str(io,\n + \"$path.current\",strVal,0)" } output string { decl "\nc for $path" decl " character*255 $id" code "\nc save output value for $path" code " call rp_lib_put_str(io,\n + \"$path.current\",$id,0)" } output * { code "\nc save output value for $path" code " call rp_lib_put_str(io,\n + \"$path.current\",$id,0)" } makefile {# simple makefile for a Rappture-based program FC = gfortran FCFLAGS = -g -Wall RAPPTURE_DIR = @@RAPPTUREDIR@@ INCLUDES = -I$(RAPPTURE_DIR)/include LIBS = -L$(RAPPTURE_DIR)/lib -lrappture -lm all: @@FILEROOT@@f77 @@FILEROOT@@f77: @@FILENAME@@ $(FC) $(FCFLAGS) $(INCLUDES) $< -o $@ $(LIBS) install: clean: $(RM) @@FILEROOT@@f77 run*.xml } }