Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ orbs:
workflows:
build-test:
jobs:
# Build GEOSgcm
- ci/build:
name: build-GEOSgcm-on-<< matrix.compiler >>
context:
Expand Down
36 changes: 18 additions & 18 deletions AdvCore_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
!
! !MODULE: AdvCore_GridCompMod
!
! !DESCRIPTION:
! !DESCRIPTION:
! This a MAPL component that can be used in
! either with offline or online applications to advect an arbitrary set
! of constituents.
Expand All @@ -21,7 +21,7 @@
! which this component is taken may be found in:
!
! \begin{quote}
! Lin, S.-J. 2004, A vertically Lagrangian Finite-Volume Dynamical
! Lin, S.-J. 2004, A vertically Lagrangian Finite-Volume Dynamical
! Core for Global Models. {\em Mon. Wea. Rev.}, {\bf 132}, 2293-2307.
! \end{quote}
!
Expand All @@ -46,7 +46,7 @@
! state. Each Field in the Bundle is tested for ``Friendliness'' to
! advection; if friendly it is advected and its values updated.
!
! Currently no Export capability is implemented.
! Currently no Export capability is implemented.
!
! !INTERFACE:

Expand All @@ -60,7 +60,7 @@ module AdvCore_GridCompMod
use m_set_eta, only: set_eta
use mpp_mod, only: mpp_pe, mpp_root_pe
use fv_arrays_mod, only: fv_atmos_type, FVPRC, REAL4, REAL8
use fms_mod, only: fms_init, set_domain, nullify_domain
use fms_mod, only: fms_init
use fv_control_mod, only: fv_init1, fv_init2, fv_end
use fv_tracer2d_mod, only: offline_tracer_advection
use fv_mp_mod, only: is,ie, js,je, is_master, tile
Expand Down Expand Up @@ -139,7 +139,7 @@ subroutine SetServices(GC, rc)

! Get my name and set-up traceback handle
! ---------------------------------------

call ESMF_GridCompGet( GC, NAME=COMP_NAME, vm=vm, RC=STATUS )
VERIFY_(STATUS)
Iam = trim(COMP_NAME) // 'SetServices'
Expand Down Expand Up @@ -195,7 +195,7 @@ subroutine SetServices(GC, rc)

call MAPL_AddImportSpec ( gc, &
SHORT_NAME = 'PLE1', &
LONG_NAME = 'pressure_at_layer_edges_after_advection', &
LONG_NAME = 'pressure_at_layer_edges_after_advection', &
UNITS = 'Pa', &
PRECISION = ESMF_KIND_R8, &
DIMS = MAPL_DimsHorzVert, &
Expand All @@ -218,7 +218,7 @@ subroutine SetServices(GC, rc)
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, RC=STATUS )
VERIFY_(STATUS)


! 3D Tracers
do ntracer=1,ntracers
Expand Down Expand Up @@ -256,7 +256,7 @@ subroutine SetServices(GC, rc)
call MAPL_GridCompSetEntryPoint ( gc, ESMF_METHOD_FINALIZE, Finalize, RC=status)
VERIFY_(STATUS)

! Check if AdvCore is running without FV3_DynCoreIsRunning, if yes then setup the MAPL Grid
! Check if AdvCore is running without FV3_DynCoreIsRunning, if yes then setup the MAPL Grid
! ----------------------------------------------------------------------------
call MAPL_GetObjectFromGC (GC, MAPL, RC=STATUS )
VERIFY_(STATUS)
Expand Down Expand Up @@ -341,7 +341,7 @@ subroutine SetServices(GC, rc)
call fv_init2(FV_Atm, dt, grids_on_my_pe, p_split)
end if

