LCOV - code coverage report
Current view: top level - hemco/HEMCO/src/Shared/NcdfUtil - hco_m_netcdf_io_create.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 16 0.0 %
Date: 2025-03-13 18:42:46 Functions: 0 2 0.0 %

          Line data    Source code
       1             : !------------------------------------------------------------------------------
       2             : !       NcdfUtilities: by Harvard Atmospheric Chemistry Modeling Group        !
       3             : !                      and NASA/GSFC, SIVO, Code 610.3                        !
       4             : !------------------------------------------------------------------------------
       5             : !BOP
       6             : !
       7             : ! !MODULE: HCO_m_netcdf_io_create.F90
       8             : !
       9             : ! !INTERFACE:
      10             : !
      11             : module HCO_m_netcdf_io_create
      12             : !
      13             :   implicit none
      14             : !
      15             : ! !PUBLIC MEMBER FUNCTIONS:
      16             : !
      17             :   public  Nccr_Wr
      18             :   public  Ncdo_Sync
      19             : !
      20             : ! !DESCRIPTION: Routines for creating and syncronizing netCDF files.
      21             : !\\
      22             : !\\
      23             : ! !AUTHOR:
      24             : !  Jules Kouatchou
      25             : !
      26             : ! !REVISION HISTORY:
      27             : !  See https://github.com/geoschem/ncdfutil for complete history
      28             : !EOP
      29             : !------------------------------------------------------------------------------
      30             : !BOC
      31             : CONTAINS
      32             : !EOC
      33             : !------------------------------------------------------------------------------
      34             : !       NcdfUtilities: by Harvard Atmospheric Chemistry Modeling Group        !
      35             : !                      and NASA/GSFC, SIVO, Code 610.3                        !
      36             : !------------------------------------------------------------------------------
      37             : !BOP
      38             : !
      39             : ! !IROUTINE: Nccr_Wr
      40             : !
      41             : ! !INTERFACE:
      42             : !
      43           0 :   subroutine Nccr_Wr (ncid, filname, WRITE_NC4)
      44             : !
      45             : ! !USES:
      46             : !
      47             :     use m_do_err_out
      48             : !
      49             :     implicit none
      50             : !
      51             :     include "netcdf.inc"
      52             : !
      53             : ! !INPUT PARAMETERS:
      54             : !   ncid    : opened netCDF file id
      55             : !   filname : name of netCDF file to open for writing
      56             :     integer          , intent(in)   :: ncid
      57             :     character (len=*), intent(in)   :: filname
      58             :     LOGICAL, OPTIONAL, INTENT(IN)   :: WRITE_NC4
      59             : !
      60             : ! !DESCRIPTION: Creates a netCDF file for writing and does some error checking.
      61             : !\\
      62             : !\\
      63             : ! !AUTHOR:
      64             : !  John Tannahill (LLNL) and Jules Kouatchou
      65             : !
      66             : ! !REMARKS:
      67             : !  If the netCDF4 library is used, then the NF_CLOBBER flag will write
      68             : !  a classic (i.e. netCDF3) file.  Use OR(NF_NETCDF4,NF_CLASSIC_MODEL) to
      69             : !  create netCDF-4 file that supports compression and uses "classic" netcdf data model
      70             : !  (no groups, no user-defined types)
      71             : !
      72             : ! !REVISION HISTORY:
      73             : !  See https://github.com/geoschem/ncdfutil for complete history
      74             : !EOP
      75             : !-------------------------------------------------------------------------
      76             : !BOC
      77             : !
      78             : ! !LOCAL VARIABLES:
      79             :     character (len=128) :: err_msg
      80             :     integer             :: ierr
      81             :     INTEGER             :: mode
      82             :     LOGICAL             :: TMP_NC4
      83             : !
      84             :     ! Save the value of the optional WRITE_NC4 variable in
      85             :     ! a local shadow variable (bmy, 11/7/11)
      86           0 :     IF ( PRESENT( WRITE_NC4 ) ) THEN
      87           0 :        TMP_NC4 = WRITE_NC4
      88             :     ELSE
      89             :        TMP_NC4 = .FALSE.
      90             :     ENDIF
      91             : 
      92           0 :     IF ( TMP_NC4 ) THEN
      93             : #if defined( NC_HAS_COMPRESSION )
      94             :        mode = IOR( NF_NETCDF4, NF_CLASSIC_MODEL )         ! netCDF4 file
      95             :        ierr = Nf_Create (filname, mode, ncid)             !  w/ compression
      96             : #else
      97           0 :        ierr = Nf_Create (filname, NF_64BIT_OFFSET, ncid)  ! netCDF4 file
      98             :                                                           !  w/o compression
      99             : #endif
     100             :     ELSE
     101           0 :        ierr = Nf_Create (filname, NF_CLOBBER, ncid)       ! netCDF3 file
     102             :     ENDIF
     103             : 
     104           0 :     if (ierr /= NF_NOERR) then
     105           0 :        err_msg = 'In Nccr_Wr, cannot create:  ' // Trim (filname)
     106           0 :        call Do_Err_Out (err_msg, .true., 0, 0, 0, 0 , 0.0d0, 0.0d0)
     107             :     end if
     108             : 
     109           0 :     return
     110             : 
     111             :   end subroutine Nccr_Wr
     112             : !EOC
     113             : !------------------------------------------------------------------------------
     114             : !       NcdfUtilities: by Harvard Atmospheric Chemistry Modeling Group        !
     115             : !                      and NASA/GSFC, SIVO, Code 610.3                        !
     116             : !------------------------------------------------------------------------------
     117             : !BOP
     118             : !
     119             : ! !IROUTINE: Ncdo_Sync
     120             : !
     121             : ! !INTERFACE:
     122             : !
     123           0 :   subroutine Ncdo_Sync (ncid)
     124             : !
     125             : ! !USES:
     126             : !
     127             :     use m_do_err_out
     128             : !
     129             :     implicit none
     130             : !
     131             :     include "netcdf.inc"
     132             : !
     133             : ! !INPUT PARAMETERS:
     134             : !!  ncid : netCDF file id
     135             :     integer, intent(in)   :: ncid
     136             : !
     137             : ! !DESCRIPTION: Synchronizes a netCDF file.
     138             : !\\
     139             : !\\
     140             : ! !AUTHOR:
     141             : !  John Tannahill (LLNL) and Jules Kouatchou
     142             : !
     143             : ! !REVISION HISTORY:
     144             : !  See https://github.com/geoschem/ncdfutil for complete history
     145             : !EOP
     146             : !------------------------------------------------------------------------------
     147             : !BOC
     148             : !
     149             : ! !LOCAL VARIABLES:
     150             :     character (len=128) :: err_msg
     151             :     integer             :: ierr
     152             : !
     153           0 :     ierr = Nf_Sync (ncid)
     154             : 
     155           0 :     if (ierr /= NF_NOERR) then
     156           0 :        err_msg = 'In Ncdo_Sync:  ' // Nf_Strerror (ierr)
     157           0 :        call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
     158             :     end if
     159             : 
     160           0 :     return
     161             : 
     162             :   end subroutine Ncdo_Sync
     163             : !EOC
     164             : end module HCO_m_netcdf_io_create

Generated by: LCOV version 1.14