Converting Fortran to SPSS

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Converting Fortran to SPSS

bdates
David,

Thank-you once more!  I really appreciate all your thoughts about this.
I hadn't thought about locating a compiler, but I can arrange that so I
can avoid as much bramage as possible (Ha, probably already too late.)
Aside from some GUI, I've done most of my actual writing in matrix.  I
have a pretty strong math background including vectors and matrices, so
it comes pretty easy to me.  In addition, looking over the years at
Martas' matrix macros, as well as others', has helped me a lot.  Thanks
again.

Brian

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: Monday, July 02, 2012 12:29 PM
To: [hidden email]
Subject: Re: Converting Fortran to SPSS

Glad to be of assistance.  I only spent about 1/2 hr or so (my mind
works in
mysterious ways ).
One last: CONTINUE can be replaced with END LOOP.
Be careful of IF () THEN and the scope of the conditional .
GOTO bites!  It will be fun to thread your way around all that jumping
about.
I caution you that staring at that code for too long might result in
irreversible Bramage.
If I were doing this I would locate a compatible FORTRAN compiler and
modify
the source to print intermediate results in strategic places. That will
provide reality checks at various points along the way.
Barring that you might complete the project and one tiny intractable bug
will drive you nuts for weeks.
I hope you have strong mastery of the MATRIX language, that will
definitely
be of benefit.

Dates, Brian wrote
>
> David,
>
> Thank-you very much for your time and energy!  You've gone way beyond
> what I expected. I really appreciate it and will persevere.  Take
care.

>
> Brian
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@.UGA] On Behalf Of
> David Marso
> Sent: Monday, July 02, 2012 10:26 AM
> To: SPSSX-L@.UGA
> Subject: Re: Converting Fortran to SPSS
>
> Brian,
> After more careful scrutiny of the source you directed our attention
and

> burrowing into distant memories the following will be useful.
> Copy Paste the whole shebang into an editor.
>
> Globally replace DO with LOOP.
> Globally replace IF with DO IF.
> Globally replace ZERO with 0.0 .
> Globally replace logical compares .LT. with ' LT ' without apostrophes
> same
> with .GT. -> GT, .EQ. -> EQ , .LE., .GE. .
>
> Globally replace -being careful not to clobber indexed values in
arrays:
> 1, -> 1 TO
> Prefix ALL assignment statements with COMPUTE.
> Figure out a way to disentangle the hippity hop skippado GOTO
business.
> Replace various FORTRAN functions DABS DSQRT -> ABS, SQRT
> E() function -> EXP
> etc......
> Finally and *GOOD LUCK*.
> unfold the 3D data structures into 2D and figure out VECTOR methods
for

> some
> of the more brutally intense inner loops.
> Figure out exactly WTF the thing is trying to achieve and see if there
> is an
> algorithm which drops from the sky.
> Test with some known data sets against Blossom and hope like hell you
> can
> get it to work ;-)
> Contrary to what Rich suggested, At this point it looks like much of
> this
> will be a line by line translation with a few vector shortcuts if you
> can
> figure out a clean way of unfolding the data structure and extract the
> relevant vectors.
>
> --
> View this message in context:
>
http://spssx-discussion.1045642.n5.nabble.com/Converting-Fortran-to-SPSS

> -tp5713876p5713945.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Converting-Fortran-to-SPSS
-tp5713876p5713957.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Converting Fortran to SPSS

Richard Ristow
In reply to this post by bdates
At 11:27 AM 6/28/2012, Dates, Brian wrote:

>I have a task on which I'm working in matrix mode in SPSS.  The only
>solution that's available in publication regarding this task is
>written in Fortran, with which I'm woefully inadequate.  Does a
>guide exist which assists in the conversion of Fortran code to SPSS
>syntax, similar to the guides that are available comparing SPSS to
>SAS or R?  Thanks.

You've had some excellent advice on this, but here's another point to consider.

As David Marso outlined (10:25 AM 7/2/2012), most of Fortran can be
translated into the SPSS transformation language. However, most
Fortran programs won't translate into 'idiomatic' SPSS.

The code of an SPSS transformation program is actually the interior
of a loop, executed once for each record ('case') in an SPSS file.
Good SPSS writing uses this implied loop to simplify the code;
techniques for this include using LEAVE and the LAG() function,
pre-processing with AGGREGATE, and preferring 'long' over 'wide'
organization of files (i.e., more records, fewer variables).

A lot depends on how your Fortran program expects to receive its
data. It may use a data matrix which is pretty much like the SPSS
file your data will actually be in. In that case, look for a
translation which loops through that data matrix only once, and then
translate the interior of that loop into your SPSS program.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Converting Fortran to SPSS