! Ending with a Generic SetServices call is a MAPL requirement
! Ending with a Generic SetServices call is a MAPL requirement
!-------------------------------------------------------------
call MAPL_GenericSetServices ( GC, rc=STATUS)
VERIFY_(STATUS)
Expand All @@ -360,7 +360,7 @@ end subroutine SetServices
subroutine Initialize(GC, IMPORT, EXPORT, CLOCK, RC)
!
! !INPUT/OUTPUT PARAMETERS:
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_State), intent(inout) :: IMPORT ! Import state
type(ESMF_State), intent(inout) :: EXPORT ! Export state
type(ESMF_Clock), intent(inout) :: CLOCK ! The clock
Expand All @@ -371,8 +371,8 @@ subroutine Initialize(GC, IMPORT, EXPORT, CLOCK, RC)
! !DESCRIPTION:
! This initialization routine creates the import and export states,
! as well as the internal state, which is attached to the component.
! It also determines the distribution (and therefore the grid)
! and performs allocations of persistent data,
! It also determines the distribution (and therefore the grid)
! and performs allocations of persistent data,
!
!EOP
!=============================================================================
Expand All @@ -389,7 +389,7 @@ subroutine Initialize(GC, IMPORT, EXPORT, CLOCK, RC)
logical :: gridCreated
type(ESMF_Grid) :: grid

! Begin...
! Begin...

! Get the target components name and set-up traceback handle.
! -----------------------------------------------------------
Expand Down Expand Up @@ -452,7 +452,7 @@ end subroutine Initialize
subroutine Run(GC, IMPORT, EXPORT, CLOCK, RC)
!
! !INPUT/OUTPUT PARAMETERS:
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_State), intent(inout) :: IMPORT ! Import state
type(ESMF_State), intent(inout) :: EXPORT ! Export state
type(ESMF_Clock), intent(inout) :: CLOCK ! The clock
Expand All @@ -461,7 +461,7 @@ subroutine Run(GC, IMPORT, EXPORT, CLOCK, RC)
integer, optional, intent( out) :: RC ! Error code
!
! !DESCRIPTION:
!
!
! The Run method advanced the advection one long time step, as
! specified in the configuration. This may be broken down int a
! number of internal, small steps, also configurable.
Expand Down Expand Up @@ -696,7 +696,7 @@ subroutine Run(GC, IMPORT, EXPORT, CLOCK, RC)
end if

if (allocated(biggerlist)) then
deallocate(biggerlist)
deallocate(biggerlist)
end if

firstRun=.false.
Expand Down Expand Up @@ -772,7 +772,7 @@ subroutine Run(GC, IMPORT, EXPORT, CLOCK, RC)
call global_integral(TMASS1, TRACERS, PLE1, IM,JM,LM, NQ)
endif

! Conserve Specific Mass of Constituents Keeping Mixing_Ratio Constant WRT_Dry_Air
! Conserve Specific Mass of Constituents Keeping Mixing_Ratio Constant WRT_Dry_Air
! --------------------------------------------------------------------------------
if (rpt_mass) then
do N=1,NQ
Expand Down Expand Up @@ -878,7 +878,7 @@ end subroutine Run
subroutine Finalize(GC, IMPORT, EXPORT, CLOCK, RC)
!
! !INPUT/OUTPUT PARAMETERS:
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
type(ESMF_State), intent(inout) :: IMPORT ! Import state
type(ESMF_State), intent(inout) :: EXPORT ! Export state
type(ESMF_Clock), intent(inout) :: CLOCK ! The clock
Expand Down
62 changes: 19 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,27 @@ if (BUILD_GEOS_GTFV3_INTERFACE)
SRCS ${srcs}
SUBCOMPONENTS fvdycore
DEPENDENCIES ${dependencies}
DEPENDENCIES FMS::fms
DEPENDENCIES geos_gtfv3_interface_py) # Make the main library depend on the Python library
else ()
esma_add_library (${this}
SRCS ${srcs}
SUBCOMPONENTS fvdycore
DEPENDENCIES ${dependencies})
DEPENDENCIES ${dependencies}
DEPENDENCIES FMS::fms)
endif ()

if (FV_PRECISION STREQUAL R4)
target_link_libraries (${this} PUBLIC FMS::fms_r4)
target_compile_definitions (${this} PRIVATE SINGLE_FV OVERLOAD_R4)
elseif (FV_PRECISION STREQUAL R4R8) # FV is R4 but FMS is R8
# fvdycore needs r4 .mod interfaces
get_target_property(inc_r4 FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${this} PRIVATE $<BUILD_INTERFACE:${inc_r4}>)

# But fvdycore should not *compile* with fms_r8 includes
target_link_libraries(${this} PUBLIC $<LINK_ONLY:FMS::fms_r8>)

target_compile_definitions (${this} PRIVATE SINGLE_FV OVERLOAD_R4)

