codee-com / codee-com/open-catalog

[Fortran] Replace `if (integer)` with `if (logical)`

Open
#38 2 comments 2 reactions 0 assignees View on GitHub
Fortran good first issue new check
Dominant language
Fortran
Stars
106
Forks
12
PR merge metrics
No merged PRs in 30d

Description

In Fortran there is no equivalence between logical and integer variables, so `0` is not a replacement for `.false.`, and `1` does not replace `.true.`. Yet, some compilers (ifort) will happily compile `if (1)`.

Example:
```fortran
if (0) write(*, *) 'Test is false'
if (1) write(*, *) 'Test is true'
```

A slightly more meaningful example
```fortran
integer val
val = 1
if (val) write(*, *) 'Test is true'
```
This should be replaced by
```fortran
integer val
val = 1
if (val > 0) write(*, *) 'Test is true'
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.