From 0d634437e1c6254a1da998935c8be70dd6e144fc Mon Sep 17 00:00:00 2001 From: Raffaele Montuoro Date: Wed, 26 Oct 2022 22:30:55 +0000 Subject: [PATCH] Replace ESMF I/O format flag with AQMIO flag. --- src/io/aqmio/aqmio.F90 | 37 ++++++++++++++++++++---------------- src/shr/aqm_emis_mod.F90 | 12 ++++++------ src/shr/aqm_internal_mod.F90 | 4 ++-- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/io/aqmio/aqmio.F90 b/src/io/aqmio/aqmio.F90 index bedc98a4..f29beaec 100644 --- a/src/io/aqmio/aqmio.F90 +++ b/src/io/aqmio/aqmio.F90 @@ -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 @@ -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 @@ -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" @@ -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, & @@ -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, & @@ -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 @@ -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) @@ -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, & @@ -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 @@ -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 @@ -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 @@ -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__, & @@ -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 @@ -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 diff --git a/src/shr/aqm_emis_mod.F90 b/src/shr/aqm_emis_mod.F90 index 12cf8171..ba0fc7cd 100644 --- a/src/shr/aqm_emis_mod.F90 +++ b/src/shr/aqm_emis_mod.F90 @@ -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 = "" @@ -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), & @@ -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 @@ -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, & @@ -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) diff --git a/src/shr/aqm_internal_mod.F90 b/src/shr/aqm_internal_mod.F90 index 9134d71d..7ddf0367 100644 --- a/src/shr/aqm_internal_mod.F90 +++ b/src/shr/aqm_internal_mod.F90 @@ -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()