bdates
Richard,

Thank-you very much.  This'll be helpful as I continue to 'translate'
both the Fortran for the MRBP and the SPSS syntax for MRPP.  I really
appreciate your taking the time, especially so long after the initial
posting.

Brian

-----Original Message-----
From: Richard Ristow [mailto:[hidden email]]
Sent: Thursday, July 12, 2012 4:31 PM
To: Dates, Brian; [hidden email]
Subject: Re: Converting Fortran to SPSS

At 11:27 AM 6/28/2012, Dates, Brian wrote:

>I have a task on which I'm working in matrix mode in SPSS.  The only
>solution that's available in publication regarding this task is
>written in Fortran, with which I'm woefully inadequate.  Does a
>guide exist which assists in the conversion of Fortran code to SPSS
>syntax, similar to the guides that are available comparing SPSS to
>SAS or R?  Thanks.

You've had some excellent advice on this, but here's another point to
consider.

As David Marso outlined (10:25 AM 7/2/2012), most of Fortran can be
translated into the SPSS transformation language. However, most
Fortran programs won't translate into 'idiomatic' SPSS.

The code of an SPSS transformation program is actually the interior
of a loop, executed once for each record ('case') in an SPSS file.
Good SPSS writing uses this implied loop to simplify the code;
techniques for this include using LEAVE and the LAG() function,
pre-processing with AGGREGATE, and preferring 'long' over 'wide'
organization of files (i.e., more records, fewer variables).

A lot depends on how your Fortran program expects to receive its
data. It may use a data matrix which is pretty much like the SPSS
file your data will actually be in. In that case, look for a
translation which loops through that data matrix only once, and then
translate the interior of that loop into your SPSS program.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Converting Fortran to SPSS

Lorin Drake
I will be out of the office in an all-day meeting on Friday, July 13. I will have occasional access to email.
If your message is urgent, please call our switchboard and someone will direct your call: (813) 207-0332.
Reply | Threaded
Open this post in threaded view
|

Re: Converting Fortran to SPSS

David Marso
Administrator
In reply to this post by Richard Ristow
Hi Richard,
Brian previously provided a link to the FORTRAN source
http://www.stat.colostate.edu/~mielke/permute.html

Assumed Data structure:
C         THIS FORTRAN PROGRAM COMPUTES THE TEST STATISTIC AND ASSOCIATED
C         P-VALUE FOR AN ANALYSIS OF A RANDOMIZED BLOCK EXPERIMENT (MRBP3).
C         THE CORRESPONDENCE BETWEEN A CORRELATION ANALYSIS AND A
C         RANDOMIZED BLOCK EXPERIMENT CAN BE USED TO GET A CORRELATION
C         COEFFICIENT AS WELL. THE MAXIMUM VALUES OF G, B AND R CAN BE
C         CHANGED FOR ANY EXAMPLE.  THE PRESENT MAXIMUM VALUES OF G, B
C         AND R IN THIS PROGRAM ARE RESPECTIVELY 10, 12 AND 15.
C
C       THIS PROGRAM IS CAPABLE OF PERFORMING (1) REPEATED MRBP ANALYSES
C       IN ONE OPERATION, (2) ALIGNMENT WITHIN BLOCKS, (3) DISTANCE
C       FUNCTION COMMENSURATION, AND (4) C(G,H) RANKS TEST.
C
C         PROGRAM MODIFIED 2/9/2003
C
C       THE DATA MATRIX MUST BE IN THE FOLLOWING SEQUENCE WITH EACH
C       OBJECT'S R RESPONSE VALUES ON A SEPARATE LINE AS FOLLOWS:
C
C         A(1,1,1),A(1,1,2),...,A(1,1,R)
C         A(1,2,1),A(1,2,2),...,A(1,2,R)
C                  ...
C         A(1,B,1),A(1,B,2),...,A(1,B,R)
C         A(2,1,1),A(2,1,2),...,A(2,1,R)
C                  ...
C         A(2,B,1),A(2,B,2),...,A(2,B,R)
C                  ...
C         A(G,1,1),A(G,1,2),...,A(G,1,R)
C                  ...
C         A(G,B,1),A(G,B,2),...,A(G,B,R)

A tiny taste of the hideous internals:
One of the many nested loops.
     DO 45 K=1,KR
         AD(K)=ZERO
         DO 44 I1=1,KG
            DO 43 I2=1,KG
               DO 42 J1=2,KB
                  DO 41 J2=1,J1-1
                     AD(K)=AD(K)+(DABS(DATA(I1,J1,K)-DATA(I2,J2,K)))**V
   41             CONTINUE
   42          CONTINUE
   43       CONTINUE
   44    CONTINUE
         AD(K)=AD(K)**(ONE/V)
   45 CONTINUE
