Skip to content

Commit 9691cc6

Browse files
authored
Merge branch 'develop' into feature/mathomp4/fixes-for-ifx
2 parents a30794e + f9b8421 commit 9691cc6

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Added macro _RETURN(_SUCCESS) to fetch_data
12+
- Added macro `_RETURN(_SUCCESS)` to fetch_data
1313
- Allow update offsets of ±timestep in ExtData2G
1414
- Minor revision (and generalization) of grid-def for GSI purposes
15-
- Trajectory sampler: fix a bug when group_name does not exist in netCDF file and a bug that omitted the first time point
15+
- Add ability to use an `ESMF_CONFIG_FILE` environment variable to specify name of file to pass in pre-`ESMF_Initialize` options to ESMF (see [ESMF Docs](https://earthsystemmodeling.org/docs/release/latest/ESMF_refdoc/node4.html#SECTION04024000000000000000) for allowed flags.
1616
- Allow lat-lon grid factory to detect and use CF compliant lat-lon bounds in a file when making a grid
1717
- PFIO/Variable class, new procedures to retrieve string/reals/int attributes from a variable
1818

@@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5252

5353
- Fixed issue of some Baselibs builds appearing to support zstandard. This is not possible due to Baselibs building HDF5 and netCDF as static libraries
5454
- Workaround ifx bug in `pfio/ArrayReference.F90` (NOTE: This currently targets all versions of ifx, but will need to be qualified or removed in the future)
55+
- Trajectory sampler: fix a bug when group_name does not exist in netCDF file and a bug that omitted the first time point
5556
- Fixed a bug where the periodicity around the earth of the lat-lon grid was not being set properly when grid did not span from pole to pole
5657

5758
### Removed

gridcomps/Cap/MAPL_Cap.F90

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,10 @@ subroutine run_model(this, comm, unusable, rc)
274274
integer :: rank, ierror
275275
integer :: status
276276
class(Logger), pointer :: lgr
277-
logical :: file_exists
277+
logical :: esmfConfigFileExists
278278
type (ESMF_VM) :: vm
279-
character(len=:), allocatable :: esmfComm
279+
character(len=:), allocatable :: esmfComm, esmfConfigFile
280+
integer :: esmfConfigFileLen
280281

281282
_UNUSED_DUMMY(unusable)
282283

@@ -288,16 +289,41 @@ subroutine run_model(this, comm, unusable, rc)
288289
call MPI_COMM_RANK(comm, rank, status)
289290
_VERIFY(status)
290291

292+
! We look to see if the user has set an environment variable for the
293+
! name of the ESMF configuration file. If they have, we use that. If not,
294+
! we use the default of "ESMF.rc" for backward compatibility
295+
296+
! Step one: default to ESMF.rc
297+
298+
esmfConfigFile = 'ESMF.rc'
299+
esmfConfigFileLen = len(esmfConfigFile)
300+
301+
! Step two: get the length of the environment variable
302+
call get_environment_variable('ESMF_CONFIG_FILE', length=esmfConfigFileLen, status=status)
303+
! Step three: if the environment variable exists, get the value of the environment variable
304+
if (status == 0) then ! variable exists
305+
! We need to deallocate so we can reallocate
306+
deallocate(esmfConfigFile)
307+
allocate(character(len = esmfConfigFileLen) :: esmfConfigFile)
308+
call get_environment_variable('ESMF_CONFIG_FILE', value=esmfConfigFile, status=status)
309+
_VERIFY(status)
310+
end if
311+
291312
if (rank == 0) then
292-
inquire(file='ESMF.rc', exist=file_exists)
313+
inquire(file=esmfConfigFile, exist=esmfConfigFileExists)
293314
end if
294-
call MPI_BCAST(file_exists, 1, MPI_LOGICAL, 0, comm, status)
315+
call MPI_BCAST(esmfConfigFileExists, 1, MPI_LOGICAL, 0, comm, status)
316+
_VERIFY(status)
317+
call MPI_BCAST(esmfConfigFile, esmfConfigFileLen, MPI_CHARACTER, 0, comm, status)
295318
_VERIFY(status)
296319

320+
lgr => logging%get_logger('MAPL')
321+
297322
! If the file exists, we pass it into ESMF_Initialize, else, we
298323
! use the one from the command line arguments
299-
if (file_exists) then
300-
call ESMF_Initialize (configFileName='ESMF.rc', mpiCommunicator=comm, vm=vm, _RC)
324+
if (esmfConfigFileExists) then
325+
call lgr%info("Using ESMF configuration file: %a", esmfConfigFile)
326+
call ESMF_Initialize (configFileName=esmfConfigFile, mpiCommunicator=comm, vm=vm, _RC)
301327
else
302328
call ESMF_Initialize (logKindFlag=this%cap_options%esmf_logging_mode, mpiCommunicator=comm, vm=vm, _RC)
303329
end if
@@ -312,7 +338,6 @@ subroutine run_model(this, comm, unusable, rc)
312338
call ESMF_MeshSetMOAB(this%cap_options%with_esmf_moab, rc=status)
313339
_VERIFY(status)
314340

315-
lgr => logging%get_logger('MAPL')
316341
call lgr%info("Running with MOAB library for ESMF Mesh: %l1", this%cap_options%with_esmf_moab)
317342

318343
call this%initialize_cap_gc(rc=status)

0 commit comments

Comments
 (0)