Skip to content

Commit

Permalink
Merge pull request #68 from ESMCI/pio-init-rework
Browse files Browse the repository at this point in the history
Work toward pio2 and async pio interfaces.

Test suite: ./create_test --xml-testlist ../src/drivers/nuopc/cime_config/testdefs/testlist_drv.xml --xml-machine cheyenne --xml-category nuopc --walltime 00:30:00 --compare jan11 --baseline-root /glade/scratch/jedwards/BASELINES
Test baseline: jan11
Test namelist changes:
Test status: bit for bit
Fixes: none
User interface changes?: No
Update gh-pages html (Y/N)?: No
Code review: mvertens
  • Loading branch information
mvertens authored Jan 28, 2019
2 parents 881436e + 3acdcfd commit f37d8e3
Show file tree
Hide file tree
Showing 24 changed files with 288 additions and 426 deletions.
7 changes: 5 additions & 2 deletions scripts/lib/CIME/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from CIME.utils import expect, get_cime_root, append_status
from CIME.utils import convert_to_type, get_model
from CIME.utils import get_project, get_charge_account, check_name
from CIME.utils import get_current_commit, safe_copy
from CIME.utils import get_current_commit, safe_copy, get_cime_default_driver
from CIME.locked_files import LOCKED_DIR, lock_file
from CIME.XML.machines import Machines
from CIME.XML.pes import Pes
Expand Down Expand Up @@ -1350,7 +1350,10 @@ def _check_testlists(self, compset_alias, grid_name, files):
tests = Testlist(tests_spec_file, files)
testlist = tests.get_tests(compset=compset_alias, grid=grid_name, supported_only=True)
for test in testlist:
if test["category"] == "prealpha" or test["category"] == "prebeta" or "aux_" in test["category"]:
if test["category"] == "prealpha" \
or test["category"] == "prebeta" \
or "aux_" in test["category"] \
or get_cime_default_driver() in test["category"]:
testcnt += 1
if testcnt > 0:
logger.warning("\n*********************************************************************************************************************************")
Expand Down
18 changes: 15 additions & 3 deletions scripts/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,15 @@ def test_a_createnewcase(self):
testdir = os.path.join(cls._testroot, 'testcreatenewcase')
if os.path.exists(testdir):
shutil.rmtree(testdir)
args = " --case %s --compset X --res f19_g16 --output-root %s --handle-preexisting-dirs=r" % (testdir, cls._testroot)
args = " --case %s --compset X --output-root %s --handle-preexisting-dirs=r --debug " % (testdir, cls._testroot)
if TEST_COMPILER is not None:
args = args + " --compiler %s"%TEST_COMPILER
if TEST_MPILIB is not None:
args = args + " --mpilib %s"%TEST_MPILIB
if CIME.utils.get_cime_default_driver() == "nuopc":
args += " --res f19_g17 "
else:
args += " --res f19_g16 "

cls._testdirs.append(testdir)
run_cmd_assert_result(self, "./create_newcase %s"%(args), from_dir=SCRIPT_DIR)
Expand Down Expand Up @@ -361,11 +365,15 @@ def test_b_user_mods(self):
cls._testdirs.append(testdir)

user_mods_dir = os.path.join(CIME.utils.get_python_libs_root(), "..", "tests", "user_mods_test1")
args = " --case %s --compset X --res f19_g16 --user-mods-dir %s --output-root %s --handle-preexisting-dirs=r"% (testdir, user_mods_dir, cls._testroot)
args = " --case %s --compset X --user-mods-dir %s --output-root %s --handle-preexisting-dirs=r"% (testdir, user_mods_dir, cls._testroot)
if TEST_COMPILER is not None:
args = args + " --compiler %s"%TEST_COMPILER
if TEST_MPILIB is not None:
args = args + " --mpilib %s"%TEST_MPILIB
if CIME.utils.get_cime_default_driver() == "nuopc":
args += " --res f19_g17 "
else:
args += " --res f19_g16 "

run_cmd_assert_result(self, "%s/create_newcase %s "
% (SCRIPT_DIR, args),from_dir=SCRIPT_DIR)
Expand Down Expand Up @@ -540,11 +548,15 @@ def test_h_primary_component(self):
shutil.rmtree(testdir)

