Skip to content

Commit 85bc34c

Browse files
committed
Now able to read cubed output
1 parent 7dac75d commit 85bc34c

File tree

1 file changed

+70
-26
lines changed

1 file changed

+70
-26
lines changed

GEOSmkiau_GridComp/GEOS_mkiauGridComp.F90

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module GEOS_mkiauGridCompMod
1818
use ESMF_CFIOFileMod
1919
use GEOS_UtilsMod
2020
! use GEOS_RemapMod, only: myremap => remap
21+
use MAPL_CubedSphereGridFactoryMod
2122
use m_set_eta, only: set_eta
2223
#ifdef PYMKIAU_INTEGRATION
2324
use pyMKIAU_interface_mod
@@ -671,6 +672,7 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
671672
integer :: nymdm1,nhmsm1
672673
integer :: nymdm2,nhmsm2
673674
integer :: NX,NY,IMG,JMG
675+
integer :: NX_CUBE,NY_CUBE
674676
integer :: method
675677
integer :: DIMS(ESMF_MAXGRIDDIM)
676678
integer :: JCAP,LMP1
@@ -695,6 +697,9 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
695697
real :: REPLAY_O3_FACTOR
696698
real :: REPLAY_TS_FACTOR
697699

700+
type (CubedSphereGridFactory) :: cs_factory
701+
type (LatlonGridFactory) :: ll_factory
702+
698703
class (AbstractRegridder), pointer :: ANA2BKG => null()
699704
class (AbstractRegridder), pointer :: BKG2ANA => null()
700705
integer :: NPHIS, NPHIS_MAX
@@ -1077,30 +1082,36 @@ subroutine RUN ( GC, IMPORT, EXPORT, CLOCK, RC )
10771082
VERIFY_(STATUS)
10781083
end if
10791084

1085+
call CFIO_Open ( REPLAY_FILEP0, 1, fid, STATUS )
1086+
VERIFY_(STATUS)
1087+
call CFIO_DimInquire ( fid, IMana_World, JMana_world, LMana, nt, nvars, natts, rc=STATUS )
1088+
VERIFY_(STATUS)
1089+
call CFIO_Close ( fid, STATUS )
1090+
VERIFY_(STATUS)
1091+
10801092
call WRITE_PARALLEL("Creating GRIDana...")
10811093
write(imstr,*) IMana_World
10821094
write(jmstr,*) JMana_World
10831095
gridAnaName='PC'//trim(adjustl(imstr))//'x'//trim(adjustl(jmstr))//'-DC'
10841096

10851097
! Get grid_dimensions from file.
1086-
call CFIO_Open(REPLAY_FILEP0, 1, fid, rc=status)
1087-
VERIFY_(status)
1088-
call CFIO_DimInquire (fid, IMana_World, JMana_World, LMana, nt, nvars, natts, rc=status)
1089-
VERIFY_(status)
1090-
call CFIO_Close(fid, rc=status)
1091-
VERIFY_(status)
1098+
if ( JMana_world == 6*IMana_World ) then
10921099

1093-
block
1094-
use MAPL_LatLonGridFactoryMod
1095-
GRIDrep = grid_manager%make_grid( &
1096-
LatLonGridFactory(im_world=IMana_World, jm_world=JMana_World, lm=LMana, &
1097-
nx=NX, ny=NY, pole='PC', dateline= 'DC', rc=status) )
1098-
VERIFY_(STATUS)
1099-
GRIDana = grid_manager%make_grid( &
1100-
LatLonGridFactory(im_world=IMana_World, jm_world=JMana_World, lm=LMbkg, &
1101-
nx=NX, ny=NY, pole='PC', dateline= 'DC', rc=status) )
1102-
VERIFY_(STATUS)
1103-
end block
1100+
call MAPL_MakeDecomposition(NX_CUBE,NY_CUBE,reduceFactor=6,__RC__)
1101+
cs_factory = CubedSphereGridFactory(im_world=IMana_World,lm=LMana,nx=nx_cube,ny=ny_cube,__RC__)
1102+
GRIDana = grid_manager%make_grid(cs_factory,__RC__)
1103+
GRIDrep = grid_manager%make_grid(cs_factory,__RC__)
1104+
1105+
else
1106+
1107+
block
1108+
class(AbstractGridFactory), allocatable :: factory
1109+
allocate(factory, source = grid_manager%make_factory(trim(REPLAY_FILEP0),force_file_coordinates = .false.))
1110+
GRIDrep = grid_manager%make_grid(factory)
1111+
GRIDana = grid_manager%make_grid(factory)
1112+
end block
1113+
1114+
endif
11041115

