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

Add nwp physics option #451

Closed
ekluzek opened this issue Jul 26, 2018 · 13 comments · Fixed by #685
Closed

Add nwp physics option #451

ekluzek opened this issue Jul 26, 2018 · 13 comments · Fixed by #685
Assignees
Labels
enhancement new capability or improved behavior of existing capability priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations

Comments

@ekluzek
Copy link
Collaborator

ekluzek commented Jul 26, 2018

We need to add a new physics option that for now I'm calling ctsm-nwp1_0 that's based on clm5_0 physics, but flags a few specific namelist items that are important for the NWP (Numerical Weather Prediction) configuration for CTSM.

I think the way to do this is to have it retain the model comparison features for clm series (so it would be assigned a value of 5.0), but also have specific namelist items check the exact string and be set accordingly.

In the long run with the python version we'll probably want a more general solution. But, we want a quick and dirty version that will work in the current environment that will allow a new physics setting.

@billsacks

@ekluzek ekluzek added enhancement new capability or improved behavior of existing capability priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations investigation Needs to be verified and more investigation into what's going on. labels Jul 26, 2018
@billsacks billsacks removed the investigation Needs to be verified and more investigation into what's going on. label Jul 27, 2018
@billsacks
Copy link
Member

I was looking into how we use the numeric comparisons in CLMBuildNamelist, by searching for uses of as_long() (and then I did a quick search for other uses of phys or physv to see if I missed anything). It looks like, for the most part, this is just used to distinguish between clm4.0 and anything later (since clm4.0 uses a different code base). So, unless there's some other use of the numeric comparisons that I'm not aware of, it seems like this task will become much easier and cleaner if we first remove clm4.0 support.

Here are some exceptions, where we use the numeric comparisons in different ways. As I note below, I think all three of these exceptions are unnecessary:

(1)

  # These should NOT be set for CLM5.0 and beyond
  if ( $physv->as_long() > $physv->as_long("clm4_5") ) {
     foreach my $var ( "origflag", "h2osfcflag", "oldfflag" ) {
        my $val = $nl->get_value($var);
        if ( defined($val) ) {
           $log->fatal_error( "ERROR:: $var=$val is deprecated and can only be used with CLM4.5" );
        }
     }
  }

but I think we can just remove that one error-check to keep things simpler.

(2)

    my $var = "jmaxb1";
    if ( $physv->as_long() >= $physv->as_long("clm5_0") && &value_is_true( $nl_flags->{'use_luna'} ) ) {
       add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
                     'use_luna'=>$nl_flags->{'use_luna'} );
    }

I would (somewhat naively) argue that this logic is wrong: it seems like this should just depend on use_luna without considering the phys version number. For example, if you want to run with mostly clm4_5 but turn on luna, my guess is that jmaxb1 should be added to the namelist, too. This feeling is supported by the following lines, which check for physv >= clm4_5, not clm5_0:

    my $val = $nl->get_value($var);
    if ( $physv->as_long() >= $physv->as_long("clm4_5") && ! &value_is_true( $nl_flags->{'use_luna'} ) ) {
       if ( defined($val) ) {
          $log->fatal_error("Cannot set $var when use_luna is NOT on" );
       }
    }

(3)

  if ( $physv->as_long() >= $physv->as_long("clm4_5") && $nl_flags->{'bgc_mode'} ne "sp" ) {
    # When FUN is on and it's clm5_0 get a default value
    if ( &value_is_true( $nl->get_value('use_fun') ) && $physv->as_long() >= $physv->as_long("clm5_0")) {
       add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults,
                   $nl, 'br_root', 'phys'=>$nl_flags->{'phys'},
                   'use_fun'=>$nl->get_value('use_fun'),
                   'use_cn'=>$nl_flags->{'use_cn'} );
    }

As with (2), I'd argue that this shouldn't be checking for physv >= clm5_0: it should just be checking if use_fun is on.

@billsacks
Copy link
Member

@ekluzek - given my previous comment, my sense is that, if we first remove clm4.0 support (which I could plan to do soon for this purpose), we can remove the need for numeric comparisons. Can you let me know if you agree with this, or if I'm missing something?

