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

379 continue integrating the ground water hydrology work into cable #411

Open
wants to merge 77 commits into
base: main
Choose a base branch
from

Conversation

rkutteh
Copy link
Collaborator

@rkutteh rkutteh commented Sep 30, 2024

This pull request contains ALL remaining ground water hydrology work of Mengyuan Mu.

PLEASE do not delete any of my in-code comments (tagged rk4417) for now. Once the ground water hydrology functionality is confirmed to reproduce the results obtained already outside of the repo, I will clean-up all of my comments in a single pull request. Deleting any of my comments now will just make it much more difficult for me to track down and fix any issues that might arise during this process.


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

@rkutteh rkutteh added GWH Ground water hydrology integration work priority:high High priority issues that should be included in the next release. labels Sep 30, 2024
@rkutteh rkutteh added this to the GW milestone Sep 30, 2024
@rkutteh rkutteh requested a review from ccarouge September 30, 2024 04:29
@rkutteh rkutteh self-assigned this Sep 30, 2024
@rkutteh rkutteh linked an issue Sep 30, 2024 that may be closed by this pull request
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of things in there. I let you digest but for a few things to start with:

  • revert the changes on soilparmnew. This isn't going to be introduced in this work. Happy to have it proposed as a standalone change.
  • I would like to move the addition of force_npatches_as also as a standalone issue and PR. And it will need associated documentation changes.

Also, since with this PR we will be able to evaluate the impact of the changes on the simulation without GW and with GW, I will want to remove all commented alternate versions before we merge. This can be done at the end, just putting in on the list of tasks.

src/offline/cable_checks.F90 Outdated Show resolved Hide resolved
Comment on lines +1384 to +1389
nn = INDEX(inFile,'19')
READ(inFile(nn:nn+3),'(i4)') idummy
WRITE(inFile(nn:nn+3),'(i4.4)') ncciy
nn = INDEX(inFile,'19')
READ(inFile(nn:nn+3),'(i4)') idummy
WRITE(inFile(nn:nn+3),'(i4.4)') ncciy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it doing twice the same thing?

Is there any explanation anywhere of what this does?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I traced this back to the code from MMY (phase 1). The only explanation is what you see "MMY for Princeton input". It could be intentional or a simple duplication error. We can ping MMY about it of you like

src/offline/cable_driver.F90 Outdated Show resolved Hide resolved
src/offline/cable_driver.F90 Outdated Show resolved Hide resolved
src/offline/cable_driver.F90 Outdated Show resolved Hide resolved
src/util/cable_runtime_opts_mod.F90 Outdated Show resolved Hide resolved
Comment on lines +120 to +121
!line below inserted to fix compilation error - rk4417 - phase2
INTEGER :: force_npatches_as=-1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new namelist option needs an entry in the documentation to explain what it is.

It does not seem to be related to the GW so I would rather introduce it separately than within the GW changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All I can say here is that I needed this line to get the code to compile at the time. Perhaps the present code will compile without it, I don't know. I suggest we leave this bit till the end to see whether it is still needed to get the code to compile.

src/science/soilsnow/cbl_stempv.F90 Outdated Show resolved Hide resolved
src/science/soilsnow/cbl_surfbv.F90 Outdated Show resolved Hide resolved
src/science/soilsnow/cbl_thermal.F90 Show resolved Hide resolved
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of things in there. I let you digest but for a few things to start with:

  • revert the changes on soilparmnew. This isn't going to be introduced in this work. Happy to have it proposed as a standalone change.
  • I would like to move the addition of force_npatches_as also as a standalone issue and PR. And it will need associated documentation changes.

Also, since with this PR we will be able to evaluate the impact of the changes on the simulation without GW and with GW, I will want to remove all commented alternate versions before we merge. This can be done at the end, just putting in on the list of tasks.

rkutteh and others added 16 commits November 5, 2024 12:31
Reverted soilparmnew occurrence
revert occurrences of soilparmnew
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
Co-authored-by: Claire Carouge <ccarouge@users.noreply.github.com>
@rkutteh rkutteh requested a review from ccarouge January 9, 2025 09:49
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkutteh A new wave of comments but they are for me to do stuff, nothing new for you yet.

