Re: [AMBER] Looping over a trajectory

From: Jason Swails <jason.swails.gmail.com>
Date: Tue, 29 May 2012 11:06:37 -0700

On Tue, May 29, 2012 at 10:53 AM, Lee-Ping Wang <leeping.stanford.edu>wrote:

> Hi Jason,
>
> Thanks; the tough part for me is that "debug_frc" needs to know if it's
> being called for the first time or not (in a given run). I don't know
> what's the cleanest way to do this; do you think specifying a global
> variable (and incrementing it every time debug_frc is called) is the way to
> go?
>
> The alternate option is to add a logical to the debug_frc input arguments.
> However, I would rather not change the input arguments to existing
> functions because I don't want to break anything.
>

If you're just hacking it for your own uses, you can use the "save"
attribute for a logical "first" variable. For instance:

logical, save :: first = .true.

Then, at the end of that subroutine, put the statement:

first = .false.

Then, open with "Overwrite" if (first), or open with append if (.not.
first).

An alternative (but the same idea) is to do something like this:

character, save :: open_mode = 'O'

Then, at the end of that subroutine, put the statement:

open_mode = 'A'

Then you can just open using the open_mode variable, which will be set
appropriately.


While this approach may not be endorsed by everyone, it gets the job done,
is quite general, and requires the least amount of additional code
modification.

HTH,
Jason

-- 
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
352-392-4032
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Tue May 29 2012 - 11:30:03 PDT
Custom Search