11051116
mkiau_internal_state%im = IMana_World
11061117
mkiau_internal_state%jm = JMana_World
@@ -1223,7 +1234,7 @@ subroutine handleINC_
12231234
VERIFY_(STATUS)
12241235
call ESMF_FieldBundleSet(RBUNDLEP0, grid=GRIDana, rc=status)
12251236
VERIFY_(STATUS)
1226-
call MAPL_CFIORead ( REPLAY_FILEP0, REPLAY_TIMEP0, RBUNDLEP0, RC=status)
1237+
call MAPL_read_bundle( RBUNDLEP0, REPLAY_FILEP0, REPLAY_TIMEP0, RC=status)
12271238
VERIFY_(STATUS)
12281239
call ESMF_FieldBundleGet ( RBUNDLEP0, fieldCount=NQ, RC=STATUS )
12291240
VERIFY_(STATUS)
@@ -1513,13 +1524,13 @@ subroutine handleANA_
15131524
if ( trim(GRIDINC)=="ANA" ) call ESMF_FieldBundleSet(RBUNDLEP0, grid=GRIDrep, rc=status)
15141525
if ( trim(GRIDINC)=="BKG" ) call ESMF_FieldBundleSet(RBUNDLEP0, grid=GRIDbkg, rc=status)
15151526
VERIFY_(STATUS)
1516-
call MAPL_CFIORead ( REPLAY_FILEP0, REPLAY_TIMEP0, RBUNDLEP0 , RC=status)
1527+
call MAPL_read_bundle( RBUNDLEP0, REPLAY_FILEP0, REPLAY_TIMEP0, RC=status)
15171528
VERIFY_(STATUS)
15181529
FILEP0 = REPLAY_FILEP0
15191530
FILE_TIMEP0 = REPLAY_TIMEP0
15201531
NEED_BUNDLEP0 = .FALSE.
15211532
else if( (FILE_TIMEP0 .ne. REPLAY_TIMEP0) .or. (FILEP0 .ne. REPLAY_FILEP0) ) then
1522-
call MAPL_CFIORead ( REPLAY_FILEP0, REPLAY_TIMEP0, RBUNDLEP0 , RC=status)
1533+
call MAPL_read_bundle( RBUNDLEP0, REPLAY_FILEP0, REPLAY_TIMEP0, RC=status)
15231534
VERIFY_(STATUS)
15241535
FILEP0 = REPLAY_FILEP0
15251536
FILE_TIMEP0 = REPLAY_TIMEP0
@@ -1532,13 +1543,13 @@ subroutine handleANA_
15321543
if ( trim(GRIDINC)=="ANA" ) call ESMF_FieldBundleSet(RBUNDLEM1, grid=GRIDrep, rc=status)
15331544
if ( trim(GRIDINC)=="BKG" ) call ESMF_FieldBundleSet(RBUNDLEM1, grid=GRIDbkg, rc=status)
15341545
VERIFY_(STATUS)
1535-
call MAPL_CFIORead ( REPLAY_FILEM1, REPLAY_TIMEM1, RBUNDLEM1 , RC=status)
1546+
call MAPL_read_bundle( RBUNDLEM1, REPLAY_FILEM1, REPLAY_TIMEM1, RC=status)
15361547
VERIFY_(STATUS)
15371548
FILEM1 = REPLAY_FILEM1
15381549
FILE_TIMEM1 = REPLAY_TIMEM1
15391550
NEED_BUNDLEM1 = .FALSE.
15401551
else if ( (FILE_TIMEM1 .ne. REPLAY_TIMEM1) .or. (FILEM1 .ne. REPLAY_FILEM1) ) then
1541-
call MAPL_CFIORead ( REPLAY_FILEM1, REPLAY_TIMEM1, RBUNDLEM1 , RC=status)
1552+
call MAPL_read_bundle( RBUNDLEM1, REPLAY_FILEM1, REPLAY_TIMEM1, RC=status)
15421553
VERIFY_(STATUS)
15431554
FILEM1 = REPLAY_FILEM1
15441555
FILE_TIMEM1 = REPLAY_TIMEM1
@@ -1551,13 +1562,13 @@ subroutine handleANA_
15511562
if ( trim(GRIDINC)=="ANA" ) call ESMF_FieldBundleSet(RBUNDLEP1, grid=GRIDrep, rc=status)
15521563
if ( trim(GRIDINC)=="BKG" ) call ESMF_FieldBundleSet(RBUNDLEP1, grid=GRIDbkg, rc=status)
15531564
VERIFY_(STATUS)
1554-
call MAPL_CFIORead ( REPLAY_FILEP1, REPLAY_TIMEP1, RBUNDLEP1 , RC=status)
1565+
call MAPL_read_bundle( RBUNDLEP1, REPLAY_FILEP1, REPLAY_TIMEP1, RC=status)
15551566
VERIFY_(STATUS)
15561567
FILEP1 = REPLAY_FILEP1
15571568
FILE_TIMEP1 = REPLAY_TIMEP1
15581569
NEED_BUNDLEP1 = .FALSE.
15591570
else if ( FILE_TIMEP1 .ne. REPLAY_TIMEP1 .or. (FILEP1 .ne. REPLAY_FILEP1) ) then
1560-
call MAPL_CFIORead ( REPLAY_FILEP1, REPLAY_TIMEP1, RBUNDLEP1 , RC=status)
1571+
call MAPL_read_bundle( RBUNDLEP1, REPLAY_FILEP1, REPLAY_TIMEP1, RC=status)
15611572
VERIFY_(STATUS)
15621573
FILEP1 = REPLAY_FILEP1
15631574
FILE_TIMEP1 = REPLAY_TIMEP1
@@ -1569,13 +1580,13 @@ subroutine handleANA_
15691580
if ( trim(GRIDINC)=="ANA" ) call ESMF_FieldBundleSet(RBUNDLEM2, grid=GRIDrep, rc=status)
15701581
if ( trim(GRIDINC)=="BKG" ) call ESMF_FieldBundleSet(RBUNDLEM2, grid=GRIDbkg, rc=status)
15711582
VERIFY_(STATUS)
1572-
call MAPL_CFIORead ( REPLAY_FILEM2, REPLAY_TIMEM2, RBUNDLEM2 , RC=status)
1583+
call MAPL_read_bundle( RBUNDLEM2, REPLAY_FILEM2, REPLAY_TIMEM2, RC=status)
15731584
VERIFY_(STATUS)
15741585
FILEM2 = REPLAY_FILEM2
15751586
FILE_TIMEM2 = REPLAY_TIMEM2
15761587
NEED_BUNDLEM2 = .FALSE.
15771588
else if ( FILE_TIMEM2 .ne. REPLAY_TIMEM2 .or. (FILEM2 .ne. REPLAY_FILEM2) ) then
1578-
call MAPL_CFIORead ( REPLAY_FILEM2, REPLAY_TIMEM2, RBUNDLEM2 , RC=status)
1589+
call MAPL_read_bundle( RBUNDLEM2, REPLAY_FILEM2, REPLAY_TIMEM2, RC=status)
15791590
VERIFY_(STATUS)
15801591
FILEM2 = REPLAY_FILEM2
15811592
FILE_TIMEM2 = REPLAY_TIMEM2
@@ -1591,6 +1602,7 @@ subroutine handleANA_
15911602
VERIFY_(STATUS)
15921603
call ESMF_FieldBundleGet ( RBUNDLEP0, fieldNameList=RNAMES, rc=STATUS )
15931604
VERIFY_(STATUS)
1605+
call RedanduncyCheck(RNAMES)
15941606
if( first ) then
15951607
if(MAPL_AM_I_ROOT() ) then
15961608
print *
@@ -2863,11 +2875,13 @@ function match (replay_name,replay_alias,replay_var)
28632875

