Git Product home page Git Product logo

fortran-delete-files's Introduction

Fortran Delete Files

This is sort of my "Hello World" program; my first ever in the programming language Fortran.

Index

  1. Motivation
  2. Tests
  3. Code & Source
  4. Files
  5. License

Motivation

I like to learn lots of programming languages and Fortran was next on my list. I don't really do HW programs as I usually have an idea for what kind of software I want, need, or just want to write something different.

Tests - Compile and Run

This has been compiled and tested on both Windows and Linux.

$OSI = Get-ComputerInfo
Write-Host ""$OSI.OsName "`n" $OSI.OsVerion 
 Microsoft Windows 10 Pro
 10.0.18363
g95 -o delete delete.f95 # compile
delete.exe *.file # assumming a.file and b.file
 Deleting: a.file.
 a.file was deleted successfully.
 Deleting: b.file.
 b.file was deleted successfully.
$ cat /etc/*-release|grep "PRETTY_NAME"|cut -d'=' -f2
"Ubuntu 18.04.4 LTS"
$ uname -a|awk '{print $1" "$3" "$11}'
Linux 4.4.0-18362-Microsoft x86_64
$ gfortran -o delete delete.f95 # compile
$ delete *.file # assumming a.file and b.file
 Deleting: a.file.
 a.file was deleted successfully.
 Deleting: b.file.
 b.file was deleted successfully.

Code

Source

program delete
    integer::numArgs,getArg,stat,stat_close
    logical::file_exists
    character(256)::trimArg,thisArg
    numArgs=command_argument_count()
    if(numArgs>0)then
        do getArg=1,numArgs
            call get_command_argument(getArg,thisArg)
            trimArg=trim(thisArg)
            inquire(file=trimArg,exist=file_exists)
            if ( file_exists ) then
                print *, 'Deleting: ',trim(trimArg), '.'
                open(unit=10, iostat=stat, file=trimArg, status='old')
                if (stat == 0) close(10, iostat=stat_close,status='delete')
                if (stat_close .gt. 0) then
                    print *, trim(trimArg),' was not deleted.'
                else
                    print *, trim(trimArg),' was deleted successfully.'
                end if
            else
                print *,trim(trimArg), ' does not exist.'
            end if
        end do
    end if
end program delete

Files

License

LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.