Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cam history always chooses first averaging flag when using duplicate fields #1149

Open
peverwhee opened this issue Sep 13, 2024 · 7 comments
Assignees
Labels
bug Something isn't working correctly CoupledEval3

Comments

@peverwhee
Copy link
Collaborator

What happened?

If, in user_nl_cam you're trying to do something like:

fincl2='Q:I', 'Q:A'

in the hopes that you'll get an h1i and h1a file, both with 'Q', it won't work!

You'll get whichever flag you specify first. So, in this case, you'd just get an h1i with 'Q'

What are the steps to reproduce the bug?

Run CAM with the user_nl_cam described above. Be sure your nhtfrq /= 1 for the test, since that overrides everything to "I" anyway.

What CAM tag were you using?

cam6_4_032

What machine were you running CAM on?

CGD machine (e.g. izumi)

What compiler were you using?

GNU

Path to a case directory, if applicable

No response

Will you be addressing this bug yourself?

Any CAM SE can do this

Extra info

Not sure exactly, but this seems like the problem area (in fldlst)

      listentry => masterlinkedlist
      do while(associated(listentry))
        mastername = listentry%field%name

        call list_index (fwrtpr(1,t), mastername, ffld)
        if (ffld > 0) then
          prec_wrt = getflag(fwrtpr(ffld,t))
        else
          prec_wrt = ' '
        end if

        call list_index (fincl(1,t), mastername, ffld)

        if (ffld > 0) then
          avgflag = getflag (fincl(ffld,t))
          call inifld (t, listentry, avgflag,  prec_wrt)
        else if ((.not. empty_htapes) .or. (is_initfile(file_index=t))) then
          call list_index (fexcl(1,t), mastername, ffld)
          if (ffld == 0 .and. listentry%actflag(t)) then
            call inifld (t, listentry, ' ', prec_wrt)
          else
            listentry%actflag(t) = .false.
          end if
        else
          listentry%actflag(t) = .false.
        end if
        listentry=>listentry%next_entry

      end do
@peverwhee peverwhee added the bug Something isn't working correctly label Sep 13, 2024
@adamrher
Copy link

Peanut gallery here.

Be sure your nhtfrq /= 1 for the test, since that overrides everything to "I" anyway.

You can't have nhtfrq = 1 and use the "A" flag? This is useful for outfld calls in the macmic loops. For those variables I often set them to "A" and nhtfrq=1, so it is represents an average over all subcycles in a single time-step.

@peverwhee
Copy link
Collaborator Author

@adamrher hmmmm... I'm not really familiar with subcycling, but looking at the code, we're overriding the averaging flag with "I" when nhtfrq = 1. So my guess is you're not actually getting an average for those variables.

    !
    ! Initialize history variables
    !
    do t=1,ptapes
      do fld=1,nflds(t)
        if (nhtfrq(t) == 1) then
           ! Override any non-I flags if nhtfrq equals 1
           tape(t)%hlist(fld)%avgflag = 'I'
        end if
        ...

@adamrher
Copy link

It's always operated like that? Yikes, noted.

It would be ideal to have this functionality -- if I outfld a variable N times in a single time-step, then "A" and nhtfrq=1 should give me the average over those N calls -- but this is not a high priority.

@peverwhee
Copy link
Collaborator Author

@adamrher just checked an it was me in fact who added that override.

So it's definitely probable it used to work that way! I'll make an issue.

@gold2718
Copy link
Collaborator

Is this now superseded by #1150?

@peverwhee
Copy link
Collaborator Author

@gold2718 They're two separate issues. #1150 is for subcycling averages, this one is for duplicate fields for all history variables (won't be fixed by removing the override)

@PeterHjortLauritzen
Copy link
Collaborator

The functionality of outputting the same field with ‘I’ and ‘A’ in the same history stream was never supported in CAM (as far as I know). Let’s add an endrun if someone tries to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly CoupledEval3
Projects
Status: To Do
Development

No branches or pull requests

5 participants