Need Macro Fortran to VBA

S

sylphide

Hi I need to create a function in VBA derived from an actual fortran coding:
ER_ELIG = .false.
ERPOINTS = iage + vsvcb
IF ((IGRP.eq.1).and.(iage.ge.55).and.(vsvcb.ge.10))
ER_ELIG = .true.

IF ((IGRP.eq.2).and.(iage.ge.50))
ER_ELIG = .true.

ERF = 0.00
IF (ER_ELIG) THEN
IF (IGRP.eq.1) THEN
IF (ERPOINTS.ge.75) then
ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage)))
+ .03*MIN(3,DIM(58,MAX(55,iage))) )
ELSE
ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage)))
+ .0333*MIN(5,DIM(60,MAX(55,iage))) )
ENDIF
IF (vsvcb.ge.25) ERF = 1.000
IF ((iage.ge.62).and.(ERPOINTS.ge.75)) ERF = 1.000
ELSE
ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage)))
+ .036*MIN(5,DIM(60,MAX(50,iage)))
+ .052*MIN(5,DIM(55,MAX(50,iage))) )
IF (iage.ge.62) ERF = 1.000
ENDIF
ENDIF

Any tips on how to? I am not as familiar in VBA.....
 
M

Martin Brown

sylphide said:
Hi I need to create a function in VBA derived from an actual fortran coding:
ER_ELIG = .false.
ERPOINTS = iage + vsvcb
IF ((IGRP.eq.1).and.(iage.ge.55).and.(vsvcb.ge.10))

IF ((IGRP.eq.2).and.(iage.ge.50))

ERF = 0.00
IF (ER_ELIG) THEN
IF (IGRP.eq.1) THEN
IF (ERPOINTS.ge.75) then
ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage)))
ELSE
ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage)))
ENDIF
IF (vsvcb.ge.25) ERF = 1.000
IF ((iage.ge.62).and.(ERPOINTS.ge.75)) ERF = 1.000
ELSE
ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage)))
IF (iage.ge.62) ERF = 1.000
ENDIF
ENDIF

Any tips on how to? I am not as familiar in VBA.....

In a VBA pane type

SUB FortranTest <enter>

Inside the resultig block paste your fortran

s/.false./FALSE/
s/.true./TRUE/
s/.eq./=/
s/.ge./>=/
s/DIM/DIMB/
(DIM is a reserved word in Basic)

s/MIN/Application.WorksheetFunction.Min/
etc.

Clumsy but they are intrinsic functions in Excel VBA.
And then fix the remaining syntax errors.

Beware that integer variables need to be declared explicitly in VBA or
they will be stored as variants.

Regards,
Martin Brown
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top