# This tells CMake that we need these targets built before we can build
add_dependencies(${this} FMS::fms_r4 FMS::fms_r8)
elseif (FV_PRECISION STREQUAL R8)
target_link_libraries (${this} PUBLIC FMS::fms_r8)
if (FV_PRECISION STREQUAL R8)
string(REPLACE " " ";" tmp ${FREAL8})
foreach(flag ${tmp})
target_compile_options (${this} PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${flag}>)
endforeach()
endif ()

if (FV_PRECISION MATCHES R4)
target_compile_definitions (${this} PRIVATE -DSINGLE_FV -DOVERLOAD_R4)
endif ()

message(STATUS "Building FV as ${FV_PRECISION}")

#set (CMAKE_Fortran_FLAGS_RELEASE "${GEOS_Fortran_FLAGS_VECT}")
Expand Down Expand Up @@ -193,31 +183,17 @@ ecbuild_add_executable (
SOURCES interp_restarts_bin.F90
LIBS ${this} OpenMP::OpenMP_Fortran)

# If we are doing R4R8 we also need add_dependencies for both fms_r4 and fms_r8
# for all our executables that link to ${this} because of the way we set up the
# main library above.
if (FV_PRECISION STREQUAL R4R8)
foreach(executable
StandAlone_FV3_Dycore.x
rs_scale.x
StandAlone_AdvCore.x
StandAlone_DynAdvCore.x
c2c.x
interp_restarts.x
interp_restarts_bin.x)

# fvdycore needs r4 .mod interfaces
get_target_property(inc_r4 FMS::fms_r4 INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${executable} PRIVATE $<BUILD_INTERFACE:${inc_r4}>)

# But fvdycore should not *compile* with FMS::fms_r8 includes
target_link_libraries(${executable} $<LINK_ONLY:FMS::fms_r8>)

# This tells CMake that we need these targets built before we can build
add_dependencies(${executable} FMS::fms_r4 FMS::fms_r8)
endforeach()
endif ()

# Note this macro requires ESMA_cmake v4.19.0 or later
include(check_fms1_io_support)
check_fms1_io_support(FMS1_IO_SUPPORTED)
if(FMS1_IO_SUPPORTED)
message(STATUS "Using deprecated FMS1 I/O for ${this}")
target_compile_definitions (${this} PRIVATE FMS1_IO)
target_compile_definitions (interp_restarts.x PRIVATE FMS1_IO)
target_compile_definitions (interp_restarts_bin.x PRIVATE FMS1_IO)
else()
message(STATUS "Using FMS2 I/O for ${this}")
endif()

