To build the DLL file, I used the old Compaq Visual Fortran (version 6.6) compiler. INTEGER*4, INTENT(OUT) :: OUTARRAY(ELEMENTS)ġ. INTEGER*4, INTENT(IN) :: INARRAY(ELEMENTS) !Receives as input a one-dimensional array and it doubles tis values. SUBROUTINE DOUBLEARRAY (ELEMENTS, INARRAY, OUTARRAY) !Calculate the intermediate variables A and B.Ī=((2.457 * LOG(1. REYNOLDS = (DIAMETER * VELOCITY) / VISCOSITY !Calculate the Reynolds number (diameter in m, velocity in m/s, kinematic viscosity in m2/s). REAL*8:: FRICTIONFACTOR,ROUGHNESS, DIAMETER, VELOCITY, VISCOSITY ,REYNOLDS, A, B, C, D !This equation is valid for all types of flows (from laminar to turbulent). !Calculates the friction factor of a pipe using Churchill's equation (1977). !DEC$ ATTRIBUTES DLLEXPORT:: FRICTIONFACTOR FUNCTION FRICTIONFACTOR (ROUGHNESS, DIAMETER, VELOCITY,VISCOSITY) thesis (actually Fortran became case-insensitive from Fortran 90 and onwards). By the way, sorry for the uppercase in the code, but it is an old habit that I acquired when I was writing the Fortran code for my M.Sc. I used the Fortran code that you will find below the FRICTIONFACTOR function is actually a Fortran version of an old VBA function that I developed some years ago. The first step in this tutorial is to build the DLL file. In short, the idea is to build a Dynamic-link library (DLL) file that will include the necessary Fortran functions and subs, and, then, call these functions/subs (DLL file) from VBA. Well, I have some good news, the answer is YES! So, in this post, I will try to provide you some insights about how to do it. And, now, the big question is: why not take advantage of the code already written in Fortran and use it from Excel/VBA? Is it possible to do that? Literally, thousands of lines of Fortran code have been written in the last 50+ years by several developers throughout the world. Only the above paragraph is probably not enough to describe the importance of the Fortran language in engineering and the scientific world. It is one of the most popular languages in the area of high-performance computing and is the language used for programs that benchmark and rank the world’s fastest supercomputers”. Originally developed by IBM in New York City in the 1950s for scientific and engineering applications, Fortran came to dominate this area of programming early on and has been in continuous use for over half a century in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, computational physics, and computational chemistry. According to Wikipedia: “Fortran (derived from Formula Translating System) is a general-purpose, imperative programming language that is especially suited to numeric computation and scientific computing.
0 Comments
Leave a Reply. |