28642876
if( trim(name) == 'U' ) then
28652877
if( trim(var) == 'U' ) match = .true.
2878+
if( trim(var) == 'UA' ) match = .true.
28662879
if( trim(var) == 'UGRD' ) match = .true.
28672880
endif
28682881

28692882
if( trim(name) == 'V' ) then
28702883
if( trim(var) == 'V' ) match = .true.
2884+
if( trim(var) == 'VA' ) match = .true.
28712885
if( trim(var) == 'VGRD' ) match = .true.
28722886
endif
28732887

@@ -2907,6 +2921,7 @@ function match (replay_name,replay_alias,replay_var)
29072921

29082922
if( trim(name) == 'O3' ) then
29092923
if( trim(var) == 'O3' ) match = .true.
2924+
if( trim(var) == 'O3PPMV' ) match = .true.
29102925
if( trim(var) == 'OZONE' ) match = .true.
29112926
endif
29122927

@@ -3410,4 +3425,33 @@ subroutine myremap ( ple_in,ple_out, &
34103425
return
34113426
end subroutine myremap
34123427

3428+
subroutine RedanduncyCheck(rnames)
3429+
3430+
character(len=*), intent(inout) :: rnames(:)
3431+
! completely wired
3432+
! at the moment, the files generated for/by JEDI
3433+
! largely ignore GEOS naming convensions, this
3434+
! here a paliative to a solution/clean-up to come
3435+
! in the future (Todling).
3436+
3437+
! when both t and tv are in file, bypass t
3438+
if (any(rnames=='t') .and. any(rnames=='tv')) then
3439+
where(rnames=='t')
3440+
rnames = 't-bypass'
3441+
endwhere
3442+
endif
3443+
! when both u and ua are in file, bypass u
3444+
if (any(rnames=='u') .and. any(rnames=='ua')) then
3445+
where(rnames=='u')
3446+
rnames = 'u-bypass'
3447+
endwhere
3448+
endif
3449+
! when both v and va are in file, bypass v
3450+
if (any(rnames=='v') .and. any(rnames=='va')) then
3451+
where(rnames=='v')
3452+
rnames = 'v-bypass'
3453+
endwhere
3454+
endif
3455+
end subroutine RedanduncyCheck
3456+
34133457
end module GEOS_mkiauGridCompMod

0 commit comments

Comments
 (0)