Skip to content

Commit

Permalink
Merge branch 'master' into jedwards/solar_zenith_angle_correction
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b authored Dec 8, 2021
2 parents 4f99c9f + 3e486d4 commit 70009ce
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
1 change: 1 addition & 0 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jobs:
run: |
export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
export PIO=$HOME/pio
export SRC_ROOT=
git submodule init
git submodule update
mkdir build-cdeps
Expand Down
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ if (DEFINED CIMEROOT)
if (${PIO_VERSION} LESS 2)
message( FATAL_ERROR "Version 2 of the PIO library required")
endif()
if (${MPILIB} STREQUAL "mpi-serial")
set(CMAKE_C_COMPILER ${SCC})
if (MPILIB STREQUAL mpi-serial)
set(CMAKE_Fortran_COMPILER ${SFC})
set(CMAKE_CXX_COMPILER ${SCXX})
set(CMAKE_C_COMPILER ${SCC})
else()
set(CMAKE_C_COMPILER ${MPICC})
set(CMAKE_Fortran_COMPILER ${MPIFC})
set(CMAKE_CXX_COMPILER ${MPICXX})
set(CMAKE_C_COMPILER ${MPICC})
endif()
set(CMAKE_Fortran_FLAGS "${FFLAGS} ${CPPDEFS} -I${LIBROOT}/include -I${LIBROOT}/finclude -I${LIBROOT}/nuopc/esmf/${NINST_VALUE}/include")
add_compile_definitions(CESMCOUPLED)
list(APPEND CMAKE_MODULE_PATH ${SRC_ROOT}/components/cdeps/cmake)
set(FOX_ROOT ${SRC_ROOT}/components/cdeps/fox)
else()
set(BLD_STANDALONE TRUE)
project(NUOPC_DATA_MODELS LANGUAGES Fortran VERSION 0.1)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(FOX_ROOT ${CMAKE_SOURCE_DIR}/fox)
endif()

project(NUOPC_DATA_MODELS LANGUAGES Fortran VERSION 0.1)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

message("CMAKE_MODULE_PATH is ${CMAKE_MODULE_PATH}")
message("CMAKE_MODULE_PATH is ${CMAKE_MODULE_PATH}, CMAKE_Fortran_COMPILER is ${CMAKE_Fortran_COMPILER}")
enable_language(Fortran)

if (TARGET esmf)
message("Target esmf is already found. Skip find_package ...")
Expand Down Expand Up @@ -61,15 +60,15 @@ endif()
add_subdirectory(streams)
add_subdirectory(dshr)

if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/fox")
if(IS_DIRECTORY "${FOX_ROOT}")
message(STATUS "FoX library is already checked out!")
message(STATUS "FoX source dir: ${PROJECT_SOURCE_DIR}/fox")
message(STATUS "FoX source dir: ${FOX_ROOT}")
else()
FetchContent_Declare(fox
GIT_REPOSITORY https://github.com/ESMCI/fox.git
GIT_TAG 4.1.2.1
SOURCE_DIR ${PROJECT_SOURCE_DIR}/fox
BINARY_DIR ${PROJECT_SOURCE_DIR}
SOURCE_DIR ${FOX_ROOT}
BINARY_DIR ${FOX_ROOT}/..
)
FetchContent_GetProperties(fox)
if(NOT fox_POPULATED)
Expand Down
1 change: 1 addition & 0 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def buildlib(bldroot, libroot, case, compname=None):
bld_time = src_time - 1

# if any file in src is newer than CmakeFiles in the build directory, rerun cmake

