Skip to content

Commit fc7efae

Browse files
authored
Merge pull request #421 from GEOS-ESM/feature/420-migrate-mapl2-to-mapl3
Migrate use MAPL2 to use MAPL (MAPL3) in GEOS_Shared (#420)
2 parents 59a3304 + 9202c85 commit fc7efae

8 files changed

Lines changed: 81 additions & 106 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
- Migrate `GEOS_TopoGet.F90` from bare `use MAPL2` to `use MAPL` + `use MAPL2, only:` for remaining MAPL2-only symbols
15+
1416
### Fixed
1517

1618
- Fix for Open MPI calls in `esma_mpirun` from Open MPI 5 testing

GEOS_Shared/G3_MPI_Util_Mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "unused_dummy.H"
22
module G3_MPI_Util_Mod
33

4-
use MAPL2
4+
use MAPL, only: MAPL_PI
55
implicit none
66

77
! Define Lattice

GEOS_Shared/GEOS_TopoGet.F90

Lines changed: 67 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
! $Id$
2-
! VERIFY_ and RETURN_ macros for error handling
3-
4-
#include "MAPL_Generic.h"
2+
#include "MAPL_ErrLog.h"
53

64
!BOP
75

@@ -14,7 +12,8 @@ module GEOS_TopoGetMod
1412
! !USES:
1513

1614
use ESMF
17-
use MAPL2
15+
use MAPL
16+
use MAPL2, only: MAPL_VarRead, GETFILE
1817

1918
implicit none
2019
private
@@ -36,11 +35,46 @@ module GEOS_TopoGetMod
3635
! directional variances associated with Gravity-Wave-Drag scales (10-100 km)
3736
! and turbulence scales (0-10 km).
3837

39-
4038
!EOP
4139

4240
contains
4341

42+
!==========================================================================
43+
44+
! Helper: get a string value from HConfig with a default
45+
subroutine hconfig_get_string(cf, label, value, default, rc)
46+
type(ESMF_HConfig), intent(in) :: cf
47+
character(len=*), intent(in) :: label
48+
character(len=*), intent(out) :: value
49+
character(len=*), intent(in) :: default
50+
integer, optional, intent(out) :: rc
51+
integer :: status
52+
logical :: defined
53+
character(len=:), allocatable :: tmp
54+
value = default
55+
defined = ESMF_HConfigIsDefined(cf, keyString=label, _RC)
56+
if (defined) then
57+
tmp = ESMF_HConfigAsString(cf, keyString=label, _RC)
58+
value = tmp
59+
end if
60+
_RETURN(ESMF_SUCCESS)
61+
end subroutine hconfig_get_string
62+
63+
! Helper: get a real(4) value from HConfig with a default
64+
subroutine hconfig_get_r4(cf, label, value, default, rc)
65+
type(ESMF_HConfig), intent(in) :: cf
66+
character(len=*), intent(in) :: label
67+
real, intent(out) :: value
68+
real, intent(in) :: default
69+
integer, optional, intent(out) :: rc
70+
integer :: status
71+
logical :: defined
72+
value = default
73+
defined = ESMF_HConfigIsDefined(cf, keyString=label, _RC)
74+
if (defined) value = ESMF_HConfigAsR4(cf, keyString=label, _RC)
75+
_RETURN(ESMF_SUCCESS)
76+
end subroutine hconfig_get_r4
77+
4478
!==========================================================================
4579

4680
!BOP
@@ -56,7 +90,7 @@ subroutine GEOS_TopoGet ( cf, &
5690

5791
! !ARGUMENTS
5892

59-
type(ESMF_Config) :: cf
93+
type(ESMF_HConfig), intent(in ) :: cf
6094
type(ESMF_Field), optional, intent(INOUT) :: MEAN
6195
type(ESMF_Field), optional, intent(INOUT) :: GWDVAR
6296
type(ESMF_Field), optional, intent(INOUT) :: GWDVARX
@@ -66,45 +100,6 @@ subroutine GEOS_TopoGet ( cf, &
66100
type(ESMF_Field), optional, intent(INOUT) :: TRBVAR
67101
integer, optional, intent(OUT) :: RC
68102

69-
! !DESCRIPTION
70-
71-
! This subroutine creates topographic data associated with an input
72-
! ESMF grid. The available topographic data types are: MEAN, GWDVAR,
73-
! GWDVARX, GWDVARY, GWDVARXY, GWDVARYX, and TRBVAR. The raw data
74-
! for each of these types has been pre-processed and stored at 2.5'x2.5'
75-
! resolution. The resulting gridded data will be binned-averaged on the
76-
! input ESMF grid from the 2.5'x2.5' data.
77-
! The arguments are:
78-
!
79-
! \begin{description}
80-
! \item[GRID]
81-
! The ESMF GRID which contains information about
82-
! horizontal grid structure.
83-
! \item[MEAN]
84-
! The mean values of topography with scales >= 100 km.
85-
! \item[GWDVAR]
86-
! The isotropic variance of the GWD topography data,
87-
! (scales 10-100 km).
88-
! \item[GWDVARX]
89-
! The variance of the GWD topography data in the
90-
! East - West direction.
91-
! \item[GWDVARY]
92-
! The variance of the GWD topography data in the
93-
! North - South direction.
94-
! \item[GWDVARXY]
95-
! The variance of the GWD topography data in the
96-
! South_West - North_East direction.
97-
! \item[GWDVARYX]
98-
! The variance of the GWD topography data in the
99-
! North_West - South_East direction.
100-
! \item[TRBVAR]
101-
! The isotropic variance of the Turbulence topography data,
102-
! (scales 1-10 km).
103-
! \item[RC]
104-
! Return code
105-
! \end{description}
106-
!
107-
108103
!EOP
109104

110105
! Locals
@@ -122,119 +117,93 @@ subroutine GEOS_TopoGet ( cf, &
122117
real :: GWDFACYX
123118
real :: TRBFAC
124119

125-
type(MAPL_MetaComp) :: MAPLOBJ
126-
127-
! Initialize CONFIG File into MAPL Object
128-
! ---------------------------------------
129-
call MAPL_Set (MAPLOBJ, name='DUMMY', cf=cf, rc=STATUS )
130-
VERIFY_(STATUS)
131-
132120
! Get filenames for Get_Topo utility
133121
! ----------------------------------
134-
call ESMF_ConfigGetAttribute ( cf, value=filename(1), label ='TOPO_MEAN_FILE:', &
135-
default='hmean.2.5x2.5min.data', rc=status )
136-
VERIFY_(STATUS)
137-
138-
call ESMF_ConfigGetAttribute ( cf, value=filename(2), label ='TOPO_GWDVAR_FILE:', &
139-
default='hgrav_var.2.5x2.5min.data', rc=status )
140-
VERIFY_(STATUS)
141-
142-
call ESMF_ConfigGetAttribute ( cf, value=filename(3), label ='TOPO_GWDVARX_FILE:', &
143-
default='hgrav_varx.2.5x2.5min.data', rc=status )
144-
VERIFY_(STATUS)
145-
146-
call ESMF_ConfigGetAttribute ( cf, value=filename(4), label ='TOPO_GWDVARY_FILE:', &
147-
default='hgrav_vary.2.5x2.5min.data', rc=status )
148-
VERIFY_(STATUS)
149-
150-
call ESMF_ConfigGetAttribute ( cf, value=filename(5), label ='TOPO_GWDVARXY_FILE:', &
151-
default='hgrav_varxy.2.5x2.5min.data', rc=status )
152-
VERIFY_(STATUS)
153-
154-
call ESMF_ConfigGetAttribute ( cf, value=filename(6), label ='TOPO_GWDVARYX_FILE:', &
155-
default='hgrav_varyx.2.5x2.5min.data', rc=status )
156-
VERIFY_(STATUS)
157-
158-
call ESMF_ConfigGetAttribute ( cf, value=filename(7), label ='TOPO_TRBVAR_FILE:', &
159-
default='hturb_var.2.5x2.5min.data', rc=status )
160-
VERIFY_(STATUS)
122+
call hconfig_get_string(cf, 'TOPO_MEAN_FILE', filename(1), default='hmean.2.5x2.5min.data', _RC)
123+
call hconfig_get_string(cf, 'TOPO_GWDVAR_FILE', filename(2), default='hgrav_var.2.5x2.5min.data', _RC)
124+
call hconfig_get_string(cf, 'TOPO_GWDVARX_FILE', filename(3), default='hgrav_varx.2.5x2.5min.data', _RC)
125+
call hconfig_get_string(cf, 'TOPO_GWDVARY_FILE', filename(4), default='hgrav_vary.2.5x2.5min.data', _RC)
126+
call hconfig_get_string(cf, 'TOPO_GWDVARXY_FILE', filename(5), default='hgrav_varxy.2.5x2.5min.data', _RC)
127+
call hconfig_get_string(cf, 'TOPO_GWDVARYX_FILE', filename(6), default='hgrav_varyx.2.5x2.5min.data', _RC)
128+
call hconfig_get_string(cf, 'TOPO_TRBVAR_FILE', filename(7), default='hturb_var.2.5x2.5min.data', _RC)
161129

162130
if( present(MEAN) ) then
163131
! -------------------------
164132
UNIT = GETFILE ( filename(1),form="unformatted" )
165133
call MAPL_VarRead (UNIT,MEAN)
166134
CALL FREE_FILE (UNIT)
167135
call ESMF_FieldGet(MEAN, 0, PTR, rc=status)
136+
_VERIFY(STATUS)
168137
ptr = ptr*MAPL_GRAV
169138
endif
170139

171140
if( present(GWDVAR) ) then
172141
! --------------------------
173-
call MAPL_GetResource( MAPLOBJ, GWDFAC, label="GWDVAR_FACTOR:", default = 1.0, RC=STATUS )
174-
VERIFY_(STATUS)
142+
call hconfig_get_r4(cf, 'GWDVAR_FACTOR', GWDFAC, default=1.0, _RC)
175143
UNIT = GETFILE (filename(2), form="unformatted")
176144
call MAPL_VarRead (UNIT,GWDVAR)
177145
CALL FREE_FILE (UNIT)
178-
call ESMF_FieldGet (GWDVAR, 0, PTR, rc = status)
146+
call ESMF_FieldGet (GWDVAR, 0, PTR, rc=status)
147+
_VERIFY(STATUS)
179148
ptr = sqrt( max(gwdfac*ptr,0.0) )
180149
endif
181150

182151
if( present(GWDVARX) ) then
183152
! ---------------------------
184-
call MAPL_GetResource( MAPLOBJ, GWDFACX, label="GWDVARX_FACTOR:", default = 1.0, RC=STATUS )
185-
VERIFY_(STATUS)
153+
call hconfig_get_r4(cf, 'GWDVARX_FACTOR', GWDFACX, default=1.0, _RC)
186154
UNIT = GETFILE (filename(3), form="unformatted")
187155
call MAPL_VarRead (UNIT,GWDVARX)
188156
CALL FREE_FILE (UNIT)
189-
call ESMF_FieldGet (GWDVARX, 0, PTR, rc = status)
157+
call ESMF_FieldGet (GWDVARX, 0, PTR, rc=status)
158+
_VERIFY(STATUS)
190159
ptr = sqrt( max(gwdfacx*ptr,0.0) )
191160
endif
192161

193162
if( present(GWDVARY) ) then
194163
! ---------------------------
195-
call MAPL_GetResource( MAPLOBJ, GWDFACY, label="GWDVARY_FACTOR:", default = 1.0, RC=STATUS )
196-
VERIFY_(STATUS)
164+
call hconfig_get_r4(cf, 'GWDVARY_FACTOR', GWDFACY, default=1.0, _RC)
197165
UNIT = GETFILE (filename(4), form="unformatted")
198166
call MAPL_VarRead (UNIT,GWDVARY)
199167
CALL FREE_FILE (UNIT)
200-
call ESMF_FieldGet (GWDVARY, 0, PTR, rc = status)
168+
call ESMF_FieldGet (GWDVARY, 0, PTR, rc=status)
169+
_VERIFY(STATUS)
201170
ptr = sqrt( max(gwdfacy*ptr,0.0) )
202171
endif
203172

204173
if( present(GWDVARXY) ) then
205174
! ----------------------------
206-
call MAPL_GetResource( MAPLOBJ, GWDFACXY, label="GWDVARXY_FACTOR:", default = 1.0, RC=STATUS )
207-
VERIFY_(STATUS)
175+
call hconfig_get_r4(cf, 'GWDVARXY_FACTOR', GWDFACXY, default=1.0, _RC)
208176
UNIT = GETFILE (filename(5), form="unformatted")
209177
call MAPL_VarRead (UNIT,GWDVARXY)
210178
CALL FREE_FILE (UNIT)
211-
call ESMF_FieldGet (GWDVARXY, 0, PTR, rc = status)
179+
call ESMF_FieldGet (GWDVARXY, 0, PTR, rc=status)
180+
_VERIFY(STATUS)
212181
ptr = sqrt( max(gwdfacxy*ptr,0.0) )
213182
endif
214183

215184
if( present(GWDVARYX) ) then
216185
! ----------------------------
217-
call MAPL_GetResource( MAPLOBJ, GWDFACYX, label="GWDVARYX_FACTOR:", default = 1.0, RC=STATUS )
218-
VERIFY_(STATUS)
186+
call hconfig_get_r4(cf, 'GWDVARYX_FACTOR', GWDFACYX, default=1.0, _RC)
219187
UNIT = GETFILE (filename(6), form="unformatted")
220188
call MAPL_VarRead (UNIT,GWDVARYX)
221189
CALL FREE_FILE (UNIT)
222-
call ESMF_FieldGet (GWDVARYX, 0, PTR, rc = status)
190+
call ESMF_FieldGet (GWDVARYX, 0, PTR, rc=status)
191+
_VERIFY(STATUS)
223192
ptr = sqrt( max(gwdfacyx*ptr,0.0) )
224193
endif
225194

226195
if( present(TRBVAR) ) then
227196
! --------------------------
228-
call MAPL_GetResource( MAPLOBJ, TRBFAC, label="TRBVAR_FACTOR:", default = 1.0, RC=STATUS )
229-
VERIFY_(STATUS)
197+
call hconfig_get_r4(cf, 'TRBVAR_FACTOR', TRBFAC, default=1.0, _RC)
230198
UNIT = GETFILE (filename(7), form="unformatted")
231199
call MAPL_VarRead (UNIT,TRBVAR)
232200
CALL FREE_FILE (UNIT)
233-
call ESMF_FieldGet (TRBVAR, 0, PTR, rc = status)
201+
call ESMF_FieldGet (TRBVAR, 0, PTR, rc=status)
202+
_VERIFY(STATUS)
234203
ptr = max(trbfac*ptr,0.0)
235204
endif
236205

237-
return
206+
_RETURN(ESMF_SUCCESS)
238207
end subroutine GEOS_TopoGet
239208

240209
end module GEOS_TopoGetMod

GEOS_Shared/atmOceanIntLayer.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ module atmOcnIntlayer
22

33
! !USES:
44

5-
use MAPL2
5+
use MAPL, only: MAPL_ALHF, MAPL_ALHL, MAPL_AM_I_ROOT, MAPL_CAPWTR, &
6+
MAPL_GRAV, MAPL_KARMAN, MAPL_RHO_SEAWATER, MAPL_RHOWTR, &
7+
MAPL_TICE, MAPL_UNDEF
68
use GEOS_UtilsMod, only: GEOS_QSAT, GEOS_DQSAT
79

810
implicit none

GEOS_Shared/condense.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ subroutine condensation(T,P,Qv,Ql,SuperSat)
3131

3232
subroutine Iterate(TT,PP,QQ,QC,SuperSat)
3333

34-
use MAPL2, only : QSAT=>MAPL_EQSAT, MAPL_ALHL, MAPL_CP, MAPL_AIRMW, MAPL_RUNIV, MAPL_RDRY, MAPL_RGAS, MAPL_CP
34+
use MAPL, only : QSAT=>MAPL_EQSAT, MAPL_ALHL, MAPL_CP, MAPL_AIRMW, MAPL_RUNIV, MAPL_RDRY, MAPL_RGAS, MAPL_CP
3535

3636
implicit none
3737

GEOS_Shared/surfacelayer.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module sfclayer
55

66
! !USES:
77

8-
use MAPL2
8+
use MAPL, only: MAPL_CP, MAPL_GRAV, MAPL_KAPPA, MAPL_KARMAN, &
9+
MAPL_NUAIR, MAPL_RGAS, MAPL_USMIN, MAPL_VIREPS
910
use DragCoefficientsMod
1011

1112
implicit none

GEOS_Shared/tropovars.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ subroutine tropovars (im,jm,lm,ple,pl, &
1717
! profile. In a standard Skew-T Log P diagram the isotherms
1818
! intersect the Log P scale at a 45 degree angle. To more
1919
! effectively isolate the tropopause, this angle can be adjusted.
20-
! ThatÕs how this program works. It adjusts the angle at which
20+
! That�s how this program works. It adjusts the angle at which
2121
! the isotherms intersect the Log P axis via the coeffiecient
22-
! Òalpha.Ó It simply looks for the furthest point to the left on
22+
! �alpha.� It simply looks for the furthest point to the left on
2323
! the profile. The routine defines the leftward position of each
2424
! temperature point as xfact:
2525
!
@@ -62,7 +62,7 @@ subroutine tropovars (im,jm,lm,ple,pl, &
6262
!
6363
!********************************************************************
6464

65-
use MAPL2
65+
use MAPL, only: MAPL_UNDEF
6666

6767
implicit none
6868

GEOS_Shared/windfix.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ subroutine windfix ( ua,va,plea, &
66
vintdiva,vintdivb,vintdivc )
77

88
use ESMF
9-
use MAPL2
9+
use MAPL, MAPL_GridGet_UNUSED => MAPL_GridGet
10+
use MAPL2, only: MAPL_GridGet
1011

1112
implicit none
1213

0 commit comments

Comments
 (0)