if (BUILD_GEOS_GTFV3_INTERFACE)
ecbuild_add_executable (
Expand Down
43 changes: 26 additions & 17 deletions CreateTopography.F90
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
PROGRAM CreateTopography

use ESMF
use constants_mod, only: pi, grav
#if defined (SINGLE_FV)
use constantsr4_mod, only: pi, grav
#else
use constants_mod, only: pi, grav
#endif

! Shared Utilities
use fms_mod, only: fms_init, fms_end, file_exist
use fms_mod, only: fms_init, fms_end
#if defined(FMS1_IO)
use fms_mod, only: file_exists => file_exist
#else
use fms2_io_mod, only: file_exists
#endif
use mpp_mod, only: mpp_error, FATAL, NOTE
use fv_arrays_mod, only: fv_atmos_type, FVPRC, REAL4, REAL8
use fv_control_mod, only: npx,npy,npz, ntiles
Expand Down Expand Up @@ -39,7 +48,7 @@ PROGRAM CreateTopography
real(REAL8) :: dlon, dlat
integer :: nlon, nlat
integer :: c2c_interp_npts

real(REAL8), allocatable :: lat1(:)
real(REAL8), allocatable :: lon1(:)
real(REAL8), allocatable :: r8latlon1(:,:)
Expand Down Expand Up @@ -115,7 +124,7 @@ PROGRAM CreateTopography
deallocate( phis_m )
endif

! Get GWD/TRB Variance
! Get GWD/TRB Variance
! if (npx-1 <= 180) then
allocate( r8tmp(Atm(1)%isd:Atm(1)%ied,Atm(1)%jsd:Atm(1)%jed) )
allocate ( gwd_global(im,im,6) )
Expand All @@ -133,13 +142,13 @@ PROGRAM CreateTopography
enddo
! Read GWD
write(fname1, "('topo_GWD_var_',i3.3,'x',i2.2,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) then
if (.not. file_exists(fname1)) then
write(fname1, "('topo_GWD_var_',i3.3,'x',i3.3,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) then
if (.not. file_exists(fname1)) then
write(fname1, "('topo_GWD_var_',i4.4,'x',i3.3,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) then
if (.not. file_exists(fname1)) then
write(fname1, "('topo_GWD_var_',i4.4,'x',i4.4,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) call mpp_error(FATAL,fname1)
if (.not. file_exists(fname1)) call mpp_error(FATAL,fname1)
endif
endif
endif
Expand Down Expand Up @@ -178,13 +187,13 @@ PROGRAM CreateTopography
allocate ( rtrb(im,jm) )
! Read TRB
write(fname1, "('topo_TRB_var_',i3.3,'x',i2.2,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) then
if (.not. file_exists(fname1)) then
write(fname1, "('topo_TRB_var_',i3.3,'x',i3.3,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) then
if (.not. file_exists(fname1)) then
write(fname1, "('topo_TRB_var_',i4.4,'x',i3.3,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) then
if (.not. file_exists(fname1)) then
write(fname1, "('topo_TRB_var_',i4.4,'x',i4.4,'_DC.data')") nlon,nlat
if (.not. file_exist(fname1)) call mpp_error(FATAL,fname1)
if (.not. file_exists(fname1)) call mpp_error(FATAL,fname1)
endif
endif
endif
Expand Down Expand Up @@ -390,7 +399,7 @@ subroutine cube2cube_gwd_trb(npx_in,npx_out)
! Do DYN_ave interp
allocate( var_out(npx_out,npx_out,ntiles) )
write(fname1, "('topo_DYN_ave_',i4.4,'x',i5.5,'.data')") (npx_in),ntiles*(npx_in)
if (.not. file_exist(fname1)) call mpp_error(FATAL,fname1)
if (.not. file_exists(fname1)) call mpp_error(FATAL,fname1)
open(IUNIT,file=fname1,form='unformatted',status='old')
read(IUNIT) vari
close(IUNIT)
Expand Down Expand Up @@ -418,7 +427,7 @@ subroutine cube2cube_gwd_trb(npx_in,npx_out)
! Do GWD interp
if (npx_out-1 <= 360) then
write(fname1, "('topo_GWD_var_',i4.4,'x',i5.5,'.data')") (npx_in),ntiles*(npx_in)
if (.not. file_exist(fname1)) call mpp_error(FATAL,fname1)
if (.not. file_exists(fname1)) call mpp_error(FATAL,fname1)
open(IUNIT,file=fname1,form='unformatted',status='old')
read(IUNIT) vari
close(IUNIT)
Expand Down Expand Up @@ -449,7 +458,7 @@ subroutine cube2cube_gwd_trb(npx_in,npx_out)
! Do TRB interp
if (npx_out-1 <= 360) then
write(fname1, "('topo_TRB_var_',i4.4,'x',i5.5,'.data')") (npx_in),ntiles*(npx_in)
if (.not. file_exist(fname1)) call mpp_error(FATAL,fname1)
if (.not. file_exists(fname1)) call mpp_error(FATAL,fname1)
open(IUNIT,file=fname1,form='unformatted',status='old')
read(IUNIT) vari
close(IUNIT)
Expand All @@ -467,10 +476,10 @@ subroutine cube2cube_gwd_trb(npx_in,npx_out)
else
var_out(:,:,:) = 0.0
endif
write(fname2, "('topo_TRB_var_',i4.4,'x',i5.5,'.data')") (npx_out),ntiles*(npx_out)
write(fname2, "('topo_TRB_var_',i4.4,'x',i5.5,'.data')") (npx_out),ntiles*(npx_out)
open(OUNIT,file=fname2,form='unformatted',status='unknown')
do l=1,ntiles
j1 = (npx_out)*(l-1) + 1
j1 = (npx_out)*(l-1) + 1
j2 = (npx_out)*(l-1) + npx_out
varo(:,j1:j2)=var_out(:,:,l)
enddo
Expand Down
Loading
Loading