****************
The grand UGLY MF of all time.  My eyes are bleeding and I'm about to suffer a cranial implosion ;-)
--
  51 DO 100 IS=2,KB
         IS1=IS-1
         DO 99 IR=1,IS1
            TIJ2(IR,IS)=ZERO
            TIJ3(IR,IS)=ZERO
            VI(IR,IS)=ZERO
            UIJ(IR,IS)=ZERO
            DO 98 I=1,KG
               TIJ2(IR,IS)=TIJ2(IR,IS)+SJ(I,IR,IS)**2+SJ(I,IS,IR)**2
               TIJ3(IR,IS)=TIJ3(IR,IS)+SJ(I,IR,IS)**3+SJ(I,IS,IR)**3
               VI(IR,IS)=VI(IR,IS)+SJ(I,IR,IS)*SJ2(I,IR,IS)+
     1           SJ(I,IS,IR)*SJ2(I,IS,IR)
               UJ(I,IR,IS)=ZERO
               DO 97 J=1,KG
                  IRR=KB*(I-1)+IR
                  JSS=KB*(J-1)+IS
                  UJ(I,IR,IS)=UJ(I,IR,IS)+
     1              D(IRR,JSS)*SJ(I,IR,IS)*SJ(J,IS,IR)
   97          CONTINUE
               UIJ(IR,IS)=UIJ(IR,IS)+UJ(I,IR,IS)
   98       CONTINUE
   99    CONTINUE
  100 CONTINUE

These are merely 2 of the many challenges in that source.
There is *NO* way in hell that that will easily map to normal SPSS transformation syntax.
The only reasonable solution in SPSS is MATRIX and careful indexing from the 3 dimensional arrays into 2 dimensions. Ideally in such a way that one isn't spending too much effort calculating offsets or doing element by element subtractions etc (ie use the MATRIX vector extraction and operations whenever possible).
<Tongue in Cheek>
I notice we haven't heard from Brian in awhile.  I hope he isn't babbling incoherently in a mental ward after gouging his eyes out after prolonged exposure to the 3-D FORTRAN madness.
In order to get my rent deposit back I'm going to need to patch the wall in my living room and clean up the blood from the carpet after deliberately bashing my head (Just for the hell of it and my cat like curiosity I began a seat of the pants stab in the dark to see what would happen).  After about an hour my cat began to look at me funny and ran into the bedroom (and closed the door).  Considering that to be an ominous sign I packed it in, took a cold shower and vowed *NEVER AGAIN*.
OTOH:  If someone were paying me (*ALOT*) to do it I would be delighted to don a hazmat suit and risk losing what little remains of my sanity ;-))))))
</Tongue in Cheek>

Richard Ristow wrote
At 11:27 AM 6/28/2012, Dates, Brian wrote:

>I have a task on which I'm working in matrix mode in SPSS.  The only
>solution that's available in publication regarding this task is
>written in Fortran, with which I'm woefully inadequate.  Does a
>guide exist which assists in the conversion of Fortran code to SPSS
>syntax, similar to the guides that are available comparing SPSS to
>SAS or R?  Thanks.

You've had some excellent advice on this, but here's another point to consider.

As David Marso outlined (10:25 AM 7/2/2012), most of Fortran can be
translated into the SPSS transformation language. However, most
Fortran programs won't translate into 'idiomatic' SPSS.

The code of an SPSS transformation program is actually the interior
of a loop, executed once for each record ('case') in an SPSS file.
Good SPSS writing uses this implied loop to simplify the code;
techniques for this include using LEAVE and the LAG() function,
pre-processing with AGGREGATE, and preferring 'long' over 'wide'
organization of files (i.e., more records, fewer variables).

A lot depends on how your Fortran program expects to receive its
data. It may use a data matrix which is pretty much like the SPSS
file your data will actually be in. In that case, look for a
translation which loops through that data matrix only once, and then
translate the interior of that loop into your SPSS program.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Converting Fortran to SPSS

David Marso
Administrator
In reply to this post by bdates
Ah Brian,
Great to see you here.  
Hope my TIC postlude didn't offend you (see below - Your post had not arrived prior to my <send>) and I was a little worried given your 'long' absence from this place.  Would love to see how you ended up suspending the descent into bat-shit-crazy after eyeballing that 3D monstrosity for more than 42 minutes ;-).  Still peeling dry wall fragments from my hair ;-)))))
----------------------------------------------------------------


Dates, Brian wrote
Richard,