cls._testdirs.append(testdir)
args = " --case CreateNewcaseTest --script-root %s --compset X --res f19_g16 --output-root %s --handle-preexisting-dirs u" % (testdir, cls._testroot)
args = " --case CreateNewcaseTest --script-root %s --compset X --output-root %s --handle-preexisting-dirs u" % (testdir, cls._testroot)
if TEST_COMPILER is not None:
args += " --compiler %s"%TEST_COMPILER
if TEST_MPILIB is not None:
args += " --mpilib %s"%TEST_MPILIB
if CIME.utils.get_cime_default_driver() == "nuopc":
args += " --res f19_g17 "
else:
args += " --res f19_g16 "

run_cmd_assert_result(self, "%s/create_newcase %s" % (SCRIPT_DIR, args), from_dir=SCRIPT_DIR)
self.assertTrue(os.path.exists(testdir))
Expand Down
6 changes: 4 additions & 2 deletions src/build_scripts/buildlib.gptl
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ def buildlib(bldroot, installpath, case):
comp_interface = case.get_value("COMP_INTERFACE")
caseroot = case.get_value("CASEROOT")
gptl_dir = os.path.join(case.get_value("CIMEROOT"), "src", "share", "timing")
debug = case.get_value("DEBUG")
gmake_opts = "-f {gptl}/Makefile install -C {bldroot} MACFILE={macfile} MODEL=gptl GPTL_DIR={gptl} GPTL_LIBDIR={bldroot}"\
" SHAREDPATH={install} COMP_INTERFACE={comp_interface}"\
.format(gptl=gptl_dir, bldroot=bldroot, macfile=os.path.join(caseroot,"Macros.make"),
install=installpath,comp_interface=comp_interface)
build_threaded = case.get_build_threaded()
if build_threaded:
if debug:
gmake_opts += " DEBUG=True"
if case.get_build_threaded():
gmake_opts += " compile_threaded=true "

gmake_cmd = case.get_value("GMAKE")
Expand Down
4 changes: 3 additions & 1 deletion src/components/data_comps/datm/nuopc/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ end subroutine InitializeRealize

subroutine ModelAdvance(gcomp, rc)
use shr_nuopc_utils_mod, only : shr_nuopc_log_clock_advance, shr_nuopc_memcheck
use perf_mod, only : t_startf, t_stopf
type(ESMF_GridComp) :: gcomp
integer, intent(out) :: rc

Expand Down Expand Up @@ -503,7 +504,7 @@ subroutine ModelAdvance(gcomp, rc)
integer :: dbrc
character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) '
!-------------------------------------------------------------------------------

call t_startf(subname)
rc = ESMF_SUCCESS
call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=dbrc)

Expand Down Expand Up @@ -628,6 +629,7 @@ subroutine ModelAdvance(gcomp, rc)
call shr_file_setLogUnit (shrlogunit)

call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=dbrc)
call t_stopf(subname)

end subroutine ModelAdvance

Expand Down
3 changes: 1 addition & 2 deletions src/components/xcpl_comps/xshare/nuopc/dead_nuopc_mod.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module dead_nuopc_mod

use ESMF , only : ESMF_Gridcomp, ESMF_State, ESMF_StateGet
Expand Down Expand Up @@ -382,7 +381,7 @@ subroutine dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len,
gbuf(n,dead_grid_lat ) = yc
gbuf(n,dead_grid_index) = gindex(n)
gbuf(n,dead_grid_area ) = area
gbuf(n,dead_grid_mask ) = 1
gbuf(n,dead_grid_mask ) = 0
gbuf(n,dead_grid_frac ) = 1.0_R8
enddo

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/mct/main/cime_comp_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ subroutine cime_pre_init2()
! Initialize freezing point calculation for all components
!----------------------------------------------------------

call shr_frz_freezetemp_init(tfreeze_option)
call shr_frz_freezetemp_init(tfreeze_option, iamroot_GLOID)

if (trim(orb_mode) == trim(seq_infodata_orb_variable_year)) then
call seq_timemgr_EClockGetData( EClock_d, curr_ymd=ymd)
Expand Down
6 changes: 4 additions & 2 deletions src/drivers/nuopc/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ def _create_component_modelio_namelists(confdir, case, files):
for entry in entries:
nmlgen.add_default(entry)

