File: class_15.f90

package info (click to toggle)
lfortran 0.59.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 56,736 kB
  • sloc: cpp: 168,052; f90: 74,272; python: 17,537; ansic: 7,705; yacc: 2,345; sh: 1,334; fortran: 895; makefile: 37; javascript: 15
file content (32 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module class_15_mod
    type :: logger_type
    contains
        private
        procedure, public, pass(self) :: add_log_file
    
    end type logger_type
    contains
        subroutine add_log_file(self, filename, unit)
            class(logger_type), intent(inout) :: self
            character(*), optional :: filename
            integer, optional :: unit
            if (present(filename)) filename = "lfortran"
            if (present(unit)) unit = 10    
        end subroutine add_log_file
end module
    
program class_15
    use class_15_mod
    type(logger_type) :: logger
    integer :: unit
    character(len=100) :: filename
    call logger % add_log_file(unit=unit) !> which is already done
    call logger % add_log_file(filename=filename)
    call logger % add_log_file(unit=unit, filename=filename)
    call logger % add_log_file(filename=filename, unit=unit) ! reverse the order
    call logger % add_log_file()
    print *, filename
    if (filename /= "lfortran") error stop
    print *, unit
    if (unit /= 10) error stop
end program