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

New const_get_index logic without cam_ccpp_cap dependency (in atmos_phys) #314

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
fxDONOTUSEurl = https://github.com/MPAS-Dev/MPAS-Model.git
[submodule "ncar-physics"]
path = src/physics/ncar_ccpp
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = atmos_phys0_05_001
url = https://github.com/jimmielin/atmospheric_physics
fxtag = fbea5c86954f6d043d8d8a94715cb745469114b8
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
[submodule "ccs_config"]
Expand Down
23 changes: 21 additions & 2 deletions cime_config/cam_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ def generate_physics_suites(build_cache, preproc_defs, host_name,

# Check that directory exists
if not os.path.isdir(atm_phys_util_dir):
#CAM-SIMA will likely not run without this, so raise an error
# CAM-SIMA will likely not run without this, so raise an error
emsg = "ERROR: Unable to find CCPP physics utilities directory:\n"
emsg += f" {atm_phys_util_dir}\n Have you run 'checkout_externals'?"
emsg += f" {atm_phys_util_dir}\n Have you run 'git-fleximod'?"
raise CamAutoGenError(emsg)
# end if

Expand All @@ -611,6 +611,25 @@ def generate_physics_suites(build_cache, preproc_defs, host_name,
for util_file in atm_phys_util_files:
shutil.copy(util_file, physics_blddir)
# end for

# Copy to_be_ccppized utility modules to the build directory,
# as SIMA cam_constituents depends on them.
# Note: to_be_ccppized utility modules to be removed once functionality is migrated
# to SIMA or CCPPized in atmospheric_physics.
atm_phys_to_be_ccppized_dir = os.path.join(atm_phys_top_dir, "to_be_ccppized")

# Check that the directory exists
if not os.path.isdir(atm_phys_to_be_ccppized_dir):
# CAM-SIMA will likely not run without this, so raise an error
emsg = "ERROR: Unable to find CCPP physics to_be_ccppized directory:\n"
emsg += f" {atm_phys_util_dir}\n Have you run 'git-fleximod'?"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be atm_phys_to_be_ccppized_dir here:

Suggested change
emsg += f" {atm_phys_util_dir}\n Have you run 'git-fleximod'?"
emsg += f" {atm_phys_to_be_ccppized_dir}\n Have you run 'git-fleximod'?"

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, my bad! Fixed

raise CamAutoGenError(emsg)
# end if

atm_phys_to_be_ccppized_files = glob.glob(os.path.join(atm_phys_to_be_ccppized_dir, "*.F90"))
for to_be_ccppized_file in atm_phys_to_be_ccppized_files:
shutil.copy(to_be_ccppized_file, physics_blddir)
# end for
# end if

if do_gen_ccpp or do_gen_nl:
Expand Down
2 changes: 1 addition & 1 deletion src/physics/ncar_ccpp
28 changes: 18 additions & 10 deletions src/physics/utils/cam_constituents.F90
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ end function const_molec_weight
!#######################################################################

subroutine const_get_index(name, cindex, abort, warning, caller)
use shr_kind_mod, only: CX => SHR_KIND_CX
use cam_abortutils, only: endrun
use cam_logfile, only: iulog
use cam_ccpp_cap, only: cam_const_get_index
! from to_be_ccppized utility routine
use ccpp_const_utils, only: ccpp_const_get_idx

use shr_kind_mod, only: CX => SHR_KIND_CX
use cam_abortutils, only: endrun
use cam_logfile, only: iulog
use phys_vars_init_check, only: std_name_len
use string_utils, only: to_str

! Get the index of a constituent with standard name, <name>.
! Setting optional <abort> argument to .false. returns control to
Expand All @@ -298,11 +302,11 @@ subroutine const_get_index(name, cindex, abort, warning, caller)
! instead of <subname> in messages.

!-----------------------------Arguments---------------------------------
character(len=*), intent(in) :: name ! constituent name
integer, intent(out) :: cindex ! global constituent ind
logical, optional, intent(in) :: abort ! flag controlling abort
character(len=*), intent(in) :: name ! constituent name
integer, intent(out) :: cindex ! global constituent index
logical, optional, intent(in) :: abort ! flag controlling abort
logical, optional, intent(in) :: warning ! flag controlling warning
character(len=*), optional, intent(in) :: caller ! calling routine
character(len=*), optional, intent(in) :: caller ! calling routine

!---------------------------Local workspace-----------------------------
logical :: warning_on_error
Expand All @@ -312,10 +316,14 @@ subroutine const_get_index(name, cindex, abort, warning, caller)
character(len=*), parameter :: subname = 'const_get_index: '
!-----------------------------------------------------------------------

! Find tracer name in the master table
call cam_const_get_index(name, cindex, errcode=errcode, errmsg=errmsg)
call ccpp_const_get_idx(const_props, name, cindex, errmsg, errcode)

if (errcode /= 0) then
call endrun(subname//"Error "//to_str(errcode)//": "// &
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might use stringify here instead of to_str (my hope is to eventually use stringify for all string conversions):

Suggested change
call endrun(subname//"Error "//to_str(errcode)//": "// &
use string_utils, only: stringify
...
call endrun(subname//"Error "//stringify((/errcode/))//": "// &

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, updated!

trim(errmsg), file=__FILE__, line=__LINE__)
endif

if (cindex == -1) then
! Unrecognized name, set an error return and possibly abort
cindex = -1
if (present(abort)) then
Expand Down
Loading