Skip to content

Commit

Permalink
Merge pull request #583 from GEOS-ESM/hotfix/cs_with_corner_input
Browse files Browse the repository at this point in the history
fix so cubed sphere input can be read in when it has the corners
  • Loading branch information
mathomp4 authored Oct 20, 2020
2 parents b0fc74b + b016709 commit dd1c99a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Changed
### Fixed

- Fixed bug with reading in cubed-sphere files that have the corners

### Removed

## [2.3.3] - 2020-10-14
Expand Down
4 changes: 4 additions & 0 deletions MAPL_cfio/ESMF_CFIOSdfMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ subroutine ESMF_CFIOSdfFileOpen (cfio, fmode, rc, expid, cyclic)
if(vnameTemp == 'contacts') cycle
if(vnameTemp == 'orientation') cycle
if(vnameTemp == 'anchor') cycle
if(vnameTemp == 'corner_lons') cycle
if(vnameTemp == 'corner_lats') cycle
end if
if (nvDims .EQ. 1) cycle
nVars = nVars + 1
Expand All @@ -528,6 +530,8 @@ subroutine ESMF_CFIOSdfFileOpen (cfio, fmode, rc, expid, cyclic)
if (dimName(iv)=='nf') cycle
if (dimName(iv)=='orientationStrLen') cycle
if (dimName(iv)=='ncontact') cycle
if (dimName(iv)=='XCdim') cycle
if (dimName(iv)=='YCdim') cycle
end if
rtcode = NF90_INQ_VARID(fid,dimName(iv),varId)
dimUnits(iv) = ' '
Expand Down
22 changes: 20 additions & 2 deletions MAPL_cfio/ESMF_CFIOUtilMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,15 @@ subroutine CFIO_DimInquire (fid,im,jm,km,lm,nvars,ngatts,vdir,rc)
integer tmpNvar
logical :: cs_found
integer :: vdir_
integer :: found_xc, found_yc,vid

! Initialize variables

surfaceOnly = .FALSE.
stationFile = .false.
vdir_ = -1 ! Assume 3D and same orientation
found_xc = 0
found_yc = 0

! Check FID here.

Expand Down Expand Up @@ -534,7 +537,13 @@ subroutine CFIO_DimInquire (fid,im,jm,km,lm,nvars,ngatts,vdir,rc)
tmpNvar = tmpNvar - 1
end if
enddo
if (cs_found) tmpNvar = tmpNvar - 3
if (cs_found) then
tmpNvar = tmpNvar - 3
found_xc = NF90_INQ_VARID(fid,"corner_lons",vid)
if (found_xc ==0) tmpNvar = tmpNvar - 1
found_yc = NF90_INQ_VARID(fid,"corner_lats",vid)
if (found_yc ==0) tmpNvar = tmpNvar - 1
end if
nvars = tmpNvar

! Extract dimension information
Expand All @@ -550,7 +559,9 @@ subroutine CFIO_DimInquire (fid,im,jm,km,lm,nvars,ngatts,vdir,rc)
end if
if (trim(dimName) .eq. 'nv') cycle
if (trim(dimName) .eq. 'nf') cycle
if (trim(dimName) .eq. 'ncontact') cycle
if (trim(dimName) .eq. 'ncontact') cycle
if (trim(dimName) .eq. 'XCdim') cycle
if (trim(dimName) .eq. 'YCdim') cycle
if (trim(dimName) .eq. 'orientationStrLen') cycle

rc = NF90_INQ_VARID (fid, dimName, dimId)
Expand Down Expand Up @@ -602,6 +613,7 @@ subroutine CFIO_DimInquire (fid,im,jm,km,lm,nvars,ngatts,vdir,rc)
enddo

if (cs_found .and. nDims == 6) surfaceOnly = .TRUE.
if (cs_found .and. nDims == 8) surfaceOnly = .TRUE.
if (nDims .EQ. 3 .and. .NOT. stationFile) then
surfaceOnly = .TRUE.
endif
Expand Down Expand Up @@ -695,6 +707,8 @@ subroutine GetDateTimeVec ( fid, begDate, begTime, incVec, rc )
if (trim(dimName) .eq. 'nv') cycle
if (trim(dimName) .eq. 'nf') cycle
if (trim(dimName) .eq. 'ncontact') cycle
if (trim(dimName) .eq. 'XCdim') cycle
if (trim(dimName) .eq. 'YCdim') cycle
if (trim(dimName) .eq. 'orientationStrLen') cycle

rc = NF90_INQ_VARID (fid, dimName, dimId)
Expand Down Expand Up @@ -890,6 +904,8 @@ subroutine GetBegDateTime ( fid, begDate, begTime, incSecs, rc )
if (dimName=='nf') cycle
if (dimName=='orientationStrLen') cycle
if (dimName=='ncontact') cycle
if (trim(dimName) .eq. 'XCdim') cycle
if (trim(dimName) .eq. 'YCdim') cycle
rc = NF90_INQ_VARID (fid, dimName, dimId)
if (err("GetBegDateTime: NF90_INQ_VARID failed",rc,-40) .NE. 0) return
! If it has the standard_name attribute, use that instead
Expand Down Expand Up @@ -3316,6 +3332,8 @@ subroutine CFIO_GetVar ( fid, vname, yyyymmdd, hhmmss,&
if (dimName=='nf') cycle
if (dimName=='orientationStrLen') cycle
if (dimName=='ncontact') cycle
if (trim(dimName) .eq. 'XCdim') cycle
if (trim(dimName) .eq. 'YCdim') cycle
rc = NF90_INQ_VARID (fid, dimName, dimId)
if (err("DimInqure: NF90_INQ_VARID failed",rc,-40) .NE. 0) return
rc = NF90_GET_ATT(fid,dimId,'units',dimUnits)
Expand Down

0 comments on commit dd1c99a

Please sign in to comment.