Skip to content

Commit

Permalink
Merge pull request #2031 from GEOS-ESM/develop
Browse files Browse the repository at this point in the history
GitFlow: Merge Develop into main for 2.36.0 release
  • Loading branch information
mathomp4 authored Mar 24, 2023
2 parents c271ace + 6f73354 commit 8725f96
Show file tree
Hide file tree
Showing 16 changed files with 1,528 additions and 234 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

## [2.36.0] - 2023-03-23

### Added

- Added config array overload to `MAPL_GetResource`
- Implemented new generic XY grid factory to create regional grids on any input set of 2D lons and lats
- **NOTE**: This grid factory is experimental and the API may change or it might be superseded by another grid factory

### Changed

- Updated `components.yaml` to match GEOSgcm v10.25.1
- ESMA_env v4.8.0 → v4.9.1 (Move to Baselibs 7.8.1: ESMF v8.4.1)
- ESMA_cmake v3.24.0 → v3.28.0 (Detection of additional sites, updated Intel Fortran flags, updates for Python3 support)
- Converted files in `Python/MAPL` to Python 3.
- **NOTE 1**: This will require changes to codes that call MAPL's Python layer.
- **NOTE 2**: If building with F2PY support, you will need to use ESMA_cmake v3.28.0 or later if using in a mixed Python 2/3 environment.

## [2.35.3] - 2023-03-17

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy (SET CMP0054 NEW)

