Run Fortran Code - Tips from Ilango

In summary, the author is trying to compile a Fortran program, but is having errors due to missing variables. He suggests contacting the authors to ask for help.
  • #1
Ilango
3
0
Dear all,
Let me introduce myself first. I am Ilango from India. I am new to Fortran, mostly working on Matlab, Modelica & Dymola. Working in an automobile company I was required to go through some battery models and hence landed at this page. http://www.cchem.berkeley.edu/jsngrp/fortran.html
It contains a model of a battery entirely built in Fortran. The author claims it to be a full running model. In spite of following the instructions to run the model at the end of the same page, I only get a page full of errors due to missing variables. Any help in getting this model run would be greatly appreciated. Thank you.
Regards,
Ilango
 
Technology news on Phys.org
  • #2
Ilango said:
I only get a page full of errors due to missing variables.
Ilango

"missing variables" is vague. This sounds like a compiler or linker error. Are you running the executable program, compiling the Fortran, or linking the final executable? You need to give more detail about what you did and exactly what the errors are.
 
  • #3
FactChecker said:
"missing variables" is vague. This sounds like a compiler or linker error. Are you running the executable program, compiling the Fortran, or linking the final executable? You need to give more detail about what you did and exactly what the errors are.

Hi Fastchecker,
The link pasted in my first post contains a fortran program by name "dualfoin5.2.f". I had compiled it in DOS by typing g77 dualfoin5.2.f. Ideally, I should receive an executable file by name a.exe.

Some where after the start of the program it reads, "open (1, FILE = 'li-ion.in', status = 'old')", which I think the program has to open a file called "li-ion.in". In the attached picture showing the error message, the first few lines mean that the missing variables which have to be loaded from "li-ion.in" is not being loaded. The rest of the error message is releated to an error in calling a function by name "vardc" coded inside "dualfoil5.2.f" itself. Looking for a way to run this.

Also attached is the code of dualfoin5.2.f. Please rename it from *.txt to *.f
 

Attachments

  • Error.jpg
    Error.jpg
    40 KB · Views: 454
  • dualfoil5.2.txt
    214.3 KB · Views: 476
  • #4
The first problem encountered is in the piece of code
Code:
c     Split of RG into its components;Test for first leg. WHT 3/10/14
      RG=RGin(1) total resistance in foils, leads, and contacts, ohm-m2
      RGn=RG/3.0d0 resistance affecting negative half cell
      RGp=RG-RGn resistance affecting positive half cell
      RGext=RG/4.0d0  resistance outside cell
There is a blaring mistake here, as comments are not preceded by a !. It should read
Code:
c     Split of RG into its components;Test for first leg. WHT 3/10/14
      RG=RGin(1) ! total resistance in foils, leads, and contacts, ohm-m2
      RGn=RG/3.0d0 ! resistance affecting negative half cell
      RGp=RG-RGn ! resistance affecting positive half cell
      RGext=RG/4.0d0  ! resistance outside cell
The first commented line makes me think that this was a later modification. It obviously has never been tested, as no compiler would be able to compile this code. It might be that the authors have put a link to the wrong file.

I strongly suggest contacting those who wrote the code and ask them. I wouldn't trust any program that has such blatant errors, since it is not debugged.
 
  • #5
Thank you DrClaude. You were really quick. Will get in touch with the author. Thank you.
 

1. What is Fortran code?

Fortran (FORmula TRANslation) is a high-level programming language designed specifically for scientific and engineering applications. It was first developed in the 1950s and has evolved over the years to become one of the most widely used programming languages in scientific computing.

2. How do I run Fortran code?

To run Fortran code, you will need a Fortran compiler installed on your computer. Once you have a compiler, you can write your code in a text editor and save it with the .f90 or .f95 extension. Then, use the compiler to translate your code into an executable file, which you can run on your computer.

3. What are some tips for writing efficient Fortran code?

Some tips for writing efficient Fortran code include using arrays instead of loops, minimizing the use of unnecessary variables, and using built-in functions instead of writing your own. Additionally, optimizing your code for the specific compiler and hardware you are using can also improve its efficiency.

4. How do I debug my Fortran code?

Debugging is an important part of the coding process. To debug your Fortran code, you can use a debugger tool such as GDB or a debugger built into your Fortran compiler. These tools allow you to step through your code line by line and identify any errors or bugs.

5. Can I use Fortran with other programming languages?

Yes, Fortran can be used in conjunction with other programming languages. Many scientific computing applications use a combination of Fortran, C, and C++ to take advantage of the strengths of each language. Additionally, there are tools and libraries available that allow for interoperability between Fortran and other languages.

Similar threads

  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
2
Replies
61
Views
21K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
2
Views
12K
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
8
Views
12K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
727
  • Quantum Physics
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top