AMBER Archive (2005)

Subject: Re: AMBER: [OT] A nab programming question

From: David A. Case (case_at_scripps.edu)
Date: Mon Jul 25 2005 - 16:35:49 CDT


On Thu, Jul 21, 2005, M. L. Dodson wrote:
>
> I need to use some fortran functions in a (fairly large) project
> written in nab. There is a lot of trig, and due to the diffences
> in angle representation (degrees in nab, radians in fortran), I
> decided to convert the fortran to nab. My problem is that the
> fortran uses named common blocks to pass around global variables.
> I have not been able to come up with a way to implement an
> equivalent using nab. Has anyone done something similar to this
> or does anyone have a suggestion? Thanks,
>
Hi Bud:

Strange: I've just been doing a similar thing: removing all fortran
routines from the main NAB code. But this involved converting to C,
not to NAB, and you might think about that. C has structures, which can
act like named common blocks in Fortran.

If you do want to go with nab, variables that are placed outside any routines,
they will be written as static variables, and be available to any routines
inside that file. For example:

int a,b;

int sub1(){

        a = 1;
        b = 3;
        printf( %d %d\n", a,b );
}

int sub2(){

        x = a;
        y = b;
        printf( %d %d\n", x,y );
}

Look at the C code the above creates. Basically, a, b are "global" variables
that are available to any subroutine in the file. Note that "a" and "b" may
not be next to each other in memory, as would be the case for common blocks.

....hope this helps....dac
-----------------------------------------------------------------------
The AMBER Mail Reflector
To post, send mail to amber_at_scripps.edu
To unsubscribe, send "unsubscribe amber" to majordomo_at_scripps.edu