Fortran code conversion into Excel VBA

In summary, the conversation is about someone seeking help with converting a Fortran code into Excel VBA. They have encountered problems with converting a COMMON statement in Fortran to VBA and are unsure about how to define arrays and global variables in VBA. They also have questions about the WRITE statement in Fortran and how it translates to VBA. They are looking for assistance with these issues.
  • #1
kay90
3
0
Hi,

I'm currently working on a project that requires me to convert a Fortran code into excel vba.
There are some problems that I've stumbled into, so itll be great if someone could help out.

one of it would be on how to convert a COMMON statement in Fortran to Excel VBA ( as in how would the coding be??) the coding is below:


IMPLICIT REAL*8 (A-H,O-Z)
REAL*8 C2X,C3X
REAL*8 KR1E,KR2E,M,N
COMMON /INFSVE/ PRES,TRES,SALN,FOINIT,DENC,ZC,YKSVE,SCSVE
COMMON /FLSH/ S(2),C(3,2),XK(3)
COMMON /PROP/
+ SWC(6), VWC(6), CWC(6), SLW(4), SFC(4),
+ TVC(5), PVC(6), VCO2(5,6),
+ TDC(5), PDC(7), DCO2(5,7),
+ TSC(5), PSC(6), SCO2(5,6),
+ TZC(7),PZC(19), ZCO2(7,19),
+ TBW(9),BWC(15), RHO(9,15)

Is the SWC and the others after it arrays??

hope there's someone to help me out here. thanks
 
Technology news on Phys.org
  • #2
I'd just define them as global variables. Global variables should be described in whatever reference material you are using to learn VBA.
 
  • #3
Yes, SWC and the other variables listed after it are arrays, as areS, C, and XK. C is a two-dimensional array, with 3 rows and 2 columns.
 
  • #4
thanks.

so if that's the case before the subroutine in vba should i declare it as a GLOBAL file?? where then the arrays will be available to all subroutines in the module.
 
  • #5
Another doubt that I'm having would be the WRITE statements

for example:

IF(POROS.LE.0.0)WRITE (NOT1,9600)ICHK
IF (PERM.LE.0.0)ICHK=3

Looking at the fortran code, is the WRITE statement equivalent to writing on file NOT1 and then skipping to line 9600.

if so can i define line 9600 in VBA as follows:

9600:

(and then put in the required coding into the line)hope u guys can help me out.thanks
 

Related to Fortran code conversion into Excel VBA

1. How can I convert Fortran code into Excel VBA?

To convert Fortran code into Excel VBA, you will need to use a specialized software or script that can translate the code into a readable format for Excel. There are several options available, such as the FORTRAN to VBA Converter tool or manually rewriting the code using Excel VBA syntax.

2. Is it possible to preserve the functionality of my Fortran code when converting it to Excel VBA?

In most cases, it is possible to preserve the functionality of your Fortran code when converting it to Excel VBA. However, it may require some adjustments and modifications to ensure that the code works properly in the new environment. It is recommended to carefully test and debug the converted code to ensure its functionality.

3. Can I convert Fortran code into Excel VBA if I have no prior experience with either language?

While having some knowledge of Fortran and Excel VBA can be helpful, it is not necessary to successfully convert Fortran code into Excel VBA. As long as you have access to a conversion tool and a basic understanding of programming concepts, you should be able to complete the conversion process.

4. What are the benefits of converting Fortran code into Excel VBA?

Converting Fortran code into Excel VBA can offer several benefits, such as making the code more accessible and user-friendly for those who are more familiar with Excel. It can also allow for easier integration with other Excel-based tools and functions, as well as the ability to take advantage of Excel's built-in features and functionality.

5. Are there any limitations to converting Fortran code into Excel VBA?

While converting Fortran code into Excel VBA can offer many advantages, there are also some limitations to keep in mind. This includes potential compatibility issues with certain Fortran code or features, as well as the need for manual modifications to ensure the code works correctly in the new environment.

Back
Top