Run a single-source Fortran program using the current compiler Compile a Fortran object Create temporary source file Write contents Compile and link program Run and retrieve exit code
Successful exit on 0 exit code
Delete files
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(compiler_t), | intent(in) | :: | self |
Instance of the compiler object |
||
character(len=*), | intent(in) | :: | input |
Program Source |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | public, | allocatable | :: | exe | |||
character(len=:), | public, | allocatable | :: | logf | |||
character(len=:), | public, | allocatable | :: | object | |||
character(len=:), | public, | allocatable | :: | source | |||
integer, | public | :: | stat | ||||
integer, | public | :: | unit |
logical function check_fortran_source_runs(self, input) result(success) !> Instance of the compiler object class(compiler_t), intent(in) :: self !> Program Source character(len=*), intent(in) :: input integer :: stat,unit character(:), allocatable :: source,object,logf,exe success = .false. !> Create temporary source file exe = get_temp_filename() source = exe//'.f90' object = exe//'.o' logf = exe//'.log' open(newunit=unit, file=source, action='readwrite', iostat=stat) if (stat/=0) return !> Write contents write(unit,*) input close(unit) !> Compile and link program call self%compile_fortran(source, object, self%get_default_flags(release=.false.), logf, stat) if (stat==0) & call self%link(exe, self%get_default_flags(release=.false.)//" "//object, logf, stat) !> Run and retrieve exit code if (stat==0) & call run(exe,echo=.false., exitstat=stat, verbose=.false., redirect=logf) !> Successful exit on 0 exit code success = stat==0 !> Delete files open(newunit=unit, file=source, action='readwrite', iostat=stat) close(unit,status='delete') open(newunit=unit, file=object, action='readwrite', iostat=stat) close(unit,status='delete') open(newunit=unit, file=logf, action='readwrite', iostat=stat) close(unit,status='delete') open(newunit=unit, file=exe, action='readwrite', iostat=stat) close(unit,status='delete') end function check_fortran_source_runs