Skip to content

Commit

Permalink
Checking of all-sky reference results
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPincus committed Jun 21, 2023
1 parent 766494e commit 62cbf43
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/containerized-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
with:
repository: earth-system-radiation/rrtmgp-data
path: rrtmgp-data
ref: feature-timing
#
# Cache RFMIP files
#
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
with:
repository: earth-system-radiation/rrtmgp-data
path: rrtmgp-data
ref: feature-timing
#
# Synchronize the package index
#
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/self-hosted-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
with:
repository: earth-system-radiation/rrtmgp-data
path: rrtmgp-data
ref: feature-timing
#
# Finalize build environment
#
Expand Down
8 changes: 4 additions & 4 deletions examples/all-sky/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ rrtmgp_allsky.o: $(ADDITIONS) rrtmgp_allsky.F90

mo_cloud_optics_rrtmgp.o: mo_cloud_optics_rrtmgp.F90
mo_aerosol_optics_rrtmgp_merra.o: mo_aerosol_optics_rrtmgp_merra.F90
mo_load_coefficients.o: mo_simple_netcdf.o mo_load_coefficients.F90
mo_load_cloud_coefficients.o: mo_simple_netcdf.o mo_cloud_optics_rrtmgp.o mo_load_cloud_coefficients.F90
mo_load_coefficients.o: mo_simple_netcdf.o mo_load_coefficients.F90
mo_load_cloud_coefficients.o: mo_simple_netcdf.o mo_cloud_optics_rrtmgp.o mo_load_cloud_coefficients.F90
mo_load_aerosol_coefficients.o: mo_simple_netcdf.o mo_aerosol_optics_rrtmgp_merra.o mo_load_aerosol_coefficients.F90

tests:
$(RUN_CMD) ./rrtmgp_allsky 24 72 1 rrtmgp-allsky.nc ${RRTMGP_DATA}/rrtmgp-gas-lw-g256.nc ${RRTMGP_DATA}/rrtmgp-clouds-lw.nc ${RRTMGP_DATA}/rrtmgp-aerosols-merra-lw.nc
$(RUN_CMD) ./rrtmgp_allsky 24 72 1 rrtmgp-allsky.nc ${RRTMGP_DATA}/rrtmgp-gas-sw-g224.nc ${RRTMGP_DATA}/rrtmgp-clouds-sw.nc ${RRTMGP_DATA}/rrtmgp-aerosols-merra-sw.nc

check:
echo "No checking of all sky results at this time"
# python ./compare-to-reference.py
python ./compare-to-reference.py --allsky_file rrtmgp-allsky-lw.nc
python ./compare-to-reference.py --allsky_file rrtmgp-allsky-sw.nc

clean:
-rm rrtmgp_allsky *.o *.optrpt ../*.optrpt *.mod *.nc
10 changes: 5 additions & 5 deletions examples/all-sky/compare-to-reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
parser = argparse.ArgumentParser(
description="Compares all-sky example output to file in reference "
"directory")
parser.add_argument("--allsky_file", type=str, default="rrtmgp-allsky.nc",
parser.add_argument("--allsky_file", type=str, default="rrtmgp-allsky-lw.nc",
dest="file",
help="Name of file inputs and outputs for "
"all-sky problem (same for test and reference)")
Expand All @@ -35,13 +35,13 @@
ref = xr.open_dataset(ref_file)

failed = False
for v in ['lw_flux_up', 'lw_flux_dn', 'sw_flux_up', 'sw_flux_dn',
'sw_flux_dir']:
for v in tst.variables:
if np.any(np.isnan(ref.variables[v].values)):
raise Exception(v + ": some ref values are missing. Now that is strange.")
if np.all(np.isnan(tst.variables[v].values)):
raise Exception("All test values are missing. Were the tests run?")
if np.any(np.isnan(tst.variables[v].values)):
raise Exception(
"Some test values are missing. Now that is strange.")
raise Exception(v + ":Some test values are missing. Now that is strange.")

# express as (tst-ref).variables[v].values when replacing reference file
# to have same number of columns
Expand Down
23 changes: 13 additions & 10 deletions examples/all-sky/rrtmgp_allsky.F90
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,10 @@ program rte_rrtmgp_clouds_aerosols
call system_clock(finish_all, clock_rate)

! Release GPU memory for p_lay, t_lay, p_lev, t_lev, q, o3)
!$acc exit data delete(p_lay, p_lev, t_lay, t_lev)
!$acc exit data delete( p_lay, p_lev, t_lay, t_lev)
!$omp target exit data map(release:p_lay, p_lev, t_lay, t_lev)
if(do_clouds) then
!$acc exit data delete( lwp, iwp, rel, rei)
!$omp target exit data map(release:lwp, iwp, rel, rei)
end if
!
! TK - release aerosol memory
!

! Memory for clouds and aerosols is released in write-fluxes

#if defined(_OPENACC) || defined(_OPENMP)
avg = sum( elapsed(merge(2,1,nloops>1):) ) / real(merge(nloops-1,nloops,nloops>1))
Expand Down Expand Up @@ -681,8 +676,8 @@ subroutine write_fluxes
!
! Define dimensions
!
if(nf90_create("rrmtgp_allsky_" // merge("lw", "sw", is_lw) // ".nc", NF90_CLOBBER, ncid) /= NF90_NOERR) &
call stop_on_err("rrtmgp_allsky: can't create file rrmtgp_allsky_" // merge("lw", "sw", is_lw) // ".nc")
if(nf90_create("rrtmgp-allsky-" // merge("lw", "sw", is_lw) // ".nc", NF90_CLOBBER, ncid) /= NF90_NOERR) &
call stop_on_err("rrtmgp_allsky: can't create file rrmtgp-allsky-" // merge("lw", "sw", is_lw) // ".nc")

if(nf90_def_dim(ncid, "col", ncol, col_dim) /= NF90_NOERR) &
call stop_on_err("rrtmgp_allsky: can't define col dimension")
Expand Down Expand Up @@ -739,6 +734,14 @@ subroutine write_fluxes
call stop_on_err(gas_concs%get_vmr("o3", vmr))
call stop_on_err(write_field(ncid, "o3", vmr))

if(do_clouds) then
!$acc exit data delete( lwp, iwp, rel, rei)
!$omp target exit data map(release:lwp, iwp, rel, rei)
end if

if(do_aerosols) then
end if

! Fluxes - writing
!$acc exit data copyout( flux_up, flux_dn)
!$omp target exit data map(from:flux_up, flux_dn)
Expand Down

0 comments on commit 62cbf43

Please sign in to comment.