CABLE-LSM / CABLE

Home to the CABLE land surface model and its documentation
https://cable.readthedocs.io/en/latest/
Other
12 stars 6 forks source link

Bug fix: outputs broken in MPI implementation #360

Closed ccarouge closed 3 months ago

ccarouge commented 3 months ago

CABLE

Thank you for submitting a pull request to the CABLE Project.

Description

Fixes #359 Changes for checking ranges have changed how the output%X logical switches are set. This was not reflected in the MPI driver which meant no outputs were produced from simulations using MPI.

Fix include:

Type of change

Please delete options that are not relevant.

Testing

Fluxsite tests with benchcab ran as expected showing no differences with the main branch.

Ran spatial tests with benchcab for this branch and the main branch. The netcdf files for this branch now contain outputs for all requested variables.

Output file header for main:

netcdf cable_out {
dimensions:
    x = 192 ;
    y = 112 ;
    patch = 7 ;
    soil = 6 ;
    rad = 3 ;
    soil_carbon_pools = 2 ;
    plant_carbon_pools = 3 ;
    time = UNLIMITED ; // (12 currently)
    z = 1 ;
variables:
    double time(time) ;
        time:units = "seconds since 1901-01-01 00:00:00" ;
        time:coordinate = "GMT" ;
        time:calendar = "standard" ;
    float latitude(y, x) ;
        latitude:units = "degrees_north" ;
    float longitude(y, x) ;
        longitude:units = "degrees_east" ;
    float x(x) ;
        x:units = "degrees_east" ;
        x:comment = "x coordinate variable for GrADS compatibility" ;
    float y(y) ;
        y:units = "degrees_north" ;
        y:comment = "y coordinate variable for GrADS compatibility" ;
    float Area(time, y, x) ;
        Area:units = "km2" ;
        Area:long_name = "Patch Area" ;
        Area:_FillValue = -1.e+33f ;
        Area:missing_value = -1.e+33f ;

// global attributes:
        :Production = "2024/08/05 at 12:35:48" ;
        :Source = "CABLE LSM output file" ;
        :CABLE_input_file = "" ;
        :Output_averaging = "monthly" ;
}

Output file header for this branch:

netcdf cable_out {
dimensions:
    x = 192 ;
    y = 112 ;
    patch = 7 ;
    soil = 6 ;
    rad = 3 ;
    soil_carbon_pools = 2 ;
    plant_carbon_pools = 3 ;
    time = UNLIMITED ; // (12 currently)
    z = 1 ;
variables:
    double time(time) ;
        time:units = "seconds since 1901-01-01 00:00:00" ;
        time:coordinate = "GMT" ;
        time:calendar = "standard" ;
    float latitude(y, x) ;
        latitude:units = "degrees_north" ;
    float longitude(y, x) ;
        longitude:units = "degrees_east" ;
    float x(x) ;
        x:units = "degrees_east" ;
        x:comment = "x coordinate variable for GrADS compatibility" ;
    float y(y) ;
        y:units = "degrees_north" ;
        y:comment = "y coordinate variable for GrADS compatibility" ;
    float SWdown(time, y, x) ;
        SWdown:units = "W/m^2" ;
        SWdown:long_name = "Downward shortwave radiation" ;
        SWdown:_FillValue = -1.e+33f ;
        SWdown:missing_value = -1.e+33f ;
...

Please add a reviewer when ready for review.


📚 Documentation preview 📚: https://cable--360.org.readthedocs.build/en/360/

ccarouge commented 3 months ago

@JhanSrbinovsky There was a bug in the MPI version for checking the variable ranges. To simplify the fix, I decided to remove wlogn which tracked the unit number for the CABLE log files on the workers. It's not needed in the offline version (can use logn for all cores). Can you confirm we don't use it in ESM1.5 and CM2? I've checked the code base for ESM1.5 and haven't seen it but I don't know where is the CM2 code base.

JhanSrbinovsky commented 3 months ago

I have never come across it online Claire. In circa AM3 models we dont even talk to the outside world - definitely not. Same in circa CM2 models, albeit less efficiently. Although there seem to be a bunch of mentions of slogan in sci and POP?

ccarouge commented 3 months ago

there seem to be a bunch of mentions of slogan in sci and POP

POP declares it but doesn't use it, at least in the main branch. The CABLE-POP_TRENDY we'll worry about later.

SLI is using it but I now set logn to the value wlogn used to hold, so it's simply a renaming from wlogn to logn for SLI.

ccarouge commented 3 months ago

@Whyborn I couldn't test the changes for CASA, LUC, POP and SLI so keep an eye out for inconsistencies in there when reviewing. POP is not used from main so I don't worry too much about it and will be changed for CABLE4 anyway. LUC and CASA all seemed to declare the variable locally but without using it (might need a second check). For SLI, renaming wlogn to logn should work, just like for the rest of the CABLE code.