project (
MAPL
VERSION 2.35.3
VERSION 2.36.0
LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF

# Set the default build type to release
Expand Down
6 changes: 3 additions & 3 deletions MAPL_cfio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ endif ()

if (USE_F2PY)
if (precision STREQUAL "r4")
find_package(F2PY2)
if (F2PY2_FOUND)
esma_add_f2py2_module(ShaveMantissa_
find_package(F2PY3)
if (F2PY3_FOUND)
esma_add_f2py3_module(ShaveMantissa_
SOURCES ShaveMantissa_py.F90 ShaveMantissa.c
DESTINATION lib/Python/${this}
INCLUDEDIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/lib ${include_${this}}
Expand Down
2 changes: 1 addition & 1 deletion MAPL_cfio/shavemantissa.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def shave(a,xbits=12,has_undef=0,undef=MISSING,chunksize=-1):
a_shaved, rc = shave32(a,xbits,has_undef,undef,chunksize)

if rc:
raise ValueError, 'shave: error on return from ShaveMantissa_.shave32: %d'%rc
raise ValueError('shave: error on return from ShaveMantissa_.shave32: %d'%rc)

return a_shaved

15 changes: 3 additions & 12 deletions Python/MAPL/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
carried out by means of several *jobs* which are submitted through a
queueing system such as PBS.
job
job
This package defines the base class *Job* which inherits from
*Exp*. A *job* carries out a portion of the *experiment*,
itself consisting of several *run* segments.
Expand All @@ -38,19 +38,10 @@
|----------------------- Experiment ------------------------|
|------ Job 1 ------|------ Job 2 ------|------ Job 3 ------|
|- Run 1 -|- Run 2 -|- Run 3 -|- Run 4 -|- Run 5 -|- Run 6 -|
If each run segment is 2 weeks long, each job performs a 4 week
integration, and the the whole experiment is about 3 month long.
"""

__version__ = "0.1.2"

from exp import *
from job import *
from run import *
from config import *
from history import *
from Date import *
from filelock import *

__version__ = "1.0.0"
88 changes: 44 additions & 44 deletions Python/MAPL/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
from types import *
from datetime import datetime

class Config(object):

def __init__(self,RcFiles,delim=':',Environ=True):
Expand All @@ -23,7 +23,7 @@ def __init__(self,RcFiles,delim=':',Environ=True):
the current value of environment variables.
"""

if type(RcFiles) is StringType:
if isinstance(RcFiles, str):
Files = ( RcFiles, ) # in case a single file is given
else:
Files = RcFiles # more often, a List/Tuple of RC files
Expand All @@ -39,22 +39,22 @@ def __init__(self,RcFiles,delim=':',Environ=True):
if value is not None:
value = string.Template(value).safe_substitute(os.environ)
if name:
self.Rc[name] = { 'value': value,
'comment': comment,
self.Rc[name] = { 'value': value,
'comment': comment,
'flag': 0}

def __call__(self,name,value=None):
"""Either get or set a resource depending on whether *value* is given"""
if value == None:
if self.Rc.__contains__(name):
return self.Rc[name]['value']
else:
if self.Rc.__contains__(name):
self.Rc[name]['value'] = value
self.Rc[name]['value'] = value
self.Rc[name]['flag'] = 1
return self.Rc[name]['value']
return None

get = __call__

def set(self,name,value):
Expand All @@ -65,7 +65,7 @@ def save(self,rcfile=None):
if rcfile is None:
f = sys.stdout
else:
f = open(rcfile,'w')
f = open(rcfile,'w')
for line in self.Lines:
line = line.rstrip()
name, value, comment = _parseLine(line,self.delim)
Expand All @@ -76,16 +76,16 @@ def save(self,rcfile=None):
else:
comment = ''
value = self.Rc[name]['value']
print >>f, name + self.delim+' ' + str(value) + comment # this line has been edited
print(name + self.delim+' ' + str(value) + comment, file=f) # this line has been edited
else:
print >>f, line
print(line, file=f)
else:
print >>f, line
print(line, file=f)
f.close()

def upd(self,dict):
pass

def interp(self,str,outFile=None,**kws):
"""
Use the resource values for $-substitution (a.k.a.
Expand All @@ -108,7 +108,7 @@ def interpFile(self,template,outFile,**kws):
for tmpl in Tmpl:
Text.append(self.interpStr(tmpl,**kws))
open(outFile,"w").writelines(Text)

def interpStr(self,template,strict=False):
"""
Replace occurences of resource variables in the
Expand Down Expand Up @@ -149,21 +149,21 @@ def setenv(self,Only=None):
Use resources to set environment variables. Option,
one can provide a list of strings (*Only*) with those
resources to be turned into environment variables.
"""
"""
for name in self.Rc:
if Only is None:
os.environ[name] = self.Rc[name]['value']
elif name in Only:
os.environ[name] = self.Rc[name]['value']

def keys(self):
"""
"""
Return list of resource names.
"""
return self.Rc.keys()
return list(self.Rc.keys())

def values(self):
"""
"""
Return list of resource names.
"""
vals = []
Expand Down Expand Up @@ -216,7 +216,7 @@ def strTemplate(templ,expid=None,nymd=None,nhms=None,
dtime --- python datetime
Unlike GrADS, notice that seconds are expanded using the %S2 token.
Unlike GrADS, notice that seconds are expanded using the %S2 token.
Input date/time can be either strings or integers.
Examples:
Expand All @@ -229,9 +229,9 @@ def strTemplate(templ,expid=None,nymd=None,nhms=None,
"""

MMM = ( 'jan', 'feb', 'mar', 'apr', 'may', 'jun',
'jul', 'aug', 'sep', 'oct', 'nov', 'dec' )
MMM = ( 'jan', 'feb', 'mar', 'apr', 'may', 'jun',
'jul', 'aug', 'sep', 'oct', 'nov', 'dec' )

str_ = templ[:]

if dtime is not None:
Expand All @@ -254,24 +254,24 @@ def strTemplate(templ,expid=None,nymd=None,nhms=None,
m = (nhms - h * 10000)/100
s = nhms - (10000*h + 100*m)

if expid is not None:
if expid is not None:
str_ = str_.replace('%s',expid)
if yy is not None:
if yy is not None:
y2 = yy%100
str_ = str_.replace('%y4',str(yy))
str_ = str_.replace('%y2',"%02d"%y2)
if mm is not None:
if mm is not None:
mm = int(mm)
mmm = MMM[mm-1]
str_ = str_.replace('%m2',"%02d"%mm)
str_ = str_.replace('%m3',mmm)
if dd is not None:
if dd is not None:
str_ = str_.replace('%d2',"%02d"%int(dd))
if h is not None:
if h is not None:
str_ = str_.replace('%h2',"%02d"%int(h))
if m is not None:
if m is not None:
str_ = str_.replace('%n2',"%02d"%int(m))
if s is not None:
if s is not None:
str_ = str_.replace('%S2',"%02d"%int(s))

return str_
Expand All @@ -284,14 +284,14 @@ def strTemplate(templ,expid=None,nymd=None,nhms=None,
def _ut_strTemplate():



templ = "%s.aer_f.eta.%m3%y2.%y4%m2%d2_%h2:%n2:%S2z.nc"

expid = "e0054A"
yy = "2008"
mm = "10"
dd = "30"

h = "1"
m = "30"
s = "47"
Expand All @@ -301,20 +301,20 @@ def _ut_strTemplate():
nymd = int(yy) * 10000 + int(mm)*100 + int(dd)
nhms = int(h) * 10000 + int(m) * 100 + int(s)

print "Template: "+templ
print strTemplate(templ)
print strTemplate(templ,expid=expid)
print strTemplate(templ,expid=expid,yy=2008)
print strTemplate(templ,expid=expid,yy=2008,mm=mm)
print strTemplate(templ,expid=expid,yy=2008,mm=mm,dd=dd)
print strTemplate(templ,expid=expid,yy=2008,mm=mm,dd=dd,h=h)
print strTemplate(templ,expid=expid,yy=2008,mm=mm,dd=dd,h=h,m=m,s=s)
print strTemplate(templ,expid=expid,nymd=nymd)
print strTemplate(templ,expid=expid,nymd=nymd,nhms=nhms)
print strTemplate(templ,expid=expid,dtime=dtime)
print("Template: "+templ)
print(strTemplate(templ))
print(strTemplate(templ,expid=expid))
print(strTemplate(templ,expid=expid,yy=2008))
print(strTemplate(templ,expid=expid,yy=2008,mm=mm))
print(strTemplate(templ,expid=expid,yy=2008,mm=mm,dd=dd))
print(strTemplate(templ,expid=expid,yy=2008,mm=mm,dd=dd,h=h))
print(strTemplate(templ,expid=expid,yy=2008,mm=mm,dd=dd,h=h,m=m,s=s))
print(strTemplate(templ,expid=expid,nymd=nymd))
print(strTemplate(templ,expid=expid,nymd=nymd,nhms=nhms))
print(strTemplate(templ,expid=expid,dtime=dtime))

if __name__ == "__main__":
cf = Config('test.rc', delim=' = ')

# _ut_strTemplate()

34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ MAPL is a foundation layer of the GEOS architecture, whose original purpose is t

MAPL has 10 primary subdirectories for Fortran source code:

1. shared - low level utilities that are used throughout the remainder of MAPL.
2. profiler - time and memory profiling utility
3. pfio - high-performance client-server I/O layer
5. base (formerly MAPL_Base) - legacy core of MAPL. This layer will gradually evaporate under further refactoring.
6. generic (under construction) - new home for MAPL extension of ESMF framework.
7. oomph - next gen generic will eventually disappear
8. gridcomps - Cap, History, and ExtData gridcomps used by all GEOS configurations.
9. MAPL_cfio - this is a deprecated lower-level I/O layer that is generally replaced by GMAO_pFIO. Not all of the strings have been cut yet. Sometime soon, this directory will be eliminated.
10. griddedio - layer between ESMF container and pfio library
1. **shared** - low level utilities that are used throughout the remainder of MAPL.
2. **profiler** - time and memory profiling utility
3. [**pfio**](https://github.com/GEOS-ESM/MAPL/tree/main/pfio) - high-performance client-server I/O layer
5. **base** (formerly MAPL_Base) - legacy core of MAPL. This layer will gradually evaporate under further refactoring.
6. **generic** (under construction) - new home for MAPL extension of ESMF framework.
7. **oomph** - next gen generic will eventually disappear
8. **gridcomps** - Cap, [History](https://github.com/GEOS-ESM/MAPL/tree/main/gridcomps/History), and [ExtData](https://github.com/GEOS-ESM/MAPL/tree/main/gridcomps/ExtData2G) gridcomps used by all GEOS configurations.
9. **MAPL_cfio** - this is a deprecated lower-level I/O layer that is generally replaced by GMAO_pFIO. Not all of the strings have been cut yet. Sometime soon, this directory will be eliminated.
10. **griddedio** - layer between ESMF container and pfio library


MAPL also has a variety of other auxiliary directories:

1. include - include files used by external gridded components.
2. Apps - various Python and Perl scripts used by gridded components.
3. Python - beginnings of a run-time scripting framework for GEOS configurations
4. cmake - CMake build macros
5. MAPL_pFUnit - implements extensions of pFUnit unit testing framework that enable unit tests of grid comp run methods. This layer should eventually be migrated into pFUnit itself.
6. Tests - miscellaneous standalone drivers.
7. pflogger_stub - workaround for apps that wish to avoid a dependency on pFlogger
8. pfunit - pFUnit (unit testing framework) extensions for ESMF components
1. **include** - include files used by external gridded components.
2. **Apps** - various Python and Perl scripts used by gridded components.
3. **Python** - beginnings of a run-time scripting framework for GEOS configurations
4. **cmake** - CMake build macros
5. **MAPL_pFUnit** - implements extensions of pFUnit unit testing framework that enable unit tests of grid comp run methods. This layer should eventually be migrated into pFUnit itself.
6. **Tests** - miscellaneous standalone drivers.
7. **pflogger_stub** - workaround for apps that wish to avoid a dependency on pFlogger
8. **pfunit** - pFUnit (unit testing framework) extensions for ESMF components

## Contributing

Expand Down
1 change: 1 addition & 0 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ set (srcs
MAPL_ISO8601_DateTime_ESMF.F90
FieldUtilities.F90
MAPL_Resource.F90
MAPL_XYGridFactory.F90
# Orphaned program: should not be in this library.
# tstqsat.F90
)
Expand Down
3 changes: 3 additions & 0 deletions base/MAPL_GridManager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ subroutine initialize_prototypes(this, unusable, rc)
use MAPL_TripolarGridFactoryMod, only: TripolarGridFactory
use MAPL_LlcGridFactoryMod, only: LlcGridFactory
use MAPL_ExternalGridFactoryMod, only: ExternalGridFactory
use MAPL_XYGridFactoryMod, only: XYGridFactory

class (GridManager), intent(inout) :: this
class (KeywordEnforcer), optional, intent(in) :: unusable
Expand All @@ -131,6 +132,7 @@ subroutine initialize_prototypes(this, unusable, rc)
type (TripolarGridFactory) :: tripolar_factory
type (LlcGridFactory) :: llc_factory
type (ExternalGridFactory) :: external_factory
type (XYGridFactory) :: xy_factory

! This is a local variable to prevent the subroutine from running
! initialiazation twice. Calling functions have their own local variables
Expand All @@ -148,6 +150,7 @@ subroutine initialize_prototypes(this, unusable, rc)
call this%prototypes%insert('Tripolar', tripolar_factory)
call this%prototypes%insert('llc', llc_factory)
call this%prototypes%insert('External', external_factory)
call this%prototypes%insert('XY', xy_factory)
initialized = .true.
end if

Expand Down
Loading

0 comments on commit 8725f96

Please sign in to comment.