ExtDataCollection.F90 Source File


This file depends on

sourcefile~~extdatacollection.f90~~EfferentGraph sourcefile~extdatacollection.f90 ExtDataCollection.F90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~extdatacollection.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~netcdf4_fileformatter.f90 NetCDF4_FileFormatter.F90 sourcefile~extdatacollection.f90->sourcefile~netcdf4_fileformatter.f90 sourcefile~pfio_constants.f90 pFIO_Constants.F90 sourcefile~extdatacollection.f90->sourcefile~pfio_constants.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~netcdf4_fileformatter.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~netcdf4_fileformatter.f90->sourcefile~pfio_constants.f90 sourcefile~attribute.f90 Attribute.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~attribute.f90 sourcefile~coordinatevariable.f90 CoordinateVariable.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~coordinatevariable.f90 sourcefile~filemetadata.f90 FileMetadata.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~filemetadata.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~keywordenforcer.f90 sourcefile~netcdf_supplement.f90 NetCDF_Supplement.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~netcdf_supplement.f90 sourcefile~stringvariablemap.f90 StringVariableMap.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~stringvariablemap.f90 sourcefile~unlimitedentity.f90 UnlimitedEntity.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~unlimitedentity.f90 sourcefile~variable.f90 Variable.F90 sourcefile~netcdf4_fileformatter.f90->sourcefile~variable.f90 sourcefile~attribute.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~attribute.f90->sourcefile~unlimitedentity.f90 sourcefile~pfio_utilities.f90 pFIO_Utilities.F90 sourcefile~attribute.f90->sourcefile~pfio_utilities.f90 sourcefile~coordinatevariable.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~coordinatevariable.f90->sourcefile~pfio_constants.f90 sourcefile~coordinatevariable.f90->sourcefile~keywordenforcer.f90 sourcefile~coordinatevariable.f90->sourcefile~variable.f90 sourcefile~coordinatevariable.f90->sourcefile~pfio_utilities.f90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~filemetadata.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~filemetadata.f90->sourcefile~pfio_constants.f90 sourcefile~filemetadata.f90->sourcefile~attribute.f90 sourcefile~filemetadata.f90->sourcefile~coordinatevariable.f90 sourcefile~filemetadata.f90->sourcefile~keywordenforcer.f90 sourcefile~filemetadata.f90->sourcefile~stringvariablemap.f90 sourcefile~filemetadata.f90->sourcefile~unlimitedentity.f90 sourcefile~filemetadata.f90->sourcefile~variable.f90 sourcefile~filemetadata.f90->sourcefile~pfio_utilities.f90 sourcefile~stringintegermaputil.f90 StringIntegerMapUtil.F90 sourcefile~filemetadata.f90->sourcefile~stringintegermaputil.f90 sourcefile~stringvectorutil.f90 StringVectorUtil.F90 sourcefile~filemetadata.f90->sourcefile~stringvectorutil.f90 sourcefile~stringvariablemap.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~stringvariablemap.f90->sourcefile~coordinatevariable.f90 sourcefile~stringvariablemap.f90->sourcefile~variable.f90 sourcefile~stringvariablemap.f90->sourcefile~pfio_utilities.f90 sourcefile~unlimitedentity.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~unlimitedentity.f90->sourcefile~pfio_constants.f90 sourcefile~unlimitedentity.f90->sourcefile~pfio_utilities.f90 sourcefile~variable.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~variable.f90->sourcefile~pfio_constants.f90 sourcefile~variable.f90->sourcefile~attribute.f90 sourcefile~variable.f90->sourcefile~keywordenforcer.f90 sourcefile~variable.f90->sourcefile~unlimitedentity.f90 sourcefile~variable.f90->sourcefile~pfio_utilities.f90 sourcefile~variable.f90->sourcefile~stringvectorutil.f90 sourcefile~pfio_utilities.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~pfio_utilities.f90->sourcefile~pfio_constants.f90 sourcefile~stringintegermaputil.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~stringintegermaputil.f90->sourcefile~pfio_utilities.f90 sourcefile~stringvectorutil.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~stringvectorutil.f90->sourcefile~attribute.f90 sourcefile~stringvectorutil.f90->sourcefile~pfio_utilities.f90

Files dependent on this one

