Skip to content

Commit

Permalink
Merge branch 'hotfix-v6.2'
Browse files Browse the repository at this point in the history
This merge addresses minor issues in the MPAS infrastructure with how character
strings are read from netCDF files via PIO, and it adds the 'recursive'
attribute to the mpas_log_write routine to avoid errors raised by several
newer compilers when critical errors are written.

* hotfix-v6.2:
  Add missing 'recursive' attribute to MPAS_log_write(...) routine
  Increment version number to 6.2
  Remove C null characters from strings read by PIO
  Add new MPAS_sanitize_string routine to mpas_c_interfacing
  Change length of xtime variables to ShortStrKIND to match netCDF files
  • Loading branch information
mgduda committed Mar 14, 2019
2 parents c970b61 + acce87d commit ce78c32
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2013-2018, Los Alamos National Security, LLC (LANS) (Ocean: LA-CC-13-047;
Copyright (c) 2013-2019, Los Alamos National Security, LLC (LANS) (Ocean: LA-CC-13-047;
Land Ice: LA-CC-13-117) and the University Corporation for Atmospheric Research (UCAR).

All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
MPAS-v6.1
MPAS-v6.2
====

The Model for Prediction Across Scales (MPAS) is a collaborative project for
Expand Down
2 changes: 1 addition & 1 deletion src/core_atmosphere/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="atmosphere" core_abbrev="atm" version="6.1">
<registry model="mpas" core="atmosphere" core_abbrev="atm" version="6.2">

<!-- **************************************************************************************** -->
<!-- ************************************** Dimensions ************************************** -->
Expand Down
2 changes: 1 addition & 1 deletion src/core_init_atmosphere/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="init_atmosphere" core_abbrev="init_atm" version="6.1">
<registry model="mpas" core="init_atmosphere" core_abbrev="init_atm" version="6.2">

<!-- **************************************************************************************** -->
<!-- ************************************** Dimensions ************************************** -->
Expand Down
2 changes: 1 addition & 1 deletion src/core_landice/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="landice" core_abbrev="li" version="6.1">
<registry model="mpas" core="landice" core_abbrev="li" version="6.2">


<!-- ======================================================================= -->
Expand Down
2 changes: 1 addition & 1 deletion src/core_ocean/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="ocean" core_abbrev="ocn" version="6.1">
<registry model="mpas" core="ocean" core_abbrev="ocn" version="6.2">

<dims>
<dim name="nCells" units="unitless"
Expand Down
2 changes: 1 addition & 1 deletion src/core_seaice/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="seaice" core_abbrev="seaice" version="6.1">
<registry model="mpas" core="seaice" core_abbrev="seaice" version="6.2">

<dims>
<dim name="nCells"
Expand Down
2 changes: 1 addition & 1 deletion src/core_sw/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="sw" core_abbrev="sw" version="6.1">
<registry model="mpas" core="sw" core_abbrev="sw" version="6.2">
<dims>
<dim name="nCells"/>
<dim name="nEdges"/>
Expand Down
2 changes: 1 addition & 1 deletion src/core_test/Registry.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="test" core_abbrev="test" version="6.1">
<registry model="mpas" core="test" core_abbrev="test" version="6.2">
<dims>
<dim name="nCells"/>
<dim name="nEdges"/>
Expand Down
31 changes: 31 additions & 0 deletions src/framework/mpas_c_interfacing.F
Expand Up @@ -4,6 +4,37 @@ module mpas_c_interfacing
contains


!-----------------------------------------------------------------------
! routine mpas_sanitize_string
!
!> \brief Converts C null characters in a Fortran string to spaces
!> \author Michael Duda
!> \date 19 February 2019
!> \details
!> Converts all C null characters in a Fortran string to spaces.
!> This may be useful for strings that were provided by C code through other
!> Fortran code external to MPAS.
!
!-----------------------------------------------------------------------
subroutine mpas_sanitize_string(str)

use iso_c_binding, only : c_null_char

implicit none

character(len=*), intent(inout) :: str

integer :: i

do i=1,len(str)
if (str(i:i) == c_null_char) then
str(i:i) = ' '
end if
end do

end subroutine mpas_sanitize_string


!-----------------------------------------------------------------------
! routine mpas_c_to_f_string
!
Expand Down
10 changes: 10 additions & 0 deletions src/framework/mpas_io.F
Expand Up @@ -2187,6 +2187,8 @@ end subroutine MPAS_io_get_var_real5d

subroutine MPAS_io_get_var_char0d(handle, fieldname, val, ierr)

use mpas_c_interfacing, only : MPAS_sanitize_string

implicit none

type (MPAS_IO_Handle_type), intent(inout) :: handle
Expand All @@ -2198,23 +2200,31 @@ subroutine MPAS_io_get_var_char0d(handle, fieldname, val, ierr)
if (present(ierr)) ierr = MPAS_IO_NOERR

call MPAS_io_get_var_generic(handle, fieldname, charVal=val, ierr=ierr)
call MPAS_sanitize_string(val)

end subroutine MPAS_io_get_var_char0d


subroutine MPAS_io_get_var_char1d(handle, fieldname, val, ierr)

use mpas_c_interfacing, only : MPAS_sanitize_string

implicit none

type (MPAS_IO_Handle_type), intent(inout) :: handle
character (len=*), intent(in) :: fieldname
character (len=*), dimension(:), intent(out) :: val
integer, intent(out), optional :: ierr

integer :: i

! call mpas_log_write('Called MPAS_io_get_var_char1d()')
if (present(ierr)) ierr = MPAS_IO_NOERR

call MPAS_io_get_var_generic(handle, fieldname, charArray1d=val, ierr=ierr)
do i=1,size(val)
call MPAS_sanitize_string(val(i))
end do

end subroutine MPAS_io_get_var_char1d

Expand Down
14 changes: 7 additions & 7 deletions src/framework/mpas_io_streams.F
Expand Up @@ -148,12 +148,12 @@ integer function MPAS_seekStream(stream, seekTime, seekPosition, actualTime, max
integer :: io_err
integer :: i
integer :: timeDim
character (len=StrKIND), dimension(:), pointer :: xtimes
character (len=StrKIND) :: strTemp
character (len=ShortStrKIND), dimension(:), pointer :: xtimes
character (len=ShortStrKIND) :: strTemp
type (MPAS_Time_type) :: sliceTime, startTime
type (MPAS_TimeInterval_type) :: timeDiff, minTimeDiff

character (len=StrKIND) :: xtime0, xtime1, xtime2, xtimeGuess
character (len=ShortStrKIND) :: xtime0, xtime1, xtime2, xtimeGuess
type (MPAS_Time_type) :: time0, time1, time2, timeGuess, timeGuessData
type (MPAS_TimeInterval_type) :: timeInterval

Expand Down Expand Up @@ -1510,10 +1510,10 @@ subroutine MPAS_streamAddField_0dChar(stream, field, ierr)
idim = ndims
allocate(indices(0))
allocate(dimSizes(1))
dimSizes(1) = 64
dimSizes(1) = ShortStrKIND
dimNames(1) = 'StrLen'
globalDimSize = 64
totalDimSize = 64
globalDimSize = ShortStrKIND
totalDimSize = ShortStrKIND
if (field % isVarArray) then
Expand Down Expand Up @@ -1602,7 +1602,7 @@ subroutine MPAS_streamAddField_1dChar(stream, field, ierr)
idim = ndims
allocate(indices(1))
allocate(dimSizes(2))
dimSizes(1) = 64
dimSizes(1) = ShortStrKIND
dimNames(1) = 'StrLen'
dimSizes(2) = field % dimSizes(1)
dimNames(2) = field % dimNames(1)
Expand Down
2 changes: 1 addition & 1 deletion src/framework/mpas_log.F
Expand Up @@ -461,7 +461,7 @@ end subroutine mpas_log_open
!
!-----------------------------------------------------------------------

subroutine mpas_log_write(message, messageType, masterOnly, flushNow, &
recursive subroutine mpas_log_write(message, messageType, masterOnly, flushNow, &
intArgs, realArgs, logicArgs, err)

use mpas_threading
Expand Down

0 comments on commit ce78c32

Please sign in to comment.