diff --git a/.github/workflows/extbuild.yml b/.github/workflows/extbuild.yml index 12e57ea2..7f1260af 100644 --- a/.github/workflows/extbuild.yml +++ b/.github/workflows/extbuild.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f465069..116f8aaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ...") @@ -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) diff --git a/cime_config/buildlib b/cime_config/buildlib index 552adecb..d982a719 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -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) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index 22237102..af792834 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -654,7 +654,7 @@ null - redist + bilinear null $DATM_YR_ALIGN @@ -686,7 +686,7 @@ null - redist + bilinear null $DATM_YR_ALIGN @@ -722,7 +722,7 @@ null - redist + bilinear null $DATM_YR_ALIGN diff --git a/datm/datm_datamode_clmncep_mod.F90 b/datm/datm_datamode_clmncep_mod.F90 index 3db1165c..86484151 100644 --- a/datm/datm_datamode_clmncep_mod.F90 +++ b/datm/datm_datamode_clmncep_mod.F90 @@ -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 @@ -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) diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index b132c3a8..942a0060 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -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 @@ -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, & @@ -355,6 +355,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! ******************* ! *** RETURN HERE *** ! ******************* + call ESMF_VMLogMemInfo("Leaving "//trim(subname)) RETURN end if @@ -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 !=============================================================================== diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 1b6df3d5..eddac413 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -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 @@ -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)' ! ---------------------------------------------- @@ -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 @@ -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 @@ -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" @@ -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) @@ -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 @@ -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) @@ -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