|
****JavaScript based drop down DHTML menu generated by NavStudio. (OpenCube Inc. - http://www.opencube.com)****
| Search |
|||||||||||||
|
Fortran Source, Spring 1998
Volume 14, Issue 1
FEATURES
DEPARTMENTS
LF90
v4.5 Released
VA performs static analysis of programs written in Fortran or C and provides visual displays of the analysis results. The displays allow you to check program structure, logic flow, standards conformance, argument mismatches, and more. VA includes a 90-page, online manual. (See "Understand Code with Visual Analyzer") SSL II is an optimized math library of linear algebra, eigenvalue and eigenvector, nonlinear equation, extrema, interpolation and approximation, transform, numerical differentiation and quadrature, differential equation, special function, and pseudo random number procedures. SSL II includes an 800-page online manual. (See "New SSL II Math and Statistics Library") A new version of the Winteracter Starter Kit (WiSK) offers semi-modeless dialog boxes, radio buttons, improvements to the visual dialog and menu editors, and a handful of miscellaneous new procedures. Support for linking Microsoft Visual C++ and Borland C++ code into your executable means you don't have to ship your mixed language applications with DLLs. You’ll also be able to link with commercial C libraries. (See "Static Linking with C”) An Automake Configuration File Editor is provided for creating and maintaining Automake configuration files. In addition, the LF90 v4.5 User’s Guide contains a revised Automake Chapter. The LF90 v4.5 User's Guide contains a revised Automake chapter and more Automake examples are included on the distribution CD. Update to LF90 v4.5 from v4.0 for US$150, from v3.5 for US$270, and
from v3.0 or earlier for US$350. Through July 31, 1998, a competitive
upgrade from 32-bit, PC Fortrans is available for US$595. New purchase
price is US$895. Shipping and handling is not included.
Understand
Code with Visual Analyzer
Now you could break out some butcher paper and colored pens and try diagramming the program's call tree and the logic flow of the important program units. Might even be fun to do, but it's going to take a week or two to get any kind of grasp and you might make some mistakes. Fujitsu's Visual Analyzer (VA) will do all of this and more for you
in less than the time it takes to compile the code. VA will produce
a graphical call tree.
The call tree can be focused to just the section of the program you are interested in. VA will show you each program unit's logic flow.
You can filter in or out of the logic flow program comments, include files, and C header files. VA will also show you a detailed cross reference of all the variables in the program and where modules and commons are defined and referenced. C global variable definitions and references are also displayed. More than that, VA will detect subtle programming errors, even across multiple files. A couple of mouse clicks gets you a list of argument mismatches, common block misalignments, and violations of the Fortran and C standards. Still want to mess with the butcher paper and colored pens? Visual Analyzer is bundled at no extra charge with version 4.5 of LF90.
A standalone version of Visual Analyzer will be available soon.
An
LF90-Based Application Development System for Global Optimization
The objective of global optimization (GO) is to find the best solution of difficult nonlinear decision models in the presence of multiple local solutions (Horst and Pardalos, 1995; Pinter 1996). For illustration, consider the multiextremal function shown below. This could depict, for example, a projection of the aggregated error function in an inverse model parameterization (calibration) problem.
Typically, GO problems are very difficult to solve, and require a sophisticated model development environment. When I started to develop LGO, a proprietary integrated modeling and solver system for analyzing general-continuous and Lipschitz-GO problems (Pintér, 1997), I was looking for a robust and efficient software platform. LGO was to be suitable to handle GO problems which are related to standalone “black box” system models or to models supported by limited, difficult-to-use analytical information. This feature makes LGO uniquely and easily applicable to numerous scientific, engineering, and economic decision problems. However, it also implies specific requirements of the implementation platforms. The possibility of external system calls and mixed platform development was among the most highly desirable features. Further, a consistent and aesthetic DOS and Windows 3.1x/95/NT interface has also been one of the important criteria. Obviously, robustness and program execution speed have been also crucial, since GO problems tend to be numerically very demanding (even problems in, say, 5 or 10 variables can be far from trivial). Lahey Fortran has all the listed capabilities and its add-on LISK/WiSK interface libraries also make possible very fast problem visualization. Graphical problem representation-built into LGO-can greatly assist the model development and solution process. An excellent feature of Lahey Fortran is its direct connectivity to several other popular platforms such as Borland Delphi, Microsoft Visual Basic, and C/C++ environments, in addition to its generic connectivity to Windows applications. Last, but very far from least, over the past years I have found Lahey's customer support truly responsive, knowledgeable, and fast. As a result, Lahey Fortran has become my primary LGO development platform. Currently, LGO is implemented at leading universities, research institutes, and several major industrial companies in over half a dozen countries. Among other tasks, it is used for robust product design, model development in chemical industries, hydrodynamical design, and environmental management decision support. (LGO demonstration executable programs, a detailed list of relevant professional references, and additional information are available upon request.) References
János D. Pintér can be reached at Pintér Consulting Services, 129 Glenforest Drive, Halifax, NS, Canada B3M 1J2, +1-902-443-5910, pinter@tuns.ca, http://www.tuns.ca/~pinter. LF90-Compatible
IMSL
Static
Linking with C
Version 4.5 of LF90 supports static linking with Microsoft Visual C++ version 2.0 and greater and with Borland C++ version 4.5 and greater. The LF90 driver automates the process of linking your LF90 code with C code produced by either of these compilers. Still, there are several steps and a few pitfalls. For this article we will create a simple program in Fortran 90, then link with the required C libraries to create a working application. This and other examples (including an example using OpenGL) are provided on the LF90 v4.5 CD. The program we will create has Fortran calling C. You can also create applications that call Fortran from C. This program creates a table of Fahrenheit to Centigrade conversions. The main program and some of the I/O are in Fortran. The calculations and the rest of the I/O are done in C. The program also exercises LF90's ability to create Fortran common blocks accessible by C and to properly invoke and return values from C functions. Our Fortran 90 code looks like this:
! F90CALLC.F90 ! 1
! Copyright 1998 Lahey Computer Systems, Inc. ! 2
! ! 3
ml_external GenTable ! 4
integer gentable,totalf ! 5
real totalc ! 6
common /mycommon/ totalc, totalf ! 7
integer start, end, table_lines ! 8
! 9
write(6,1) 'Where should the table start (enter an &
&integer less than 10) ? ' ! 10
read(5,*) start ! 11
write(6,1) 'In Fortran, now calling C' ! 12
table_lines=gentable(start, end) ! 13
write(6,1) 'Back in Fortran, after calling C' ! 14
write(6,2) 'The table ended at:',end ! 15
write(6,3) 'Total degrees c=',totalc ! 16
write(6,2) 'Total degrees f=',totalf ! 17
! 18
write(6,2) 'Number of lines in table:',table_lines ! 19
1 format(1x,a) ! 20
2 format(1x,a,i4) ! 21
3 format(1x,a,f6.2) ! 22
end ! 23
! 24
block data setmycommon ! 25
common /mycommon/ totalc, totalf ! 26
data totalc/0.0/, totalf/0.0/ ! 27
end block data setmycommon ! 28
Our C code looks like this:
/* F90callC1.C */ // 29
/* Copyright 1998 Lahey Computer Systems, Inc. */ // 30
// 31
#include <stdio.h> // 32
#include <stdlib.h> // 33
// 34
#define common(name) lc_##name // 35
/* prepending lc_ matches name generated by LF90 */ // 36
// 37
extern struct // 38
{ // 39
float total_c; // 40
int total_f; // 41
} common(MYCOMMON); // 42
// 43
// 44
int GenTable(int *start, int *end) // 45
{ // 46
char endstring[10]; // 47
int f; // 48
float c; // 49
FILE *output; // 50
int lines_in_table, lines_left; // 51
// 52
/* Fortran leaves us on the line just printed, so we need to output */ // 53
/* an extra newline before we do any I/O */ // 54
printf("\n"); // 55
// 56
printf("IN C\n"); // 57
printf("%s%s", "Where should the table end (Enter an ",
"integer less than 30) ? "); // 58
gets(endstring); // 59
*end=atoi(endstring); // 60
output=fopen("F90callC.out","w"); // 61
printf("Placing Fahrenheit to Centigrade table in F90CALLC.OUT\n");// 62
lines_left = lines_in_table = *end - *start + 1; // 63
for (f=*start; lines_left > 0; f++, lines_left--) // 64
{ // 65
c=5./9.*(f-32); // 66
common(MYCOMMON).total_c+=c; // 67
common(MYCOMMON).total_f+=f; // 68
fprintf(output,"%d F = %f C\n",f,c); // 69
} // 70
fclose(output); // 71
printf("Table generated\n"); // 72
// 73
/* After the last thing output from C, it is easiest to stay on the */ // 74
/* same line so the next thing output from Fortran can use standard */ // 75
/* carriage control */ // 76
printf("LEAVING C"); /* note the lack of a \n */ // 77
// 78
/* We flush stdout to make sure all output is out of the buffers */ // 79
/* and displayed on the screen. If we don't do this, Fortran may */ // 80
/* end up displaying its output before C */ // 81
fflush(stdout); // 82
// 83
return(lines_in_table); // 84
} // 85
The first thing to notice is the ML_EXTERNAL declaration in line 4. All C functions referenced in your Fortran code must be declared using the ML_EXTERNAL statement. Notice that the arguments on the C side of GenTable are picked up by reference instead of by value (note the * in front of the variable names in GenTable's argument list on line 45 and references to those variables on line 63). You could instead pass by value if you wished, using the Fortran CARG intrinsic procedure with each argument in the invocation of GenTable on line 13. To access the common block defined on line 7 from C we will need to pick up the values as components of a C structure. This structure is declared in lines 35 to 42. The #define on line 35 prepends a leading "lc_" to the structure name, which LF90 requires. Use of the #define will make subsequent code more readable, as in lines 67 and 68. The final perhaps non-intuitive thing to do is to flush stdout before returning to Fortran from C. Otherwise, the C output might display after output from subsequent Fortran I/O statements. A linker response file, provided with LF90, automates the link process. Before using this file you must edit it to make sure that the libpath switch points to the correct directory where the C libraries reside. To build the executable, first compile the C source as follows for Microsoft Visual C++: CL /c F90CALLC1.COr as follows for Borland C++: BCC32 /c F90CALLC1.CThen compile the Fortran source and link using the following command line: LF90 F90CALLC.F90 F90CALLC1.OBJ -WINCONSOLE -ML MSVC -STATICLINK(use -ML BC if you are using Borland C++) We now run the executable file and get the following output: Where should the table start (enter an integer less than 10) ? 3 In Fortran, now calling C IN C Where should the table end (Enter an integer less than 30) ? 29 Placing Fahrenheit to Centigrade table in F90CALLC.OUT Table generated LEAVING C Back in Fortran, after calling C The table ended at: 29 Total degrees c= -240.00 Total degrees f= 432 Number of lines in table: 27 That's all there is to it (and you thought this was going to be hard). New
SSL II Math and Statistics Library
Linear Algebra
Eigenvalues and Eigenvectors
Nonlinear Equations
Extrema
Interpolation and Approximation
Transforms
Numerical Differentiation and Quadrature Differential Equations Special Functions
Pseudo Random Numbers
Free,
Unlimited Tech Support
Some of the answers we give can be found in the manuals, readme files, and the Frequently Asked Questions at our Web site, http://www.lahey.com/faq.htm. Check these sources before you call. We look forward to helping you find solutions to your problems.
CEO's
Letter
Now we come to the best part. You try Essential LF90 for a while and find you would like to see some changes. Send me e-mail (tlahe@lahey.com) telling me the changes you would make for the educational version and, more importantly, what Essential LF90 needs to make it a production language. I'll consider and respond to every suggestion. I have a caution here. As examples, please don't suggest restoration of multiple statements per line in the educational version or to allow the PRINT statement. One of our goals is to keep the educational version minimal. In the Fortran 90 Workshops, I have learned that few sites adhere to a Fortran coding standard -- each programmer does his/her own thing. My perception is that most workshop participants agree that a standard would be a good thing for their group. Here's a shortcut to getting a good start on a Fortran coding standard: Adopt Essential LF90! I guarantee your group's code will be meaningfully more consistent. Last argument: Do you remember reading above that Essential LF90 has no extensions? That means that taking into account "implementation dependent," your code will port to other platforms with zero changes. Here's another shortcut. The US Geological Survey has a Fortran [77] Coding Standard; it's available at http://water.usgs.gov/software/sysdoc.html. Regards,
New
ISV Products
The following three products are available from AEM Engineering Computations: FORGL
µRAS
µHIDE
AEM Engineering Computations
News
Briefs
Lahey/Fujitsu
Alliance
"Fujitsu's strength in code generation and optimization technology, the craftsmanship of their tools and their experience in Fortran will augment our existing strengths in the PC Fortran marketplace," said Bob Runyan, President, Lahey Computer Systems. "Together we will have the development, distribution, service, and support strength to continue to bring the best Fortran tools to Windows users worldwide." According to Toshiaki Hirota, Manager of Compiler Technology for Fujitsu, "Fujitsu is delighted to enter into this alliance with Lahey Computer Systems. Lahey's solid reputation and expertise in the PC Fortran arena will complement Fujitsu's high performance and reliable compiler technology making world-class Fortran development tools possible." Founded in 1935, Fujitsu Limited is an international leader in information
technology, telecommunications, semiconductors, and other electronics devices.
Fujitsu, with over 400 technology, software, and service companies, posted
global revenues of more than US$36 billion in the fiscal year ended March
31, 1997. Visit Fujitsu at http://www.fujitsu.co.jp/index-e.html.
Fortran
90 Workshop IX
"I learned that in some large measures my goals were rather naive. It is not simply a question of adding some more modern features, but to a large extent exploring a new way of coding. This will require some careful consideration and a lot of experience - but I am NO LONGER AFRAID OF IT! THANKS!" Stephen Ross, University of New Brunswick "I wouldn't know what I was missing in Fortran 90 without coming to the workshop. I didn't need a semester-long class to learn Fortran 90 as may be taught at colleges. I needed a transition class like this one." Kevin Bratcher, Framatome Technologies "Both Tim and Tom are excellent teachers, and the Lahey staff was great. I had a wonderful time! I would and will recommend your workshop to others." Paula Arsenault, PMA Engineering Call us to reserve your seat at our next Fortran 90 Workshop!
1998
Reseller Seminar
1998
Lahey User Meeting
Here's what happened: Tom Lahey discussed the future of Fortran. Bob Runyan, President, Lahey Computer Systems, and Steven Terui, Fortran Product Manager, Fujitsu Software Corporation, discussed the new features of LF90 v4.5. Steven demonstrated the Fujitsu Visual Analyzer and talked a bit about the Lahey/Fujitsu Fortran Alliance. Richard Hanson, Visual Numerics, Inc., talked about the Lahey/VNI relationship and discussed the Fortran 90 advantages of the IMSL Fortran 90 MP Library. Mike Boucher, Vice President, Dakota Scientific Software, talked about parallel processing and high performance math libraries. David McNamara, Product Manager, Pacific-Sierra Research Corporation, gave us some advice about porting FORTRAN 77 code to Fortran 90 using the VAST 77 to 90 translator. Bruce Bush, Indowsway Software, and Eric Wilson, Berkeley Simulation Software, demonstrated how to use RealWin to create custom Windows applications. Kevin Bradly, Bradly Associates, showed how GinoMenu makes Windows GUI programming easy. Lawson Wakefield, Interactive Software Services, was unable to attend, but did send along a 25-minute, multimedia presentation of Winteracter, MenuED, DialogED, and the beta version of his new Winteracter Development Environment (WiDE). Joe Chirieleison, Lahey Computer Systems, demonstrated a blackjack program written with LF90 and the Winteracter Starter Kit. Howell Johnson, Lahey Computer Systems, discussed calling Fortran DLLs from Windows applications. John Appleyard, President, Polyhedron Software, showed us the new Automake Configuration File Editor and talked about the benefits of using the plusFORT analysis tools. We all sat around on Thursday evening and discussed things like DLLs, graphics, and exception handling. A lot happened in two days. Thank you to all our guest speakers
for your well received presentations and to Danielle Kirby for organizing
the 1998 Lahey User Meeting.
Q&A
You must have the LF90 keyword in AUTOMAKE.FIG. If it is omitted, Automake will not run the LF90 compiler. In most cases the COMPILE= commands should have -c as a switch. The exception is when building libraries. Every FILES= statement should have an associated COMPILE= statement, which should occur before the AND. If the COMPILE= is omitted, it will use the default command, even if another COMPILE= command is specified further down in the file. If you have multiple FILES= statements, you cannot use a response file to compile your code. A response file in the link command is fine in this situation. If you need to link in a .LIB file that's not in the same as directory as your program source files, you need a "-lib x:\mypath\mylib" statement on your LINK= line. LF90 v4.5 includes the new Windows Automake Configuration File Editor. Give it a try. Q: Do my programs
have a "Year 2000" date problem?
Our Fortran 90 compiler, LF90, and our educational Fortran compiler, Essential LF90, include the Fortran 90 standard DATE_AND_TIME subroutine. DATE_AND_TIME returns a 4-digit date. We recommend changing all code that uses DATE to use DATE_AND_TIME instead. DATE_AND_TIME is not included with our FORTRAN 77 compiler, F77L-EM/32. We recommend that EM/32 owners upgrade to LF90. Q: Does LF90
support Holleriths?
When literal data of any type, including those using a Hollerith, are assigned to a variable that has not been declared as a character. When a Hollerith is used and the line has characters past column 72. When a Hollerith is extended to the next line. The TRANSFER function or EQUIVALENCE statement can be used if a numeric representation of a variable is required after it has been assigned an alpha-numeric expression by a Hollerith. The TRANSFER function is recommended. Q: When compiling
my LF90 programs from the Editor, the compiler output is not showing up.
What could be the problem?
Q: Are C compilers
compatible with Lahey Fortran 90?
Q: Where can
I find a listing of LF90 runtime error messages?
Q: What can
I do to minimize the size of my Windows executable program?
Consider compiling for DOS (using -nwin -pack -bind) and running the resulting program in a DOS box. This will give you an extended-DOS rather than a Windows console-mode application. Our linker will compress extended-DOS applications. Make your large arrays allocatable (a Fortran 90 feature). In this way, your executable stays small. You allocate the memory at runtime as needed. There is a third-party product called Shrinker available from Blink,
Inc. that will compress your Windows executables. See http://www.blinkinc.com.
|