Fortran Fortran code conversion into Excel VBA

AI Thread Summary
The discussion revolves around converting Fortran code to Excel VBA, specifically addressing the conversion of COMMON statements and handling arrays. The user seeks assistance with translating a Fortran COMMON statement, which includes multiple variables and arrays, into VBA. It is clarified that variables like SWC and others are indeed arrays, with SWC being a one-dimensional array and C being a two-dimensional array. The user contemplates declaring these arrays as global variables in VBA to ensure they are accessible across different subroutines. Additionally, there is a query about the Fortran WRITE statements, where the user seeks to understand if they correspond to writing to a file and how to implement a similar structure in VBA. The discussion emphasizes the need for clear variable declarations and understanding the equivalent coding logic between Fortran and VBA.
kay90
Messages
3
Reaction score
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
I'd just define them as global variables. Global variables should be described in whatever reference material you are using to learn VBA.
 
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.
 
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.
 
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
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top