From a032396596cbb0972bdedccb8e80f9ef9013b525 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Fri, 14 Jul 2023 18:17:43 -0400 Subject: [PATCH 1/2] HEMCO netCDF utilities now use netCDF-Fortran90 (aka NF90) interface src/Core/hcoio_write_std_mod.F90 - Set Compress=.FALSE. for the P0 variable. This prevents a netCDF error when netCDF tries to compress a zero-dimension variable. src/shared/NcdfUtil/hco_m_netcdf_*.F90 - Replaced"INCLUDE netcdf.inc" with "use netCDF" - Now use the NF90_ function and variables CHANGELOG.md - Updated accordingly Signed-off-by: Bob Yantosca --- CHANGELOG.md | 4 + src/Core/hcoio_write_std_mod.F90 | 2 +- .../NcdfUtil/hco_m_netcdf_io_checks.F90 | 73 +- src/Shared/NcdfUtil/hco_m_netcdf_io_close.F90 | 17 +- .../NcdfUtil/hco_m_netcdf_io_create.F90 | 44 +- .../NcdfUtil/hco_m_netcdf_io_define.F90 | 329 ++-- .../NcdfUtil/hco_m_netcdf_io_get_dimlen.F90 | 49 +- .../NcdfUtil/hco_m_netcdf_io_handle_err.F90 | 7 +- src/Shared/NcdfUtil/hco_m_netcdf_io_open.F90 | 26 +- src/Shared/NcdfUtil/hco_m_netcdf_io_read.F90 | 1546 ++++++++--------- .../NcdfUtil/hco_m_netcdf_io_readattr.F90 | 187 +- src/Shared/NcdfUtil/hco_ncdf_mod.F90 | 52 +- src/Shared/NcdfUtil/m_do_err_out.F90 | 2 +- 13 files changed, 1111 insertions(+), 1227 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c76a252..b20f4b79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Changed +- NetCDF routines in `src/Shared/NcdfUtil` now use the Fortran-90 API + ## [Unreleased 3.7.1] - TBD ### Changed - Updated version numbers to 3.7.1 diff --git a/src/Core/hcoio_write_std_mod.F90 b/src/Core/hcoio_write_std_mod.F90 index 5119f8d0..14b7688f 100644 --- a/src/Core/hcoio_write_std_mod.F90 +++ b/src/Core/hcoio_write_std_mod.F90 @@ -547,7 +547,7 @@ SUBROUTINE HCOIO_Write( HcoState, ForceWrite, & VarUnit = 'Pa', & DataType = dp, & VarCt = VarCt, & - Compress = .TRUE. ) + Compress = .FALSE. ) CALL NC_Var_Write( fId, 'P0', P0 ) ! Deallocate arrays diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_checks.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_checks.F90 index b3fdb2ee..e8115926 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_checks.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_checks.F90 @@ -1,5 +1,5 @@ !------------------------------------------------------------------------------ -! NcdfUtilities: by Harvard Atmospheric Chemistry Modeling Group ! +! Ncdfutilities: by Harvard Atmospheric Chemistry Modeling Group ! ! and NASA/GSFC, SIVO, Code 610.3 ! !------------------------------------------------------------------------------ !BOP @@ -44,9 +44,7 @@ module HCO_m_netcdf_io_checks ! function Ncdoes_Udim_Exist (ncid) ! - implicit none -! - include "netcdf.inc" + use netCDF ! ! !INPUT PARAMETERS: !! ncid : netCDF file id to check @@ -69,19 +67,12 @@ function Ncdoes_Udim_Exist (ncid) !BOC ! ! !LOCAL VARIABLES: - integer :: ierr - integer :: udimid -! - ierr = Nf_Inq_Unlimdim (ncid, udimid) - - if (ierr == NF_NOERR) then - Ncdoes_Udim_Exist = .true. - else - Ncdoes_Udim_Exist = .false. - end if - - return + integer :: ierr, udim_id + Ncdoes_Udim_Exist = .false. + ierr = NF90_Inquire(ncid, unlimitedDimId=udim_id) + IF ( ierr /= NF90_NOERR ) Ncdoes_Udim_Exist = .true. + end function Ncdoes_Udim_Exist !EOC !------------------------------------------------------------------------------ @@ -96,9 +87,7 @@ end function Ncdoes_Udim_Exist ! function Ncdoes_Var_Exist (ncid, varname) ! - implicit none -! - include "netcdf.inc" + use netCDF ! ! !INPUT PARAMETERS: !! ncid : netCDF file id to check @@ -126,15 +115,9 @@ function Ncdoes_Var_Exist (ncid, varname) integer :: ierr integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) - - if (ierr == NF_NOERR) then - Ncdoes_Var_Exist = .true. - else - Ncdoes_Var_Exist = .false. - end if - - return + ierr = NF90_Inq_Varid(ncid, varname, varid) + Ncdoes_Var_Exist = .false. + if (ierr == NF90_NOERR) Ncdoes_Var_Exist = .true. end function Ncdoes_Var_Exist !EOC @@ -148,11 +131,9 @@ end function Ncdoes_Var_Exist ! ! !INTERFACE: ! - function Ncdoes_Attr_Exist (ncid, varname, attname, attType) + function Ncdoes_Attr_Exist(ncid, varname, attname, attType) ! - implicit none -! - include "netcdf.inc" + use netCDF ! ! !INPUT PARAMETERS: !! ncid : netCDF file id to check @@ -185,27 +166,24 @@ function Ncdoes_Attr_Exist (ncid, varname, attname, attType) !BOC ! ! !LOCAL VARIABLES: - integer :: ierr - integer :: varid - INTEGER :: attLen + INTEGER :: ierr, varId, attLen, attNum ! Init Ncdoes_Attr_Exist = .false. attType = -1 ! First check the variable - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_Varid (ncid, varname, varid) ! Check the attribute if variable was found - IF ( ierr == NF_NOERR ) THEN - ierr = Nf_Inq_Att( ncId, varId, attName, attType, attLen ) - IF ( ierr == NF_NOERR ) THEN + IF ( ierr == NF90_NOERR ) THEN + ierr = NF90_Inquire_Attribute( ncId, varId, attName, & + attType, attLen, attNum ) + IF ( ierr == NF90_NOERR ) THEN NcDoes_Attr_Exist = .TRUE. ENDIF ENDIF - return - end function Ncdoes_Attr_Exist !EOC !------------------------------------------------------------------------------ @@ -220,9 +198,7 @@ end function Ncdoes_Attr_Exist ! function Ncdoes_Dim_Exist (ncid, dimname ) ! - implicit none -! - include "netcdf.inc" + use netCDF ! ! !INPUT PARAMETERS: !! ncid : netCDF file id to check @@ -251,14 +227,11 @@ function Ncdoes_Dim_Exist (ncid, dimname ) integer :: dimid ! First check the variable - ierr = Nf_Inq_Dimid (ncid, dimname, dimid) + ierr = NF90_Inq_Dimid(ncid, dimname, dimid) ! Check the attribute if variable was found - if (ierr == NF_NOERR) then - Ncdoes_Dim_Exist = .true. - else - Ncdoes_Dim_Exist = .false. - end if + Ncdoes_Dim_Exist = .false. + if (ierr == NF90_NOERR) Ncdoes_Dim_Exist = .true. return diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_close.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_close.F90 index 81e2f9d3..4f593a8d 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_close.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_close.F90 @@ -44,11 +44,8 @@ subroutine Nccl (ncid) ! ! !USES: ! + use netCDF use m_do_err_out -! - implicit none -! - include "netcdf.inc" ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -70,10 +67,10 @@ subroutine Nccl (ncid) character (len=512) :: err_msg integer :: ierr ! - ierr = Nf_Close (ncid) + ierr = Nf90_Close (ncid) - if (ierr /= NF_NOERR) then - err_msg = 'In Nccl: ' // Nf_Strerror (ierr) + if (ierr /= NF90_NOERR) then + err_msg = 'In Nccl: ' // Nf90_Strerror (ierr) call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) end if @@ -93,9 +90,7 @@ end subroutine Nccl ! subroutine Nccl_Noerr (ncid) ! - implicit none -! - include "netcdf.inc" + use netCDF ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -117,7 +112,7 @@ subroutine Nccl_Noerr (ncid) ! !LOCAL VARIABLES: integer :: ierr ! - ierr = Nf_Close (ncid) + ierr = Nf90_Close (ncid) return diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_create.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_create.F90 index ccf91853..024480e6 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_create.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_create.F90 @@ -44,18 +44,15 @@ subroutine Nccr_Wr (ncid, filname, WRITE_NC4) ! ! !USES: ! + use netCDF use m_do_err_out -! - implicit none -! - include "netcdf.inc" ! ! !INPUT PARAMETERS: ! ncid : opened netCDF file id ! filname : name of netCDF file to open for writing - integer , intent(in) :: ncid - character (len=*), intent(in) :: filname - LOGICAL, OPTIONAL, INTENT(IN) :: WRITE_NC4 + integer , intent(INOUT) :: ncid + character (len=*), intent(IN) :: filname + LOGICAL, OPTIONAL, INTENT(IN) :: WRITE_NC4 ! ! !DESCRIPTION: Creates a netCDF file for writing and does some error checking. !\\ @@ -64,10 +61,10 @@ subroutine Nccr_Wr (ncid, filname, WRITE_NC4) ! John Tannahill (LLNL) and Jules Kouatchou ! ! !REMARKS: -! If the netCDF4 library is used, then the NF_CLOBBER flag will write +! If the netCDF4 library is used, then the NF90_CLOBBER flag will write ! a classic (i.e. netCDF3) file. Use OR(NF_NETCDF4,NF_CLASSIC_MODEL) to -! create netCDF-4 file that supports compression and uses "classic" netcdf data model -! (no groups, no user-defined types) +! create netCDF-4 file that supports compression and uses "classic" +! netcdf data model (no groups, no user-defined types) ! ! !REVISION HISTORY: ! See https://github.com/geoschem/ncdfutil for complete history @@ -91,17 +88,17 @@ subroutine Nccr_Wr (ncid, filname, WRITE_NC4) IF ( TMP_NC4 ) THEN #if defined( NC_HAS_COMPRESSION ) - mode = IOR( NF_NETCDF4, NF_CLASSIC_MODEL ) ! netCDF4 file - ierr = Nf_Create (filname, mode, ncid) ! w/ compression + mode = IOR( NF90_NETCDF4, NF90_CLASSIC_MODEL ) ! netCDF4 file + ierr = NF90_Create(filname, mode, ncid) ! w/ compression #else - ierr = Nf_Create (filname, NF_64BIT_OFFSET, ncid) ! netCDF4 file - ! w/o compression + ierr = NF90_Create(filname, NF90_64BIT_OFFSET, ncid) ! netCDF4 file + ! w/o compression #endif ELSE - ierr = Nf_Create (filname, NF_CLOBBER, ncid) ! netCDF3 file + ierr = NF90_Create(filname, NF90_CLOBBER, ncid) ! netCDF3 file ENDIF - if (ierr /= NF_NOERR) then + if (ierr /= NF90_NOERR) then err_msg = 'In Nccr_Wr, cannot create: ' // Trim (filname) call Do_Err_Out (err_msg, .true., 0, 0, 0, 0 , 0.0d0, 0.0d0) end if @@ -120,15 +117,12 @@ end subroutine Nccr_Wr ! ! !INTERFACE: ! - subroutine Ncdo_Sync (ncid) + subroutine Ncdo_Sync(ncid) ! ! !USES: ! + use netCDF use m_do_err_out -! - implicit none -! - include "netcdf.inc" ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -150,15 +144,13 @@ subroutine Ncdo_Sync (ncid) character (len=128) :: err_msg integer :: ierr ! - ierr = Nf_Sync (ncid) + ierr = Nf90_Sync (ncid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncdo_Sync: ' // Nf_Strerror (ierr) + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncdo_Sync: ' // Nf90_Strerror (ierr) call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) end if - return - end subroutine Ncdo_Sync !EOC end module HCO_m_netcdf_io_create diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 index 02c399cf..97eb4ef1 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 @@ -89,11 +89,8 @@ SUBROUTINE NcDef_dimension(ncid,name,len,id,unlimited) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -130,14 +127,14 @@ SUBROUTINE NcDef_dimension(ncid,name,len,id,unlimited) len0 = len if (present(unlimited)) then if (unlimited) then - len0 = NF_UNLIMITED + len0 = NF90_UNLIMITED endif endif - ierr = Nf_Def_Dim (ncid, name, len0, id) + ierr = NF90_Def_Dim(ncid, name, len0, id) - IF (ierr.ne.NF_NOERR) then - err_msg = 'Nf_Def_Dim: can not define dimension : '// Trim (name) + IF (ierr.ne.NF90_NOERR) then + err_msg = 'NF90_Def_Dim: can not define dimension : '// Trim (name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) END IF @@ -153,33 +150,30 @@ END SUBROUTINE NcDef_dimension ! ! !INTERFACE: ! - SUBROUTINE NcDef_variable(ncid,name,type,ndims,dims,var_id,compress) + SUBROUTINE NcDef_variable(ncid, name, xtype, ndims, dims, var_id, compress) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: ! !! ncid : netCDF file id !! name : name of the variable !! type : type of the variable -!! (NF_FLOAT, NF_CHAR, NF_INT, NF_DOUBLE, NF_BYTE, NF_SHORT) +!! (NF90_FLOAT, NF90_CHAR, NF90_INT, NF90_DOUBLE, NF90_BYTE, NF90_SHORT) !! ndims : number of dimensions of the variable !! dims : netCDF dimension id of the variable CHARACTER (LEN=*), INTENT(IN) :: name INTEGER, INTENT(IN) :: ncid, ndims INTEGER, INTENT(IN) :: dims(ndims) - INTEGER, INTENT(IN) :: type + INTEGER, INTENT(IN) :: xtype LOGICAL, OPTIONAL, INTENT(IN) :: compress ! ! !OUTPUT PARAMETERS: ! -!! varid : netCDF variable id returned by NF_DEF_VAR +!! varid : netCDF variable id returned by NF90_DEF_VAR INTEGER, INTENT(OUT) :: var_id ! ! !DESCRIPTION: Defines a netCDF variable. @@ -195,58 +189,75 @@ SUBROUTINE NcDef_variable(ncid,name,type,ndims,dims,var_id,compress) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - logical :: doStop - ! Compression settings - ! choose deflate_level=1 for fast, minimal compression. - ! Informal testing suggests minimal benefit from higher compression level - integer, parameter :: shuffle=1, deflate=1, deflate_level=1 -! - ierr = Nf_Def_Var (ncid, name, type, ndims, dims, var_id) - - IF (ierr.ne.NF_NOERR) THEN - err_msg = 'Nf_Def_Var: can not define variable : '// Trim (name) - CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) - END IF + character(len=512) :: err_msg + integer :: ierr + logical :: doStop -#if defined( NC_HAS_COMPRESSION ) +#ifdef NC_HAS_COMPRESSION !===================================================================== ! If the optional "compress" variable is used and set to TRUE, ! then enable variable compression (cdh, 0/17/17) ! ! NOTE: We need to block this out with an #ifdef because some - ! netCDF installations might lack the nf_def_var_deflate function + ! netCDF installations might lack the NF90_def_var_deflate function ! which would cause a compile-time error. (bmy, 3/1/17) ! ! ALSO NOTE: Newer versions of netCDF balk when you try to compress ! a scalar variable. This generates an annoying warning message. ! To avoid this, only compress array variables. (bmy, 11/30/20) !===================================================================== - if (present(Compress) .and. ndims > 0) then + if ( PRESENT( Compress ) ) then - if (Compress) then + ! Skip compression for zero-dimension variables + IF ( Compress .and. ndims > 0 ) THEN - ! Set compression - ierr = nf_def_var_deflate( ncid, var_id, shuffle, & - deflate, deflate_level ) + ! Define variable with deflation (aka compression). + ! Choose deflate_level=1 for fast, minimal deflation. + ! Testing shows minimal benefit from higher deflation levels. + ierr = NF90_Def_Var( ncid, name, xtype, dims, var_id, & + shuffle=.TRUE., deflate_level=1 ) ! Check for errors. ! No message will be generated if the error is simply that the ! file is not netCDF-4 ! (i.e. netCDF-3 don't support compression) - IF ( (ierr.ne.NF_NOERR) .and. (ierr.ne.NF_ENOTNC4)) THEN + IF ( (ierr.ne.NF90_NOERR) .and. (ierr.ne.NF90_ENOTNC4)) THEN ! Errors enabling compression will not halt the program doStop = .False. ! Print error - err_msg = 'Nf_Def_Var_Deflate: can not compress variable : '// Trim (name) + err_msg = 'NF90_Def_Var: can not create compressed variable : '//& + Trim(name) CALL Do_Err_Out (err_msg, doStop, 0, 0, 0, 0, 0.0d0, 0.0d0) END IF - endif - endif + ELSE + + ! Create uncompressed variable if COMPRESS = .FALSE. + ! or if the number of dimensions is zero + ierr = NF90_Def_Var( ncid, name, xtype, dims, var_id ) + IF ( ierr /= NF90_NOERR ) THEN + err_msg = 'NF90_Def_Var_Deflate: can not create variable : '// & + Trim (name) + CALL Do_Err_Out (err_msg, doStop, 0, 0, 0, 0, 0.0d0, 0.0d0) + ENDIF + + ENDIF + ENDIF + +#else + !===================================================================== + ! Define variable without compression if HEMCO was compiled + ! with netCDF deflation turned off. + !===================================================================== + ierr = NF90_Def_Var( ncid, name, xtype, dims, var_id ) + IF ( ierr /= NF90_NOERR ) THEN + err_msg = 'NF90_Def_Var_Deflate: can not create variable : '// & + Trim(name) + CALL Do_Err_Out (err_msg, doStop, 0, 0, 0, 0, 0.0d0, 0.0d0) + ENDIF + #endif END SUBROUTINE NcDef_variable @@ -261,14 +272,12 @@ END SUBROUTINE NcDef_variable ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_c(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_c(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -276,7 +285,7 @@ SUBROUTINE NcDef_var_attributes_c(ncid,var_id,att_name,att_val) !! att_name: attribute name !! att_val : attribute value CHARACTER (LEN=*), INTENT(IN) :: att_name, att_val - INTEGER, INTENT(IN) :: ncid, var_id + INTEGER, INTENT(IN) :: ncid, var_id ! ! !DESCRIPTION: Defines a netCDF variable attribute of type: CHARACTER. !\\ @@ -292,12 +301,11 @@ SUBROUTINE NcDef_var_attributes_c(ncid,var_id,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = LEN(att_val) - ierr = Nf_Put_Att_Text (ncid, var_id, att_name, mylen, att_val) + ierr = NF90_Put_Att(ncid, var_id, att_name, att_val) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr /= NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_c: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -315,10 +323,11 @@ END SUBROUTINE NcDef_var_attributes_c ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_i(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_i(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out ! IMPLICIT NONE @@ -350,11 +359,9 @@ SUBROUTINE NcDef_var_attributes_i(ncid,var_id,att_name,att_val) character (len=512) :: err_msg integer :: mylen, ierr ! - mylen = 1 - ierr = Nf_Put_Att_Int( ncid, var_id, att_name, & - NF_INT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, var_id, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_i: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -372,14 +379,12 @@ END SUBROUTINE NcDef_var_attributes_i ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_r4(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_r4(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out - - IMPLICIT NONE - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -405,13 +410,11 @@ SUBROUTINE NcDef_var_attributes_r4(ncid,var_id,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = 1 - ierr = Nf_Put_Att_Real( ncid, var_id, att_name, & - NF_FLOAT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, var_id, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_r4: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -429,14 +432,12 @@ END SUBROUTINE NcDef_var_attributes_r4 ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_r8(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_r8(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -462,13 +463,11 @@ SUBROUTINE NcDef_var_attributes_r8(ncid,var_id,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = 1 - ierr = Nf_Put_Att_Double( ncid, var_id, att_name, & - NF_DOUBLE, mylen, att_val ) + ierr = NF90_Put_Att( ncid, var_id, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_r8: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -486,14 +485,12 @@ END SUBROUTINE NcDef_var_attributes_r8 ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_i_arr(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_i_arr(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -519,13 +516,11 @@ SUBROUTINE NcDef_var_attributes_i_arr(ncid,var_id,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = SIZE( att_val ) - ierr = Nf_Put_Att_Int( ncid, var_id, att_name, & - NF_INT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, var_id, att_name, att_val ) - iF (ierr.ne.NF_NOERR) THEN + iF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_i_arr: can not define attribute : ' & // TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -543,14 +538,12 @@ END SUBROUTINE NcDef_var_attributes_i_arr ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_r4_arr(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_r4_arr(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -576,13 +569,11 @@ SUBROUTINE NcDef_var_attributes_r4_arr(ncid,var_id,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = SIZE( att_val ) - ierr = Nf_Put_Att_Real( ncid, var_id, att_name, & - NF_FLOAT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, var_id, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_r4_arr: can not define attribute : ' & // TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -600,14 +591,12 @@ END SUBROUTINE NcDef_var_attributes_r4_arr ! ! !INTERFACE: ! - SUBROUTINE NcDef_var_attributes_r8_arr(ncid,var_id,att_name,att_val) + SUBROUTINE NcDef_var_attributes_r8_arr(ncid, var_id, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -633,13 +622,11 @@ SUBROUTINE NcDef_var_attributes_r8_arr(ncid,var_id,att_name,att_val) ! ! !LOCAL VARIABLES: character (len=512) :: err_msg - integer :: mylen, ierr + integer :: ierr ! - mylen = size( att_val ) - ierr = Nf_Put_Att_Double( ncid, var_id, att_name, & - NF_DOUBLE, mylen, att_val ) + ierr = NF90_Put_Att( ncid, var_id, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_var_attributes_r4_arr: can not define attribute : '& // Trim (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -657,15 +644,12 @@ END SUBROUTINE NcDef_var_attributes_r8_arr ! ! !INTERFACE: ! - SUBROUTINE NcDef_glob_attributes_c(ncid,att_name,att_val) + SUBROUTINE NcDef_glob_attributes_c(ncid, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -691,12 +675,11 @@ SUBROUTINE NcDef_glob_attributes_c(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = len(att_val) - ierr = Nf_Put_Att_Text (ncid, NF_GLOBAL, att_name, mylen, att_val) + ierr = NF90_Put_Att(ncid, NF90_GLOBAL, att_name, att_val) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_c: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -714,15 +697,12 @@ END SUBROUTINE NcDef_glob_attributes_c ! ! !INTERFACE: ! - SUBROUTINE NcDef_glob_attributes_i(ncid,att_name,att_val) + SUBROUTINE NcDef_glob_attributes_i(ncid, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -748,13 +728,11 @@ SUBROUTINE NcDef_glob_attributes_i(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = 1 - ierr = Nf_Put_Att_Int( ncid, NF_GLOBAL, att_name, & - NF_INT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, NF90_GLOBAL, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_i: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -772,15 +750,12 @@ END SUBROUTINE NcDef_glob_attributes_i ! ! !INTERFACE: ! - SUBROUTINE NcDef_glob_attributes_r4(ncid,att_name,att_val) + SUBROUTINE NcDef_glob_attributes_r4(ncid, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -806,13 +781,11 @@ SUBROUTINE NcDef_glob_attributes_r4(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: character (len=512) :: err_msg - integer :: mylen, ierr + integer :: ierr ! - mylen = 1 - ierr = Nf_Put_Att_Real( ncid, NF_GLOBAL, att_name, & - NF_FLOAT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, NF90_GLOBAL, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_r4: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -830,15 +803,12 @@ END SUBROUTINE NcDef_glob_attributes_r4 ! ! !INTERFACE: ! - SUBROUTINE NcDef_glob_attributes_r8(ncid,att_name,att_val) + SUBROUTINE NcDef_glob_attributes_r8(ncid, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -864,13 +834,11 @@ SUBROUTINE NcDef_glob_attributes_r8(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: character (len=512) :: err_msg - integer :: mylen, ierr + integer :: ierr ! - mylen = 1 - ierr = Nf_Put_Att_Double( ncid, NF_GLOBAL, att_name, & - NF_FLOAT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, NF90_GLOBAL, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_r8: can not define attribute : ' // & TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -888,15 +856,12 @@ END SUBROUTINE NcDef_glob_attributes_r8 ! ! !INTERFACE: ! - SUBROUTINE NcDef_glob_attributes_i_arr(ncid,att_name,att_val) + SUBROUTINE NcDef_glob_attributes_i_arr(ncid, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -922,13 +887,11 @@ SUBROUTINE NcDef_glob_attributes_i_arr(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: CHARACTER (LEN=512) :: err_msg - INTEGER :: mylen, ierr + INTEGER :: ierr ! - mylen = SIZE( att_val ) - ierr = Nf_Put_Att_Int( ncid, NF_GLOBAL, att_name, & - NF_INT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, NF90_GLOBAL, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_i_arr: can not define attribute : ' & // Trim (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -950,11 +913,8 @@ SUBROUTINE NcDef_glob_attributes_r4_arr(ncid,att_name,att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -980,13 +940,11 @@ SUBROUTINE NcDef_glob_attributes_r4_arr(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: character (len=512) :: err_msg - integer :: mylen, ierr + integer :: ierr ! - mylen = SIZE( att_val ) - ierr = Nf_Put_Att_Real( ncid, NF_GLOBAL, att_name, & - NF_FLOAT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, NF90_GLOBAL, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_r4_arr: can not define attribute : ' & // TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -1004,15 +962,12 @@ END SUBROUTINE NcDef_glob_attributes_r4_arr ! ! !INTERFACE: ! - SUBROUTINE NcDef_glob_attributes_r8_arr(ncid,att_name,att_val) + SUBROUTINE NcDef_glob_attributes_r8_arr(ncid, att_name, att_val) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -1038,13 +993,11 @@ SUBROUTINE NcDef_glob_attributes_r8_arr(ncid,att_name,att_val) ! ! !LOCAL VARIABLES: character (len=512) :: err_msg - integer :: mylen, ierr + integer :: ierr ! - mylen = SIZE( att_val ) - ierr = Nf_Put_Att_Double( ncid, NF_GLOBAL, att_name, & - NF_FLOAT, mylen, att_val ) + ierr = NF90_Put_Att( ncid, NF90_GLOBAL, att_name, att_val ) - IF (ierr.ne.NF_NOERR) THEN + IF (ierr.ne.NF90_NOERR) THEN err_msg = 'NcDef_glob_attributes_r8_arr: can not define attribute : ' & // TRIM (att_name) CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) @@ -1062,19 +1015,17 @@ END SUBROUTINE NcDef_glob_attributes_r8_arr ! ! !INTERFACE: ! - SUBROUTINE NcSetFill(ncid,ifill,omode) + SUBROUTINE NcSetFill(ncid, ifill, omode) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: ! - INTEGER, INTENT(in) :: ncid, ifill,omode + INTEGER, INTENT(IN ) :: ncid, ifill + INTEGER, INTENT(INOUT) :: omode ! ! !DESCRIPTION: Sets fill method. !\\ @@ -1090,12 +1041,12 @@ SUBROUTINE NcSetFill(ncid,ifill,omode) ! ! !LOCAL VARIABLES: character (len=512) :: err_msg - integer :: mylen, ierr + integer :: mylen, ierr ! - ierr = Nf_Set_Fill (ncid, NF_NOFILL, omode) + ierr = NF90_Set_Fill(ncid, NF90_NOFILL, omode) - IF (ierr.ne.NF_NOERR) THEN - err_msg = 'Nf_Set_FIll: Error in omode ' + IF (ierr.ne.NF90_NOERR) THEN + err_msg = 'NF90_Set_FIll: Error in omode ' CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) END IF @@ -1115,11 +1066,8 @@ SUBROUTINE NcEnd_Def(ncid) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT NONE -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: ! @@ -1141,10 +1089,10 @@ SUBROUTINE NcEnd_Def(ncid) CHARACTER (LEN=512) :: err_msg INTEGER :: ierr ! - ierr = Nf_Enddef (ncid) + ierr = NF90_Enddef(ncid) - IF (ierr.ne.NF_NOERR) THEN - err_msg = 'Nf_EndDef: Error in closing netCDF define mode!' + IF (ierr.ne.NF90_NOERR) THEN + err_msg = 'NF90_EndDef: Error in closing netCDF define mode!' CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) END IF @@ -1164,11 +1112,8 @@ SUBROUTINE NcBegin_Def(ncid) ! ! !USES: ! + USE netCDF USE m_do_err_out -! - IMPLICIT none -! - INCLUDE 'netcdf.inc' ! ! !INPUT PARAMETERS: ! @@ -1192,10 +1137,10 @@ SUBROUTINE NcBegin_Def(ncid) character (len=512) :: err_msg integer :: ierr ! - ierr = Nf_Redef (ncid) + ierr = NF90_Redef (ncid) - IF (ierr.ne.NF_NOERR) THEN - err_msg = 'Nf_ReDef: Error in opening netCDF define mode!' + IF (ierr.ne.NF90_NOERR) THEN + err_msg = 'NF90_ReDef: Error in opening netCDF define mode!' CALL Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) END IF diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_get_dimlen.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_get_dimlen.F90 index 2e509746..9a86d189 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_get_dimlen.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_get_dimlen.F90 @@ -40,15 +40,12 @@ module HCO_m_netcdf_io_get_dimlen ! ! !INTERFACE: ! - subroutine Ncget_Dimlen (ncid, dim_name, dim_len ) + subroutine Ncget_Dimlen(ncid, dim_name, dim_len) ! ! !USES: ! + use netCDF use m_do_err_out -! - implicit none -! - include 'netcdf.inc' ! ! !INPUT PARAMETERS: !! dim_name : netCDF dimension name @@ -80,18 +77,18 @@ subroutine Ncget_Dimlen (ncid, dim_name, dim_len ) integer :: dimid integer :: ierr - ierr = Nf_Inq_Dimid (ncid, dim_name, dimid) + ierr = NF90_Inq_Dimid(ncid, dim_name, dimid) - if (ierr /= NF_NOERR ) then + if (ierr /= NF90_NOERR ) then err_msg = 'In Ncget_Dimlen #1: ' // Trim (dim_name) // & - ', ' // Nf_Strerror (ierr) + ', ' // NF90_Strerror (ierr) call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) end if - ierr = Nf_Inq_Dimlen (ncid, dimid, dim_len) + ierr = NF90_Inquire_Dimension(ncid, dimid, len=dim_len) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncget_Dimlen #2: ' // Nf_Strerror (ierr) + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncget_Dimlen #2: ' // NF90_Strerror (ierr) call Do_Err_Out (err_msg, .true., 2, ncid, dimid, 0, 0.0d0, 0.0d0) end if @@ -112,11 +109,8 @@ subroutine Ncget_Unlim_Dimlen (ncid, udim_len) ! ! !USES: ! + use netCDF use m_do_err_out -! - implicit none -! - include 'netcdf.inc' ! ! !INPUT PARAMETERS: !! ncid : netCDF file id @@ -139,25 +133,14 @@ subroutine Ncget_Unlim_Dimlen (ncid, udim_len) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: udimid -! - ierr = Nf_Inq_Unlimdim (ncid, udimid) + character(len=512) :: err_msg + integer :: ierr, udim_id - if (ierr /= NF_NOERR) then - err_msg = 'In Ncget_Unlim_Dimlen #1: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if - - ierr = Nf_Inq_Dimlen (ncid, udimid, udim_len) - - if (ierr /= NF_NOERR) then - err_msg = 'In Ncget_Unlim_Dimlen #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, udimid, 0, 0.0d0, 0.0d0) - end if - - return + udim_len = -1 + ierr = NF90_Inquire(ncid, unlimitedDimId=udim_id) + IF ( ierr /= NF90_NOERR ) THEN + ierr = NF90_Inquire_Dimension( ncid, udim_id, len=udim_len ) + ENDIF end subroutine Ncget_Unlim_Dimlen !EOC diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_handle_err.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_handle_err.F90 index 86474497..64719b7d 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_handle_err.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_handle_err.F90 @@ -43,11 +43,8 @@ subroutine Nchandle_Err (ierr) ! ! !USES: ! + use netCDF use m_do_err_out -! - implicit none -! - include "netcdf.inc" ! ! !INPUT PARAMETERS: ! ierr : netCDF error number @@ -68,7 +65,7 @@ subroutine Nchandle_Err (ierr) ! !LOCAL VARIABLES: character (len=512) :: err_msg ! - err_msg = 'In Nchandle_Err: ' // Nf_Strerror (ierr) + err_msg = 'In Nchandle_Err: ' // Nf90_Strerror (ierr) call Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_open.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_open.F90 index 31e8f65e..0d600b3b 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_open.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_open.F90 @@ -40,15 +40,12 @@ module HCO_m_netcdf_io_open ! ! !INTERFACE: ! - subroutine Ncop_Rd (ncid, filname) + subroutine Ncop_Rd (ncid, filname, rc) ! ! !USES: ! + USE netCDF use m_do_err_out -! - implicit none -! - include "netcdf.inc" ! ! !INPUT PARAMETERS: !! filname : name of netCDF file to open for reading @@ -57,6 +54,7 @@ subroutine Ncop_Rd (ncid, filname) ! !OUTPUT PARAMETERS: !! ncid : opened netCDF file id integer , intent (out) :: ncid + integer, optional :: rc ! ! !DESCRIPTION: Opens a netCDF file for reading and does some error checking. !\\ @@ -71,14 +69,15 @@ subroutine Ncop_Rd (ncid, filname) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr + character(len=512) :: err_msg + integer :: ierr ! - ierr = Nf_Open (filname, NF_NOWRITE, ncid) + ierr = Nf90_Open( filname, NF90_NOWRITE, ncid ) - if (ierr /= NF_NOERR) then + if (ierr /= NF90_NOERR) then err_msg = 'In Ncop_Rd, cannot open: ' // Trim (filname) call Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) + return end if return @@ -99,11 +98,8 @@ subroutine Ncop_Wr (ncid, filname) ! ! !USES: ! + USE netCDF use m_do_err_out -! - implicit none -! - include "netcdf.inc" ! ! !INPUT PARAMETERS: !! filname : name of netCDF file to open for reading @@ -130,9 +126,9 @@ subroutine Ncop_Wr (ncid, filname) character (len=512) :: err_msg integer :: ierr ! - ierr = Nf_Open (filname, NF_WRITE, ncid) + ierr = Nf90_Open (filname, NF90_WRITE, ncid) - if (ierr /= NF_NOERR) then + if (ierr /= NF90_NOERR) then err_msg = 'In Ncop_Rd, cannot open: ' // Trim (filname) call Do_Err_Out (err_msg, .true., 0, 0, 0, 0, 0.0d0, 0.0d0) end if diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_read.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_read.F90 index 73cf8e25..b7ed044e 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_read.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_read.F90 @@ -8,44 +8,44 @@ ! ! !INTERFACE: ! - MODULE HCO_m_netcdf_io_read +MODULE HCO_m_netcdf_io_read ! ! !USES: ! - IMPLICIT NONE - PRIVATE + IMPLICIT NONE + PRIVATE ! ! !PUBLIC MEMBER FUNCTIONS: ! - ! Public interface - PUBLIC :: NcRd - - ! Private methods overloaded by public interface - ! (see below for info about these routines & the arguments they take) - INTERFACE NcRd - MODULE PROCEDURE Ncrd_Scal - MODULE PROCEDURE Ncrd_Scal_Int - MODULE PROCEDURE Ncrd_1d_R8 - MODULE PROCEDURE Ncrd_1d_R4 - MODULE PROCEDURE Ncrd_1d_Int - MODULE PROCEDURE Ncrd_1d_Char - MODULE PROCEDURE Ncrd_2d_R8 - MODULE PROCEDURE Ncrd_2d_R4 - MODULE PROCEDURE Ncrd_2d_Int - MODULE PROCEDURE Ncrd_2d_Char - MODULE PROCEDURE Ncrd_3d_R8 - MODULE PROCEDURE Ncrd_3d_R4 - MODULE PROCEDURE Ncrd_3d_Int - MODULE PROCEDURE Ncrd_4d_R8 - MODULE PROCEDURE Ncrd_4d_R4 - MODULE PROCEDURE Ncrd_4d_Int - MODULE PROCEDURE Ncrd_5d_R8 - MODULE PROCEDURE Ncrd_5d_R4 - MODULE PROCEDURE Ncrd_6d_R8 - MODULE PROCEDURE Ncrd_6d_R4 - MODULE PROCEDURE Ncrd_7d_R8 - MODULE PROCEDURE Ncrd_7d_R4 - END INTERFACE + ! Public interface + PUBLIC :: NcRd + + ! Private methods overloaded by public interface + ! (see below for info about these routines & the arguments they take) + INTERFACE NcRd + MODULE PROCEDURE Ncrd_Scal + MODULE PROCEDURE Ncrd_Scal_Int + MODULE PROCEDURE Ncrd_1d_R8 + MODULE PROCEDURE Ncrd_1d_R4 + MODULE PROCEDURE Ncrd_1d_Int + MODULE PROCEDURE Ncrd_1d_Char + MODULE PROCEDURE Ncrd_2d_R8 + MODULE PROCEDURE Ncrd_2d_R4 + MODULE PROCEDURE Ncrd_2d_Int + MODULE PROCEDURE Ncrd_2d_Char + MODULE PROCEDURE Ncrd_3d_R8 + MODULE PROCEDURE Ncrd_3d_R4 + MODULE PROCEDURE Ncrd_3d_Int + MODULE PROCEDURE Ncrd_4d_R8 + MODULE PROCEDURE Ncrd_4d_R4 + MODULE PROCEDURE Ncrd_4d_Int + MODULE PROCEDURE Ncrd_5d_R8 + MODULE PROCEDURE Ncrd_5d_R4 + MODULE PROCEDURE Ncrd_6d_R8 + MODULE PROCEDURE Ncrd_6d_R4 + MODULE PROCEDURE Ncrd_7d_R8 + MODULE PROCEDURE Ncrd_7d_R4 + END INTERFACE NcRd ! ! !DESCRIPTION: Routines for reading variables in a netCDF file. !\\ @@ -67,25 +67,22 @@ MODULE HCO_m_netcdf_io_read ! ! !INTERFACE: ! - subroutine Ncrd_Scal (varrd_scal, ncid, varname) + subroutine Ncrd_Scal(varrd_scal, ncid, varname) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read variable from -!! varname : netCDF variable name - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname +!! ncid : netCDF file id to read variable from +!! varname : netCDF variable name + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname ! ! !OUTPUT PARAMETERS: -!! varrd_scal : variable to fill - real*8 , intent(out) :: varrd_scal +!! varrd_scal : variable to fill + real*8 , intent(out) :: varrd_scal ! ! !DESCRIPTION: Reads in a netCDF scalar variable. !\\ @@ -100,31 +97,31 @@ subroutine Ncrd_Scal (varrd_scal, ncid, varname) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid - real*4 :: varrd_scal_tmp + character (len=512) :: err_msg + integer :: ierr + integer :: varid + real*4 :: varrd_scal_tmp ! - ierr = Nf_Inq_Varid (ncid, varname, varid) - - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_Scal #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + ierr = NF90_Inq_VarId(ncid, varname, varid) - ierr = Nf_Get_Var_Real (ncid, varid, varrd_scal_tmp) + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_Scal #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_Scal #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + ierr = NF90_Get_Var(ncid, varid, varrd_scal_tmp) - varrd_scal = varrd_scal_tmp + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_Scal #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if + + varrd_scal = varrd_scal_tmp - return + return - end subroutine Ncrd_Scal + end subroutine Ncrd_Scal !EOC !------------------------------------------------------------------------- !BOP @@ -133,25 +130,22 @@ end subroutine Ncrd_Scal ! ! !INTERFACE: ! - subroutine Ncrd_Scal_Int (varrd_scali, ncid, varname) + subroutine Ncrd_Scal_Int(varrd_scali, ncid, varname) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read variable from -!! varname : netCDF variable name - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname +!! ncid : netCDF file id to read variable from +!! varname : netCDF variable name + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname ! ! !OUTPUT PARAMETERS: -!! varrd_scali : integer variable to fill - integer , intent(out) :: varrd_scali +!! varrd_scali : integer variable to fill + integer , intent(out) :: varrd_scali ! ! !DESCRIPTION: Reads in a netCDF integer scalar variable. !\\ @@ -166,28 +160,28 @@ subroutine Ncrd_Scal_Int (varrd_scali, ncid, varname) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_Scal_Int #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_Scal_Int #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if + + ierr = NF90_Get_Var(ncid, varid, varrd_scali) - ierr = Nf_Get_Var_Int (ncid, varid, varrd_scali) + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_Scal_Int #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_Scal_Int #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if - - return + return - end subroutine Ncrd_Scal_Int + end subroutine Ncrd_Scal_Int !EOC !------------------------------------------------------------------------- !BOP @@ -196,33 +190,29 @@ end subroutine Ncrd_Scal_Int ! ! !INTERFACE: ! - subroutine Ncrd_1d_R8 (varrd_1d, ncid, varname, strt1d, cnt1d, & - err_stop, stat) + subroutine Ncrd_1d_R8(varrd_1d, ncid, varname, strt1d, cnt1d, err_stop, stat) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt1d : vector specifying the index in varrd_1d where -!! the first of the data values will be read -!! cnt1d : varrd_1d dimension - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt1d(1) - integer , intent(in) :: cnt1d (1) - logical, optional, intent(in) :: err_stop +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt1d : vector specifying the index in varrd_1d where +!! the first of the data values will be read +!! cnt1d : varrd_1d dimension + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt1d(1) + integer , intent(in) :: cnt1d (1) + logical, optional, intent(in) :: err_stop ! ! !OUTPUT PARAMETERS: -!! varrd_1d : array to fill - real*8 , intent(out) :: varrd_1d(cnt1d(1)) - integer, optional, intent(out) :: stat +!! varrd_1d : array to fill + real*8 , intent(out) :: varrd_1d(cnt1d(1)) + integer, optional, intent(out) :: stat ! ! !DESCRIPTION: Reads in a 1D netCDF real array and does some error checking. !\\ @@ -238,49 +228,49 @@ subroutine Ncrd_1d_R8 (varrd_1d, ncid, varname, strt1d, cnt1d, & ! ! !LOCAL VARIABLES: ! - character (len=512) :: err_msg - integer :: ierr - integer :: varid - logical :: dostop + character (len=512) :: err_msg + integer :: ierr + integer :: varid + logical :: dostop - ! set dostop flag - if ( present ( err_stop ) ) then - dostop = err_stop - else - dostop = .true. - endif + ! set dostop flag + if ( present ( err_stop ) ) then + dostop = err_stop + else + dostop = .true. + endif - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - if ( dostop ) then + if (ierr /= NF90_NOERR) then + if ( dostop ) then err_msg = 'In Ncrd_1d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) + ', ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - else + else varrd_1d(:) = -999d0 if ( present ( stat ) ) stat = 1 return - end if - end if - - ierr = Nf_Get_Vara_Double (ncid, varid, strt1d, cnt1d, varrd_1d) - - if (ierr /= NF_NOERR) then - if ( dostop ) then - err_msg = 'In Ncrd_1d_R8 #2: ' // Nf_Strerror (ierr) + end if + end if + + ierr = NF90_Get_Var(ncid, varid, varrd_1d, start=strt1d, count=cnt1d) + + if (ierr /= NF90_NOERR) then + if ( dostop ) then + err_msg = 'In Ncrd_1d_R8 #2: ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - else + else varrd_1d(:) = -999d0 if ( present ( stat ) ) stat = 2 return - endif - end if - - ! set stat to 0 (= success) - if ( present ( stat ) ) stat = 0 - - end subroutine Ncrd_1d_R8 + endif + end if + + ! set stat to 0 (= success) + if ( present ( stat ) ) stat = 0 + + end subroutine Ncrd_1d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -289,33 +279,29 @@ end subroutine Ncrd_1d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_1d_R4 (varrd_1d, ncid, varname, strt1d, cnt1d, & - err_stop, stat) + subroutine Ncrd_1d_R4(varrd_1d, ncid, varname, strt1d, cnt1d, err_stop, stat) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt1d : vector specifying the index in varrd_1d where -!! the first of the data values will be read -!! cnt1d : varrd_1d dimension - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt1d(1) - integer , intent(in) :: cnt1d (1) - logical, optional, intent(in) :: err_stop +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt1d : vector specifying the index in varrd_1d where +!! the first of the data values will be read +!! cnt1d : varrd_1d dimension + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt1d(1) + integer , intent(in) :: cnt1d (1) + logical, optional, intent(in) :: err_stop ! ! !OUTPUT PARAMETERS: -!! varrd_1d : array to fill - real*4 , intent(out) :: varrd_1d(cnt1d(1)) - integer, optional, intent(out) :: stat +!! varrd_1d : array to fill + real*4 , intent(out) :: varrd_1d(cnt1d(1)) + integer, optional, intent(out) :: stat ! ! !DESCRIPTION: Reads in a 1D netCDF real array and does some error checking. !\\ @@ -331,50 +317,50 @@ subroutine Ncrd_1d_R4 (varrd_1d, ncid, varname, strt1d, cnt1d, & ! ! !LOCAL VARIABLES: ! - character (len=512) :: err_msg - integer :: ierr - integer :: varid - logical :: dostop - - ! set dostop flag - if ( present ( err_stop ) ) then - dostop = err_stop - else - dostop = .true. - endif - - ierr = Nf_Inq_Varid (ncid, varname, varid) - - if (ierr /= NF_NOERR) then - if ( dostop ) then - err_msg = 'In Ncrd_1d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - else + character (len=512) :: err_msg + integer :: ierr + integer :: varid + logical :: dostop + + ! set dostop flag + if ( present ( err_stop ) ) then + dostop = err_stop + else + dostop = .true. + endif + + ierr = NF90_Inq_VarId(ncid, varname, varid) + + if (ierr /= NF90_NOERR) then + if ( dostop ) then + err_msg = 'In Ncrd_1d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + else varrd_1d(:) = -999.0 if ( present ( stat ) ) stat = 1 return - end if - end if + end if + end if - ierr = Nf_Get_Vara_Real (ncid, varid, strt1d, cnt1d, varrd_1d) + ierr = NF90_Get_Var(ncid, varid, varrd_1d, start=strt1d, count=cnt1d) - if (ierr /= NF_NOERR) then - if ( dostop ) then - err_msg = 'In Ncrd_1d_R4 #2: ' // Nf_Strerror (ierr) + if (ierr /= NF90_NOERR) then + if ( dostop ) then + err_msg = 'In Ncrd_1d_R4 #2: ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - else + else varrd_1d(:) = -999.0 if ( present ( stat ) ) stat = 2 return - endif - end if + endif + end if - ! set stat to 0 (= success) - if ( present ( stat ) ) stat = 0 - return + ! set stat to 0 (= success) + if ( present ( stat ) ) stat = 0 + return - end subroutine Ncrd_1d_R4 + end subroutine Ncrd_1d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -383,34 +369,31 @@ end subroutine Ncrd_1d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_1d_Int (varrd_1di, ncid, varname, strt1d, cnt1d, & - err_stop, stat) + subroutine Ncrd_1d_Int(varrd_1di, ncid, varname, strt1d, & + cnt1d, err_stop, stat) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: ! -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt1d : vector specifying the index in varrd_1di where -!! the first of the data values will be read -!! cnt1d : varrd_1di dimension - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt1d(1) - integer , intent(in) :: cnt1d (1) - logical, optional, intent(in) :: err_stop +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt1d : vector specifying the index in varrd_1di where +!! the first of the data values will be read +!! cnt1d : varrd_1di dimension + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt1d(1) + integer , intent(in) :: cnt1d (1) + logical, optional, intent(in) :: err_stop ! ! !OUTPUT PARAMETERS: -!! varrd_1di : intger array to fill - integer , intent(out) :: varrd_1di(cnt1d(1)) - integer, optional, intent(out) :: stat +!! varrd_1di : intger array to fill + integer , intent(out) :: varrd_1di(cnt1d(1)) + integer, optional, intent(out) :: stat ! ! !DESCRIPTION: Reads in a 1D netCDF integer array and does some error ! checking. @@ -427,51 +410,51 @@ subroutine Ncrd_1d_Int (varrd_1di, ncid, varname, strt1d, cnt1d, & ! ! !LOCAL VARIABLES: ! - character (len=512) :: err_msg - integer :: ierr - integer :: varid - logical :: dostop + character (len=512) :: err_msg + integer :: ierr + integer :: varid + logical :: dostop - ! set dostop flag - if ( present ( err_stop ) ) then - dostop = err_stop - else - dostop = .true. - endif + ! set dostop flag + if ( present ( err_stop ) ) then + dostop = err_stop + else + dostop = .true. + endif - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - if ( dostop ) then + if (ierr /= NF90_NOERR) then + if ( dostop ) then err_msg = 'In Ncrd_1d_Int #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) + ', ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - else + else varrd_1di(:) = -999 if ( present ( stat ) ) stat = 1 return - end if - end if + end if + end if - ierr = Nf_Get_Vara_Int (ncid, varid, strt1d, cnt1d, varrd_1di) + ierr = NF90_Get_Var(ncid, varid, varrd_1di, start=strt1d, count=cnt1d) - if (ierr /= NF_NOERR) then - if ( dostop ) then - err_msg = 'In Ncrd_1d_Int #2: ' // Nf_Strerror (ierr) + if (ierr /= NF90_NOERR) then + if ( dostop ) then + err_msg = 'In Ncrd_1d_Int #2: ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - else + else varrd_1di(:) = -999 if ( present ( stat ) ) stat = 2 return - endif - end if + endif + end if - ! set stat to 0 (= success) - if ( present ( stat ) ) stat = 0 + ! set stat to 0 (= success) + if ( present ( stat ) ) stat = 0 - return + return - end subroutine Ncrd_1d_Int + end subroutine Ncrd_1d_Int !EOC !------------------------------------------------------------------------- !BOP @@ -480,30 +463,26 @@ end subroutine Ncrd_1d_Int ! ! !INTERFACE: ! - subroutine Ncrd_2d_R8 (varrd_2d, ncid, varname, strt2d, cnt2d) + subroutine Ncrd_2d_R8(varrd_2d, ncid, varname, strt2d, cnt2d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" -! -! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt2d : vector specifying the index in varrd_2d where + use netCDF + use m_do_err_out + +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt2d : vector specifying the index in varrd_2d where !! the first of the data values will be read -!! cnt2d : varrd_2d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt2d(2) - integer , intent(in) :: cnt2d (2) +!! cnt2d : varrd_2d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt2d(2) + integer , intent(in) :: cnt2d (2) ! ! !OUTPUT PARAMETERS: -!! varrd_2d : array to fill - real*8 , intent(out) :: varrd_2d(cnt2d(1), cnt2d(2)) +!! varrd_2d : array to fill + real*8 , intent(out) :: varrd_2d(cnt2d(1), cnt2d(2)) ! ! !DESCRIPTION: Reads in a 2D netCDF real array and does some error checking. !\\ @@ -518,26 +497,26 @@ subroutine Ncrd_2d_R8 (varrd_2d, ncid, varname, strt2d, cnt2d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_R8 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Double (ncid, varid, strt2d, cnt2d, varrd_2d) + ierr = NF90_Get_Var(ncid, varid, varrd_2d, start=strt2d, count=cnt2d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_R8 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_R8 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_2d_R8 + end subroutine Ncrd_2d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -546,30 +525,27 @@ end subroutine Ncrd_2d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_2d_R4 (varrd_2d, ncid, varname, strt2d, cnt2d) + subroutine Ncrd_2d_R4(varrd_2d, ncid, varname, strt2d, cnt2d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt2d : vector specifying the index in varrd_2d where -!! the first of the data values will be read -!! cnt2d : varrd_2d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt2d(2) - integer , intent(in) :: cnt2d (2) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt2d : vector specifying the index in varrd_2d where +!! the first of the data values will be read +!! cnt2d : varrd_2d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt2d(2) + integer , intent(in) :: cnt2d (2) ! ! !OUTPUT PARAMETERS: -!! varrd_2d : array to fill - real*4 , intent(out) :: varrd_2d(cnt2d(1), cnt2d(2)) +!! varrd_2d : array to fill + real*4 , intent(out) :: varrd_2d(cnt2d(1), cnt2d(2)) ! ! !DESCRIPTION: Reads in a 2D netCDF real array and does some error checking. !\\ @@ -584,26 +560,26 @@ subroutine Ncrd_2d_R4 (varrd_2d, ncid, varname, strt2d, cnt2d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Real (ncid, varid, strt2d, cnt2d, varrd_2d) + ierr = NF90_Get_Var(ncid, varid, varrd_2d, start=strt2d, count=cnt2d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_R4 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_R4 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_2d_R4 + end subroutine Ncrd_2d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -612,30 +588,27 @@ end subroutine Ncrd_2d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_2d_Int (varrd_2di, ncid, varname, strt2d, cnt2d) + subroutine Ncrd_2d_Int(varrd_2di, ncid, varname, strt2d, cnt2d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt2d : vector specifying the index in varrd_2d where -!! the first of the data values will be read -!! cnt2d : varrd_2di dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt2d(2) - integer , intent(in) :: cnt2d (2) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt2d : vector specifying the index in varrd_2d where +!! the first of the data values will be read +!! cnt2d : varrd_2di dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt2d(2) + integer , intent(in) :: cnt2d (2) ! ! !OUTPUT PARAMETERS: -!! varrd_2di : intger array to fill - integer , intent(out) :: varrd_2di(cnt2d(1), cnt2d(2)) +!! varrd_2di : intger array to fill + integer , intent(out) :: varrd_2di(cnt2d(1), cnt2d(2)) ! ! !DESCRIPTION: Reads in a 2D netCDF integer array and does some error ! checking. @@ -651,26 +624,26 @@ subroutine Ncrd_2d_Int (varrd_2di, ncid, varname, strt2d, cnt2d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_Int #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_Int #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Int (ncid, varid, strt2d, cnt2d, varrd_2di) + ierr = NF90_Get_Var(ncid, varid, varrd_2di, start=strt2d, count=cnt2d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_Int #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_Int #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_2d_Int + end subroutine Ncrd_2d_Int !EOC !------------------------------------------------------------------------- !BOP @@ -679,31 +652,28 @@ end subroutine Ncrd_2d_Int ! ! !INTERFACE: ! - subroutine Ncrd_3d_R8 (varrd_3d, ncid, varname, strt3d, cnt3d) + subroutine Ncrd_3d_R8(varrd_3d, ncid, varname, strt3d, cnt3d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt3d : vector specifying the index in varrd_3d where +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt3d : vector specifying the index in varrd_3d where !! the first of the data values will be read -!! cnt3d : varrd_3d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt3d(3) - integer , intent(in) :: cnt3d (3) +!! cnt3d : varrd_3d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt3d(3) + integer , intent(in) :: cnt3d (3) ! ! !OUTPUT PARAMETERS: -!! varrd_3d : array to fill - real*8 , intent(out) :: varrd_3d(cnt3d(1), cnt3d(2), & - cnt3d(3)) +!! varrd_3d : array to fill + real*8 , intent(out) :: varrd_3d(cnt3d(1), cnt3d(2), & + cnt3d(3)) ! ! !DESCRIPTION: Reads in a 3D netCDF real array and does some error checking. !\\ @@ -718,26 +688,26 @@ subroutine Ncrd_3d_R8 (varrd_3d, ncid, varname, strt3d, cnt3d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_R8 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Double (ncid, varid, strt3d, cnt3d, varrd_3d) + ierr = NF90_Get_Var(ncid, varid, varrd_3d, start=strt3d, count=cnt3d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_R8 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_R8 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_3d_R8 + end subroutine Ncrd_3d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -746,31 +716,28 @@ end subroutine Ncrd_3d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_3d_R4 (varrd_3d, ncid, varname, strt3d, cnt3d) + subroutine Ncrd_3d_R4(varrd_3d, ncid, varname, strt3d, cnt3d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt3d : vector specifying the index in varrd_3d where -!! the first of the data values will be read -!! cnt3d : varrd_3d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt3d(3) - integer , intent(in) :: cnt3d (3) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt3d : vector specifying the index in varrd_3d where +!! the first of the data values will be read +!! cnt3d : varrd_3d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt3d(3) + integer , intent(in) :: cnt3d (3) ! ! !OUTPUT PARAMETERS: -!! varrd_3d : array to fill - real*4 , intent(out) :: varrd_3d(cnt3d(1), cnt3d(2), & - cnt3d(3)) +!! varrd_3d : array to fill + real*4 , intent(out) :: varrd_3d(cnt3d(1), cnt3d(2), & + cnt3d(3)) ! ! !DESCRIPTION: Reads in a 3D netCDF real array and does some error checking. !\\ @@ -785,26 +752,26 @@ subroutine Ncrd_3d_R4 (varrd_3d, ncid, varname, strt3d, cnt3d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Real (ncid, varid, strt3d, cnt3d, varrd_3d) + ierr = NF90_Get_Var(ncid, varid, varrd_3d, start=strt3d, count=cnt3d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_R4 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_R4 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_3d_R4 + end subroutine Ncrd_3d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -813,31 +780,28 @@ end subroutine Ncrd_3d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_3d_Int (varrd_3di, ncid, varname, strt3d, cnt3d) + subroutine Ncrd_3d_Int(varrd_3di, ncid, varname, strt3d, cnt3d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt3d : vector specifying the index in varrd_3d where -!! the first of the data values will be read -!! cnt3d : varrd_3di dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt3d(3) - integer , intent(in) :: cnt3d (3) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt3d : vector specifying the index in varrd_3d where +!! the first of the data values will be read +!! cnt3d : varrd_3di dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt3d(3) + integer , intent(in) :: cnt3d (3) ! ! !OUTPUT PARAMETERS: -!! varrd_3di : intger array to fill - integer , intent(out) :: varrd_3di(cnt3d(1), cnt3d(2), & - cnt3d(3)) +!! varrd_3di : intger array to fill + integer , intent(out) :: varrd_3di(cnt3d(1), cnt3d(2), & + cnt3d(3)) ! ! !DESCRIPTION: Reads in a 3D netCDF integer array and does some error ! checking. @@ -853,26 +817,26 @@ subroutine Ncrd_3d_Int (varrd_3di, ncid, varname, strt3d, cnt3d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_Int #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_Int #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Int (ncid, varid, strt3d, cnt3d, varrd_3di) + ierr = NF90_Get_Var(ncid, varid, varrd_3di, start=strt3d, count=cnt3d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_Int #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_Int #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_3d_Int + end subroutine Ncrd_3d_Int !EOC !------------------------------------------------------------------------- !BOP @@ -881,31 +845,30 @@ end subroutine Ncrd_3d_Int ! ! !INTERFACE: ! - subroutine Ncrd_4d_R8 (varrd_4d, ncid, varname, strt4d, cnt4d) + subroutine Ncrd_4d_R8(varrd_4d, ncid, varname, strt4d, cnt4d) ! ! !USES: ! - use m_do_err_out -! - implicit none + use netCDF + use m_do_err_out ! - include "netcdf.inc" + implicit none ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt4d : vector specifying the index in varrd_4d where -!! the first of the data values will be read -!! cnt4d : varrd_4d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt4d(4) - integer , intent(in) :: cnt4d (4) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt4d : vector specifying the index in varrd_4d where +!! the first of the data values will be read +!! cnt4d : varrd_4d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt4d(4) + integer , intent(in) :: cnt4d (4) ! ! !OUTPUT PARAMETERS: -!! varrd_4d : array to fill - real*8 , intent(out) :: varrd_4d(cnt4d(1), cnt4d(2), & - cnt4d(3), cnt4d(4)) +!! varrd_4d : array to fill + real*8 , intent(out) :: varrd_4d(cnt4d(1), cnt4d(2), & + cnt4d(3), cnt4d(4)) ! ! !DESCRIPTION: Reads in a 4D netCDF real array and does some error checking. !\\ @@ -920,27 +883,26 @@ subroutine Ncrd_4d_R8 (varrd_4d, ncid, varname, strt4d, cnt4d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) - - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_4d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + ierr = NF90_Inq_VarId(ncid, varname, varid) + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_4d_R8 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Double (ncid, varid, strt4d, cnt4d, varrd_4d) + ierr = NF90_Get_Var(ncid, varid, varrd_4d, start=strt4d, count=cnt4d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_4d_R8 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_4d_R8 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_4d_R8 + end subroutine Ncrd_4d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -949,31 +911,28 @@ end subroutine Ncrd_4d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_4d_R4 (varrd_4d, ncid, varname, strt4d, cnt4d) + subroutine Ncrd_4d_R4(varrd_4d, ncid, varname, strt4d, cnt4d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt4d : vector specifying the index in varrd_4d where -!! the first of the data values will be read -!! cnt4d : varrd_4d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt4d(4) - integer , intent(in) :: cnt4d (4) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt4d : vector specifying the index in varrd_4d where +!! the first of the data values will be read +!! cnt4d : varrd_4d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt4d(4) + integer , intent(in) :: cnt4d (4) ! ! !OUTPUT PARAMETERS: -!! varrd_4d : array to fill - real*4 , intent(out) :: varrd_4d(cnt4d(1), cnt4d(2), & - cnt4d(3), cnt4d(4)) +!! varrd_4d : array to fill + real*4 , intent(out) :: varrd_4d(cnt4d(1), cnt4d(2), & + cnt4d(3), cnt4d(4)) ! ! !DESCRIPTION: Reads in a 4D netCDF real array and does some error checking. !\\ @@ -988,26 +947,26 @@ subroutine Ncrd_4d_R4 (varrd_4d, ncid, varname, strt4d, cnt4d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_4d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_4d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Real (ncid, varid, strt4d, cnt4d, varrd_4d) + ierr = NF90_Get_Var(ncid, varid, varrd_4d, start=strt4d, count=cnt4d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_4d_R4 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_4d_R4 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_4d_R4 + end subroutine Ncrd_4d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -1016,31 +975,28 @@ end subroutine Ncrd_4d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_4d_Int (varrd_4di, ncid, varname, strt4d, cnt4d) + subroutine Ncrd_4d_Int(varrd_4di, ncid, varname, strt4d, cnt4d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt3d : vector specifying the index in varrd_3d where -!! the first of the data values will be read -!! cnt3d : varrd_3di dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt4d(4) - integer , intent(in) :: cnt4d (4) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt3d : vector specifying the index in varrd_3d where +!! the first of the data values will be read +!! cnt3d : varrd_3di dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt4d(4) + integer , intent(in) :: cnt4d (4) ! ! !OUTPUT PARAMETERS: -!! varrd_3di : intger array to fill - integer , intent(out) :: varrd_4di(cnt4d(1), cnt4d(2), & - cnt4d(3), cnt4d(4)) +!! varrd_3di : intger array to fill + integer , intent(out) :: varrd_4di(cnt4d(1), cnt4d(2), & + cnt4d(3), cnt4d(4)) ! ! !DESCRIPTION: Reads in a 3D netCDF integer array and does some error ! checking. @@ -1056,26 +1012,26 @@ subroutine Ncrd_4d_Int (varrd_4di, ncid, varname, strt4d, cnt4d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_Int #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_Int #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Int (ncid, varid, strt4d, cnt4d, varrd_4di) + ierr = NF90_Get_Var(ncid, varid, varrd_4di, start=strt4d, count=cnt4d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_3d_Int #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_3d_Int #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_4d_Int + end subroutine Ncrd_4d_Int !EOC !------------------------------------------------------------------------- !BOP @@ -1084,32 +1040,29 @@ end subroutine Ncrd_4d_Int ! ! !INTERFACE: ! - subroutine Ncrd_5d_R8 (varrd_5d, ncid, varname, strt5d, cnt5d) + subroutine Ncrd_5d_R8(varrd_5d, ncid, varname, strt5d, cnt5d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt5d : vector specifying the index in varrd_5d where -!! the first of the data values will be read -!! cnt5d : varrd_5d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt5d(5) - integer , intent(in) :: cnt5d (5) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt5d : vector specifying the index in varrd_5d where +!! the first of the data values will be read +!! cnt5d : varrd_5d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt5d(5) + integer , intent(in) :: cnt5d (5) ! ! !OUTPUT PARAMETERS: -!! varrd_5d : array to fill - real*8 , intent(out) :: varrd_5d(cnt5d(1), cnt5d(2), & - cnt5d(3), cnt5d(4), & - cnt5d(5)) +!! varrd_5d : array to fill + real*8 , intent(out) :: varrd_5d(cnt5d(1), cnt5d(2), & + cnt5d(3), cnt5d(4), & + cnt5d(5)) ! ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking. !\\ @@ -1124,26 +1077,26 @@ subroutine Ncrd_5d_R8 (varrd_5d, ncid, varname, strt5d, cnt5d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then + if (ierr /= NF90_NOERR) then err_msg = 'In Ncrd_5d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) + ', ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + end if - ierr = Nf_Get_Vara_Double (ncid, varid, strt5d, cnt5d, varrd_5d) + ierr = NF90_Get_Var(ncid, varid, varrd_5d, start=strt5d, count=cnt5d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_5d_R8 #2: ' // Nf_Strerror (ierr) + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_5d_R8 #2: ' // NF90_Strerror(ierr) call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + end if - end subroutine Ncrd_5d_R8 + end subroutine Ncrd_5d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -1152,30 +1105,27 @@ end subroutine Ncrd_5d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_5d_R4 (varrd_5d, ncid, varname, strt5d, cnt5d) + subroutine Ncrd_5d_R4(varrd_5d, ncid, varname, strt5d, cnt5d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt5d : vector specifying the index in varrd_5d where -!! the first of the data values will be read -!! cnt5d : varrd_5d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt5d(5) - integer , intent(in) :: cnt5d (5) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt5d : vector specifying the index in varrd_5d where +!! the first of the data values will be read +!! cnt5d : varrd_5d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt5d(5) + integer , intent(in) :: cnt5d (5) ! ! !OUTPUT PARAMETERS: -!! varrd_5d : array to fill - real*4 , intent(out) :: varrd_5d(cnt5d(1), cnt5d(2), & +!! varrd_5d : array to fill + real*4 , intent(out) :: varrd_5d(cnt5d(1), cnt5d(2), & cnt5d(3), cnt5d(4), & cnt5d(5)) ! @@ -1192,26 +1142,26 @@ subroutine Ncrd_5d_R4 (varrd_5d, ncid, varname, strt5d, cnt5d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid -! - ierr = Nf_Inq_Varid (ncid, varname, varid) - - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_5d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if - - ierr = Nf_Get_Vara_Real (ncid, varid, strt5d, cnt5d, varrd_5d) - - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_5d_R4 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if - - end subroutine Ncrd_5d_R4 + character (len=512) :: err_msg + integer :: ierr + integer :: varid +! + ierr = NF90_Inq_VarId(ncid, varname, varid) + + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_5d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if + + ierr = NF90_Get_Var(ncid, varid, varrd_5d, start=strt5d, count=cnt5d) + + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_5d_R4 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if + + end subroutine Ncrd_5d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -1220,32 +1170,29 @@ end subroutine Ncrd_5d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_6d_R8 (varrd_6d, ncid, varname, strt6d, cnt6d) + subroutine Ncrd_6d_R8(varrd_6d, ncid, varname, strt6d, cnt6d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt5d : vector specifying the index in varrd_5d where +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt5d : vector specifying the index in varrd_5d where !! the first of the data values will be read -!! cnt5d : varrd_5d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt6d(6) - integer , intent(in) :: cnt6d (6) +!! cnt5d : varrd_5d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt6d(6) + integer , intent(in) :: cnt6d (6) ! ! !OUTPUT PARAMETERS: -!! varrd_5d : array to fill - real*8 , intent(out) :: varrd_6d(cnt6d(1), cnt6d(2), & - cnt6d(3), cnt6d(4), & - cnt6d(5), cnt6d(6)) +!! varrd_5d : array to fill + real*8 , intent(out) :: varrd_6d(cnt6d(1), cnt6d(2), & + cnt6d(3), cnt6d(4), & + cnt6d(5), cnt6d(6)) ! ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking. !\\ @@ -1261,26 +1208,26 @@ subroutine Ncrd_6d_R8 (varrd_6d, ncid, varname, strt6d, cnt6d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_6d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_6d_R8 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Double (ncid, varid, strt6d, cnt6d, varrd_6d) + ierr = NF90_Get_Var(ncid, varid, varrd_6d, start=strt6d, count=cnt6d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_6d_R8 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_6d_R8 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_6d_R8 + end subroutine Ncrd_6d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -1289,32 +1236,29 @@ end subroutine Ncrd_6d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_6d_R4 (varrd_6d, ncid, varname, strt6d, cnt6d) + subroutine Ncrd_6d_R4(varrd_6d, ncid, varname, strt6d, cnt6d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt5d : vector specifying the index in varrd_5d where -!! the first of the data values will be read -!! cnt5d : varrd_5d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt6d(6) - integer , intent(in) :: cnt6d (6) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt5d : vector specifying the index in varrd_5d where +!! the first of the data values will be read +!! cnt5d : varrd_5d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt6d(6) + integer , intent(in) :: cnt6d (6) ! ! !OUTPUT PARAMETERS: -!! varrd_5d : array to fill - real*4 , intent(out) :: varrd_6d(cnt6d(1), cnt6d(2), & - cnt6d(3), cnt6d(4), & - cnt6d(5), cnt6d(6)) +!! varrd_5d : array to fill + real*4 , intent(out) :: varrd_6d(cnt6d(1), cnt6d(2), & + cnt6d(3), cnt6d(4), & + cnt6d(5), cnt6d(6)) ! ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking. !\\ @@ -1329,26 +1273,26 @@ subroutine Ncrd_6d_R4 (varrd_6d, ncid, varname, strt6d, cnt6d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_6d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if ( ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_6d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Real (ncid, varid, strt6d, cnt6d, varrd_6d) + ierr = NF90_Get_Var(ncid, varid, varrd_6d, start=strt6d, count=cnt6d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_6d_R4 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_6d_R4 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_6d_R4 + end subroutine Ncrd_6d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -1357,33 +1301,30 @@ end subroutine Ncrd_6d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_7d_R8 (varrd_7d, ncid, varname, strt7d, cnt7d) + subroutine Ncrd_7d_R8(varrd_7d, ncid, varname, strt7d, cnt7d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt7d : vector specifying the index in varrd_7d where -!! the first of the data values will be read -!! cnt7d : varrd_7d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt7d(7) - integer , intent(in) :: cnt7d (7) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt7d : vector specifying the index in varrd_7d where +!! the first of the data values will be read +!! cnt7d : varrd_7d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt7d(7) + integer , intent(in) :: cnt7d (7) ! ! !OUTPUT PARAMETERS: -!! varrd_5d : array to fill - real*8 , intent(out) :: varrd_7d(cnt7d(1), cnt7d(2), & - cnt7d(3), cnt7d(4), & - cnt7d(5), cnt7d(6), & - cnt7d(7)) +!! varrd_5d : array to fill + real*8 , intent(out) :: varrd_7d(cnt7d(1), cnt7d(2), & + cnt7d(3), cnt7d(4), & + cnt7d(5), cnt7d(6), & + cnt7d(7)) ! ! !DESCRIPTION: Reads in a 7D netCDF real array and does some error checking. !\\ @@ -1399,26 +1340,26 @@ subroutine Ncrd_7d_R8 (varrd_7d, ncid, varname, strt7d, cnt7d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_7d_R8 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_7d_R8 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Double (ncid, varid, strt7d, cnt7d, varrd_7d) + ierr = NF90_Get_Var(ncid, varid, varrd_7d, start=strt7d, count=cnt7d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_7d_R8 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_7d_R8 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_7d_R8 + end subroutine Ncrd_7d_R8 !EOC !------------------------------------------------------------------------- !BOP @@ -1427,33 +1368,30 @@ end subroutine Ncrd_7d_R8 ! ! !INTERFACE: ! - subroutine Ncrd_7d_R4 (varrd_7d, ncid, varname, strt7d, cnt7d) + subroutine Ncrd_7d_R4(varrd_7d, ncid, varname, strt7d, cnt7d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt7d : vector specifying the index in varrd_7d where -!! the first of the data values will be read -!! cnt7d : varrd_7d dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt7d(7) - integer , intent(in) :: cnt7d (7) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt7d : vector specifying the index in varrd_7d where +!! the first of the data values will be read +!! cnt7d : varrd_7d dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt7d(7) + integer , intent(in) :: cnt7d (7) ! ! !OUTPUT PARAMETERS: -!! varrd_7d : array to fill - real*4 , intent(out) :: varrd_7d(cnt7d(1), cnt7d(2), & - cnt7d(3), cnt7d(4), & - cnt7d(5), cnt7d(6), & - cnt7d(7)) +!! varrd_7d : array to fill + real*4 , intent(out) :: varrd_7d(cnt7d(1), cnt7d(2), & + cnt7d(3), cnt7d(4), & + cnt7d(5), cnt7d(6), & + cnt7d(7)) ! ! !DESCRIPTION: Reads in a 7D netCDF real array and does some error checking. !\\ @@ -1469,26 +1407,26 @@ subroutine Ncrd_7d_R4 (varrd_7d, ncid, varname, strt7d, cnt7d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_7d_R4 #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_7d_R4 #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Real (ncid, varid, strt7d, cnt7d, varrd_7d) + ierr = NF90_Get_Var(ncid, varid, varrd_7d, start=strt7d, count=cnt7d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_7d_R4 #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_7d_R4 #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_7d_R4 + end subroutine Ncrd_7d_R4 !EOC !------------------------------------------------------------------------- !BOP @@ -1497,31 +1435,28 @@ end subroutine Ncrd_7d_R4 ! ! !INTERFACE: ! - subroutine Ncrd_1d_Char (varrd_1dc, ncid, varname, strt1d, cnt1d) + subroutine Ncrd_1d_Char(varrd_1dc, ncid, varname, strt1d, cnt1d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: ! -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt1d : vector specifying the index in varrd_1dc where -!! the first of the data values will be read -!! cnt1d : varrd_1dc dimension - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt1d(1) - integer , intent(in) :: cnt1d (1) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt1d : vector specifying the index in varrd_1dc where +!! the first of the data values will be read +!! cnt1d : varrd_1dc dimension + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt1d(1) + integer , intent(in) :: cnt1d (1) ! ! !OUTPUT PARAMETERS: -!! varrd_1dc : intger array to fill - character (len=1), intent(out) :: varrd_1dc(cnt1d(1)) +!! varrd_1dc : intger array to fill + character (len=1), intent(out) :: varrd_1dc(cnt1d(1)) ! ! !DESCRIPTION: Reads in a 1D netCDF character array and does some error ! checking. @@ -1536,26 +1471,26 @@ subroutine Ncrd_1d_Char (varrd_1dc, ncid, varname, strt1d, cnt1d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_1d_Char #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_1d_Char #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Text (ncid, varid, strt1d, cnt1d, varrd_1dc) + ierr = NF90_Get_Var(ncid, varid, varrd_1dc, start=strt1d, count=cnt1d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_1d_Char #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_1d_Char #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_1d_Char + end subroutine Ncrd_1d_Char !EOC !------------------------------------------------------------------------- !BOP @@ -1564,30 +1499,27 @@ end subroutine Ncrd_1d_Char ! ! !INTERFACE: ! - subroutine Ncrd_2d_Char (varrd_2dc, ncid, varname, strt2d, cnt2d) + subroutine Ncrd_2d_Char(varrd_2dc, ncid, varname, strt2d, cnt2d) ! ! !USES: ! - use m_do_err_out -! - implicit none -! - include "netcdf.inc" + use netCDF + use m_do_err_out ! ! !INPUT PARAMETERS: -!! ncid : netCDF file id to read array input data from -!! varname : netCDF variable name for array -!! strt2d : vector specifying the index in varrd_2dc where -!! the first of the data values will be read -!! cnt2d : varrd_2dc dimensions - integer , intent(in) :: ncid - character (len=*), intent(in) :: varname - integer , intent(in) :: strt2d(2) - integer , intent(in) :: cnt2d (2) +!! ncid : netCDF file id to read array input data from +!! varname : netCDF variable name for array +!! strt2d : vector specifying the index in varrd_2dc where +!! the first of the data values will be read +!! cnt2d : varrd_2dc dimensions + integer , intent(in) :: ncid + character (len=*), intent(in) :: varname + integer , intent(in) :: strt2d(2) + integer , intent(in) :: cnt2d (2) ! ! !OUTPUT PARAMETERS: -!! varrd_2dc : charcter array to fill - character , intent(out) :: varrd_2dc(cnt2d(1), cnt2d(2)) +!! varrd_2dc : charcter array to fill + character , intent(out) :: varrd_2dc(cnt2d(1), cnt2d(2)) ! ! !DESCRIPTION: Reads in a 2D netCDF character array and does some error ! checking. @@ -1603,26 +1535,26 @@ subroutine Ncrd_2d_Char (varrd_2dc, ncid, varname, strt2d, cnt2d) !BOC ! ! !LOCAL VARIABLES: - character (len=512) :: err_msg - integer :: ierr - integer :: varid + character (len=512) :: err_msg + integer :: ierr + integer :: varid ! - ierr = Nf_Inq_Varid (ncid, varname, varid) + ierr = NF90_Inq_VarId(ncid, varname, varid) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_Char #1: ' // Trim (varname) // & - ', ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_Char #1: ' // Trim (varname) // & + ', ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0) + end if - ierr = Nf_Get_Vara_Text (ncid, varid, strt2d, cnt2d, varrd_2dc) + ierr = NF90_Get_Var(ncid, varid, varrd_2dc, start=strt2d, count=cnt2d) - if (ierr /= NF_NOERR) then - err_msg = 'In Ncrd_2d_Char #2: ' // Nf_Strerror (ierr) - call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) - end if + if (ierr /= NF90_NOERR) then + err_msg = 'In Ncrd_2d_Char #2: ' // NF90_Strerror(ierr) + call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0) + end if - end subroutine Ncrd_2d_Char + end subroutine Ncrd_2d_Char !EOC !------------------------------------------------------------------------ end module HCO_m_netcdf_io_read diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_readattr.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_readattr.F90 index d08bd7da..fe32ef62 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_readattr.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_readattr.F90 @@ -11,13 +11,9 @@ MODULE HCO_m_netcdf_io_readattr ! ! !USES: - - USE m_do_err_out - +! IMPLICIT NONE PRIVATE - - INCLUDE "netcdf.inc" ! ! !PUBLIC MEMBER FUNCTIONS: ! @@ -93,6 +89,11 @@ MODULE HCO_m_netcdf_io_readattr ! SUBROUTINE NcGet_Var_Attr_C( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -125,20 +126,20 @@ SUBROUTINE NcGet_Var_Attr_C( fid, varName, attName, attValue ) attValue = '' ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_C: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) ENDIF ! Get the attribute - status = Nf_Get_Att_Text( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_C: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -161,6 +162,11 @@ END SUBROUTINE NcGet_Var_Attr_C ! SUBROUTINE NcGet_Var_Attr_I4( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -193,20 +199,20 @@ SUBROUTINE NcGet_Var_Attr_I4( fid, varName, attName, attValue ) attValue = 0 ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_I4: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out ( errMsg, .TRUE., 1, fId, 0, 0, 0.0d0, 0.0d0) ENDIF ! Get the attribute - status = Nf_Get_Att_Int( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_I4: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -229,6 +235,11 @@ END SUBROUTINE NcGet_Var_Attr_I4 ! SUBROUTINE NcGet_Var_Attr_R4( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -261,20 +272,20 @@ SUBROUTINE NcGet_Var_Attr_R4( fid, varName, attName, attValue ) attValue = 0e0 ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R4: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out ( errMsg, .TRUE., 1, fId, 0, 0, 0.0d0, 0.0d0) ENDIF ! Get the attribute - status = Nf_Get_Att_Real( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R4: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -297,6 +308,11 @@ END SUBROUTINE NcGet_Var_Attr_R4 ! SUBROUTINE NcGet_Var_Attr_R8( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -329,20 +345,20 @@ SUBROUTINE NcGet_Var_Attr_R8( fid, varName, attName, attValue ) attValue = 0d0 ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R8: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out ( errMsg, .TRUE., 1, fId, 0, 0, 0.0d0, 0.0d0) ENDIF ! Get the attribute - status = Nf_Get_Att_Double( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R8: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -365,6 +381,11 @@ END SUBROUTINE NcGet_Var_Attr_R8 ! SUBROUTINE NcGet_Var_Attr_I4_arr( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -397,20 +418,20 @@ SUBROUTINE NcGet_Var_Attr_I4_arr( fid, varName, attName, attValue ) attValue = 0 ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_I4_arr: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out ( errMsg, .TRUE., 1, fId, 0, 0, 0.0d0, 0.0d0) ENDIF ! Get the attribute - status = Nf_Get_Att_Int( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_I4_arr: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -433,6 +454,11 @@ END SUBROUTINE NcGet_Var_Attr_I4_arr ! SUBROUTINE NcGet_Var_Attr_R4_arr( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -465,20 +491,20 @@ SUBROUTINE NcGet_Var_Attr_R4_arr( fid, varName, attName, attValue ) attValue = 0e0 ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R4_arr: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out ( errMsg, .TRUE., 1, fId, 0, 0, 0.0d0, 0.0d0) ENDIF ! Get the attribute - status = Nf_Get_Att_Real( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R4_arr: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -501,6 +527,11 @@ END SUBROUTINE NcGet_Var_Attr_R4_arr ! SUBROUTINE NcGet_Var_Attr_R8_arr( fid, varName, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -533,20 +564,20 @@ SUBROUTINE NcGet_Var_Attr_R8_arr( fid, varName, attName, attValue ) attValue = 0d0 ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R8_arr: ' // TRIM( varName ) // & - ', ' // Nf_Strerror( status ) + ', ' // NF90_Strerror( status ) CALL Do_Err_Out ( errMsg, .TRUE., 1, fId, 0, 0, 0.0d0, 0.0d0) ENDIF ! Get the attribute - status = Nf_Get_Att_Double( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Var_Attr_R8_arr: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -569,6 +600,11 @@ END SUBROUTINE NcGet_Var_Attr_R8_arr ! SUBROUTINE NcGet_Glob_Attr_C( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -600,10 +636,10 @@ SUBROUTINE NcGet_Glob_Attr_C( fid, attName, attValue ) attValue = '' ! Get the attribute - status = Nf_Get_Att_Text( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_C: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -626,6 +662,11 @@ END SUBROUTINE NcGet_Glob_Attr_C ! SUBROUTINE NcGet_Glob_Attr_I4( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -657,10 +698,10 @@ SUBROUTINE NcGet_Glob_Attr_I4( fid, attName, attValue ) attValue = 0 ! Get the attribute - status = Nf_Get_Att_Int( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_I4: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -683,6 +724,11 @@ END SUBROUTINE NcGet_Glob_Attr_I4 ! SUBROUTINE NcGet_Glob_Attr_R4( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -714,10 +760,10 @@ SUBROUTINE NcGet_Glob_Attr_R4( fid, attName, attValue ) attValue = 0e0 ! Get the attribute - status = Nf_Get_Att_Real( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_R4: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -740,6 +786,11 @@ END SUBROUTINE NcGet_Glob_Attr_R4 ! SUBROUTINE NcGet_Glob_Attr_R8( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -771,10 +822,10 @@ SUBROUTINE NcGet_Glob_Attr_R8( fid, attName, attValue ) attValue = 0d0 ! Get the attribute - status = Nf_Get_Att_Double( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_R8: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -797,6 +848,11 @@ END SUBROUTINE NcGet_Glob_Attr_R8 ! SUBROUTINE NcGet_Glob_Attr_I4_arr( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -828,10 +884,10 @@ SUBROUTINE NcGet_Glob_Attr_I4_arr( fid, attName, attValue ) attValue = 0 ! Get the attribute - status = Nf_Get_Att_Int( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_I4_arr: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -854,6 +910,11 @@ END SUBROUTINE NcGet_Glob_Attr_I4_arr ! SUBROUTINE NcGet_Glob_Attr_R4_arr( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -885,10 +946,10 @@ SUBROUTINE NcGet_Glob_Attr_R4_arr( fid, attName, attValue ) attValue = 0e0 ! Get the attribute - status = Nf_Get_Att_Real( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_R4_arr: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -911,6 +972,11 @@ END SUBROUTINE NcGet_Glob_Attr_R4_arr ! SUBROUTINE NcGet_Glob_Attr_R8_arr( fid, attName, attValue ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -942,10 +1008,10 @@ SUBROUTINE NcGet_Glob_Attr_R8_arr( fid, attName, attValue ) attValue = 0d0 ! Get the attribute - status = Nf_Get_Att_Double( fId, NF_GLOBAL, attName, attValue ) + status = NF90_Get_Att( fId, NF90_GLOBAL, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN errMsg = 'In NcGet_Glob_Attr_R8_arr: cannot read attribute : ' // & TRIM( attName ) CALL Do_Err_Out( errMsg, .TRUE., 0, 0, 0, 0, 0.0d0, 0.0d0 ) @@ -970,6 +1036,11 @@ END SUBROUTINE NcGet_Glob_Attr_R8_arr ! SUBROUTINE NcGet_Var_Attr_C_nostop( fId, varName, attName, attValue, RC ) ! +! USES: +! + USE netCDF + USE m_do_err_out +! ! !INPUT PARAMETERS: ! INTEGER, INTENT(IN) :: fId ! netCDF file ID @@ -1003,19 +1074,19 @@ SUBROUTINE NcGet_Var_Attr_C_nostop( fId, varName, attName, attValue, RC ) attValue = '' ! Check if VARNAME is a valid variable - status = Nf_Inq_Varid ( fId, varName, vId ) + status = NF90_Inq_VarId( fId, varName, vId ) ! Exit w/ error message if VARNAME is not valid - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN RC = status RETURN ENDIF ! Get the attribute - status = Nf_Get_Att_Text( fId, vId, attName, attValue ) + status = NF90_Get_Att( fId, vId, attName, attValue ) ! Exit w/ error message if unsuccessful - IF ( status /= NF_NOERR ) THEN + IF ( status /= NF90_NOERR ) THEN RC = status RETURN ENDIF diff --git a/src/Shared/NcdfUtil/hco_ncdf_mod.F90 b/src/Shared/NcdfUtil/hco_ncdf_mod.F90 index 5037b119..952dd9fe 100644 --- a/src/Shared/NcdfUtil/hco_ncdf_mod.F90 +++ b/src/Shared/NcdfUtil/hco_ncdf_mod.F90 @@ -17,6 +17,7 @@ MODULE HCO_NCDF_MOD ! !USES: ! ! Modules for netCDF read + USE netCDF USE HCO_m_netcdf_io_open USE HCO_m_netcdf_io_get_dimlen USE HCO_m_netcdf_io_read @@ -30,7 +31,6 @@ MODULE HCO_NCDF_MOD IMPLICIT NONE PRIVATE -# include "netcdf.inc" ! ! !PUBLIC MEMBER FUNCTIONS: ! @@ -217,11 +217,7 @@ SUBROUTINE NC_APPEND( FileName, fID, nTime ) ! Also return the number of time slices so that we can ! append to an existing file w/o clobbering any data IF ( PRESENT( nTime ) ) THEN - nTime = -1 - RC = Nf_Inq_DimId( fId, 'time', vId ) - IF ( RC == NF_NOERR ) THEN - RC = Nf_Inq_DimLen( fId, vId, nTime ) - ENDIF + CALL Ncget_Unlim_Dimlen( fId, nTime ) ENDIF END SUBROUTINE NC_APPEND @@ -1194,12 +1190,12 @@ SUBROUTINE NC_READ_ARR( fID, ncVar, lon1, lon2, lat1, & a_name = "missing_value" ReadAtt = Ncdoes_Attr_Exist ( fId, TRIM(v_name), TRIM(a_name), a_type ) IF ( ReadAtt ) THEN - IF ( a_type == NF_REAL ) THEN + IF ( a_type == NF90_REAL ) THEN CALL NcGet_Var_Attributes( fId, TRIM(v_name), TRIM(a_name), miss4 ) WHERE ( ncArr == miss4 ) ncArr = MissValue END WHERE - ELSE IF ( a_type == NF_DOUBLE ) THEN + ELSE IF ( a_type == NF90_DOUBLE ) THEN CALL NcGet_Var_Attributes( fId, TRIM(v_name), TRIM(a_name), miss8 ) miss4 = REAL( miss8 ) WHERE ( ncArr == miss4 ) @@ -1212,12 +1208,12 @@ SUBROUTINE NC_READ_ARR( fID, ncVar, lon1, lon2, lat1, & a_name = "_FillValue" ReadAtt = Ncdoes_Attr_Exist ( fId, TRIM(v_name), TRIM(a_name), a_type ) IF ( ReadAtt ) THEN - IF ( a_type == NF_REAL ) THEN + IF ( a_type == NF90_REAL ) THEN CALL NcGet_Var_Attributes( fId, TRIM(v_name), TRIM(a_name), miss4 ) WHERE ( ncArr == miss4 ) ncArr = MissValue END WHERE - ELSE IF ( a_type == NF_DOUBLE ) THEN + ELSE IF ( a_type == NF90_DOUBLE ) THEN CALL NcGet_Var_Attributes( fId, TRIM(v_name), TRIM(a_name), miss8 ) miss4 = REAL( miss8 ) WHERE ( ncArr == miss4 ) @@ -3115,7 +3111,7 @@ SUBROUTINE NC_DEFINE ( ncFile, nLon, nLat, nLev, nTime,& CALL NcCr_Wr( fId, TRIM(ncFile) ) ! Turn filling off - CALL NcSetFill( fId, NF_NOFILL, omode ) + CALL NcSetFill( fId, NF90_NOFILL, omode ) !-------------------------------- ! GLOBAL ATTRIBUTES @@ -3170,7 +3166,7 @@ SUBROUTINE NC_DEFINE ( ncFile, nLon, nLat, nLev, nTime,& ! Define the "lon" variable v_name = "lon" var1d = (/ id_lon /) - CALL NcDef_Variable( fId, TRIM(v_name), NF_FLOAT, 1, var1d, vId ) + CALL NcDef_Variable( fId, TRIM(v_name), NF90_FLOAT, 1, var1d, vId ) ! Define the "lon:long_name" attribute a_name = "long_name" @@ -3189,7 +3185,7 @@ SUBROUTINE NC_DEFINE ( ncFile, nLon, nLat, nLev, nTime,& ! Define the "lat" variable v_name = "lat" var1d = (/ id_lat /) - CALL NcDef_Variable( fId, TRIM(v_name), NF_FLOAT, 1, var1d, vId ) + CALL NcDef_Variable( fId, TRIM(v_name), NF90_FLOAT, 1, var1d, vId ) ! Define the "lat:long_name" attribute a_name = "long_name" @@ -3210,7 +3206,7 @@ SUBROUTINE NC_DEFINE ( ncFile, nLon, nLat, nLev, nTime,& ! Define the "levels" variable v_name = "lev" var1d = (/ id_lev /) - CALL NcDef_Variable( fId, TRIM(v_name), NF_INT, 1, var1d, vId ) + CALL NcDef_Variable( fId, TRIM(v_name), NF90_INT, 1, var1d, vId ) ! Define the "time:long_name" attribute a_name = "long_name" @@ -3230,7 +3226,7 @@ SUBROUTINE NC_DEFINE ( ncFile, nLon, nLat, nLev, nTime,& ! Define the "time" variable v_name = "time" var1d = (/ id_time /) - CALL NcDef_Variable( fId, TRIM(v_name), NF_INT, 1, var1d, vId ) + CALL NcDef_Variable( fId, TRIM(v_name), NF90_INT, 1, var1d, vId ) ! Define the "time:long_name" attribute a_name = "long_name" @@ -3251,10 +3247,10 @@ SUBROUTINE NC_DEFINE ( ncFile, nLon, nLat, nLev, nTime,& v_name = TRIM(ncVars(I)) IF ( PRESENT(nlev) ) THEN var4d = (/ id_lon, id_lat, id_lev, id_time /) - CALL NcDef_Variable(fId,TRIM(v_name),NF_DOUBLE,4,var4d,vId) + CALL NcDef_Variable(fId,TRIM(v_name),NF90_DOUBLE,4,var4d,vId) ELSE var3d = (/ id_lon, id_lat, id_time /) - CALL NcDef_Variable(fId,TRIM(v_name),NF_DOUBLE,3,var3d,vId) + CALL NcDef_Variable(fId,TRIM(v_name),NF90_DOUBLE,3,var3d,vId) ENDIF ! Define the long_name attribute @@ -3648,7 +3644,7 @@ SUBROUTINE Nc_Create( NcFile, Title, nLon, & CALL NcCr_Wr( fId, TRIM( ncFile ), Save_As_Nc4 ) ! Turn filling off - CALL NcSetFill( fId, NF_NOFILL, omode ) + CALL NcSetFill( fId, NF90_NOFILL, omode ) !======================================================================= ! Set global attributes @@ -3792,7 +3788,7 @@ SUBROUTINE NC_Var_Def( fId, lonId, latId, levId, & ! Scalars INTEGER :: nDim, Pos - INTEGER :: NF_TYPE, tmpIlevId + INTEGER :: NF90_TYPE, tmpIlevId LOGICAL :: isDefMode ! Strings @@ -3859,20 +3855,20 @@ SUBROUTINE NC_Var_Def( fId, lonId, latId, levId, & ! Set data type IF ( DataType == 1 ) THEN - NF_TYPE = NF_INT + NF90_TYPE = NF90_INT ELSEIF ( DataType == 4 ) THEN - NF_TYPE = NF_FLOAT + NF90_TYPE = NF90_FLOAT ELSEIF ( DataType == 8 ) THEN - NF_TYPE = NF_DOUBLE + NF90_TYPE = NF90_DOUBLE ELSE - NF_TYPE = NF_FLOAT + NF90_TYPE = NF90_FLOAT ENDIF !----------------------------------------------------------------------- ! Define variable !----------------------------------------------------------------------- - CALL NcDef_Variable( fId, TRIM(VarName), NF_TYPE, & - nDim, VarDims, VarCt, Compress ) + CALL NcDef_Variable( fId, TRIM(VarName), NF90_TYPE, & + nDim, VarDims, VarCt, Compress ) DEALLOCATE( VarDims ) !----------------------------------------------------------------------- @@ -3881,11 +3877,11 @@ SUBROUTINE NC_Var_Def( fId, lonId, latId, levId, & ! long_name (reuired) Att = 'long_name' - CALL NcDef_Var_Attributes( fId, VarCt, TRIM(Att), TRIM(VarLongName) ) + CALL NcDef_Var_Attributes( fId, VarCt, TRIM(Att), TRIM(VarLongName) ) ! units (requited) Att = 'units' - CALL NcDef_Var_Attributes( fId, VarCt, TRIM(Att), TRIM(VarUnit) ) + CALL NcDef_Var_Attributes( fId, VarCt, TRIM(Att), TRIM(VarUnit) ) ! add_offset (optional) IF ( PRESENT( AddOffset ) ) THEN @@ -4009,7 +4005,7 @@ SUBROUTINE Nc_Var_Chunk( fId, vId, ChunkSizes, RC ) ! Turn on chunking for this variable ! But only if the netCDF library supports it - RC = NF_Def_Var_Chunking( fId, vId, NF_CHUNKED, ChunkSizes ) + RC = NF90_Def_Var_Chunking( fId, vId, NF90_CHUNKED, ChunkSizes ) #else diff --git a/src/Shared/NcdfUtil/m_do_err_out.F90 b/src/Shared/NcdfUtil/m_do_err_out.F90 index b6df11e5..593fa835 100644 --- a/src/Shared/NcdfUtil/m_do_err_out.F90 +++ b/src/Shared/NcdfUtil/m_do_err_out.F90 @@ -127,7 +127,7 @@ subroutine Do_Err_Out & ! NOTE: Should not exit but pass error code up ! work on this for a future version - stop 999 + stop 999 ENDIF RETURN From a695de55ed28186c42915107c0284dc1764927c0 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Mon, 17 Jul 2023 10:17:47 -0400 Subject: [PATCH 2/2] Clean up logic in Ncdef_variable (in hco_m_netcdf_io_define.F90) src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 - Eliminate ELSE blocks by using never-nesting techniques - First execute the IF block in the #ifdef. If COMPRESS is not passed, or is false, or if ndims == 0, then do not create the variable with netCDF compression. Signed-off-by: Bob Yantosca --- .../NcdfUtil/hco_m_netcdf_io_define.F90 | 62 ++++++++----------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 b/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 index 97eb4ef1..1812106e 100644 --- a/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 +++ b/src/Shared/NcdfUtil/hco_m_netcdf_io_define.F90 @@ -162,7 +162,8 @@ SUBROUTINE NcDef_variable(ncid, name, xtype, ndims, dims, var_id, compress) !! ncid : netCDF file id !! name : name of the variable !! type : type of the variable -!! (NF90_FLOAT, NF90_CHAR, NF90_INT, NF90_DOUBLE, NF90_BYTE, NF90_SHORT) +!! (NF90_FLOAT, NF90_CHAR, NF90_INT, +!! NF90_DOUBLE, NF90_BYTE, NF90_SHORT) !! ndims : number of dimensions of the variable !! dims : netCDF dimension id of the variable CHARACTER (LEN=*), INTENT(IN) :: name @@ -195,32 +196,32 @@ SUBROUTINE NcDef_variable(ncid, name, xtype, ndims, dims, var_id, compress) #ifdef NC_HAS_COMPRESSION !===================================================================== - ! If the optional "compress" variable is used and set to TRUE, - ! then enable variable compression (cdh, 0/17/17) + ! Create a compressed (deflated) netCDF variable ! ! NOTE: We need to block this out with an #ifdef because some - ! netCDF installations might lack the NF90_def_var_deflate function + ! netCDF installations might lack the deflation capability, ! which would cause a compile-time error. (bmy, 3/1/17) - ! - ! ALSO NOTE: Newer versions of netCDF balk when you try to compress - ! a scalar variable. This generates an annoying warning message. - ! To avoid this, only compress array variables. (bmy, 11/30/20) - !===================================================================== - if ( PRESENT( Compress ) ) then + !======================================================================== + IF ( PRESENT( Compress ) ) then - ! Skip compression for zero-dimension variables + !------------------------------------------------------------------ + ! If COMPRESS is passed as an optional argument, and is TRUE, + ! then define the variable with deflate_level=1. Higher values + ! of deflate_level yield minimal additiional benefit. + ! + ! ALSO NOTE: Newer versions of netCDF balk when you try to compress + ! a scalar variable. This generates an annoying warning message. + ! To avoid this, only compress array variables. (bmy, 11/30/20) + !------------------------------------------------------------------- IF ( Compress .and. ndims > 0 ) THEN - ! Define variable with deflation (aka compression). - ! Choose deflate_level=1 for fast, minimal deflation. - ! Testing shows minimal benefit from higher deflation levels. + ! Create deflated variable ierr = NF90_Def_Var( ncid, name, xtype, dims, var_id, & shuffle=.TRUE., deflate_level=1 ) ! Check for errors. ! No message will be generated if the error is simply that the - ! file is not netCDF-4 - ! (i.e. netCDF-3 don't support compression) + ! file is not netCDF-4 (as netCDF-3 doesn't support compression) IF ( (ierr.ne.NF90_NOERR) .and. (ierr.ne.NF90_ENOTNC4)) THEN ! Errors enabling compression will not halt the program @@ -232,33 +233,24 @@ SUBROUTINE NcDef_variable(ncid, name, xtype, ndims, dims, var_id, compress) CALL Do_Err_Out (err_msg, doStop, 0, 0, 0, 0, 0.0d0, 0.0d0) END IF - ELSE - - ! Create uncompressed variable if COMPRESS = .FALSE. - ! or if the number of dimensions is zero - ierr = NF90_Def_Var( ncid, name, xtype, dims, var_id ) - IF ( ierr /= NF90_NOERR ) THEN - err_msg = 'NF90_Def_Var_Deflate: can not create variable : '// & - Trim (name) - CALL Do_Err_Out (err_msg, doStop, 0, 0, 0, 0, 0.0d0, 0.0d0) - ENDIF - + ! Return successfully + RETURN ENDIF ENDIF +#endif -#else - !===================================================================== - ! Define variable without compression if HEMCO was compiled - ! with netCDF deflation turned off. - !===================================================================== + !======================================================================== + ! Create an uncompressed netCDF variable if: + ! (1) COMPRESS is not passed as an optional argument + ! (2) COMPRESS is passed as an optional argument but is FALSE + ! (3) The variable is a scalar (ndims == 0) + !======================================================================== ierr = NF90_Def_Var( ncid, name, xtype, dims, var_id ) IF ( ierr /= NF90_NOERR ) THEN err_msg = 'NF90_Def_Var_Deflate: can not create variable : '// & - Trim(name) + Trim (name) CALL Do_Err_Out (err_msg, doStop, 0, 0, 0, 0, 0.0d0, 0.0d0) ENDIF - -#endif END SUBROUTINE NcDef_variable !EOC