Re: [AMBER] Looping over a trajectory

From: Lee-Ping Wang <leeping.stanford.edu>
Date: Tue, 29 May 2012 11:18:15 -0700 (PDT)

Hi Jason,

Thanks. The variable "open_mode" sounds like a good way to go, and I'll try it out.

I'm writing an interface between AMBER and my force field parameterization program (https://simtk.org/home/forcebalance). I'm pretty much the only person using my program at the moment. If someone would like to use my program to parameterize force fields in AMBER, they would have to compile AMBER with the modified debug_frc.F90 and trajene.F90 files as I did.

Because of this, I'm trying to modify the code in a way that doesn't break other stuff for the possibility that others might use it in the future.

- Lee-Ping

----- Original Message -----
From: "Jason Swails" <jason.swails.gmail.com>
To: "AMBER Mailing List" <amber.ambermd.org>
Sent: Tuesday, May 29, 2012 11:06:37 AM
Subject: Re: [AMBER] Looping over a trajectory

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
_______________________________________________
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