LCOV - code coverage report
Current view: top level - hemco/HEMCO/src/Shared/NcdfUtil - hco_m_netcdf_io_write.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 210 0.0 %
Date: 2025-01-13 21:54:50 Functions: 0 21 0.0 %

          Line data    Source code
       1             : !-------------------------------------------------------------------------
       2             : !  NASA/GFSC, SIVO, Code 610.3
       3             : !-------------------------------------------------------------------------
       4             : !BOP
       5             : !
       6             : ! !MODULE: HCO_m_netcdf_io_write
       7             : !
       8             : ! !INTERFACE:
       9             : !
      10             : MODULE HCO_m_netcdf_io_write
      11             : !
      12             :   IMPLICIT NONE
      13             :   PRIVATE
      14             : !
      15             : ! !PUBLIC MEMBER FUNCTIONS:
      16             : !
      17             :   ! Public interface
      18             :   PUBLIC :: NcWr
      19             : 
      20             :   ! Private methods overloaded by public interface
      21             :   ! (see below for info about these routines & the arguments they take)
      22             :   INTERFACE NcWr
      23             :      MODULE PROCEDURE Ncwr_Scal_R4
      24             :      MODULE PROCEDURE Ncwr_Scal_R8
      25             :      MODULE PROCEDURE Ncwr_Scal_Int
      26             :      MODULE PROCEDURE Ncwr_1d_R8
      27             :      MODULE PROCEDURE Ncwr_1d_R4
      28             :      MODULE PROCEDURE Ncwr_1d_Int
      29             :      MODULE PROCEDURE Ncwr_1d_Char
      30             :      MODULE PROCEDURE Ncwr_2d_R8
      31             :      MODULE PROCEDURE Ncwr_2d_R4
      32             :      MODULE PROCEDURE Ncwr_2d_Int
      33             :      MODULE PROCEDURE Ncwr_2d_Char
      34             :      MODULE PROCEDURE Ncwr_3d_R8
      35             :      MODULE PROCEDURE Ncwr_3d_R4
      36             :      MODULE PROCEDURE Ncwr_3d_Int
      37             :      MODULE PROCEDURE Ncwr_4d_R8
      38             :      MODULE PROCEDURE Ncwr_4d_R4
      39             :      MODULE PROCEDURE Ncwr_4d_Int
      40             :      MODULE PROCEDURE Ncwr_5d_R8
      41             :      MODULE PROCEDURE Ncwr_5d_R4
      42             :      MODULE PROCEDURE Ncwr_6d_R8
      43             :      MODULE PROCEDURE Ncwr_6d_R4
      44             :   END INTERFACE NcWr
      45             : !
      46             : ! !DESCRIPTION: Routines for writing variables in a netCDF file.
      47             : !\\
      48             : !\\
      49             : ! !AUTHOR:
      50             : !  Jules Kouatchou
      51             : !
      52             : ! !REMARKS:
      53             : !  This file is based on code from NASA/GSFC, SIVO, Code 610.3
      54             : !
      55             : ! !REVISION HISTORY:
      56             : !  See https://github.com/geoschem/ncdfutil for complete history
      57             : !EOP
      58             : !-------------------------------------------------------------------------
      59             : !BOC
      60             : CONTAINS
      61             : !EOC
      62             : !-------------------------------------------------------------------------
      63             : !BOP
      64             : !
      65             : ! !IROUTINE: Ncwr_Scal_R4
      66             : !
      67             : ! !INTERFACE:
      68             : !
      69           0 :   subroutine NcWr_Scal_R4(varwr_scal, ncid, varname)
      70             : !
      71             : ! !USES:
      72             : !
      73             :     use netCDF
      74             :     use m_do_err_out
      75             : !
      76             : ! !INPUT PARAMETERS:
      77             : !!  ncid       : netCDF file id to write variable to
      78             : !!  varname    : netCDF variable name
      79             : !!  varwr_scal : variable to write out
      80             :     integer         , intent(in)   :: ncid
      81             :     character(len=*), intent(in)   :: varname
      82             :     real*4          , intent(in)   :: varwr_scal
      83             : !
      84             : ! !DESCRIPTION: Writes out a netCDF real scalar variable.
      85             : !\\
      86             : !\\
      87             : ! !AUTHOR:
      88             : !  John Tannahill (LLNL) and Jules Kouatchou
      89             : !
      90             : ! !REVISION HISTORY:
      91             : !  See https://github.com/geoschem/ncdfutil for complete history
      92             : !EOP
      93             : !-------------------------------------------------------------------------
      94             : !BOC
      95             : !
      96             : ! !LOCAL VARIABLES:
      97             :     character(len=512) :: err_msg
      98             :     integer            :: ierr
      99             :     integer            :: varid
     100             : !
     101           0 :     ierr = NF90_Inq_VarId(ncid, varname, varid)
     102             : 
     103           0 :     if (ierr /= NF90_NOERR) then
     104             :        err_msg = 'In Ncwr_Scal_R4 #1:  ' // Trim(varname) // &
     105           0 :                  ', ' // NF90_strerror(ierr)
     106           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     107             :     end if
     108             : 
     109           0 :     ierr = Nf90_Put_Var(ncid, varid, varwr_scal)
     110             : 
     111           0 :     if (ierr /= NF90_NOERR) then
     112           0 :        err_msg = 'In Ncwr_Scal+R4 #2:  ' // NF90_strerror(ierr)
     113           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     114             :     end if
     115             : 
     116           0 :   end subroutine Ncwr_Scal_R4
     117             : 
     118             : !-------------------------------------------------------------------------
     119             : !BOP
     120             : !
     121             : ! !IROUTINE: Ncwr_Scal_R8
     122             : !
     123             : ! !INTERFACE:
     124             : !
     125           0 :   subroutine Ncwr_Scal_R8(varwr_scal, ncid, varname)
     126             : !
     127             : ! !USES:
     128             : !
     129             :     use netCDF
     130             :     use m_do_err_out
     131             : !
     132             : ! !INPUT PARAMETERS:
     133             : !!  ncid       : netCDF file id to write variable to
     134             : !!  varname    : netCDF variable name
     135             : !!  varwr_scal : variable to write out
     136             :     integer         , intent(in)   :: ncid
     137             :     character(len=*), intent(in)   :: varname
     138             :     real*8          , intent(in)   :: varwr_scal
     139             : !
     140             : ! !DESCRIPTION: Writes out a netCDF real scalar variable.
     141             : !\\
     142             : !\\
     143             : ! !AUTHOR:
     144             : !  John Tannahill (LLNL) and Jules Kouatchou
     145             : !
     146             : ! !REVISION HISTORY:
     147             : !  See https://github.com/geoschem/ncdfutil for complete history
     148             : !EOP
     149             : !-------------------------------------------------------------------------
     150             : !BOC
     151             : !
     152             : ! !LOCAL VARIABLES:
     153             :     character(len=512) :: err_msg
     154             :     integer            :: ierr
     155             :     integer            :: varid
     156             : !
     157           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     158             : 
     159           0 :     if (ierr /= NF90_NOERR) then
     160             :        err_msg = 'In Ncwr_Scal_R8 #1:  ' // Trim(varname) // &
     161           0 :                  ', ' // NF90_strerror(ierr)
     162           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     163             :     end if
     164             : 
     165           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_scal)
     166             : 
     167           0 :     if (ierr /= NF90_NOERR) then
     168           0 :        err_msg = 'In Ncwr_Scal_R8 #2:  ' // NF90_strerror(ierr)
     169           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     170             :     end if
     171             : 
     172           0 :   end subroutine Ncwr_Scal_R8
     173             : !EOC
     174             : !-------------------------------------------------------------------------
     175             : !BOP
     176             : !
     177             : ! !IROUTINE: Ncwr_Scal_Int
     178             : !
     179             : ! !INTERFACE:
     180             : !
     181           0 :   subroutine Ncwr_Scal_Int(varwr_scali, ncid, varname)
     182             : !
     183             : ! !USES:
     184             : !
     185             :     use netCDF
     186             :     use m_do_err_out
     187             : !
     188             : ! !INPUT PARAMETERS:
     189             : !!  ncid       : netCDF file id to write variable to
     190             : !!  varname    : netCDF variable name
     191             : !!  varwr_scali : integer variable to write out
     192             :     integer         , intent(in)   :: ncid
     193             :     character(len=*), intent(in)   :: varname
     194             :     integer         , intent(in)   :: varwr_scali
     195             : !
     196             : ! !DESCRIPTION: Writes out a netCDF integer scalar variable.
     197             : !\\
     198             : !\\
     199             : ! !AUTHOR:
     200             : !  John Tannahill (LLNL) and Jules Kouatchou
     201             : !
     202             : ! !REVISION HISTORY:
     203             : !  See https://github.com/geoschem/ncdfutil for complete history
     204             : !EOP
     205             : !-------------------------------------------------------------------------
     206             : !BOC
     207             : !
     208             : ! !LOCAL VARIABLES:
     209             :     character(len=512) :: err_msg
     210             :     integer            :: ierr
     211             :     integer            :: varid
     212             : !
     213           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     214             : 
     215           0 :     if (ierr /= NF90_NOERR) then
     216             :        err_msg = 'In Ncwr_Scal_Int #1:  ' // Trim(varname) // &
     217           0 :                   ', ' // NF90_strerror(ierr)
     218           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     219             :     end if
     220             : 
     221           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_scali)
     222             : 
     223           0 :     if (ierr /= NF90_NOERR) then
     224           0 :        err_msg = 'In Ncwr_Scal_Int #2:  ' // NF90_strerror(ierr)
     225           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     226             :     end if
     227             : 
     228           0 :   end subroutine Ncwr_Scal_Int
     229             : !EOC
     230             : !-------------------------------------------------------------------------
     231             : !BOP
     232             : !
     233             : ! !IROUTINE: Ncwr_1d_R8
     234             : !
     235             : ! !INTERFACE:
     236             : !
     237           0 :   subroutine Ncwr_1d_R8(varwr_1d, ncid, varname, strt1d, cnt1d)
     238             : !
     239             : ! !USES:
     240             : !
     241             :     use netCDF
     242             :     use m_do_err_out
     243             : !
     244             : ! !INPUT PARAMETERS:
     245             : !!  ncid     : netCDF file id to write array output data to
     246             : !!  varname  : netCDF variable name for array
     247             : !!  strt1d   : vector specifying the index in varwr_1d where
     248             : !!             the first of the data values will be written
     249             : !!  cnt1d    : varwr_1d dimension
     250             : !!  varwr_1d : array to write out
     251             :     integer         , intent(in)   :: ncid
     252             :     character(len=*), intent(in)   :: varname
     253             :     integer         , intent(in)   :: strt1d(1)
     254             :     integer         , intent(in)   :: cnt1d (1)
     255             :     real*8          , intent(in)   :: varwr_1d(cnt1d(1))
     256             : !
     257             : ! !DESCRIPTION: Writes out a 1D netCDF real array and does some error
     258             : !  checking.
     259             : !\\
     260             : !\\
     261             : ! !AUTHOR:
     262             : !  John Tannahill (LLNL) and Jules Kouatchou
     263             : !
     264             : ! !REVISION HISTORY:
     265             : !  See https://github.com/geoschem/ncdfutil for complete history
     266             : !EOP
     267             : !-------------------------------------------------------------------------
     268             : !BOC
     269             : !
     270             : ! !LOCAL VARIABLES:
     271             :     character(len=512) :: err_msg
     272             :     integer             :: ierr
     273             :     integer             :: varid
     274             : !
     275           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     276             : 
     277           0 :     if (ierr /= NF90_NOERR) then
     278             :        err_msg = 'In Ncwr_1d_R8 #1:  ' // Trim(varname) // &
     279           0 :                   ', ' // NF90_strerror(ierr)
     280           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     281             :     end if
     282             : 
     283           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_1d, start=strt1d, count=cnt1d)
     284             :       
     285           0 :     if (ierr /= NF90_NOERR) then
     286           0 :        err_msg = 'In Ncwr_1d_R8 #2:  ' // NF90_strerror(ierr)
     287           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     288             :     end if
     289             : 
     290           0 :   end subroutine Ncwr_1d_R8
     291             : !EOC
     292             : !-------------------------------------------------------------------------
     293             : !BOP
     294             : !
     295             : ! !IROUTINE: Ncwr_1d_R4
     296             : !
     297             : ! !INTERFACE:
     298             : !
     299           0 :   subroutine Ncwr_1d_R4(varwr_1d, ncid, varname, strt1d, cnt1d)
     300             : !
     301             : ! !USES:
     302             : !
     303             :     use netCDF
     304             :     use m_do_err_out
     305             : !
     306             : ! !INPUT PARAMETERS:
     307             : !!  ncid     : netCDF file id to write array output data to
     308             : !!  varname  : netCDF variable name for array
     309             : !!  strt1d   : vector specifying the index in varwr_1d where
     310             : !!             the first of the data values will be written
     311             : !!  cnt1d    : varwr_1d dimension
     312             : !!  varwr_1d : array to write out
     313             :     integer          , intent(in)   :: ncid
     314             :     character (len=*), intent(in)   :: varname
     315             :     integer          , intent(in)   :: strt1d(1)
     316             :     integer          , intent(in)   :: cnt1d (1)
     317             :     real*4           , intent(in)   :: varwr_1d(cnt1d(1))
     318             : !
     319             : ! !DESCRIPTION: Writes out a 1D netCDF real array and does some error
     320             : !  checking.
     321             : !\\
     322             : !\\
     323             : ! !AUTHOR:
     324             : !  John Tannahill (LLNL) and Jules Kouatchou
     325             : !
     326             : ! !REVISION HISTORY:
     327             : !  See https://github.com/geoschem/ncdfutil for complete history
     328             : !EOP
     329             : !-------------------------------------------------------------------------
     330             : !BOC
     331             : !
     332             : ! !LOCAL VARIABLES:
     333             :     character(len=512) :: err_msg
     334             :     integer            :: ierr
     335             :     integer            :: varid
     336             : !
     337           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     338             : 
     339           0 :     if (ierr /= NF90_NOERR) then
     340             :        err_msg = 'In Ncwr_1d_R4 #1:  ' // Trim(varname) // &
     341           0 :                   ', ' // NF90_strerror(ierr)
     342           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     343             :     end if
     344             : 
     345           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_1d, start=strt1d, count=cnt1d)
     346             : 
     347           0 :     if (ierr /= NF90_NOERR) then
     348           0 :        err_msg = 'In Ncwr_1d_R4 #2:  ' // NF90_strerror(ierr)
     349           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     350             :     end if
     351             : 
     352           0 :   end subroutine Ncwr_1d_R4
     353             : !EOC
     354             : !-------------------------------------------------------------------------
     355             : !BOP
     356             : !
     357             : ! !IROUTINE: Ncwr_1d_Int
     358             : !
     359             : ! !INTERFACE:
     360             : !
     361           0 :   subroutine Ncwr_1d_Int(varwr_1di, ncid, varname, strt1d, cnt1d)
     362             : !
     363             : ! !USES:
     364             : !
     365             :     use netCDF
     366             :     use m_do_err_out
     367             : !
     368             : ! !INPUT PARAMETERS:
     369             : !!  ncid     : netCDF file id to write array output data to
     370             : !!  varname  : netCDF variable name for array
     371             : !!  strt1d   : vector specifying the index in varwr_1di where
     372             : !!             the first of the data values will be written
     373             : !!  cnt1d    : varwr_1di dimension
     374             : !!  varwr_1di : intger array to write out
     375             :     integer         , intent(in)   :: ncid
     376             :     character(len=*), intent(in)   :: varname
     377             :     integer         , intent(in)   :: strt1d(1)
     378             :     integer         , intent(in)   :: cnt1d (1)
     379             :     integer         , intent(in)   :: varwr_1di(cnt1d(1))
     380             : !
     381             : ! !DESCRIPTION: Writes out a 1D netCDF integer array and does some error
     382             : ! checking.
     383             : !\\
     384             : !\\
     385             : ! !AUTHOR:
     386             : !  John Tannahill (LLNL) and Jules Kouatchou
     387             : !
     388             : ! !REVISION HISTORY:
     389             : !  See https://github.com/geoschem/ncdfutil for complete history
     390             : !EOP
     391             : !-------------------------------------------------------------------------
     392             : !BOC
     393             : !
     394             : ! !LOCAL VARIABLES:
     395             :     character(len=512) :: err_msg
     396             :     integer            :: ierr
     397             :     integer            :: varid
     398             : !
     399           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     400             : 
     401           0 :     if (ierr /= NF90_NOERR) then
     402             :        err_msg = 'In Ncwr_1d_Int #1:  ' // Trim(varname) // &
     403           0 :                  ', ' // NF90_strerror(ierr)
     404           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     405             :     end if
     406             : 
     407           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_1di, start=strt1d, count=cnt1d)
     408             : 
     409           0 :     if (ierr /= NF90_NOERR) then
     410           0 :        err_msg = 'In Ncwr_1d_Int #2:  ' // NF90_strerror(ierr)
     411           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     412             :     end if
     413             : 
     414           0 :   end subroutine Ncwr_1d_Int
     415             : !EOC
     416             : !-------------------------------------------------------------------------
     417             : !BOP
     418             : !
     419             : ! !IROUTINE: Ncwr_2d_R8
     420             : !
     421             : ! !INTERFACE:
     422             : !
     423           0 :   subroutine Ncwr_2d_R8(varwr_2d, ncid, varname, strt2d, cnt2d)
     424             : !
     425             : ! !USES:
     426             : !
     427             :     use netCDF
     428             :     use m_do_err_out
     429             : !
     430             : ! !INPUT PARAMETERS:
     431             : !!  ncid     : netCDF file id to write array output data to
     432             : !!  varname  : netCDF variable name for array
     433             : !!  strt2d   : vector specifying the index in varwr_2d where
     434             : !!             the first of the data values will be written
     435             : !!  cnt2d    : varwr_2d dimensions
     436             : !!  varwr_2d : array to write out
     437             :     integer         , intent(in)   :: ncid
     438             :     character(len=*), intent(in)   :: varname
     439             :     integer         , intent(in)   :: strt2d(2)
     440             :     integer         , intent(in)   :: cnt2d (2)
     441             :     real*8          , intent(in)   :: varwr_2d(cnt2d(1), cnt2d(2))
     442             : !
     443             : ! !DESCRIPTION: Writes out a 2D netCDF real array and does some error checking.
     444             : !\\
     445             : !\\
     446             : ! !AUTHOR:
     447             : !  John Tannahill (LLNL) and Jules Kouatchou
     448             : !
     449             : ! !REVISION HISTORY:
     450             : !  See https://github.com/geoschem/ncdfutil for complete history
     451             : !EOP
     452             : !-------------------------------------------------------------------------
     453             : !BOC
     454             : !
     455             : ! !LOCAL VARIABLES:
     456             :     character(len=512) :: err_msg
     457             :     integer            :: ierr
     458             :     integer            :: varid
     459             : !
     460           0 :     ierr = NF90_Inq_Varid (ncid, varname, varid)
     461             : 
     462           0 :     if (ierr /= NF90_NOERR) then
     463             :        err_msg = 'In Ncwr_2d_R8 #1:  ' // Trim(varname) // &
     464           0 :                  ', ' // NF90_strerror(ierr)
     465           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     466             :     end if
     467             : 
     468           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_2d, start=strt2d, count=cnt2d)
     469             : 
     470           0 :     if (ierr /= NF90_NOERR) then
     471           0 :        err_msg = 'In Ncwr_2d_R8 #2:  ' // NF90_strerror(ierr)
     472           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     473             :     end if
     474             : 
     475           0 :   end subroutine Ncwr_2d_R8
     476             : !EOC
     477             : !-------------------------------------------------------------------------
     478             : !BOP
     479             : !
     480             : ! !IROUTINE: Ncwr_2d_R4
     481             : !
     482             : ! !INTERFACE:
     483             : !
     484           0 :   subroutine Ncwr_2d_R4(varwr_2d, ncid, varname, strt2d, cnt2d)
     485             : !
     486             : ! !USES:
     487             : !
     488             :     use netCDF
     489             :     use m_do_err_out
     490             : !
     491             : ! !INPUT PARAMETERS:
     492             : !!  ncid     : netCDF file id to write array output data to
     493             : !!  varname  : netCDF variable name for array
     494             : !!  strt2d   : vector specifying the index in varwr_2d where
     495             : !!             the first of the data values will be written
     496             : !!  cnt2d    : varwr_2d dimensions
     497             : !!  varwr_2d : array to write out
     498             :     integer          , intent(in)   :: ncid
     499             :     character (len=*), intent(in)   :: varname
     500             :     integer          , intent(in)   :: strt2d(2)
     501             :     integer          , intent(in)   :: cnt2d (2)
     502             :     real*4           , intent(in)   :: varwr_2d(cnt2d(1), cnt2d(2))
     503             : !
     504             : ! !DESCRIPTION: Writes out a 2D netCDF real array and does some error checking.
     505             : !\\
     506             : !\\
     507             : ! !AUTHOR:
     508             : !  John Tannahill (LLNL) and Jules Kouatchou
     509             : !
     510             : ! !REVISION HISTORY:
     511             : !  See https://github.com/geoschem/ncdfutil for complete history
     512             : !EOP
     513             : !-------------------------------------------------------------------------
     514             : !BOC
     515             : !
     516             : ! !LOCAL VARIABLES:
     517             :     character(len=512) :: err_msg
     518             :     integer            :: ierr
     519             :     integer            :: varid
     520             : !
     521           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     522             : 
     523           0 :     if (ierr /= NF90_NOERR) then
     524             :        err_msg = 'In Ncwr_2d_R4 #1:  ' // Trim(varname) // &
     525           0 :                   ', ' // NF90_strerror(ierr)
     526           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     527             :     end if
     528             : 
     529           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_2d, start=strt2d, count=cnt2d)
     530             : 
     531           0 :     if (ierr /= NF90_NOERR) then
     532           0 :        err_msg = 'In Ncwr_2d_R4 #2:  ' // NF90_strerror(ierr)
     533           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     534             :     end if
     535             : 
     536           0 :   end subroutine Ncwr_2d_R4
     537             : !EOC
     538             : !-------------------------------------------------------------------------
     539             : !BOP
     540             : !
     541             : ! !IROUTINE: Ncwr_2d_Int
     542             : !
     543             : ! !INTERFACE:
     544             : !
     545           0 :   subroutine Ncwr_2d_Int(varwr_2di, ncid, varname, strt2d, cnt2d)
     546             : !
     547             : ! !USES:
     548             : !
     549             :     use netCDF
     550             :     use m_do_err_out
     551             : !
     552             : ! !INPUT PARAMETERS:
     553             : !!  ncid     : netCDF file id to write array output data to
     554             : !!  varname  : netCDF variable name for array
     555             : !!  strt2d   : vector specifying the index in varwr_2di where
     556             : !!             the first of the data values will be written
     557             : !!  cnt2d    : varwr_2di dimensions
     558             : !!  varwr_2di : intger array to write out
     559             :     integer         , intent(in)   :: ncid
     560             :     character(len=*), intent(in)   :: varname
     561             :     integer         , intent(in)   :: strt2d(2)
     562             :     integer         , intent(in)   :: cnt2d (2)
     563             :     integer         , intent(in)   :: varwr_2di(cnt2d(1), cnt2d(2))
     564             : !
     565             : ! !DESCRIPTION: Writes out a 2D netCDF integer array and does some error
     566             : !   checking.
     567             : !\\
     568             : !\\
     569             : ! !AUTHOR:
     570             : !  John Tannahill (LLNL) and Jules Kouatchou
     571             : !
     572             : ! !REVISION HISTORY:
     573             : !  See https://github.com/geoschem/ncdfutil for complete history
     574             : !EOP
     575             : !-------------------------------------------------------------------------
     576             : !BOC
     577             : !
     578             : ! !LOCAL VARIABLES:
     579             :     character(len=512) :: err_msg
     580             :     integer            :: ierr
     581             :     integer            :: varid
     582             : !
     583           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     584             : 
     585           0 :     if (ierr /= NF90_NOERR) then
     586             :        err_msg = 'In Ncwr_2d_Int #1:  ' // Trim(varname) //  &
     587           0 :                  ', ' // NF90_strerror(ierr)
     588           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     589             :     end if
     590             : 
     591           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_2di, start=strt2d, count=cnt2d)
     592             : 
     593           0 :     if (ierr /= NF90_NOERR) then
     594           0 :        err_msg = 'In Ncwr_2d_Int #2:  ' // NF90_strerror(ierr)
     595           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     596             :     end if
     597             : 
     598           0 :   end subroutine Ncwr_2d_Int
     599             : !EOC
     600             : !-------------------------------------------------------------------------
     601             : !BOP
     602             : !
     603             : ! !IROUTINE: Ncwr_3d_R8
     604             : !
     605             : ! !INTERFACE:
     606             : !
     607           0 :   subroutine Ncwr_3d_R8(varwr_3d, ncid, varname, strt3d, cnt3d)
     608             : !
     609             : ! !USES:
     610             : !
     611             :     use netCDF
     612             :     use m_do_err_out
     613             : !
     614             : ! !INPUT PARAMETERS:
     615             : !!  ncid     : netCDF file id to write array output data to
     616             : !!  varname  : netCDF variable name for array
     617             : !!  strt3d   : vector specifying the index in varwr_3d where
     618             : !!             the first of the data values will be written
     619             : !!  cnt3d    : varwr_3d dimensions
     620             : !!  varwr_3d : array to write out
     621             :     integer         , intent(in)   :: ncid
     622             :     character(len=*), intent(in)   :: varname
     623             :     integer         , intent(in)   :: strt3d(3)
     624             :     integer         , intent(in)   :: cnt3d (3)
     625             :     real*8          , intent(in)   :: varwr_3d(cnt3d(1), cnt3d(2), cnt3d(3))
     626             : !
     627             : ! !DESCRIPTION: Writes out a 3D netCDF real array and does some error checking.
     628             : !\\
     629             : !\\
     630             : ! !AUTHOR:
     631             : !  John Tannahill (LLNL) and Jules Kouatchou
     632             : !
     633             : ! !REVISION HISTORY:
     634             : !  See https://github.com/geoschem/ncdfutil for complete history
     635             : !EOP
     636             : !-------------------------------------------------------------------------
     637             : !BOC
     638             : !
     639             : ! !LOCAL VARIABLES:
     640             :     character(len=512) :: err_msg
     641             :     integer            :: ierr
     642             :     integer            :: varid
     643             : !
     644           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     645             : 
     646           0 :     if (ierr /= NF90_NOERR) then
     647             :        err_msg = 'In Ncwr_3d_R8 #1:  ' // Trim(varname) // &
     648           0 :                   ', ' // NF90_strerror(ierr)
     649           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     650             :     end if
     651             : 
     652           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_3d, start=strt3d, count=cnt3d)
     653             : 
     654           0 :     if (ierr /= NF90_NOERR) then
     655           0 :        err_msg = 'In Ncwr_3d_R8 #2:  ' // NF90_strerror(ierr)
     656           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     657             :     end if
     658             : 
     659           0 :   end subroutine Ncwr_3d_R8
     660             : !EOC
     661             : !-------------------------------------------------------------------------
     662             : !BOP
     663             : !
     664             : ! !IROUTINE: Ncwr_3d_R4
     665             : !
     666             : ! !INTERFACE:
     667             : !
     668           0 :   subroutine Ncwr_3d_R4(varwr_3d, ncid, varname, strt3d, cnt3d)
     669             : !
     670             : ! !USES:
     671             : !
     672             :     use netCDF
     673             :     use m_do_err_out
     674             : !
     675             : ! !INPUT PARAMETERS:
     676             : !!  ncid     : netCDF file id to write array output data to
     677             : !!  varname  : netCDF variable name for array
     678             : !!  strt3d   : vector specifying the index in varwr_3d where
     679             : !!             the first of the data values will be written
     680             : !!  cnt3d    : varwr_3d dimensions
     681             : !!  varwr_3d : array to write out
     682             :     integer         , intent(in)   :: ncid
     683             :     character(len=*), intent(in)   :: varname
     684             :     integer         , intent(in)   :: strt3d(3)
     685             :     integer         , intent(in)   :: cnt3d (3)
     686             :     real*4          , intent(in)   :: varwr_3d(cnt3d(1), cnt3d(2), cnt3d(3))
     687             : !
     688             : ! !DESCRIPTION: Writes out a 3D netCDF real array and does some error checking.
     689             : !\\
     690             : !\\
     691             : ! !AUTHOR:
     692             : !  John Tannahill (LLNL) and Jules Kouatchou
     693             : !
     694             : ! !REVISION HISTORY:
     695             : !  See https://github.com/geoschem/ncdfutil for complete history
     696             : !EOP
     697             : !-------------------------------------------------------------------------
     698             : !BOC
     699             : !
     700             : ! !LOCAL VARIABLES:
     701             :     character(len=512) :: err_msg
     702             :     integer            :: ierr
     703             :     integer            :: varid
     704             : !
     705           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     706             : 
     707           0 :     if (ierr /= NF90_NOERR) then
     708             :        err_msg = 'In Ncwr_3d_R4 #1:  ' // Trim(varname) // &
     709           0 :                  ', ' // NF90_strerror(ierr)
     710           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     711             :     end if
     712             : 
     713           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_3d, start=strt3d, count=cnt3d)
     714             : 
     715           0 :     if (ierr /= NF90_NOERR) then
     716           0 :        err_msg = 'In Ncwr_3d_R4 #2:  ' // NF90_Strerror(ierr)
     717           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     718             :     end if
     719             : 
     720           0 :   end subroutine Ncwr_3d_R4
     721             : !EOC
     722             : !-------------------------------------------------------------------------
     723             : !BOP
     724             : !
     725             : ! !IROUTINE: Ncwr_3d_Int
     726             : !
     727             : ! !INTERFACE:
     728             : !
     729           0 :   subroutine Ncwr_3d_Int(varwr_3di, ncid, varname, strt3d, cnt3d)
     730             : !
     731             : ! !USES:
     732             : !
     733             :     use netCDF
     734             :     use m_do_err_out
     735             : !
     736             : ! !INPUT PARAMETERS:
     737             : !!  ncid     : netCDF file id to write array output data to
     738             : !!  varname  : netCDF variable name for array
     739             : !!  strt3d   : vector specifying the index in varwr_3di where
     740             : !!             the first of the data values will be written
     741             : !!  cnt3d    : varwr_3di dimensions
     742             : !!  varwr_3di : intger array to write out
     743             :     integer         , intent(in)   :: ncid
     744             :     character(len=*), intent(in)   :: varname
     745             :     integer         , intent(in)   :: strt3d(3)
     746             :     integer         , intent(in)   :: cnt3d (3)
     747             :     integer         , intent(in)   :: varwr_3di(cnt3d(1), cnt3d(2), cnt3d(3))
     748             : !
     749             : ! !DESCRIPTION: Writes out a 3D netCDF integer array and does some error
     750             : !  checking.
     751             : !\\
     752             : !\\
     753             : ! !AUTHOR:
     754             : !  John Tannahill (LLNL) and Jules Kouatchou
     755             : !
     756             : ! !REVISION HISTORY:
     757             : !  See https://github.com/geoschem/ncdfutil for complete history
     758             : !EOP
     759             : !-------------------------------------------------------------------------
     760             : !BOC
     761             : !
     762             : ! !LOCAL VARIABLES:
     763             :     character(len=512) :: err_msg
     764             :     integer            :: ierr
     765             :     integer            :: varid
     766             : !
     767           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     768             : 
     769           0 :     if (ierr /= NF90_NOERR) then
     770             :        err_msg = 'In Ncwr_3d_Int #1:  ' // Trim(varname) // &
     771           0 :                   ', ' // NF90_strerror(ierr)
     772           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     773             :     end if
     774             : 
     775           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_3di, start=strt3d, count=cnt3d)
     776             : 
     777           0 :     if (ierr /= NF90_NOERR) then
     778           0 :        err_msg = 'In Ncwr_3d_Int #2:  ' // NF90_Strerror(ierr)
     779           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     780             :     end if
     781             : 
     782           0 :   end subroutine Ncwr_3d_Int
     783             : !EOC
     784             : !-------------------------------------------------------------------------
     785             : !BOP
     786             : !
     787             : ! !IROUTINE: Ncwr_4d_R8
     788             : !
     789             : ! !INTERFACE:
     790             : !
     791           0 :   subroutine Ncwr_4d_R8(varwr_4d, ncid, varname, strt4d, cnt4d)
     792             : !
     793             : ! !USES:
     794             : !
     795             :     use netCDF
     796             :     use m_do_err_out
     797             : !
     798             : ! !INPUT PARAMETERS:
     799             : !!  ncid     : netCDF file id to write array output data to
     800             : !!  varname  : netCDF variable name for array
     801             : !!  strt4d   : vector specifying the index in varwr_4d where
     802             : !!             the first of the data values will be written
     803             : !!  cnt4d    : varwr_4d dimensions
     804             : !!  varwr_4d : array to write out
     805             :     integer         , intent(in)   :: ncid
     806             :     character(len=*), intent(in)   :: varname
     807             :     integer         , intent(in)   :: strt4d(4)
     808             :     integer         , intent(in)   :: cnt4d (4)
     809             :     real*8          , intent(in)   :: varwr_4d(cnt4d(1), cnt4d(2), &
     810             :                                                cnt4d(3), cnt4d(4))
     811             : !
     812             : ! !DESCRIPTION: Writes out a 4D netCDF real array and does some error checking.
     813             : !\\
     814             : !\\
     815             : ! !AUTHOR:
     816             : !  John Tannahill (LLNL) and Jules Kouatchou
     817             : !
     818             : ! !REVISION HISTORY:
     819             : !  See https://github.com/geoschem/ncdfutil for complete history
     820             : !EOP
     821             : !-------------------------------------------------------------------------
     822             : !BOC
     823             : !
     824             : ! !LOCAL VARIABLES:
     825             :     character(len=512) :: err_msg
     826             :     integer            :: ierr
     827             :     integer            :: varid
     828             : !
     829           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     830             : 
     831           0 :     if (ierr /= NF90_NOERR) then
     832             :        err_msg = 'In Ncwr_4d_R8 #1:  ' // Trim(varname) // &
     833           0 :                   ', ' // NF90_strerror(ierr)
     834           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     835             :     end if
     836             : 
     837           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_4d, start=strt4d, count=cnt4d)
     838             : 
     839           0 :     if (ierr /= NF90_NOERR) then
     840           0 :        err_msg = 'In Ncwr_4d_R8 #2:  ' // NF90_strerror(ierr)
     841           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     842             :     end if
     843             : 
     844           0 :   end subroutine Ncwr_4d_R8
     845             : !EOC
     846             : !-------------------------------------------------------------------------
     847             : !BOP
     848             : !
     849             : ! !IROUTINE: Ncwr_4d_R4
     850             : !
     851             : ! !INTERFACE:
     852             : !
     853           0 :   subroutine Ncwr_4d_R4(varwr_4d, ncid, varname, strt4d, cnt4d)
     854             : !
     855             : ! !USES:
     856             : !
     857             :     use netCDF
     858             :     use m_do_err_out
     859             : !
     860             : ! !INPUT PARAMETERS:
     861             : !!  ncid     : netCDF file id to write array output data to
     862             : !!  varname  : netCDF variable name for array
     863             : !!  strt4d   : vector specifying the index in varwr_4d where
     864             : !!             the first of the data values will be written
     865             : !!  cnt4d    : varwr_4d dimensions
     866             : !!  varwr_4d : array to write out
     867             :     integer         , intent(in)   :: ncid
     868             :     character(len=*), intent(in)   :: varname
     869             :     integer         , intent(in)   :: strt4d(4)
     870             :     integer         , intent(in)   :: cnt4d (4)
     871             :     real*4          , intent(in)   :: varwr_4d(cnt4d(1), cnt4d(2), &
     872             :                                                cnt4d(3), cnt4d(4))
     873             : !
     874             : ! !DESCRIPTION: Writes out a 4D netCDF real array and does some error checking.
     875             : !\\
     876             : !\\
     877             : ! !AUTHOR:
     878             : !  John Tannahill (LLNL) and Jules Kouatchou
     879             : !
     880             : ! !REVISION HISTORY:
     881             : !  See https://github.com/geoschem/ncdfutil for complete history
     882             : !EOP
     883             : !-------------------------------------------------------------------------
     884             : !BOC
     885             : !
     886             : ! !LOCAL VARIABLES:
     887             :     character(len=512) :: err_msg
     888             :     integer            :: ierr
     889             :     integer            :: varid
     890             : !
     891           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     892             : 
     893           0 :     if (ierr /= NF90_NOERR) then
     894             :        err_msg = 'In Ncwr_4d_R4 #1:  ' // Trim(varname) // &
     895           0 :                   ', ' // NF90_strerror(ierr)
     896           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     897             :     end if
     898             : 
     899           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_4d, start=strt4d, count=cnt4d)
     900             : 
     901           0 :     if (ierr /= NF90_NOERR) then
     902           0 :        err_msg = 'In Ncwr_4d_R4 #2:  ' // NF90_strerror(ierr)
     903           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     904             :     end if
     905             : 
     906           0 :   end subroutine Ncwr_4d_R4
     907             : !EOC
     908             : !-------------------------------------------------------------------------
     909             : !BOP
     910             : !
     911             : ! !IROUTINE: Ncwr_3d_Int
     912             : !
     913             : ! !INTERFACE:
     914             : !
     915           0 :   subroutine Ncwr_4d_Int(varwr_4di, ncid, varname, strt4d, cnt4d)
     916             : !
     917             : ! !USES:
     918             : !
     919             :     use netCDF
     920             :     use m_do_err_out
     921             : !
     922             : ! !INPUT PARAMETERS:
     923             : !!  ncid     : netCDF file id to write array output data to
     924             : !!  varname  : netCDF variable name for array
     925             : !!  strt3d   : vector specifying the index in varwr_3di where
     926             : !!             the first of the data values will be written
     927             : !!  cnt3d    : varwr_3di dimensions
     928             : !!  varwr_3di : intger array to write out
     929             :     integer         , intent(in)   :: ncid
     930             :     character(len=*), intent(in)   :: varname
     931             :     integer         , intent(in)   :: strt4d(4)
     932             :     integer         , intent(in)   :: cnt4d (4)
     933             :     integer         , intent(in)   :: varwr_4di(cnt4d(1), cnt4d(2), &
     934             :                                                 cnt4d(3), cnt4d(4))
     935             : !
     936             : ! !DESCRIPTION: Writes out a 3D netCDF integer array and does some error
     937             : !  checking.
     938             : !\\
     939             : !\\
     940             : ! !AUTHOR:
     941             : !  John Tannahill (LLNL) and Jules Kouatchou
     942             : !
     943             : ! !REVISION HISTORY:
     944             : !  See https://github.com/geoschem/ncdfutil for complete history
     945             : !EOP
     946             : !-------------------------------------------------------------------------
     947             : !BOC
     948             : !
     949             : ! !LOCAL VARIABLES:
     950             :     character(len=512) :: err_msg
     951             :     integer            :: ierr
     952             :     integer            :: varid
     953             : !
     954           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
     955             : 
     956           0 :     if (ierr /= NF90_NOERR) then
     957             :        err_msg = 'In Ncwr_4d_Int #1:  ' // Trim(varname) // &
     958           0 :                   ', ' // NF90_strerror(ierr)
     959           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     960             :     end if
     961             : 
     962           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_4di, start=strt4d, count=cnt4d)
     963             :       
     964           0 :     if (ierr /= NF90_NOERR) then
     965           0 :        err_msg = 'In Ncwr_4d_Int #2:  ' // NF90_strerror(ierr)
     966           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
     967             :     end if
     968             : 
     969           0 :   end subroutine Ncwr_4d_Int
     970             : !EOC
     971             : !-------------------------------------------------------------------------
     972             : !BOP
     973             : !
     974             : ! !IROUTINE: Ncwr_5d_R8
     975             : !
     976             : ! !INTERFACE:
     977             : !
     978           0 :   subroutine Ncwr_5d_R8(varwr_5d, ncid, varname, strt5d, cnt5d)
     979             : !
     980             : ! !USES:
     981             : !
     982             :     use netCDF
     983             :     use m_do_err_out
     984             : !
     985             : ! !INPUT PARAMETERS:
     986             : !!  ncid     : netCDF file id to write array output data to
     987             : !!  varname  : netCDF variable name for array
     988             : !!  strt5d   : vector specifying the index in varwr_5d where
     989             : !!             the first of the data values will be written
     990             : !!  cnt5d    : varwr_5d dimensions
     991             : !!  varwr_5d : array to write out
     992             :     integer         , intent(in)   :: ncid
     993             :     character(len=*), intent(in)   :: varname
     994             :     integer         , intent(in)   :: strt5d(5)
     995             :     integer         , intent(in)   :: cnt5d (5)
     996             :     real*8          , intent(in)   :: varwr_5d(cnt5d(1), cnt5d(2), &
     997             :                                                cnt5d(3), cnt5d(4), &
     998             :                                                cnt5d(5))
     999             : !
    1000             : ! !DESCRIPTION: Writes out a 5D netCDF real array and does some error checking.
    1001             : !\\
    1002             : !\\
    1003             : ! !AUTHOR:
    1004             : !  John Tannahill (LLNL) and Jules Kouatchou
    1005             : !
    1006             : ! !REVISION HISTORY:
    1007             : !  See https://github.com/geoschem/ncdfutil for complete history
    1008             : !EOP
    1009             : !-------------------------------------------------------------------------
    1010             : !BOC
    1011             : !
    1012             : ! !LOCAL VARIABLES:
    1013             :     character(len=512) :: err_msg
    1014             :     integer            :: ierr
    1015             :     integer            :: varid
    1016             : !
    1017           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
    1018             : 
    1019           0 :     if (ierr /= NF90_NOERR) then
    1020             :        err_msg = 'In Ncwr_5d_R8 #1:  ' // Trim(varname) // &
    1021           0 :                  ', ' // NF90_strerror(ierr)
    1022           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
    1023             :     end if
    1024             : 
    1025           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_5d, start=strt5d, count=cnt5d)
    1026             : 
    1027           0 :     if (ierr /= NF90_NOERR) then
    1028           0 :        err_msg = 'In Ncwr_5d_R8 #2:  ' // NF90_Strerror(ierr)
    1029           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
    1030             :     end if
    1031             : 
    1032           0 :   end subroutine Ncwr_5d_R8
    1033             : !EOC
    1034             : !-------------------------------------------------------------------------
    1035             : !BOP
    1036             : !
    1037             : ! !IROUTINE: Ncwr_5d_R4
    1038             : !
    1039             : ! !INTERFACE:
    1040             : !
    1041           0 :   subroutine Ncwr_5d_R4(varwr_5d, ncid, varname, strt5d, cnt5d)
    1042             : !
    1043             : ! !USES:
    1044             : !
    1045             :     use netCDF
    1046             :     use m_do_err_out
    1047             : !
    1048             : ! !INPUT PARAMETERS:
    1049             : !!  ncid     : netCDF file id to write array output data to
    1050             : !!  varname  : netCDF variable name for array
    1051             : !!  strt5d   : vector specifying the index in varwr_5d where
    1052             : !!             the first of the data values will be written
    1053             : !!  cnt5d    : varwr_5d dimensions
    1054             : !!  varwr_5d : array to write out
    1055             :     integer         , intent(in)   :: ncid
    1056             :     character(len=*), intent(in)   :: varname
    1057             :     integer         , intent(in)   :: strt5d(5)
    1058             :     integer         , intent(in)   :: cnt5d (5)
    1059             :     real*4          , intent(in)   :: varwr_5d(cnt5d(1), cnt5d(2), &
    1060             :                                                cnt5d(3), cnt5d(4), &
    1061             :                                                cnt5d(5))
    1062             : !
    1063             : ! !DESCRIPTION: Writes out a 5D netCDF real array and does some error checking.
    1064             : !\\
    1065             : !\\
    1066             : ! !AUTHOR:
    1067             : !  John Tannahill (LLNL) and Jules Kouatchou
    1068             : !
    1069             : ! !REVISION HISTORY:
    1070             : !  See https://github.com/geoschem/ncdfutil for complete history
    1071             : !EOP
    1072             : !-------------------------------------------------------------------------
    1073             : !BOC
    1074             : !
    1075             : ! !LOCAL VARIABLES:
    1076             :     character(len=512) :: err_msg
    1077             :     integer            :: ierr
    1078             :     integer            :: varid
    1079             : !
    1080           0 :     ierr = NF90_Inq_Varid (ncid, varname, varid)
    1081             : 
    1082           0 :     if (ierr /= NF90_NOERR) then
    1083             :        err_msg = 'In Ncwr_5d_R4 #1:  ' // Trim(varname) // &
    1084           0 :                  ', ' // NF90_Strerror(ierr)
    1085           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
    1086             :     end if
    1087             : 
    1088           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_5d, start=strt5d, count=cnt5d)
    1089             : 
    1090           0 :     if (ierr /= NF90_NOERR) then
    1091           0 :        err_msg = 'In Ncwr_5d_R4 #2:  ' // NF90_strerror(ierr)
    1092           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
    1093             :     end if
    1094             : 
    1095           0 :   end subroutine Ncwr_5d_R4
    1096             : !EOC
    1097             : !-------------------------------------------------------------------------
    1098             : !BOP
    1099             : !
    1100             : ! !IROUTINE: Ncwr_6d_R8
    1101             : !
    1102             : ! !INTERFACE:
    1103             : !
    1104           0 :   subroutine Ncwr_6d_R8(varwr_6d, ncid, varname, strt6d, cnt6d)
    1105             : !
    1106             : ! !USES:
    1107             : !
    1108             :     use netCDF
    1109             :     use m_do_err_out
    1110             : !
    1111             : ! !INPUT PARAMETERS:
    1112             : !!  ncid     : netCDF file id to write array output data to
    1113             : !!  varname  : netCDF variable name for array
    1114             : !!  strt6d   : vector specifying the index in varwr_6d where
    1115             : !!             the first of the data values will be written
    1116             : !!  cnt6d    : varwr_6d dimensions
    1117             : !!  varwr_6d : array to write out
    1118             :     integer         , intent(in)   :: ncid
    1119             :     character(len=*), intent(in)   :: varname
    1120             :     integer         , intent(in)   :: strt6d(6)
    1121             :     integer         , intent(in)   :: cnt6d (6)
    1122             :     real*8          , intent(in)   :: varwr_6d(cnt6d(1), cnt6d(2), &
    1123             :                                                cnt6d(3), cnt6d(4), &
    1124             :                                                cnt6d(5), cnt6d(6))
    1125             : !
    1126             : ! !DESCRIPTION: Writes out a 6D netCDF real array and does some error checking.
    1127             : !\\
    1128             : !\\
    1129             : ! !AUTHOR:
    1130             : !  John Tannahill (LLNL) and Jules Kouatchou
    1131             : !
    1132             : ! !REVISION HISTORY:
    1133             : !  See https://github.com/geoschem/ncdfutil for complete history
    1134             : !EOP
    1135             : !-------------------------------------------------------------------------
    1136             : !BOC
    1137             : !
    1138             : ! !LOCAL VARIABLES:
    1139             :     character(len=512) :: err_msg
    1140             :     integer            :: ierr
    1141             :     integer            :: varid
    1142             : !
    1143           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
    1144             : 
    1145           0 :     if (ierr /= NF90_NOERR) then
    1146             :        err_msg = 'In Ncwr_6d_R8 #1:  ' // Trim(varname) // &
    1147           0 :                   ', ' // NF90_Strerror(ierr)
    1148           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
    1149             :     end if
    1150             : 
    1151           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_6d, start=strt6d, count=cnt6d)
    1152             : 
    1153           0 :     if (ierr /= NF90_NOERR) then
    1154           0 :        err_msg = 'In Ncwr_6d_R8 #2:  ' // NF90_strerror(ierr)
    1155           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
    1156             :     end if
    1157             : 
    1158           0 :   end subroutine Ncwr_6d_R8
    1159             : !EOC
    1160             : !-------------------------------------------------------------------------
    1161             : !BOP
    1162             : !
    1163             : ! !IROUTINE: Ncwr_6d_R4
    1164             : !
    1165             : ! !INTERFACE:
    1166             : !
    1167           0 :   subroutine Ncwr_6d_R4(varwr_6d, ncid, varname, strt6d, cnt6d)
    1168             : !
    1169             : ! !USES:
    1170             : !
    1171             :     use netCDF
    1172             :     use m_do_err_out
    1173             : !
    1174             : ! !INPUT PARAMETERS:
    1175             : !!  ncid     : netCDF file id to write array output data to
    1176             : !!  varname  : netCDF variable name for array
    1177             : !!  strt6d   : vector specifying the index in varwr_6d where
    1178             : !!             the first of the data values will be written
    1179             : !!  cnt6d    : varwr_6d dimensions
    1180             : !!  varwr_6d : array to write out
    1181             :     integer         , intent(in)   :: ncid
    1182             :     character(len=*), intent(in)   :: varname
    1183             :     integer         , intent(in)   :: strt6d(6)
    1184             :     integer         , intent(in)   :: cnt6d (6)
    1185             :     real*4          , intent(in)   :: varwr_6d(cnt6d(1), cnt6d(2), &
    1186             :                                                cnt6d(3), cnt6d(4), &
    1187             :                                                cnt6d(5), cnt6d(6))
    1188             : !
    1189             : ! !DESCRIPTION: Writes out a 6D netCDF real array and does some error checking.
    1190             : !\\
    1191             : !\\
    1192             : ! !AUTHOR:
    1193             : !  John Tannahill (LLNL) and Jules Kouatchou
    1194             : !
    1195             : ! !REVISION HISTORY:
    1196             : !  See https://github.com/geoschem/ncdfutil for complete history
    1197             : !EOP
    1198             : !-------------------------------------------------------------------------
    1199             : !BOC
    1200             : !
    1201             : ! !LOCAL VARIABLES:
    1202             :     character(len=512) :: err_msg
    1203             :     integer            :: ierr
    1204             :     integer            :: varid
    1205             : !
    1206           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
    1207             : 
    1208           0 :     if (ierr /= NF90_NOERR) then
    1209             :        err_msg = 'In Ncwr_6d_R4 #1:  ' // Trim(varname) // &
    1210           0 :                   ', ' // NF90_Strerror(ierr)
    1211           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
    1212             :     end if
    1213             : 
    1214           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_6d, start=strt6d, count=cnt6d)
    1215             : 
    1216           0 :     if (ierr /= NF90_NOERR) then
    1217           0 :        err_msg = 'In Ncwr_6d_R4 #2:  ' // NF90_Strerror(ierr)
    1218           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
    1219             :     end if
    1220             : 
    1221           0 :   end subroutine Ncwr_6d_R4
    1222             : !EOC
    1223             : !-------------------------------------------------------------------------
    1224             : !BOP
    1225             : !
    1226             : ! !IROUTINE: Ncwr_1d_Char
    1227             : !
    1228             : ! !INTERFACE:
    1229             : !
    1230           0 :   subroutine Ncwr_1d_Char(varwr_1dc, ncid, varname, strt1d, cnt1d)
    1231             : !
    1232             : ! !USES:
    1233             : !
    1234             :     use netCDF
    1235             :     use m_do_err_out
    1236             : !
    1237             : ! !INPUT PARAMETERS:
    1238             : !!  ncid     : netCDF file id to write array output data to
    1239             : !!  varname  : netCDF variable name for array
    1240             : !!  strt1d   : vector specifying the index in varwr_1dc where
    1241             : !!             the first of the data values will be written
    1242             : !!  cnt1d    : varwr_1dc dimension
    1243             : !!  varwr_1dc : intger array to write out
    1244             :     integer          , intent(in)   :: ncid
    1245             :     character (len=*), intent(in)   :: varname
    1246             :     integer          , intent(in)   :: strt1d(1)
    1247             :     integer          , intent(in)   :: cnt1d (1)
    1248             :     character (len=1), intent(in)   :: varwr_1dc(cnt1d(1))
    1249             : !
    1250             : ! !DESCRIPTION: Writes out a 1D netCDF character array and does some error
    1251             : !   checking.
    1252             : !\\
    1253             : !\\
    1254             : ! !AUTHOR:
    1255             : !  Jules Kouatchou
    1256             : !
    1257             : ! !REVISION HISTORY:
    1258             : !  See https://github.com/geoschem/ncdfutil for complete history
    1259             : !EOP
    1260             : !-------------------------------------------------------------------------
    1261             : !BOC
    1262             : !
    1263             : ! !LOCAL VARIABLES:
    1264             :     character(len=512) :: err_msg
    1265             :     integer            :: ierr
    1266             :     integer            :: varid
    1267             : !
    1268           0 :     ierr = NF90_Inq_Varid(ncid, varname, varid)
    1269             :       
    1270           0 :     if (ierr /= NF90_NOERR) then
    1271             :        err_msg = 'In Ncwr_1d_Char #1:  ' // Trim(varname) // &
    1272           0 :                  ', ' // NF90_strerror(ierr)
    1273           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
    1274             :     end if
    1275             : 
    1276           0 :     ierr = NF90_Put_Var(ncid, varid, varwr_1dc, start=strt1d, count=cnt1d)
    1277             : 
    1278           0 :     if (ierr /= NF90_NOERR) then
    1279           0 :        err_msg = 'In Ncwr_1d_Char #2:  ' // NF90_strerror(ierr)
    1280           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
    1281             :     end if
    1282             : 
    1283           0 :   end subroutine Ncwr_1d_Char
    1284             : !EOC
    1285             : !-------------------------------------------------------------------------
    1286             : !BOP
    1287             : !
    1288             : ! !IROUTINE: Ncwr_2d_Char
    1289             : !
    1290             : ! !INTERFACE:
    1291             : !
    1292           0 :   subroutine Ncwr_2d_Char(char_2d, ncid, tvarname, strt2d, cnt2d)
    1293             : !
    1294             : ! !USES:
    1295             : !
    1296             :     use netCDF
    1297             :     use m_do_err_out
    1298             : !
    1299             : ! !INPUT PARAMETERS:
    1300             : !!  ncid     : netCDF file id to write text to
    1301             : !!  tvarname : netCDF variable name for text
    1302             : !!  strt2d   : vector specifying the index in char_2d where
    1303             : !!             the first of the data values will be written
    1304             : !!  cnt2d    : char_2d dimensions
    1305             : !!  char_2d  : text to write
    1306             :     integer         , intent(in)   :: ncid
    1307             :     character(len=*), intent(in)   :: tvarname
    1308             :     integer         , intent(in)   :: strt2d(2)
    1309             :     integer         , intent(in)   :: cnt2d (2)
    1310             :     character(len=1), intent(in)   :: char_2d(cnt2d(1), cnt2d(2))
    1311             : !
    1312             : ! !DESCRIPTION: Writes out a 2D netCDF character array and does some error
    1313             : !  checking.
    1314             : !\\
    1315             : !\\
    1316             : ! !AUTHOR:
    1317             : !  John Tannahill (LLNL) and Jules Kouatchou
    1318             : !
    1319             : ! !REVISION HISTORY:
    1320             : !  See https://github.com/geoschem/ncdfutil for complete history
    1321             : !EOP
    1322             : !-------------------------------------------------------------------------
    1323             : !BOC
    1324             : !
    1325             : ! !LOCAL VARIABLES:
    1326             :     character(len=512) :: err_msg
    1327             :     integer            :: ierr
    1328             :     integer            :: tvarid
    1329             : !
    1330           0 :     ierr = NF90_Inq_Varid(ncid, tvarname, tvarid)
    1331             : 
    1332           0 :     if (ierr /= NF90_NOERR) then
    1333             :        err_msg = 'In Ncwr_2d_Char #1:  ' // Trim(tvarname) // &
    1334           0 :                   ', ' // NF90_Strerror(ierr)
    1335           0 :        call Do_Err_Out(err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
    1336             :     end if
    1337             : 
    1338           0 :     ierr = NF90_Put_Var(ncid, tvarid, char_2d, start=strt2d, count=cnt2d)
    1339             : 
    1340           0 :     if (ierr /= NF90_NOERR) then
    1341           0 :        err_msg = 'In Ncwr_2d_Char #2:  ' // NF90_Strerror(ierr)
    1342           0 :        call Do_Err_Out(err_msg, .true., 2, ncid, tvarid, 0, 0.0d0, 0.0d0)
    1343             :     end if
    1344             : 
    1345           0 :   end subroutine Ncwr_2d_Char
    1346             : !EOC
    1347             : !------------------------------------------------------------------------
    1348             : end module HCO_m_netcdf_io_write
    1349             : 

Generated by: LCOV version 1.14