So I'd propose the following plan of attack, where I would do (1) - (3) in the next few weeks, and you (possibly together with me) would do (4) - (5) in the next few months:

  1. Remove clm4.0 support

  2. Remove numeric comparison ability for now

  3. Add nwp support, using exact string match

  4. Convert to python

  5. Add back in numeric comparison option, allowing this in the defaults xml file (Allow namelist defaults to apply for phys versions greater than or less than a given version #454 )

How does that sound to you?

@billsacks billsacks self-assigned this Jul 27, 2018
@billsacks
Copy link
Member

And to be clear: I'm thinking that, with my proposed plan, we would not need the "nwp1.0" option to "inherit" from "clm5_0".

@billsacks
Copy link
Member

See #456 for discussion on what should be done with this phys option.

@ekluzek
Copy link
Collaborator Author

ekluzek commented Jul 27, 2018

@billsacks I looked at the code some as well. And I think you are right, primarily the physics mode is used to distinguish out clm4_0. That's how it's actually used.

I looked a little bit into the exceptions that you list. The first group ( "origflag", "h2osfcflag", "oldfflag" ) is a way to deprecate options that should be heading towards removal.

"jmaxb1" is more complicated and probably needs more investigation. This check as it is, does go back at least until r200. It's likely it just needs to be tied to use_luna rather than clm5_0. But, we should figure that out for sure.

But, the sequence you give also makes sense to me.

@billsacks
Copy link
Member

@ekluzek I plan to start tackling this soon. Regarding your last comment: who would be the appropriate person to weigh in on the jmaxb1 logic?

@ekluzek
Copy link
Collaborator Author

ekluzek commented Jan 3, 2019

@billsacks @rosiealice and @wwieder would be two people to check with about Jmaxb1. It is local to LunaMod, so really is tied to use_luna=T.

@billsacks
Copy link
Member

@rosiealice or @wwieder can one of you please confirm my feelings in point (2) in this comment

#451 (comment)

i.e., is it correct that the presence of jmaxb1 in the namelist should only be tied to whether use_luna is true – so that it's included even if running with clm4_5 physics if use_luna is set to true?

@rosiealice
Copy link
Contributor

rosiealice commented Jan 3, 2019 via email

@billsacks
Copy link
Member

@rosiealice sorry, I'm having trouble interpreting your answer. I think the takeaway here is that I can change

    if ( $physv->as_long() >= $physv->as_long("clm5_0") && &value_is_true( $nl_flags->{'use_luna'} ) ) {
       add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
                     'use_luna'=>$nl_flags->{'use_luna'} );
    }

to simply

    if ( &value_is_true( $nl_flags->{'use_luna'} ) ) {
       add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
                     'use_luna'=>$nl_flags->{'use_luna'} );
    }

(Which I want to do to support the addition of an NWP physics option.)

But let me know if I'm misinterpreting your answer.

@rosiealice
Copy link
Contributor

rosiealice commented Jan 3, 2019 via email

@billsacks
Copy link
Member