Comment on lines 815 to 819
! Zero out lai where there is no vegetation acc. to veg. index
WHERE ( iveg%iveg(:) .GE. 14 ) iveg%vlai = 0.

! WHERE ( iveg%iveg(:) .GE. 14 ) iveg%vlai = 0.
! line above replaced by below - rk4417 - phase2
WHERE ( veg%iveg(:) .GE. 14 ) veg%vlai = 0. ! MMY change from iveg%vlai to veg%vlai

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks correct but I'll need to double check (a note to myself...)

Comment on lines +960 to 963
! WHERE ( iveg%iveg(:) .GE. 14 ) iveg%vlai = 0.
! line above replaced by below - rk4417 - phase2
WHERE ( veg%iveg(:) .GE. 14 ) veg%vlai = 0. ! MMY change from iveg%vlai to veg%vlai
! Write time step's output to file if either: we're not spinning up
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Need to review the use of veg and iveg in the MPI implementation. (a note to myself)

Comment on lines +518 to 521
! MMY start reading from gridinfo file ! 2 lines inserted by rk4417 - phase2
ok = NF90_OPEN(filename%type, 0, ncid)
IF (ok /= NF90_NOERR) CALL nc_abort(ok, 'Error MMY finding gridinfo file.') ! MMY

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove MMY from error message

Suggested change
! MMY start reading from gridinfo file ! 2 lines inserted by rk4417 - phase2
ok = NF90_OPEN(filename%type, 0, ncid)
IF (ok /= NF90_NOERR) CALL nc_abort(ok, 'Error MMY finding gridinfo file.') ! MMY
! MMY start reading from gridinfo file ! 2 lines inserted by rk4417 - phase2
ok = NF90_OPEN(filename%type, 0, ncid)
IF (ok /= NF90_NOERR) CALL nc_abort(ok, 'Error finding gridinfo file.') ! MMY

Comment on lines +188 to +217

IF( cable_runtime%um ) THEN

IF( cable_runtime%um_implicit ) THEN
IF (cable_user%gw_model) THEN
CALL soil_snow_gw(dels, soil, ssnow, canopy, met, bal,veg)
ELSE
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
ENDIF
ENDIF

ELSE
IF(cable_user%SOIL_STRUC=='default') THEN
IF (cable_user%gw_model) THEN
CALL soil_snow_gw(dels, soil, ssnow, canopy, met, bal,veg)
ELSE
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
ENDIF
ELSEIF (cable_user%SOIL_STRUC=='sli') THEN

IF (cable_user%test_new_gw) &
CALL sli_hydrology(dels,ssnow,soil,veg,canopy)

CALL sli_main(ktau,dels,veg,soil,ssnow,met,canopy,air,rad,0)
ENDIF
ENDIF

! I have inserted the above block from MMY code which was deleted from the trunk
! soil_snow_gw and sli_hydrology are crucial in the GW module - rk4417 - phase2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of CABLE has change. This code is now only for offline with a different version of coupled, so the above block can be simplified as below:

Suggested change
IF( cable_runtime%um ) THEN
IF( cable_runtime%um_implicit ) THEN
IF (cable_user%gw_model) THEN
CALL soil_snow_gw(dels, soil, ssnow, canopy, met, bal,veg)
ELSE
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
ENDIF
ENDIF
ELSE
IF(cable_user%SOIL_STRUC=='default') THEN
IF (cable_user%gw_model) THEN
CALL soil_snow_gw(dels, soil, ssnow, canopy, met, bal,veg)
ELSE
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
ENDIF
ELSEIF (cable_user%SOIL_STRUC=='sli') THEN
IF (cable_user%test_new_gw) &
CALL sli_hydrology(dels,ssnow,soil,veg,canopy)
CALL sli_main(ktau,dels,veg,soil,ssnow,met,canopy,air,rad,0)
ENDIF
ENDIF
! I have inserted the above block from MMY code which was deleted from the trunk
! soil_snow_gw and sli_hydrology are crucial in the GW module - rk4417 - phase2
IF(cable_user%SOIL_STRUC=='default') THEN
IF (cable_user%gw_model) THEN
CALL soil_snow_gw(dels, soil, ssnow, canopy, met, bal,veg)
ELSE
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
ENDIF
ELSEIF (cable_user%SOIL_STRUC=='sli') THEN
IF (cable_user%test_new_gw) &
CALL sli_hydrology(dels,ssnow,soil,veg,canopy)
CALL sli_main(ktau,dels,veg,soil,ssnow,met,canopy,air,rad,0)
ENDIF
! I have inserted the above block from MMY code which was deleted from the trunk
! soil_snow_gw and sli_hydrology are crucial in the GW module - rk4417 - phase2

