Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Macro Fortran to VBA sylphide Excel Programming 1 February 26th 10 09:20 AM
Caling fortran from excel Rafael Tini Excel Programming 1 November 13th 07 08:45 PM
compaq visual fortran dll vbfortran Excel Programming 1 June 4th 07 02:18 PM
Calling a Fortran dll from Excel Tom Kreutz Excel Programming 0 November 15th 03 06:56 PM
Link to fortran Claudia[_3_] Excel Programming 0 September 18th 03 08:58 AM


All times are GMT +1. The time now is 10:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"