Skip to content

Commit c7063d0

Browse files
committed
use nc4 tilefile when re-tiling
1 parent af950cb commit c7063d0

File tree

1 file changed

+60
-44
lines changed
  • GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts

1 file changed

+60
-44
lines changed

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/getids.F90

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -547,57 +547,73 @@ subroutine ReadTileFile_RealLatLon (InCNTileFile, ntiles, xlon, xlat,mask)
547547
integer :: n,icnt,ityp, nt, umask, i, header
548548
real :: xval,yval, pf
549549
real, allocatable :: ln1(:), lt1(:)
550-
551-
if(present(mask)) then
552-
umask = mask
553-
else
554-
umask = 100
555-
endif
550+
real, pointer :: AVR(:,:)
551+
integer :: filetype
552+
logical :: isNC4
553+
554+
if(present(mask)) then
555+
umask = mask
556+
else
557+
umask = 100
558+
endif
556559

557-
open(11,file=InCNTileFile, &
558-
form='formatted',action='read',status='old')
560+
call MAPL_NCIOGetFileType(InCNTileFile, filetype)
561+
isNC4 = (filetype == MAPL_FILETYPE_NC4)
559562

560-
! first read number of lines in the til file header
561-
! -------------------------------------------------
562-
header = 5
563-
read (11,*, iostat=n) Nt
564-
do i = 1, header -1
565-
read (11,*)
566-
end do
567-
read (11,*,IOSTAT=n)ityp,pf,xval, yval
568-
if(n /= 0) header = 8
563+
if (isNC4) then
564+
call MAPL_ReadTilingNC4(InCNTileFile, AVR=AVR)
565+
Ntiles = count(int(AVR(:,1)) == umask)
566+
if(.not.associated (xlon)) allocate(xlon(Ntiles))
567+
if(.not.associated (xlat)) allocate(xlat(Ntiles))
568+
xlon = AVR(:Ntiles, 3)
569+
xlat = AVR(:Ntiles, 4)
570+
deallocate(AVR)
571+
else
572+
573+
open(11,file=InCNTileFile, form='formatted',action='read',status='old')
574+
575+
! first read number of lines in the til file header
576+
! -------------------------------------------------
577+
header = 5
578+
read (11,*, iostat=n) Nt
579+
do i = 1, header -1
580+
read (11,*)
581+
end do
582+
read (11,*,IOSTAT=n)ityp,pf,xval, yval
583+
if(n /= 0) header = 8
569584

570-
rewind (11)
585+
rewind (11)
571586

572-
! read the tile file
573-
!-------------------
574-
read (11,*, iostat=n) Nt
587+
! read the tile file
588+
!-------------------
589+
read (11,*, iostat=n) Nt
575590

576-
allocate(ln1(Nt),lt1(Nt))
591+
allocate(ln1(Nt),lt1(Nt))
577592

578-
do n = 1,header-1 ! skip header
579-
read(11,*)
580-
end do
593+
do n = 1,header-1 ! skip header
594+
read(11,*)
595+
end do
581596

582-
icnt = 0
583-
584-
do i=1,Nt
585-
read(11,*) ityp,pf,xval,yval
586-
if(ityp == umask) then
587-
icnt = icnt + 1
588-
ln1(icnt) = xval
589-
Lt1(icnt) = yval
590-
endif
591-
end do
592-
593-
close(11)
594-
595-
Ntiles = icnt
596-
if(.not.associated (xlon)) allocate(xlon(Ntiles))
597-
if(.not.associated (xlat)) allocate(xlat(Ntiles))
598-
xlon = ln1(:Ntiles)
599-
xlat = lt1(:Ntiles)
600-
597+
icnt = 0
598+
599+
do i=1,Nt
600+
read(11,*) ityp,pf,xval,yval
601+
if(ityp == umask) then
602+
icnt = icnt + 1
603+
ln1(icnt) = xval
604+
Lt1(icnt) = yval
605+
endif
606+
end do
607+
608+
close(11)
609+
610+
Ntiles = icnt
611+
if(.not.associated (xlon)) allocate(xlon(Ntiles))
612+
if(.not.associated (xlat)) allocate(xlat(Ntiles))
613+
xlon = ln1(:Ntiles)
614+
xlat = lt1(:Ntiles)
615+
endif !isNC4
616+
601617
end subroutine ReadTileFile_RealLatLon
602618

603619
end module mk_restarts_getidsMod

0 commit comments

Comments
 (0)