sourcefile~~extdatacollection.f90~~AfferentGraph sourcefile~extdatacollection.f90 ExtDataCollection.F90 sourcefile~serverthread.f90 ServerThread.F90 sourcefile~serverthread.f90->sourcefile~extdatacollection.f90 sourcefile~baseserver.f90 BaseServer.F90 sourcefile~baseserver.f90->sourcefile~serverthread.f90 sourcefile~directoryservice.f90 DirectoryService.F90 sourcefile~directoryservice.f90->sourcefile~serverthread.f90 sourcefile~mockserverthread.f90 MockServerThread.F90 sourcefile~mockserverthread.f90->sourcefile~serverthread.f90 sourcefile~mpiserver.f90 MpiServer.F90 sourcefile~mpiserver.f90->sourcefile~serverthread.f90 sourcefile~multicommserver.f90 MultiCommServer.F90 sourcefile~multicommserver.f90->sourcefile~serverthread.f90 sourcefile~multigroupserver.f90 MultiGroupServer.F90 sourcefile~multigroupserver.f90->sourcefile~serverthread.f90 sourcefile~multilayerserver.f90 MultiLayerServer.F90 sourcefile~multilayerserver.f90->sourcefile~serverthread.f90 sourcefile~openmpserver.f90 OpenMPServer.F90 sourcefile~openmpserver.f90->sourcefile~serverthread.f90 sourcefile~pfio.f90 pFIO.F90 sourcefile~pfio.f90->sourcefile~serverthread.f90 sourcefile~serverthreadvector.f90 ServerThreadVector.F90 sourcefile~serverthreadvector.f90->sourcefile~serverthread.f90 sourcefile~test_serverthread.pf Test_ServerThread.pf sourcefile~test_serverthread.pf->sourcefile~serverthread.f90 sourcefile~test_simplesocket.pf Test_SimpleSocket.pf sourcefile~test_simplesocket.pf->sourcefile~serverthread.f90

Source Code

#include "MAPL_ErrLog.h"

module pFIO_ExtDataCollectionMod
  use gFTL_StringIntegerMap
  use pFIO_NetCDF4_FileFormatterMod
  use pFIO_FormatterPtrVectorMod
  use pFIO_ConstantsMod
  use MAPL_ExceptionHandling
  implicit none
  private

  public :: ExtDataCollection
  public :: new_ExtDataCollection

  type :: ExtDataCollection
    character(len=:), allocatable :: template
    type (FormatterPtrVector) :: formatters
    type (StringIntegerMap) :: file_ids

    type (NetCDF4_FileFormatter), pointer :: formatter => null()
  contains
    procedure :: find
    procedure :: unfind
  end type ExtDataCollection

  interface ExtDataCollection
    module procedure new_ExtDataCollection
  end interface ExtDataCollection


  integer, parameter :: MAX_FORMATTERS = 2

contains


  function new_ExtDataCollection(template) result(collection)
    type (ExtDataCollection) :: collection
    character(len=*), intent(in) :: template

    collection%template = template

  end function new_ExtDataCollection



  function find(this, file_name, rc) result(formatter)
    type (NetCDF4_FileFormatter), pointer :: formatter
    class (ExtDataCollection), target, intent(inout) :: this
    character(len=*), intent(in) :: file_name
    integer, optional, intent(out) :: rc

    integer, pointer :: file_id
    type (StringIntegerMapIterator) :: iter
    integer :: status


    file_id => this%file_ids%at(file_name)
    if (associated(file_id)) then
       formatter => this%formatters%at(file_id)
    else
       if (this%formatters%size() >= MAX_FORMATTERS) then
          formatter => this%formatters%front()
          call formatter%close(rc=status)
          _VERIFY(status)
          call this%formatters%erase(this%formatters%begin())
          !deallocate(formatter)
          nullify(formatter)

          iter = this%file_ids%begin()
          do while (iter /= this%file_ids%end())
             file_id => iter%value()
             if (file_id == 1) then
                call this%file_ids%erase(iter)
                exit
             end if
             call iter%next()
          end do

          ! Fix the old file_id's accordingly
          iter = this%file_ids%begin()
          do while (iter /= this%file_ids%end())
             file_id => iter%value()
             file_id = file_id -1
             call iter%next()
          end do

       end if

       allocate(formatter)

       call formatter%open(file_name, pFIO_READ, _RC)
       call this%formatters%push_back(formatter)
       deallocate(formatter)
       formatter => this%formatters%back()
       ! size() returns 64-bit integer;  cast to 32 bit for this usage.
       call this%file_ids%insert(file_name, int(this%formatters%size()))
    end if
    _RETURN(_SUCCESS)
  end function find

  subroutine unfind(this)
    class (ExtDataCollection), intent(inout) :: this

    call this%formatter%close()
    deallocate(this%formatter)
    nullify(this%formatter)

  end subroutine unfind

end module pFIO_ExtDataCollectionMod


module pFIO_ExtCollectionVectorMod
   use pFIO_ExtDataCollectionMod

   ! Create a map (associative array) between names and pFIO_Attributes.

#define _type type (ExtDataCollection)
#define _vector ExtCollectionVector
#define _iterator ExtCollectionVectorIterator

#include "templates/vector.inc"

end module pFIO_ExtCollectionVectorMod