Comment on lines +221 to +228

IF (cable_user%gw_model) THEN ! IF block inserted by rk4417 - phase2
! IF (call_number .eq. 1) call set_den_rat()
ssnow%wbliq(:,:) = ssnow%wb(:,:) - den_rat*ssnow%wbice(:,:)
ELSE
ssnow%wbliq(:,:) = ssnow%wb(:,:) - ssnow%wbice(:,:)
ENDIF

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@har917 GW work introduces the calculation of wbliq at the start of cable_canopy.F90. Do you see anything here that would break the ACCESS coupling?
I also think we want the version with the ratio of liq/ice densities in all cases and not just for gw_model if we go with it. Can you confirm, please?

ssnow%wetfac = 0.5*(ssnow%wetfac + ssnow%owetfac)


CALL calc_srf_wet_fraction(ssnow,soil,met,veg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code has been moved in the main branch. Will need to resolve conflicts before going further.

Comment on lines 54 to +58
rwater = MAX(1.0e-9, &
SUM(veg%froot * MAX(1.0e-9,MIN(1.0, REAL((ssnow%wbliq - &
soil%swilt_vec)/(soil%sfc_vec-soil%swilt_vec)) )),2) )
SUM(veg%froot * MAX(1.0e-9, MIN( 1.0, &
MAX(0., (real(ssnow%wbliq) - real(soil%swilt_vec)) )&
/ (real(soil%sfc_vec) - real(soil%swilt_vec)) &
)) , 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just uppercase.

Comment on lines 44 to +48
rwater = MAX(1.0e-9, &
SUM(veg%froot * MAX(1.0e-9,MIN(1.0, REAL(ssnow%wb) - &
SPREAD(soil%swilt, 2, ms))),2) /(soil%sfc-soil%swilt))

ELSE
SUM(veg%froot * MAX(1.0e-9, MIN( 1.0, &
MAX(0., (real(ssnow%wb) - SPREAD(soil%swilt, 2, ms)) )&
/ (SPREAD(soil%sfc, 2, ms) - SPREAD(soil%swilt, 2, ms)) &
)) , 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reading it, it's the same equation as before but with an added MAX(0,x) on something that should always be positive and added SPREAD(). So we can add it, no need to test the effect.

Comment on lines +320 to 322
/ soil%zshh (k+1) + z2(:,k) * 0.5 * soil%zse( MAX( k-1, &
1 ) ) / soil%zshh (k) + z3(:,k+1) + z3(:,k) )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems it will impact all simulations, will need to test the impact on non-GW simulations then.

@@ -204,6 +205,8 @@ MODULE cable_checks_module

TYPE(ranges_type), SAVE :: ranges

IF (cable_user%GW_MODEL) ranges%sucs = [30., 800.] ! MMY the range [-0.8, -0.03] doesn't suit Mark Decker's version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't be done in the module definition part. This will require some more in-depth changes that will be done later.

@ccarouge ccarouge force-pushed the 379-continue-integrating-the-ground-water-hydrology-work-into-cable branch from eb6a56c to d3e39e1 Compare January 17, 2025 04:45
@ccarouge ccarouge force-pushed the 379-continue-integrating-the-ground-water-hydrology-work-into-cable branch from 12b9505 to a7a1c9a Compare January 17, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GWH Ground water hydrology integration work priority:high High priority issues that should be included in the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Continue integrating the ground water hydrology work into CABLE
2 participants