[all-commits] [llvm/llvm-project] 959a43: [flang] FDATE extension implementation: get date a...

Yi Wu via All-commits all-commits at lists.llvm.org
Thu Jan 11 04:16:00 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 959a430a8d5b7e77b3d88327f835d9f9b8a6842e
      https://github.com/llvm/llvm-project/commit/959a430a8d5b7e77b3d88327f835d9f9b8a6842e
  Author: Yi Wu <43659785+yi-wu-arm at users.noreply.github.com>
  Date:   2024-01-11 (Thu, 11 Jan 2024)

  Changed paths:
    M flang/docs/Intrinsics.md
    M flang/include/flang/Runtime/extensions.h
    M flang/runtime/extensions.cpp
    M flang/unittests/Runtime/CommandTest.cpp

  Log Message:
  -----------
  [flang] FDATE extension implementation: get date and time in ctime format (#71222)

reference to gfortran fdate
https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html
usage:
```fortran
CHARACTER(32) :: time
CALL fdate(time)
WRITE(*,*) time
```

fdate is used in the ECP proxy application
https://proxyapps.exascaleproject.org/app/minismac2d/

https://github.com/Mantevo/miniSMAC/blob/f90446714226eeef650b78bce06ca4967792e74d/ref/smac2d.f#L1570

`fdate` now produce the same result on flang, compare to gfortran, where
If the length is too short to fit completely, blank return.
```fortran
  character(20) :: string
  call fdate(string)
  write(*, *) string, "X"
```
```bash
$ ../build-release/bin/flang-new test.f90 
$ ./a.out 
                      X
```
If length if larger than it requires(24), fill the rest of buffer space.
```fortran
  character(30) :: string
  call fdate(string)
  write(*, *) string, "X"
```
```bash
$ ../build-release/bin/flang-new test.f90 
$ ./a.out 
 Wed Nov 15 16:59:13 2023      X
```
The length value is hardcoded, because:
```c++
  // Day Mon dd hh:mm:ss yyyy\n\0 is 26 characters, e.g.
  // Tue May 26 21:51:03 2015\n\0
```
---------

Co-authored-by: Yi Wu <yiwu02 at wdev-yiwu02.arm.com>




More information about the All-commits mailing list