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
37 changes: 21 additions & 16 deletions src/io/aqmio/aqmio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ module AQMIO
type(ioData), pointer :: IO => null()
end type ioWrapper

integer, parameter :: AQMIO_FMT_BIN = 101, &
AQMIO_FMT_NETCDF = 102

private

public :: AQMIO_FMT_BIN
public :: AQMIO_FMT_NETCDF

public :: AQMIO_Create
public :: AQMIO_Destroy
public :: AQMIO_FileCreate
Expand Down Expand Up @@ -332,20 +337,20 @@ subroutine AQMIO_Open(IOComp, fileName, filePath, iomode, iofmt, rc)
character(len=*), intent(in) :: fileName
character(len=*), intent(in), optional :: filePath
character(len=*), intent(in), optional :: iomode
type(ESMF_IOFmt_flag), intent(in), optional :: iofmt
integer, intent(in), optional :: iofmt
integer, intent(out), optional :: rc

! -- local variables
integer :: localrc
integer :: ncStatus
integer :: item, localDe, localDeCount, tileCount
integer :: liofmt
integer :: cmode
logical :: create
character(len=ESMF_MAXPATHLEN) :: fullName
character(len=6) :: liomode, fmode
type(ioWrapper) :: is
type(ESMF_Grid) :: grid
type(ESMF_IOFmt_flag) :: liofmt

! -- begin
if (present(rc)) rc = ESMF_SUCCESS
Expand All @@ -363,7 +368,7 @@ subroutine AQMIO_Open(IOComp, fileName, filePath, iomode, iofmt, rc)

localDeCount = size(is % IO % IOLayout)

liofmt = ESMF_IOFMT_NETCDF
liofmt = AQMIO_FMT_NETCDF
if (present(iofmt)) liofmt = iofmt

liomode = "read"
Expand Down Expand Up @@ -409,7 +414,7 @@ subroutine AQMIO_Open(IOComp, fileName, filePath, iomode, iofmt, rc)
else
call AQMIO_FileNameGet(fullName, fileName, filePath=filePath)
end if
if (liofmt == ESMF_IOFMT_NETCDF) then
if (liofmt == AQMIO_FMT_NETCDF) then
#if HAVE_NETCDF
if (create) then
ncStatus = nf90_create(trim(fullName), cmode, &
Expand Down Expand Up @@ -442,7 +447,7 @@ subroutine AQMIO_Open(IOComp, fileName, filePath, iomode, iofmt, rc)
rcToReturn=rc)
return
#endif
else if (liofmt == ESMF_IOFMT_BIN) then
else if (liofmt == AQMIO_FMT_BIN) then

