Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions .github/workflows/bumpversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Bump version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.26.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: minor
RELEASE_BRANCHES: master
DRY_RUN: False
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ if(BLD_STANDALONE)
list(APPEND EXTRA_LIBS cdeps_share)
list(APPEND EXTRA_INCLUDES "${CMAKE_BINARY_DIR}/share" )
endif()

if("${COMPILER}" STREQUAL "nag")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D__NAG__")
endif()
add_subdirectory(fox)
add_subdirectory(streams)
add_subdirectory(dshr)
Expand Down
2 changes: 1 addition & 1 deletion cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def buildlib(bldroot, libroot, case, compname=None):
expect(time_counter <= time_to_wait," Timeout waiting for {}".format(dwav_lib))
print("HERE exeroot {} bldroot {}".format(exe_root, bldroot))

s,o,e = run_cmd("make install DESTDIR={}".format(libroot), from_dir=bldroot, verbose=True)
s,o,e = run_cmd("make install VERBOSE=1 DESTDIR={}".format(libroot), from_dir=bldroot, verbose=True)
expect(not s,"ERROR from make output={}, error={}".format(o,e))

# Link the CDEPS component directories to the location expected by cime
Expand Down
1 change: 1 addition & 0 deletions datm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ target_include_directories (datm PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories (datm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/share)
target_include_directories (datm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/streams)
target_include_directories (datm PRIVATE ${PIO_Fortran_INCLUDE_DIR})
target_include_directories (datm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../fox/include)
127 changes: 56 additions & 71 deletions datm/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ module atm_comp_nuopc
use NUOPC_Model , only : model_label_Advance => label_Advance
use NUOPC_Model , only : model_label_SetRunClock => label_SetRunClock
use NUOPC_Model , only : model_label_Finalize => label_Finalize
use NUOPC_Model , only : NUOPC_ModelGet
use NUOPC_Model , only : NUOPC_ModelGet, setVM
use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs
use shr_const_mod , only : shr_const_cday
use shr_sys_mod , only : shr_sys_abort
use shr_cal_mod , only : shr_cal_ymd2date, shr_cal_ymd2julian, shr_cal_date2julian
use shr_cal_mod , only : shr_cal_ymd2date
use shr_mpi_mod , only : shr_mpi_bcast
use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck
use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_config, shr_strdata_advance
Expand Down Expand Up @@ -81,7 +81,7 @@ module atm_comp_nuopc
private ! except

public :: SetServices

public :: SetVM
private :: InitializeAdvertise
private :: InitializeRealize
private :: ModelAdvance
Expand Down Expand Up @@ -115,7 +115,6 @@ module atm_comp_nuopc
character(CL) :: dataMode = nullstr ! flags physics options wrt input data
character(CL) :: model_meshfile = nullstr ! full pathname to model meshfile
character(CL) :: model_maskfile = nullstr ! full pathname to obtain mask from
character(CL) :: model_createmesh_fromfile = nullstr ! full pathname to obtain mask from
integer :: iradsw = 0 ! radiation interval (input namelist)
character(CL) :: factorFn_mesh = 'null' ! file containing correction factors mesh
character(CL) :: factorFn_data = 'null' ! file containing correction factors data
Expand Down Expand Up @@ -218,7 +217,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

namelist / datm_nml / datamode, &
model_meshfile, model_maskfile, model_createmesh_fromfile, &
model_meshfile, model_maskfile, &
nx_global, ny_global, restfilm, iradsw, factorFn_data, factorFn_mesh, &
flds_presaero, flds_co2, flds_wiso, bias_correct, anomaly_forcing

Expand Down Expand Up @@ -252,7 +251,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call shr_mpi_bcast(datamode , mpicom, 'datamode')
call shr_mpi_bcast(model_meshfile , mpicom, 'model_meshfile')
call shr_mpi_bcast(model_maskfile , mpicom, 'model_maskfile')
call shr_mpi_bcast(model_createmesh_fromfile , mpicom, 'model_createmesh_fromfile')
call shr_mpi_bcast(nx_global , mpicom, 'nx_global')
call shr_mpi_bcast(ny_global , mpicom, 'ny_global')
call shr_mpi_bcast(iradsw , mpicom, 'iradsw')
Expand All @@ -265,49 +263,21 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

! write namelist input to standard out
if (my_task == master_task) then
write(logunit,F00)' case_name = ',trim(case_name)
write(logunit,F00)' datamode = ',trim(datamode)
if (model_createmesh_fromfile /= nullstr) then
write(logunit,F00)' model_create_meshfile_fromfile = ',trim(model_createmesh_fromfile)
else
write(logunit,F00)' model_meshfile = ',trim(model_meshfile)
write(logunit,F00)' model_maskfile = ',trim(model_maskfile)
end if
write(logunit,F01)' nx_global = ',nx_global
write(logunit,F01)' ny_global = ',ny_global
write(logunit,F00)' restfilm = ',trim(restfilm)
write(logunit,F01)' iradsw = ',iradsw
write(logunit,F00)' factorFn_data = ',trim(factorFn_data)
write(logunit,F00)' factorFn_mesh = ',trim(factorFn_mesh)
write(logunit,F02)' flds_presaero = ',flds_presaero
write(logunit,F02)' flds_co2 = ',flds_co2
write(logunit,F02)' flds_wiso = ',flds_wiso
write(logunit,F00)' case_name = ',trim(case_name)
write(logunit,F00)' datamode = ',trim(datamode)
write(logunit,F00)' model_meshfile = ',trim(model_meshfile)
write(logunit,F00)' model_maskfile = ',trim(model_maskfile)
write(logunit,F01)' nx_global = ',nx_global
write(logunit,F01)' ny_global = ',ny_global
write(logunit,F00)' restfilm = ',trim(restfilm)
write(logunit,F01)' iradsw = ',iradsw
write(logunit,F00)' factorFn_data = ',trim(factorFn_data)
write(logunit,F00)' factorFn_mesh = ',trim(factorFn_mesh)
write(logunit,F02)' flds_presaero = ',flds_presaero
write(logunit,F02)' flds_co2 = ',flds_co2
write(logunit,F02)' flds_wiso = ',flds_wiso
end if

! check that files exists
if (my_task == master_task) then
if (model_createmesh_fromfile /= nullstr) then
inquire(file=trim(model_createmesh_fromfile), exist=exists)
if (.not.exists) then
write(logunit, *)' ERROR: model_createmesh_fromfile '//&
trim(model_createmesh_fromfile)//' does not exist'
call shr_sys_abort(trim(subname)//' ERROR: model_createmesh_fromfile '//&
trim(model_createmesh_fromfile)//' does not exist')
end if
else
inquire(file=trim(model_meshfile), exist=exists)
if (.not.exists) then
write(logunit, *)' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist'
call shr_sys_abort(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist')
end if
inquire(file=trim(model_maskfile), exist=exists)
if (.not.exists) then
write(logunit, *)' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist'
call shr_sys_abort(trim(subname)//' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist')
end if
end if
endif

! Validate sdat datamode
if (masterproc) write(logunit,*) ' datm datamode = ',trim(datamode)
if ( trim(datamode) == 'CORE2_NYF' .or. &
Expand Down Expand Up @@ -378,6 +348,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
real(R8) :: orbLambm0 ! orb mean long of perhelion (radians)
real(R8) :: orbObliqr ! orb obliquity (radians)
logical :: isPresent, isSet
real(R8) :: dayofYear
character(len=*), parameter :: subname=trim(modName)//':(InitializeRealize) '
!-------------------------------------------------------------------------------

Expand All @@ -387,8 +358,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! Initialize mesh, restart flag, compid, and logunit
call ESMF_TraceRegionEnter('datm_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ATM', nx_global, ny_global, &
model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, &
model_mask, model_frac, restart_read, rc=rc)
model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Initialize stream data type
Expand All @@ -412,7 +382,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! Get the time to interpolate the stream data to
call ESMF_ClockGet( clock, currTime=currTime, timeStep=timeStep, advanceCount=stepno, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_TimeGet(currTime, yy=current_year, mm=current_mon, dd=current_day, s=current_tod, rc=rc )
call ESMF_TimeGet(currTime, yy=current_year, mm=current_mon, dd=current_day, s=current_tod, &
dayofYear_r8=dayofYear, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd)

Expand Down Expand Up @@ -447,7 +418,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday')
endif

nextsw_cday = getNextRadCDay( current_ymd, current_tod, stepno, idt, iradsw, sdat%model_calendar )
nextsw_cday = getNextRadCDay(dayofYear, current_tod, stepno, idt, iradsw)
call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -477,6 +448,7 @@ subroutine ModelAdvance(gcomp, rc)
real(R8) :: orbMvelpp ! orb moving vernal eq (radians)
real(R8) :: orbLambm0 ! orb mean long of perhelion (radians)
real(R8) :: orbObliqr ! orb obliquity (radians)
real(R8) :: dayofYear
character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) '
!-------------------------------------------------------------------------------

Expand All @@ -495,7 +467,7 @@ subroutine ModelAdvance(gcomp, rc)
call ESMF_ClockGet( clock, currTime=currTime, timeStep=timeStep, advanceCount=stepno, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
nextTime = currTime + timeStep
call ESMF_TimeGet( nextTime, yy=yr, mm=mon, dd=day, s=next_tod, rc=rc )
call ESMF_TimeGet( nextTime, yy=yr, mm=mon, dd=day, s=next_tod, dayofYear_r8=dayofYear, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call shr_cal_ymd2date(yr, mon, day, next_ymd)

Expand Down Expand Up @@ -525,7 +497,9 @@ subroutine ModelAdvance(gcomp, rc)

! Update nextsw_cday for scalar data
! Use nextYMD and nextTOD here since since the component - clock is advance at the END of the time interval
nextsw_cday = getNextRadCDay( next_ymd, next_tod, stepno, idt, iradsw, sdat%model_calendar )

nextsw_cday = getNextRadCDay(dayofYear, next_tod, stepno, idt, iradsw)

call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -677,23 +651,18 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe
case('CORE2_NYF','CORE2_IAF')
call datm_datamode_core2_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('CORE_IAF_JRA')
call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('CLMNCEP')
call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('CPLHIST')
call datm_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('ERA5')
call datm_datamode_era5_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
case('GEFS')
call datm_datamode_gefs_restart_write(case_name, inst_suffix, target_ymd, target_tod, &
logunit, my_task, sdat)
Expand Down Expand Up @@ -799,31 +768,47 @@ end subroutine datm_init_dfields
end subroutine datm_comp_run

!===============================================================================
real(R8) function getNextRadCDay( ymd, tod, stepno, dtime, iradsw, calendar )

! Return the calendar day of the next radiation time-step.
! General Usage: nextswday = getNextRadCDay(curr_date)
real(R8) function getNextRadCDay( julday, tod, stepno, dtime, iradsw )

! Return the calendar day of the next radiation time-step.
! General Usage: nextswday = getNextRadCDay(curr_date) iradsw is
! the frequency to update the next shortwave. in number of steps
! (or hours if negative) Julian date.
! -- values greater than 1 set
! the next radiation to the present time plus 2 timesteps every iradsw
! -- values less than 0 turn set the next radiation to the present time
! plus two timesteps every -iradsw hours.
! -- if iradsw is zero, the next radiation time is the
! present time plus 1 timestep.

! input/output variables
integer , intent(in) :: ymd
integer , intent(in) :: tod
integer(i8), intent(in) :: stepno
integer , intent(in) :: dtime
integer , intent(in) :: iradsw
character(*),intent(in) :: calendar
real(r8) , intent(in) :: julday
integer , intent(in) :: tod
integer(i8) , intent(in) :: stepno
integer , intent(in) :: dtime
integer , intent(in) :: iradsw

! local variables
real(R8) :: nextsw_cday
real(R8) :: julday
integer :: liradsw
integer :: delta_radsw
character(*),parameter :: subName = '(getNextRadCDay) '
!-------------------------------------------------------------------------------

! Note that stepno is obtained via the advancecount argument to
! ESMF_GetClock and is the number of times the ESMF_Clock has been
! advanced. The ESMF clock is actually advanced an additional time
! (in order to trigger alarms) in the routine dshr_set_runclock
! which is the specialized routine for the model_lable_SetRunClock.
! This is called each time the ModelAdvance phase is called. Hence
! stepno is not used to trigger the calculation of nextsw_cday.

liradsw = iradsw
if (liradsw < 0) liradsw = nint((-liradsw *3600._r8)/dtime)
call shr_cal_date2julian(ymd,tod,julday,calendar)

if (liradsw > 1) then
if (mod(stepno+1,liradsw) == 0 .and. stepno > 0) then
delta_radsw = liradsw * dtime
if (mod(tod+dtime,delta_radsw) == 0 .and. stepno > 0) then
nextsw_cday = julday + 2*dtime/shr_const_cday
else
nextsw_cday = -1._r8
Expand Down
17 changes: 13 additions & 4 deletions datm/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,20 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
config['datm_mode'] = datm_mode
config['datm_co2_tseries'] = datm_co2_tseries
config['datm_presaero'] = datm_presaero
config['cime_model'] = get_model()
if case.get_value('PTS_MODE'):
config['mode'] = 'single_column'

if case.get_value('PTS_LON'):
scol_lon = float(case.get_value('PTS_LON'))
else:
scol_lon = -999.
if case.get_value('PTS_LAT'):
scol_lat = float(case.get_value('PTS_LAT'))
else:
config['mode'] = case.get_value("ATM_DOMAIN_MESH")
scol_lat = -999.
if case.get_value('ATM_DOMAIN_FILE'):
if scol_lon > -999. and scol_lat > -999. and case.get_value("ATM_DOMAIN_FILE") != "UNSET":
config['single_column'] = 'true'
else:
config['single_column'] = 'false'

nmlgen.init_defaults(infile, config)

Expand Down
Loading