Yes, good enough for me - thanks. (For the record: I'm going to go ahead with my proposed change.)

At some point I'd like to have more discussion about your point (2):

  1. LUNA is only ever true in CLM5. It can't be true in CLM4.5

This statement doesn't work for me, because (in my mind) the physics option (clm4_5 vs. clm5_0) just sets a suite of default parameter values, which can then be overridden. So, in principle, one should be able to set up a CLM45 case, then change all of the individual namelist options that depend on the physics option to end up with a case that is identical to a CLM50 case.

So the relevant question for me is: What CLM4.5 option(s) is LUNA incompatible with?

This isn't a purely academic question: It's relevant, for example, as we introduce an NWP option that is something of a hybrid between CLM4.5 and CLM5.0: we'll need to determine if LUNA is compatible with this NWP physics option.

@rosiealice
Copy link
Contributor

rosiealice commented Jan 3, 2019 via email

billsacks added a commit that referenced this issue May 1, 2019
Support for NWP configuration, NLDAS grid and NLDAS datm forcing

This tag includes a set of changes that, together, provide support for
running an initial Numerical Weather Prediction version of CTSM over the
Continental U.S.

(1) NWP configuration: The changes in this configuration relative to the
    climate (CLM5) configuration mainly target decreasing runtime by
    removing features that are expensive and not as important for NWP
    time scales (days to months rather than many years) and space scales
    (high resolution):

    - Single dominant landunit; if vegetated, single dominant PFT

    - Only 5 soil layers, down to 3 m

    - Only 5 snow layers

    - Plant hydraulic stress off

    - Ball-Berry rather than Medlyn stomatal conductance method (this is
      a side-effect of turning plant hydraulic stress off, and is not
      itself a critical aspect of the NWP configuration)

    - Maximum of 3 iterations to compute canopy fluxes

    - MEGAN is off

    Note that the NWP compset triggers changes in two new xml variables:
    CLM_CONFIGURATION ('clm' vs. 'nwp'; this controls things of a more
    scientific nature, like whether plant hydraulic stress is on or
    off), and CLM_STRUCTURE ('standard' vs. 'fast'; this controls
    structural things like the maximum number of landunits per grid cell
    and the soil layer structure). Thus, you can create a case that is a
    hybrid between the CLM and NWP configurations by changing these two
    xml variables independently.

(2) NLDAS2 regional grid: 0.125 deg grid over the Continental U.S.

(3) Updated version of MOSART with support for the same NLDAS2 regional
    grid

(4) NLDAS2 data atmosphere forcing: over the same regional grid; forcing
    data are available from 1980 - 2018. (We have excluded 1979 because
    a small amount of data were missing for that year, and we didn't
    have a good way to handle those missing data.)

These changes can be used independently or all together. However, note
that you will get garbage if you try to use the new NLDAS2 datm forcing
for a run that extends beyond the boundaries of the NLDAS2 domain.

There are three new NWP compsets:
- I2000Ctsm50NwpSpGswpGs: GSWP3 datm forcing; meant for global runs or
  regional runs outside the NLDAS domain
- I2000Ctsm50NwpSpNldasGs: NLDAS2 datm forcing; meant for regional runs
  over the NLDAS domain or some portion of it
- I2000Ctsm50NwpSpNldasRsGs: Same as above, but with a stub runoff model
  in place of MOSART, for runs that aren't interested in having a runoff
  model and for which you want improved throughput

The alias for the new grid is: nldas2_rnldas2_mnldas2 (indicating that
we're using the nldas2 grid for land/atmosphere, runoff ('r') and the
ocean mask ('m').

- Resolves #451 (Add NWP physics option)
- Resolves #452 (Add an NWP compset)
mariuslam pushed a commit to NordicESMhub/ctsm that referenced this issue Aug 26, 2019
olyson added a commit to olyson/ctsm that referenced this issue Sep 30, 2019
My branch is based on ctsm1.0.dev035 and NWP support started with ctsm1.0.dev038

Support for NWP configuration, NLDAS grid and NLDAS datm forcing

This tag includes a set of changes that, together, provide support for
running an initial Numerical Weather Prediction version of CTSM over the
Continental U.S.

(1) NWP configuration: The changes in this configuration relative to the
    climate (CLM5) configuration mainly target decreasing runtime by
    removing features that are expensive and not as important for NWP
    time scales (days to months rather than many years) and space scales
    (high resolution):

    - Single dominant landunit; if vegetated, single dominant PFT

    - Only 5 soil layers, down to 3 m

    - Only 5 snow layers

    - Plant hydraulic stress off

    - Ball-Berry rather than Medlyn stomatal conductance method (this is
      a side-effect of turning plant hydraulic stress off, and is not
      itself a critical aspect of the NWP configuration)

    - Maximum of 3 iterations to compute canopy fluxes

    - MEGAN is off

    Note that the NWP compset triggers changes in two new xml variables:
    CLM_CONFIGURATION ('clm' vs. 'nwp'; this controls things of a more
    scientific nature, like whether plant hydraulic stress is on or
    off), and CLM_STRUCTURE ('standard' vs. 'fast'; this controls
    structural things like the maximum number of landunits per grid cell
    and the soil layer structure). Thus, you can create a case that is a
    hybrid between the CLM and NWP configurations by changing these two
    xml variables independently.

(2) NLDAS2 regional grid: 0.125 deg grid over the Continental U.S.

(3) Updated version of MOSART with support for the same NLDAS2 regional
    grid

(4) NLDAS2 data atmosphere forcing: over the same regional grid; forcing
    data are available from 1980 - 2018. (We have excluded 1979 because
    a small amount of data were missing for that year, and we didn't
    have a good way to handle those missing data.)

These changes can be used independently or all together. However, note
that you will get garbage if you try to use the new NLDAS2 datm forcing
for a run that extends beyond the boundaries of the NLDAS2 domain.

There are three new NWP compsets:
- I2000Ctsm50NwpSpGswpGs: GSWP3 datm forcing; meant for global runs or
  regional runs outside the NLDAS domain
- I2000Ctsm50NwpSpNldasGs: NLDAS2 datm forcing; meant for regional runs
  over the NLDAS domain or some portion of it
- I2000Ctsm50NwpSpNldasRsGs: Same as above, but with a stub runoff model
  in place of MOSART, for runs that aren't interested in having a runoff
  model and for which you want improved throughput

The alias for the new grid is: nldas2_rnldas2_mnldas2 (indicating that
we're using the nldas2 grid for land/atmosphere, runoff ('r') and the
ocean mask ('m').

- Resolves ESCOMP#451 (Add NWP physics option)
- Resolves ESCOMP#452 (Add an NWP compset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new capability or improved behavior of existing capability priority: high High priority to fix/merge soon, e.g., because it is a problem in important configurations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants