ncfile_enter_groups Subroutine

public subroutine ncfile_enter_groups(sf, varname_in, grpid, varname, exists)

if variable name contains "/", these are interpreted as groups/subgroups. split the varname at first occurence of "/" to get the first group name on the file level. Then get the group id. repeat until no "/" is found anymore. output the final groupid and the variable name without the group names.

Type Bound

t_ncfile

Arguments

Type IntentOptional Attributes Name
class(t_ncfile), intent(inout) :: sf

self

character(len=*), intent(in) :: varname_in

name of the variable (can include "/" for groups)

integer, intent(out) :: grpid

id of the last group found

character(len=255), intent(out) :: varname

name of the variable without groups

logical, intent(out) :: exists

Calls

proc~~ncfile_enter_groups~~CallsGraph proc~ncfile_enter_groups t_ncfile%ncfile_enter_groups nf90_inq_ncid nf90_inq_ncid proc~ncfile_enter_groups->nf90_inq_ncid proc~mpi_check_single_access mpi_check_single_access proc~ncfile_enter_groups->proc~mpi_check_single_access proc~ncfile_openfile t_ncfile%ncfile_openfile proc~ncfile_enter_groups->proc~ncfile_openfile proc~ncfile_openfile->proc~mpi_check_single_access nf90_create nf90_create proc~ncfile_openfile->nf90_create nf90_open nf90_open proc~ncfile_openfile->nf90_open proc~ncfile_handle_error t_ncfile%ncfile_handle_error proc~ncfile_openfile->proc~ncfile_handle_error proc~ncfile_handle_error->proc~mpi_check_single_access nf90_strerror nf90_strerror proc~ncfile_handle_error->nf90_strerror

Called by

proc~~ncfile_enter_groups~~CalledByGraph proc~ncfile_enter_groups t_ncfile%ncfile_enter_groups proc~ncfile_get_array t_ncfile%ncfile_get_array proc~ncfile_get_array->proc~ncfile_enter_groups proc~ncfile_get_scalar t_ncfile%ncfile_get_scalar proc~ncfile_get_scalar->proc~ncfile_enter_groups proc~ncfile_get_var_dims t_ncfile%ncfile_get_var_dims proc~ncfile_get_var_dims->proc~ncfile_enter_groups proc~ncfile_get_var_ndims t_ncfile%ncfile_get_var_ndims proc~ncfile_get_var_ndims->proc~ncfile_enter_groups proc~ncfile_var_exists t_ncfile%ncfile_var_exists proc~ncfile_var_exists->proc~ncfile_enter_groups proc~readnetcdf ReadNETCDF proc~readnetcdf->proc~ncfile_get_array proc~readnetcdf->proc~ncfile_get_scalar proc~readnetcdf~2 ReadNETCDF proc~readnetcdf~2->proc~ncfile_get_array proc~readnetcdf~2->proc~ncfile_get_scalar proc~readnetcdf~2->proc~ncfile_var_exists proc~bff_init t_boundaryFromFile%bff_init proc~bff_init->proc~readnetcdf~2 proc~hmap_axisnb_init_params hmap_axisNB_init_params proc~hmap_axisnb_init_params->proc~readnetcdf interface~t_hmap_axisnb t_hmap_axisNB interface~t_hmap_axisnb->proc~hmap_axisnb_init_params proc~hmap_axisnb_init hmap_axisNB_init interface~t_hmap_axisnb->proc~hmap_axisnb_init proc~boundaryfromfile_new boundaryFromFile_new proc~boundaryfromfile_new->proc~bff_init proc~hmap_axisnb_init->proc~hmap_axisnb_init_params

Source Code

  SUBROUTINE ncfile_enter_groups(sf,varname_in,grpid,varname,exists)
    ! MODULES
    IMPLICIT NONE
    !-------------------------------------------------------------------------------------------------------------------------------
    ! INPUT VARIABLES
    CHARACTER(LEN=*),INTENT(IN) :: varname_in  !! name of the variable (can include "/" for groups)
    !-------------------------------------------------------------------------------------------------------------------------------
    ! OUTPUT VARIABLES
    CLASS(t_ncfile),INTENT(INOUT)  :: sf !! self
    CHARACTER(LEN=255),INTENT(OUT) :: varname  !! name of the variable without groups
    INTEGER,INTENT(OUT)            :: grpid    !! id of the last group found
    LOGICAL,INTENT(OUT)            :: exists
    !-------------------------------------------------------------------------------------------------------------------------------
    ! LOCAL VARIABLES
    CHARACTER(LEN=255) :: grpname
    INTEGER          :: grpid_old,id
    !===============================================================================================================================
    CALL mpi_check_single_access()
    IF(.NOT.sf%isopen) CALL sf%openfile()
    grpid=sf%nc_id
    varname=varname_in
    exists=.TRUE.
#if NETCDF
    id=INDEX(varname,"/")
    DO WHILE (id.NE.0)
      grpname=varname(1:id-1)
      varname=varname(id+1:)
      grpid_old=grpid
      sf%ioError = nf90_INQ_NCID(grpid_old, TRIM(grpname), grpid)
      exists=(sf%ioError .EQ. nf90_NOERR)
      IF(.NOT.exists) RETURN
      id=INDEX(varname,"/")
    END DO
#endif /*NETCDF*/
  END SUBROUTINE ncfile_enter_groups