if model != "cpl":
if model == "cpl":
modelio_file = "med_modelio.nml" + inst_string
else:
modelio_file = model + "_modelio.nml" + inst_string
nmlgen.write_nuopc_modelio_file(os.path.join(confdir, modelio_file))
nmlgen.write_nuopc_modelio_file(os.path.join(confdir, modelio_file))

# Output the following to nuopc.runconfig
moddiro = case.get_value('RUNDIR')
Expand Down
22 changes: 14 additions & 8 deletions src/drivers/nuopc/cime_driver/ensemble_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Ensemble_driver
!-----------------------------------------------------------------------------
use med_constants_mod , only : dbug_flag => med_constants_dbug_flag, CL
use shr_nuopc_methods_mod , only : shr_nuopc_methods_ChkErr

use med_internalstate_mod , only : mastertask
implicit none
private

Expand Down Expand Up @@ -78,6 +78,7 @@ subroutine SetModelServices(ensemble_driver, rc)
use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd
use NUOPC_Driver , only : NUOPC_DriverAddComp
use esm, only : ESMSetServices => SetServices, ReadAttributes
! use pio_interface, only : PIOSetServices => SetServices
use shr_nuopc_time_mod , only : shr_nuopc_time_clockInit
use med_internalstate_mod , only : logunit ! initialized here
use shr_log_mod , only : shrloglev=>shr_log_level, shrlogunit=> shr_log_unit
Expand All @@ -101,6 +102,7 @@ subroutine SetModelServices(ensemble_driver, rc)
character(len=512) :: diro
character(len=512) :: logfile
integer :: global_comm
integer :: cpl_rootpe
logical :: iamroot_med ! mediator masterproc
logical :: read_restart
integer :: dbrc
Expand Down Expand Up @@ -142,6 +144,10 @@ subroutine SetModelServices(ensemble_driver, rc)
call ReadAttributes(ensemble_driver, config, "PELAYOUT_attributes::", rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompAttributeGet(ensemble_driver, name="cpl_rootpe", value=cvalue, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) cpl_rootpe

! Check valid values of start type
call NUOPC_CompAttributeGet(ensemble_driver, name="start_type", value=start_type, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -156,17 +162,16 @@ subroutine SetModelServices(ensemble_driver, rc)

call InitRestart(ensemble_driver, read_restart, rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

! Need to get number of ensemble members here
call NUOPC_CompAttributeGet(ensemble_driver, name="ninst", value=cvalue, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue, *) number_of_members
!-------------------------------------------
! Extract the config object from the ensemble_driver
!-------------------------------------------
ntasks_per_member = PetCount/number_of_members
if(ntasks_per_member*number_of_members /= PetCount) then
write (msgstr, *) "PetCount must be evenly divisable by number of members "
if(ntasks_per_member*number_of_members .ne. PetCount) then
write (msgstr,'(a,i5,a,i3,a,i3,a)') "PetCount (",PetCount,&
") must be evenly divisable by number of members (",number_of_members,")"
call ESMF_LogSetError(ESMF_RC_ARG_BAD, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc)
return
endif
Expand Down Expand Up @@ -211,16 +216,18 @@ subroutine SetModelServices(ensemble_driver, rc)

call ReadAttributes(driver, config, "MED_modelio"//trim(inst_suffix)//"::", rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return

if (mod(localPet, ntasks_per_member) == rootpe_med) then
! Set the mediator log to the MED task 0
if (mod(localPet,ntasks_per_member)==cpl_rootpe) then
call NUOPC_CompAttributeGet(driver, name="diro", value=diro, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeGet(driver, name="logfile", value=logfile, rc=rc)
if (shr_nuopc_methods_ChkErr(rc,__LINE__,u_FILE_u)) return
logunit = shr_file_getUnit()
open(logunit,file=trim(diro)//"/"//trim(logfile))
mastertask = .true.
else
logUnit = shrlogunit
mastertask = .false.
endif
call shr_file_getLogLevel(shrloglev)
call shr_file_setLogLevel(max(shrloglev,1))
Expand Down Expand Up @@ -251,7 +258,6 @@ subroutine InitRestart(ensemble_driver, read_restart, rc)
! local variables
character(len=CL) :: cvalue ! temporary
integer :: ierr ! error return
integer :: unitn ! Namelist unit number to read

character(len=CL) :: restart_file ! Full archive path to restart file
character(len=CL) :: restart_pfile ! Restart pointer file
Expand Down
Loading

0 comments on commit f37d8e3

Please sign in to comment.