if src_time > bld_time:
logger.info("cmake_flags {}".format(cmake_flags))
s,o,e = run_cmd("cmake {} ".format(cmake_flags), from_dir=bldroot, verbose=True)
Expand Down
6 changes: 3 additions & 3 deletions datm/cime_config/stream_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<mapalgo>redist</mapalgo>
<mapalgo>bilinear</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
<stream_year_align>$DATM_YR_ALIGN</stream_year_align>
Expand Down Expand Up @@ -686,7 +686,7 @@
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<mapalgo>redist</mapalgo>
<mapalgo>bilinear</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
<stream_year_align>$DATM_YR_ALIGN</stream_year_align>
Expand Down Expand Up @@ -722,7 +722,7 @@
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<mapalgo>redist</mapalgo>
<mapalgo>bilinear</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
<stream_year_align>$DATM_YR_ALIGN</stream_year_align>
Expand Down
3 changes: 1 addition & 2 deletions datm/datm_datamode_clmncep_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ subroutine datm_datamode_clmncep_advance(masterproc, logunit, mpicom, rc)
! determine tbotmax (see below for use)
rtmp = maxval(Sa_tbot(:))
call shr_mpi_max(rtmp, tbotmax, mpicom, 'datm_tbot', all=.true.)
write(logunit,*) trim(subname),' tbotmax = ',tbotmax
if (masterproc) write(logunit,*) trim(subname),' tbotmax = ',tbotmax
if(tbotmax <= 0) then
call shr_sys_abort(subname//'ERROR: bad value in tbotmax')
endif
Expand Down Expand Up @@ -418,7 +418,6 @@ subroutine datm_datamode_clmncep_advance(masterproc, logunit, mpicom, rc)
else
call shr_sys_abort(subname//'ERROR: cannot compute shum')
endif

!--- density ---
vp = (Sa_shum(n)*pbot) / (0.622_r8 + 0.378_r8 * Sa_shum(n))
Sa_dens(n) = (pbot - 0.378_r8 * vp) / (tbot*rdair)
Expand Down
7 changes: 4 additions & 3 deletions docn/ocn_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module cdeps_docn_comp
use ESMF , only : ESMF_Alarm, ESMF_MethodRemove, ESMF_MethodAdd
use ESMF , only : ESMF_GridCompSetEntryPoint, ESMF_ClockGetAlarm, ESMF_AlarmIsRinging
use ESMF , only : ESMF_StateGet, operator(+), ESMF_AlarmRingerOff, ESMF_LogWrite
use ESMF , only : ESMF_Field, ESMF_FieldGet
use ESMF , only : ESMF_Field, ESMF_FieldGet, ESMF_VmLogMemInfo
use NUOPC , only : NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize
use NUOPC , only : NUOPC_Advertise, NUOPC_CompAttributeGet
use NUOPC_Model , only : model_routine_SS => SetServices
Expand Down Expand Up @@ -306,7 +306,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS

call ESMF_VMLogMemInfo("Entering "//trim(subname))
! Initialize model mesh, restart flag, logunit, model_mask and model_frac
call ESMF_TraceRegionEnter('docn_strdata_init')
call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'OCN', nx_global, ny_global, &
Expand Down Expand Up @@ -355,6 +355,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! *******************
! *** RETURN HERE ***
! *******************
call ESMF_VMLogMemInfo("Leaving "//trim(subname))
RETURN
end if

Expand All @@ -374,7 +375,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call dshr_state_SetScalar(dble(ny_global),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_VMLogMemInfo("Leaving "//trim(subname))
end subroutine InitializeRealize

!===============================================================================
Expand Down
16 changes: 10 additions & 6 deletions streams/dshr_strdata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module dshr_strdata_mod
use ESMF , only : ESMF_FieldReGridStore, ESMF_FieldRedistStore, ESMF_UNMAPPEDACTION_IGNORE
use ESMF , only : ESMF_TERMORDER_SRCSEQ, ESMF_FieldRegrid, ESMF_FieldFill
use ESMF , only : ESMF_REGION_TOTAL, ESMF_FieldGet, ESMF_TraceRegionExit, ESMF_TraceRegionEnter
use ESMF , only : ESMF_LOGMSG_INFO, ESMF_LogWrite
use ESMF , only : ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_RC_ARG_VALUE
use shr_kind_mod , only : r8=>shr_kind_r8, r4=>shr_kind_r4, i2=>shr_kind_I2
use shr_kind_mod , only : cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx
use shr_sys_mod , only : shr_sys_abort
Expand Down Expand Up @@ -397,6 +397,7 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc)
logical :: masterproc
integer :: nvars
integer :: i, stream_nlev, index
integer, allocatable :: mask(:)
character(CL) :: stream_vectors
character(len=*), parameter :: subname='(shr_sdat_init)'
! ----------------------------------------------
Expand Down Expand Up @@ -426,6 +427,10 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc)
call shr_sys_abort(subName//"ERROR: file does not exist: "//trim(fileName))
end if
endif
!
! We do not yet have mask information, but we are required to set it here and change it
! later.
!
if(filename /= 'none') then
stream_mesh = ESMF_MeshCreate(trim(filename), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -811,6 +816,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc)
integer ,intent(out) :: rc

! local variables

integer :: ns ! stream index
integer :: nf ! field index
integer :: i,lev ! generic indices
Expand Down Expand Up @@ -841,6 +847,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc)
integer :: year,month,day ! date year month day
integer :: nstreams
integer :: stream_index
integer :: lsize
real(r8) ,parameter :: solZenMin = 0.001_r8 ! minimum solar zenith angle
integer ,parameter :: tadj = 2
character(len=*) ,parameter :: timname = "_strd_adv"
Expand Down Expand Up @@ -1111,7 +1118,6 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc)
call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_zero')

endif

end do ! loop over ns (number of streams)

deallocate(newData)
Expand Down Expand Up @@ -1498,7 +1504,6 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, &

! read the data
call pio_setframe(pioid, varid, int(nt,kind=Pio_Offset_Kind))

if (pio_iovartype == PIO_REAL) then
! -----------------------------
! pio_iovartype is PIO_REAL
Expand Down Expand Up @@ -1736,8 +1741,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, &
lat = nu_coords(2*i)
sinlon = sin(lon*deg2rad); coslon = cos(lon*deg2rad)
sinlat = sin(lat*deg2rad); coslat = cos(lat*deg2rad)
dataptr2d_src(1,i) = coslon * dataptr(i) - sinlon * dataptr2d_src(2,i)
dataptr2d_src(2,i) = sinlon * dataptr(i) + coslon * dataptr2d_src(2,i)
dataptr2d_src(1,i) = (coslon * dataptr(i) - sinlon * dataptr2d_src(2,i))
dataptr2d_src(2,i) = (sinlon * dataptr(i) + coslon * dataptr2d_src(2,i))
enddo
vector_dst = ESMF_FieldCreate(sdat%model_mesh, ESMF_TYPEKIND_r8, name='vector_dst', &
ungriddedLbound=(/1/), ungriddedUbound=(/2/), gridToFieldMap=(/2/), meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
Expand All @@ -1762,7 +1767,6 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, &
data_u_dst(i) = coslon * dataptr2d_dst(1,i) + sinlon * dataptr2d_dst(2,i)
data_v_dst(i) = -sinlon * dataptr2d_dst(1,i) + coslon * dataptr2d_dst(2,i)
enddo

deallocate(dataptr)
endif

Expand Down

0 comments on commit 70009ce

Please sign in to comment.