diff --git a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 index 5c8d70ea68df9b7bfc2e839f47860ace982a90d4..d0d2568f358a991b87db7388167b1ac5ee2562c8 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 @@ -439,26 +439,29 @@ integer, intent(in) :: kidx !Position of the dimension in the li character(len=*), intent(in) :: hdimname !Name of the dimension integer, intent(in) :: klen !Length of the dimension +character(len=Len(hdimname)) :: ydimname_clean integer(kind=CDFINT) :: istatus +call IO_Mnhname_clean( hdimname, ydimname_clean ) + if ( .not.Associated( tpfile%tncdims ) ) & call Print_msg( NVERB_FATAL, 'IO', 'IO_Add_dim_nc4', 'tncdims not associated for ' // Trim( tpfile%cname ) ) if ( kidx < 1 .or. kidx > Size( tpfile%tncdims%tdims ) ) & - call Print_msg( NVERB_FATAL, 'IO', 'IO_Add_dim_nc4', 'index out of range for dimension ' // Trim( hdimname ) // & + call Print_msg( NVERB_FATAL, 'IO', 'IO_Add_dim_nc4', 'index out of range for dimension ' // Trim( ydimname_clean ) // & ' of file ' //Trim( tpfile%cname ) ) if ( tpfile%tncdims%tdims(kidx)%nlen /= -1 .or. tpfile%tncdims%tdims(kidx)%nid /= -1 ) & - call Print_msg( NVERB_WARNING, 'IO', 'IO_Add_dim_nc4', 'dimension ' // Trim( hdimname ) // & + call Print_msg( NVERB_WARNING, 'IO', 'IO_Add_dim_nc4', 'dimension ' // Trim( ydimname_clean ) // & ' already defined for file ' //Trim( tpfile%cname ) ) -tpfile%tncdims%tdims(kidx)%cname = hdimname +tpfile%tncdims%tdims(kidx)%cname = ydimname_clean tpfile%tncdims%tdims(kidx)%nlen = Int( klen, kind = CDFINT ) -istatus = NF90_DEF_DIM( tpfile%nncid, Trim( hdimname ), Int( klen, kind = CDFINT ), tpfile%tncdims%tdims(kidx)%nid ) +istatus = NF90_DEF_DIM( tpfile%nncid, Trim( ydimname_clean ), Int( klen, kind = CDFINT ), tpfile%tncdims%tdims(kidx)%nid ) if ( istatus /= NF90_NOERR ) & - call IO_Err_handle_nc4( istatus, 'IO_Add_dim_nc4', 'NF90_DEF_DIM', Trim( hdimname ) ) + call IO_Err_handle_nc4( istatus, 'IO_Add_dim_nc4', 'NF90_DEF_DIM', Trim( ydimname_clean ) ) end subroutine IO_Add_dim_nc4 @@ -653,7 +656,8 @@ integer(kind=CDFINT), intent(in) :: klen CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: HDIMNAME integer, intent(out) :: kidx !Position of the dimension in the dimension array -character(len=16) :: ysuffix +character(len=:), allocatable :: ydimname_clean +character(len=16) :: ysuffix integer :: inewsize integer :: ji integer(kind=CDFINT) :: istatus @@ -662,10 +666,12 @@ type(tdimnc), dimension(:), allocatable :: tzncdims kidx = -1 +if ( Present( hdimname ) ) call IO_Mnhname_clean( hdimname, ydimname_clean ) + do ji = 1, Size( tpfile%tncdims%tdims ) if ( tpfile%tncdims%tdims(ji)%nlen == klen ) then if ( Present( hdimname ) ) then - if ( hdimname == Trim( tpfile%tncdims%tdims(ji)%cname ) ) then + if ( ydimname_clean == Trim( tpfile%tncdims%tdims(ji)%cname ) ) then kidx = ji exit end if @@ -680,9 +686,9 @@ if ( kidx == - 1 ) then !Check if already exist with the provided name (if so => error) if ( Present( hdimname ) ) then do ji = 1, Size( tpfile%tncdims%tdims ) - if ( hdimname == Trim( tpfile%tncdims%tdims(ji)%cname ) ) & + if ( ydimname_clean == Trim( tpfile%tncdims%tdims(ji)%cname ) ) & call Print_msg( NVERB_ERROR, 'IO', 'IO_Dim_find_create_nc4', 'dimension ' & - // Trim( hdimname ) // ' already exist but with a different size' ) + // Trim( ydimname_clean ) // ' already exist but with a different size' ) end do end if @@ -692,7 +698,7 @@ if ( kidx == - 1 ) then tzncdims(1 : inewsize - 1) = tpfile%tncdims%tdims(:) if ( Present( hdimname ) ) then - tzncdims(inewsize)%cname = Trim( hdimname ) + tzncdims(inewsize)%cname = Trim( ydimname_clean ) else Write( ysuffix, '( i0 )' ) klen tzncdims(inewsize)%cname = 'size' // Trim( ysuffix ) diff --git a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 index d39785fbe6b4b52ac91be0ccff669351a7446e91..cc24abb6fb9727634dcf7b04dfc413c34ba28049 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_write_nc4.f90 @@ -2281,11 +2281,14 @@ subroutine Write_flyer_time_coord( tpflyer ) use modd_aircraft_balloon use modd_parameters, only: NBUNAMELGTMAX, XUNDEF + use mode_io_tools_nc4, only: IO_Mnhname_clean + use modi_aircraft_balloon, only: Aircraft_balloon_longtype_get type(flyer), intent(in) :: tpflyer character(len=NBUNAMELGTMAX) :: ytype + character(len=NBUNAMELGTMAX) :: ytype_clean integer :: istatus integer(kind=CDFINT) :: icatid integer(kind=CDFINT) :: isubcatid @@ -2303,10 +2306,11 @@ subroutine Write_flyer_time_coord( tpflyer ) end if call Aircraft_balloon_longtype_get( tpflyer, ytype ) - istatus = NF90_INQ_NCID( icatid, Trim( ytype ), isubcatid ) + call IO_Mnhname_clean( ytype, ytype_clean ) + istatus = NF90_INQ_NCID( icatid, Trim( ytype_clean ), isubcatid ) if ( istatus /= NF90_NOERR ) then call Print_msg( NVERB_ERROR, 'IO', 'Write_flyer_time_coord', & - Trim( tpfile%cname ) // ': group ' // Trim( ytype ) // ' not found' ) + Trim( tpfile%cname ) // ': group ' // Trim( ytype_clean ) // ' not found' ) end if istatus = NF90_INQ_NCID( isubcatid, Trim( tpflyer%title ), incid ) diff --git a/src/MNH/mode_les_diachro.f90 b/src/MNH/mode_les_diachro.f90 index 3ca1897c8164f7bc0d1e9b466452e57f217afd23..4a46449ecd24b3f154af5632c534635868da7045 100644 --- a/src/MNH/mode_les_diachro.f90 +++ b/src/MNH/mode_les_diachro.f90 @@ -1301,7 +1301,7 @@ tzbudiachro%clevels (NLVL_GROUP) = '' tzbudiachro%ccomments(NLVL_GROUP) = '' tzbudiachro%lleveluse(NLVL_SHAPE) = .true. -tzbudiachro%clevels (NLVL_SHAPE) = '2-point correlation' +tzbudiachro%clevels (NLVL_SHAPE) = 'Two-point correlation' tzbudiachro%ccomments(NLVL_SHAPE) = '' tzbudiachro%lleveluse(NLVL_TIMEAVG) = .true. diff --git a/src/MNH/write_diachro.f90 b/src/MNH/write_diachro.f90 index 0c3eca9ce17a8c6b2bfc59f045185b69a266ef93..3cccf5f833182f4cd6396d0ee8a68b03d1043716 100644 --- a/src/MNH/write_diachro.f90 +++ b/src/MNH/write_diachro.f90 @@ -1795,45 +1795,48 @@ use NETCDF, only: NF90_GET_ATT, NF90_INQUIRE_ATTRIBUTE, NF90_PUT_ATT, use modd_precision, only: CDFINT -use mode_io_tools_nc4, only: IO_Err_handle_nc4 +use mode_io_tools_nc4, only: IO_Err_handle_nc4, IO_Mnhname_clean character(len=*), intent(in) :: hlevel integer(kind=CDFINT), intent(in) :: kgrpid character(len=*), intent(in) :: hattname character(len=*), intent(in) :: hdata +character(len=Len(hattname)) :: yattname character(len=:), allocatable :: yatt integer(kind=CDFINT) :: ilen integer(kind=CDFINT) :: istatus integer(kind=CDFINT) :: itype -istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, hattname, xtype = itype, len = ilen ) +call IO_Mnhname_clean( hattname, yattname ) + +istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, yattname, xtype = itype, len = ilen ) if (istatus == NF90_NOERR ) then - call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' already exists for ' // Trim( hlevel ) ) + call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // yattname // ' already exists for ' // Trim( hlevel ) ) if ( itype /= NF90_CHAR ) then - call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // hattname // & + call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // yattname // & ' has changed for ' // Trim( hlevel ) ) return end if Allocate( character(len=ilen) :: yatt ) - istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, hattname, yatt ) + istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, yattname, yatt ) if ( yatt == Trim( hdata ) ) then - call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' is unchanged for ' // Trim( hlevel ) ) + call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // yattname // ' is unchanged for ' // Trim( hlevel ) ) !If unchanged, no need to write it again => return return else - cmnhmsg(1) = 'attribute ' // hattname // ' has changed for ' // Trim( hlevel ) + cmnhmsg(1) = 'attribute ' // yattname // ' has changed for ' // Trim( hlevel ) cmnhmsg(2) = yatt // ' -> ' // Trim( hdata ) call Print_msg( NVERB_WARNING, 'IO', 'Write_diachro_nc4' ) end if end if -istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, hattname, Trim( hdata ) ) +istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, yattname, Trim( hdata ) ) if (istatus /= NF90_NOERR ) & - call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( hattname ) // ' for '// Trim( hlevel ) // ' group' ) + call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( yattname ) // ' for '// Trim( hlevel ) // ' group' ) end subroutine Att_write_c0 @@ -1843,50 +1846,53 @@ use NETCDF, only: NF90_GET_ATT, NF90_INQUIRE_ATTRIBUTE, NF90_PUT_ATT, use modd_precision, only: CDFINT, MNHINT_NF90 -use mode_io_tools_nc4, only: IO_Err_handle_nc4 +use mode_io_tools_nc4, only: IO_Err_handle_nc4, IO_Mnhname_clean character(len=*), intent(in) :: hlevel integer(kind=CDFINT), intent(in) :: kgrpid character(len=*), intent(in) :: hattname integer, intent(in) :: kdata +character(len=Len(hattname)) :: yattname integer :: iatt integer(kind=CDFINT) :: ilen integer(kind=CDFINT) :: istatus integer(kind=CDFINT) :: itype -istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, hattname, xtype = itype, len = ilen ) +call IO_Mnhname_clean( hattname, yattname ) + +istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, yattname, xtype = itype, len = ilen ) if (istatus == NF90_NOERR ) then - call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' already exists for ' // Trim( hlevel ) ) + call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // yattname // ' already exists for ' // Trim( hlevel ) ) if ( itype /= MNHINT_NF90 ) then - call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // hattname // & + call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // yattname // & ' has changed for ' // Trim( hlevel ) ) return end if if ( ilen /= 1 ) then - call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'size of attribute ' // hattname // & + call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'size of attribute ' // yattname // & ' has changed for ' // Trim( hlevel ) ) return end if - istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, hattname, iatt ) + istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, yattname, iatt ) if ( iatt == kdata ) then - call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' is unchanged for ' // Trim( hlevel ) ) + call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // yattname // ' is unchanged for ' // Trim( hlevel ) ) !If unchanged, no need to write it again => return return else - cmnhmsg(1) = 'attribute ' // hattname // ' has changed for ' // Trim( hlevel ) + cmnhmsg(1) = 'attribute ' // yattname // ' has changed for ' // Trim( hlevel ) Write( cmnhmsg(2), '( I0, " -> ", I0 )' ) iatt, kdata call Print_msg( NVERB_WARNING, 'IO', 'Write_diachro_nc4' ) end if end if -istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, hattname, kdata ) +istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, yattname, kdata ) if (istatus /= NF90_NOERR ) & - call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( hattname ) // ' for '// Trim( hlevel ) // ' group' ) + call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( yattname ) // ' for '// Trim( hlevel ) // ' group' ) end subroutine Att_write_i0 @@ -1896,50 +1902,53 @@ use NETCDF, only: NF90_GET_ATT, NF90_INQUIRE_ATTRIBUTE, NF90_PUT_ATT, use modd_precision, only: CDFINT, MNHREAL_NF90 -use mode_io_tools_nc4, only: IO_Err_handle_nc4 +use mode_io_tools_nc4, only: IO_Err_handle_nc4, IO_Mnhname_clean character(len=*), intent(in) :: hlevel integer(kind=CDFINT), intent(in) :: kgrpid character(len=*), intent(in) :: hattname real, intent(in) :: pdata +character(len=Len(hattname)) :: yattname integer(kind=CDFINT) :: ilen integer(kind=CDFINT) :: istatus integer(kind=CDFINT) :: itype real :: zatt -istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, hattname, xtype = itype, len = ilen ) +call IO_Mnhname_clean( hattname, yattname ) + +istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, yattname, xtype = itype, len = ilen ) if (istatus == NF90_NOERR ) then - call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' already exists for ' // Trim( hlevel ) ) + call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // yattname // ' already exists for ' // Trim( hlevel ) ) if ( itype /= MNHREAL_NF90 ) then - call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // hattname // & + call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // yattname // & ' has changed for ' // Trim( hlevel ) ) return end if if ( ilen /= 1 ) then - call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'size of attribute ' // hattname // & + call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'size of attribute ' // yattname // & ' has changed for ' // Trim( hlevel ) ) return end if - istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, hattname, zatt ) + istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, yattname, zatt ) if ( zatt == pdata ) then - call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' is unchanged for ' // Trim( hlevel ) ) + call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // yattname // ' is unchanged for ' // Trim( hlevel ) ) !If unchanged, no need to write it again => return return else - cmnhmsg(1) = 'attribute ' // hattname // ' has changed for ' // Trim( hlevel ) + cmnhmsg(1) = 'attribute ' // yattname // ' has changed for ' // Trim( hlevel ) Write( cmnhmsg(2), '( F15.7, " -> ", F15.7 )' ) zatt, pdata call Print_msg( NVERB_WARNING, 'IO', 'Write_diachro_nc4' ) end if end if -istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, hattname, pdata ) +istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, yattname, pdata ) if (istatus /= NF90_NOERR ) & - call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( hattname ) // ' for '// Trim( hlevel ) // ' group' ) + call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( yattname ) // ' for '// Trim( hlevel ) // ' group' ) end subroutine Att_write_x0 @@ -1949,27 +1958,30 @@ use NETCDF, only: NF90_DEF_GRP, NF90_INQ_NCID, NF90_NOERR use modd_precision, only: CDFINT -use mode_io_tools_nc4, only: IO_Err_handle_nc4 +use mode_io_tools_nc4, only: IO_Err_handle_nc4, IO_Mnhname_clean integer(kind=CDFINT), intent(in) :: kpreviouslevelid logical, intent(in) :: gpreviousleveldefined logical, intent(in) :: oleveluse +! character(len=*), intent(inout) :: hlevelname character(len=*), intent(in) :: hlevelname logical, intent(out) :: gleveldefined integer(kind=CDFINT), intent(out) :: klevelid +character(len=Len(hlevelname)) :: ylevelname integer(kind=CDFINT) :: istatus +call IO_Mnhname_clean( hlevelname, ylevelname ) if ( oleveluse ) then - istatus = NF90_INQ_NCID( kpreviouslevelid, Trim( hlevelname ), klevelid ) + istatus = NF90_INQ_NCID( kpreviouslevelid, Trim( ylevelname ), klevelid ) if ( istatus == NF90_NOERR ) then gleveldefined = .true. else gleveldefined = .false. - istatus = NF90_DEF_GRP( kpreviouslevelid, Trim( hlevelname ), klevelid ) + istatus = NF90_DEF_GRP( kpreviouslevelid, Trim( ylevelname ), klevelid ) if ( istatus /= NF90_NOERR ) & - call IO_Err_handle_nc4( istatus, 'Move_to_next_level', 'NF90_DEF_GRP', 'for ' // Trim( hlevelname ) ) + call IO_Err_handle_nc4( istatus, 'Move_to_next_level', 'NF90_DEF_GRP', 'for ' // Trim( ylevelname ) ) end if else gleveldefined = gpreviousleveldefined