call ESMF_UtilIOUnitGet (unit=is % IO % IOLayout(localDe) % iounit, rc=localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
Expand Down Expand Up @@ -547,18 +552,18 @@ logical function AQMIO_IsOpen(IOComp, fileName, filePath, iofmt, rc)
type(ESMF_GridComp), intent(inout) :: IOComp
character(len=*), intent(in) :: fileName
character(len=*), intent(in), optional :: filePath
type(ESMF_IOFmt_flag), intent(in), optional :: iofmt
integer, intent(in), optional :: iofmt
integer, intent(out), optional :: rc

! -- local variables
integer :: localrc
integer :: ncStatus
integer :: item, localDe, localDeCount, tileCount, pathLen
integer :: liofmt
logical :: isFileOpen
character(len=ESMF_MAXPATHLEN) :: fullName, pathIn
type(ioWrapper) :: is
type(ESMF_Grid) :: grid
type(ESMF_IOFmt_flag) :: liofmt

! -- begin
if (present(rc)) rc = ESMF_SUCCESS
Expand All @@ -578,7 +583,7 @@ logical function AQMIO_IsOpen(IOComp, fileName, filePath, iofmt, rc)

localDeCount = size(is % IO % IOLayout)

liofmt = ESMF_IOFMT_NETCDF
liofmt = AQMIO_FMT_NETCDF
if (present(iofmt)) liofmt = iofmt

call ESMF_GridCompGet(IOComp, grid=grid, rc=localrc)
Expand All @@ -602,7 +607,7 @@ logical function AQMIO_IsOpen(IOComp, fileName, filePath, iofmt, rc)
else
call AQMIO_FileNameGet(fullName, fileName, filePath=filePath)
end if
if (liofmt == ESMF_IOFMT_NETCDF) then
if (liofmt == AQMIO_FMT_NETCDF) then
#if HAVE_NETCDF
if (is % IO % IOLayout(localDe) % ncid > 0) then
ncStatus = nf90_inq_path(is % IO % IOLayout(localDe) % ncid, &
Expand Down Expand Up @@ -642,21 +647,21 @@ subroutine AQMIO_Write(IOComp, fieldList, fieldNameList, timeSlice, &
integer, intent(in), optional :: timeSlice
character(len=*), intent(in), optional :: fileName
character(len=*), intent(in), optional :: filePath
type(ESMF_IOFmt_flag), intent(in), optional :: iofmt
integer, intent(in), optional :: iofmt
integer, intent(out), optional :: rc

! -- local variables
integer :: localrc
integer :: item, localDe, localDeCount
integer :: liofmt
type(ioWrapper) :: is
type(ESMF_IOFmt_flag) :: liofmt

! -- begin
if (present(rc)) rc = ESMF_SUCCESS

if (.not.ESMF_GridCompIsPetLocal(IOComp)) return

liofmt = ESMF_IOFMT_NETCDF
liofmt = AQMIO_FMT_NETCDF
if (present(iofmt)) liofmt = iofmt

if (present(fieldNameList)) then
Expand Down Expand Up @@ -736,7 +741,7 @@ subroutine AQMIO_Read(IOComp, fieldList, fieldNameList, timeSlice, &
integer, intent(in), optional :: timeSlice
character(len=*), intent(in), optional :: fileName
character(len=*), intent(in), optional :: filePath
type(ESMF_IOFmt_flag), intent(in), optional :: iofmt
integer, intent(in), optional :: iofmt
integer, intent(out), optional :: rc

! -- local variables
Expand Down Expand Up @@ -833,7 +838,7 @@ subroutine AQMIO_ReadTimes(IOComp, variableName, timesList, fileName, filePath,
type(ESMF_Time), intent(inout), pointer :: timesList(:)
character(len=*), intent(in), optional :: fileName
character(len=*), intent(in), optional :: filePath
type(ESMF_IOFmt_flag), intent(in), optional :: iofmt
integer, intent(in), optional :: iofmt
integer, intent(out), optional :: rc

! -- local variables
Expand All @@ -857,7 +862,7 @@ subroutine AQMIO_ReadTimes(IOComp, variableName, timesList, fileName, filePath,
if (.not.associated(is % IO % IOLayout)) return

if (present(iofmt)) then
if (.not.(iofmt == ESMF_IOFMT_NETCDF)) then
if (.not.(iofmt == AQMIO_FMT_NETCDF)) then
call ESMF_LogSetError(ESMF_RC_ARG_INCOMP, &
msg="This function only supports NetCDF I/O", &
line=__LINE__, &
Expand Down Expand Up @@ -925,6 +930,7 @@ subroutine AQMIO_FieldAccess(IOComp, field, action, variableName, timeSlice, rc)
integer :: localrc
integer :: localDe, localDeCount, rank
integer :: de, deCount, dimCount, tile, tileCount, ungriddedCount
integer :: iofmt
integer, dimension(:), pointer :: ungriddedLBound, ungriddedUBound
integer, dimension(:), allocatable :: deToTileMap, localDeToDeMap
integer, dimension(:,:), allocatable :: minIndexPDe, maxIndexPDe
Expand All @@ -936,7 +942,6 @@ subroutine AQMIO_FieldAccess(IOComp, field, action, variableName, timeSlice, rc)
type(ESMF_GeomType_flag) :: geomtype
type(ESMF_StaggerLoc) :: staggerloc
type(ESMF_TypeKind_Flag) :: typekind
type(ESMF_IOFmt_flag) :: iofmt

! -- begin
if (present(rc)) rc = ESMF_SUCCESS
Expand Down
12 changes: 6 additions & 6 deletions src/shr/aqm_emis_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ subroutine aqm_emis_src_create(config, em, rc)
em(item) % file = ""
em(item) % frequency = ""
em(item) % format = "netcdf"
em(item) % iofmt = ESMF_IOFMT_NETCDF
em(item) % iofmt = AQMIO_FMT_NETCDF
em(item) % irec = 0
em(item) % verbose = .false.
em(item) % logprefix = ""
Expand Down Expand Up @@ -311,9 +311,9 @@ subroutine aqm_emis_src_init(model, em, rc)

select case (trim(em % format))
case ("binary")
em % iofmt = ESMF_IOFMT_BIN
em % iofmt = AQMIO_FMT_BIN
case ("netcdf")
em % iofmt = ESMF_IOFMT_NETCDF
em % iofmt = AQMIO_FMT_NETCDF
case default
call ESMF_LogSetError(ESMF_RC_NOT_VALID, &
msg="- invalid emission format: "//trim(em % format), &
Expand Down Expand Up @@ -382,7 +382,7 @@ subroutine aqm_emis_src_init(model, em, rc)
rcToReturn=rc)) &
return ! bail out

if (em % iofmt == ESMF_IOFMT_BIN) then
if (em % iofmt == AQMIO_FMT_BIN) then
if (trim(em % frequency) /= "static") then
em % frequency = "static"
if (em % verbose) then
Expand Down Expand Up @@ -694,7 +694,7 @@ subroutine aqm_emis_src_init(model, em, rc)
end if

! -- open single netCDF file if selected
if (em % iofmt == ESMF_IOFMT_NETCDF) then
if (em % iofmt == AQMIO_FMT_NETCDF) then
call AQMIO_Open(em % IO, em % file, filePath=em % path, iomode="read", &
iofmt=em % iofmt, rc=localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, &
Expand Down Expand Up @@ -1038,7 +1038,7 @@ subroutine aqm_emis_update(model, rc)
rcToReturn=rc)) &
return ! bail out
end if
if (em % iofmt == ESMF_IOFMT_BIN) then
if (em % iofmt == AQMIO_FMT_BIN) then
do n = 1, size(em % sources)
call AQMIO_Read(em % IO, (/ em % fields(n) /), fileName=em % sources(n), &
filePath=em % path, iofmt=em % iofmt, rc=localrc)
Expand Down
4 changes: 2 additions & 2 deletions src/shr/aqm_internal_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ module aqm_internal_mod
character(len=ESMF_MAXSTR) :: specfile
character(len=ESMF_MAXSTR) :: specprofile
character(len=6) :: period
integer :: irec
logical :: verbose
type(ESMF_IOFmt_flag) :: iofmt
integer :: irec
integer :: iofmt
type(ESMF_GridComp) :: IO
type(ESMF_Alarm) :: alarm
character(len=ESMF_MAXSTR), dimension(:), pointer :: sources => null()
Expand Down