Oh say can you C?The proliferation of fast and cheap computers in the last few years has allowed the computational scientist to employ numerical methods of ever-increasing complexity and sophistication. As alogorithms used to solve physical problems advance in step with the faster CPU's, the programs that contain them are becoming larger and more difficult to manage. Compounding the problem for many researchers is the fact that they work with legacy codes written in fortran. A growing fortran code presents special concerns because the tendency is to just splice and tape a new subroutine into the existing mass of code. In addition, fortran's subroutine calls can quickly become unwieldy because of the number of variables involved in a complicated routine. Newer languages, specifically C and C++, offer enhanced features to more easily handle this type of situation. In both C and C++, the researcher can organize his data variables into "structures", which can often be treated as a single entity. For example, in a chemistry code, the atomic positions, velocities, and charges may all belong to a structure called "atom_info". Any time these variables are needed throughout the code, the entire structure can be passed to the subroutine in question, thus potentially reducing the call from a size of a dozen or so variable names down to just one. Besides helping to organize the data of a problem into reasonable categories, this use of structures can also obviously make a code much cleaner when read. In C++, the code developer can take advantage of the constructs of "object-oriented" programming to further organize his code. Functions and variables can be divided into objects that each have characteristics that distinguish them from the rest of the code. This scheme provides the ultimate in code organization, and is mimicked in fashionable languages such as Java. The C and C++ languages provide many benefits to the scientist who has an unwieldy code on his hand. With some work, it is not necessary to give up the performance benefits of fortran to attain these perks. In fact, fortran, C , and C++ can all be interwoven within the same code to bring the researcher the best of all worlds. Having surveyed the languages that form the "guts" of most scientific calculations, next time we'll take a look at some of the languages researchers are using for information dissemination.
The copyright of the article Oh say can you C? in Scientific Computing is owned by Adam Hughes. Permission to republish Oh say can you C? in print or online must be granted by the author in writing.
Go To Page: 1 Articles in this Topic Discussions in this Topic |