Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed Fortran to VBA
Hi
I nned to convert a Fortran code in VBA: 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 Anyone could help please? Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed Fortran to VBA
Hi
What are the data types here (strings, arrays, etc)? What does DIM do? What do .eq and .ge mean? Someone who doesn't know Fortran could probably give you a start then. regards Paul On Feb 26, 1:07*am, sylphide wrote: Hi I nned to convert a Fortran code in VBA: 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 Anyone could help please? Thanks in advance |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed Fortran to VBA
FORTRAN DIM is a positive difference (perhaps from Difference In Magnitude?)
presumably the 1st value is larger than the second, however, if 1st is smaller than the second, zero is returned: DIM(2,1) returns 1 'same as 2-1 DIM(1,2) returns 0 'same as IF(1-20,1-2,0) Actually, I guess you could look at it more generically as: DIM(Value1, Value2) could be written as IF(Value1 Value2, Value1-Value2, 0) "Paul Robinson" wrote: Hi What are the data types here (strings, arrays, etc)? What does DIM do? What do .eq and .ge mean? Someone who doesn't know Fortran could probably give you a start then. regards Paul On Feb 26, 1:07 am, sylphide wrote: Hi I nned to convert a Fortran code in VBA: 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 Anyone could help please? Thanks in advance . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed Fortran to VBA
What does "DIM" signify in Fortran?
" ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage))) + .03*MIN(3,DIM(58,MAX(55,iage))) ) " Here is a partial rewrite that may help you get going. " Sub aaa() 'Declare variables 'Unless otherwise specified all variables below are Variants Dim ER_ELIG As Boolean Dim ERPOINTS 'if integer only then "Dim ERPOINTS as Integer" Dim iage Dim vsvcb Dim IGRP Dim ERF ER_ELIG = False ERPOINTS = iage + vsvcb If IGRP = "1" And _ iage "55" And _ vsvcb "10" Then ER_ELIG = True If IGRP = "2" And _ iage = "50" Then ER_ELIG = True ERF = 0# If ER_ELIG Then If IGRP = "1" Then If ERPOINTS = "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))) ) End If If vsvcb = "25" Then ERF = "1.000" If iage = "62" And _ ERPOINTS = "75" Then 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 = "62" Then ERF = "1.000" End If End If End Sub " Code that is still in Fiortran format I dont fully understand yet, they appear to be formulas for calculations? -- Regards Rick "sylphide" wrote: Hi I nned to convert a Fortran code in VBA: 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 Anyone could help please? Thanks in advance |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro needed Fortran to VBA
Forgot to "End If"
" Sub aaa() 'Declare variables 'Unless otherwise specified all variables below are Variants Dim ER_ELIG As Boolean Dim ERPOINTS 'if integer only then "Dim ERPOINTS as Integer" Dim iage Dim vsvcb Dim IGRP Dim ERF ER_ELIG = False ERPOINTS = iage + vsvcb If IGRP = "1" And _ iage "55" And _ vsvcb "10" Then ER_ELIG = True End If If IGRP = "2" And _ iage = "50" Then ER_ELIG = True End If ERF = 0# If ER_ELIG Then If IGRP = "1" Then If ERPOINTS = "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))) ) End If End If End If If vsvcb = "25" Then ERF = "1.000" If iage = "62" And _ ERPOINTS = "75" Then 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 = "62" Then ERF = "1.000" End If End Sub " Since I can not test this, ending IF statements may not be 100% correct. -- Regards Rick "Rick S." wrote: What does "DIM" signify in Fortran? " ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage))) + .03*MIN(3,DIM(58,MAX(55,iage))) ) " Here is a partial rewrite that may help you get going. " Sub aaa() 'Declare variables 'Unless otherwise specified all variables below are Variants Dim ER_ELIG As Boolean Dim ERPOINTS 'if integer only then "Dim ERPOINTS as Integer" Dim iage Dim vsvcb Dim IGRP Dim ERF ER_ELIG = False ERPOINTS = iage + vsvcb If IGRP = "1" And _ iage "55" And _ vsvcb "10" Then ER_ELIG = True If IGRP = "2" And _ iage = "50" Then ER_ELIG = True ERF = 0# If ER_ELIG Then If IGRP = "1" Then If ERPOINTS = "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))) ) End If If vsvcb = "25" Then ERF = "1.000" If iage = "62" And _ ERPOINTS = "75" Then 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 = "62" Then ERF = "1.000" End If End If End Sub " Code that is still in Fiortran format I dont fully understand yet, they appear to be formulas for calculations? -- Regards Rick "sylphide" wrote: Hi I nned to convert a Fortran code in VBA: 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 Anyone could help please? Thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need Macro Fortran to VBA | Excel Programming | |||
Caling fortran from excel | Excel Programming | |||
compaq visual fortran dll | Excel Programming | |||
Calling a Fortran dll from Excel | Excel Programming | |||
Link to fortran | Excel Programming |