Thank-you very much.  This'll be helpful as I continue to 'translate'
both the Fortran for the MRBP and the SPSS syntax for MRPP.  I really
appreciate your taking the time, especially so long after the initial
posting.

Brian

-----Original Message-----
From: Richard Ristow [mailto:[hidden email]]
Sent: Thursday, July 12, 2012 4:31 PM
To: Dates, Brian; [hidden email]
Subject: Re: Converting Fortran to SPSS

At 11:27 AM 6/28/2012, Dates, Brian wrote:

>I have a task on which I'm working in matrix mode in SPSS.  The only
>solution that's available in publication regarding this task is
>written in Fortran, with which I'm woefully inadequate.  Does a
>guide exist which assists in the conversion of Fortran code to SPSS
>syntax, similar to the guides that are available comparing SPSS to
>SAS or R?  Thanks.

You've had some excellent advice on this, but here's another point to
consider.

As David Marso outlined (10:25 AM 7/2/2012), most of Fortran can be
translated into the SPSS transformation language. However, most
Fortran programs won't translate into 'idiomatic' SPSS.

The code of an SPSS transformation program is actually the interior
of a loop, executed once for each record ('case') in an SPSS file.
Good SPSS writing uses this implied loop to simplify the code;
techniques for this include using LEAVE and the LAG() function,
pre-processing with AGGREGATE, and preferring 'long' over 'wide'
organization of files (i.e., more records, fewer variables).

A lot depends on how your Fortran program expects to receive its
data. It may use a data matrix which is pretty much like the SPSS
file your data will actually be in. In that case, look for a
translation which loops through that data matrix only once, and then
translate the interior of that loop into your SPSS program.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Converting Fortran to SPSS

bdates
David and all,

I'm still continuing the work.  Everything's done except the skewness,
so the 3D monster seems slayable.  I'm off on vacation, and I'm going to
take the syntax with me so I can perhaps get a few more of the skewness
components finished.  My target is October 1.  Thanks for your concern,
but I've found out that drywall washes out of my hair quite easily and
chewing Zyprexa endlessly keeps me remarkably calm.  Talk to you all
upon my return.

B

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: Friday, July 13, 2012 12:20 AM
To: [hidden email]
Subject: Re: Converting Fortran to SPSS

Ah Brian,
Great to see you here.
Hope my TIC postlude didn't offend you (see below - Your post had not
arrived prior to my <send>) and I was a little worried given your 'long'
absence from this place.  Would love to see how you ended up suspending
the
descent into bat-shit-crazy after eyeballing that 3D monstrosity for
more
than 42 minutes ;-).  Still peeling dry wall fragments from my hair
;-)))))
----------------------------------------------------------------



Dates, Brian wrote

>
> Richard,
>
> Thank-you very much.  This'll be helpful as I continue to 'translate'
> both the Fortran for the MRBP and the SPSS syntax for MRPP.  I really
> appreciate your taking the time, especially so long after the initial
> posting.
>
> Brian
>
> -----Original Message-----
> From: Richard Ristow [mailto:wrristow@]
> Sent: Thursday, July 12, 2012 4:31 PM
> To: Dates, Brian; SPSSX-L@.UGA
> Subject: Re: Converting Fortran to SPSS
>
> At 11:27 AM 6/28/2012, Dates, Brian wrote:
>
>>I have a task on which I'm working in matrix mode in SPSS.  The only
>>solution that's available in publication regarding this task is
>>written in Fortran, with which I'm woefully inadequate.  Does a
>>guide exist which assists in the conversion of Fortran code to SPSS
>>syntax, similar to the guides that are available comparing SPSS to
>>SAS or R?  Thanks.
>
> You've had some excellent advice on this, but here's another point to
> consider.
>
> As David Marso outlined (10:25 AM 7/2/2012), most of Fortran can be
> translated into the SPSS transformation language. However, most
> Fortran programs won't translate into 'idiomatic' SPSS.
>
> The code of an SPSS transformation program is actually the interior
> of a loop, executed once for each record ('case') in an SPSS file.
> Good SPSS writing uses this implied loop to simplify the code;
> techniques for this include using LEAVE and the LAG() function,
> pre-processing with AGGREGATE, and preferring 'long' over 'wide'
> organization of files (i.e., more records, fewer variables).
>
> A lot depends on how your Fortran program expects to receive its
> data. It may use a data matrix which is pretty much like the SPSS
> file your data will actually be in. In that case, look for a
> translation which loops through that data matrix only once, and then
> translate the interior of that loop into your SPSS program.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Converting-Fortran-to-SPSS
-tp5713876p5714180.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
12