ESMF_UtilIOMkDir Subroutine

public subroutine ESMF_UtilIOMkDir(pathName, keywordEnforcer, mode, parentsFlag, relaxedFlag, rc)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: pathName
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(in), optional :: mode
logical, intent(in), optional :: parentsFlag
logical, intent(in), optional :: relaxedFlag
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_UtilIOMkDir (pathName, keywordEnforcer,  &
      mode, parentsFlag, relaxedFlag,  &
      rc)
!
! !PARAMETERS:
    character(*), intent(in)            :: pathName
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,      intent(in),  optional :: mode
    logical,      intent(in),  optional :: parentsFlag
    logical,      intent(in),  optional :: relaxedFlag
    integer,      intent(out), optional :: rc
!
! !DESCRIPTION:
!   Call the system-dependent routine to create a directory in the file system.
!
!     The arguments are:
!     \begin{description}
!     \item[pathName]
!       Name of the directory to be created.
!     \item[{[mode]}]
!       File permission mode.  If not specified on POSIX-compliant systems,
!       the default is {\tt o'755'}.  On native Windows, this argument is
!       ignored and default security settings are used.
!     \item[{[parentsFlag]}]
!       When set to {\tt .true.}, create parent directories as needed.
!       If not specified, the default is {\tt .false.}.
!     \item[{[relaxedFlag]}]
!       When set to {\tt .true.}, if the directory already exists, {\tt rc}
!       will be set to {\tt ESMF\_SUCCESS} instead of an error.
!       If not specified, the default is {\tt .false.}.
!     \item[{[rc]}]
!       Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!EOPI

    integer :: mode_local
    type(ESMF_Logical) :: pflag, rflag  
    integer :: localrc

    integer :: mode_default
    data mode_default/o'755'/

    if (present(rc)) rc = ESMF_FAILURE

    mode_local = mode_default
    if (present (mode)) mode_local = mode

    pflag = .false.
    if (present (parentsFlag)) pflag = parentsFlag
    if (pflag == ESMF_TRUE) then
      if (ESMF_LogFoundError (ESMF_RC_NOT_IMPL, ESMF_ERR_PASSTHRU,  &
        ESMF_CONTEXT, rcToReturn=rc))  &
      return
    end if

    rflag = .false.
    if (present (relaxedFlag)) rflag = relaxedFlag

    call c_esmc_makedirectory (pathname, mode_local, rflag, localrc)
    if (ESMF_LogFoundError (localrc, ESMF_ERR_PASSTHRU,  &
        ESMF_CONTEXT, rcToReturn=rc))  &
      return

    if (present (rc)) then
      rc = localrc
    end if

  end subroutine ESMF_UtilIOMkDir