Last active
August 29, 2015 14:05
-
-
Save andersx/b80bdb6a651487c80419 to your computer and use it in GitHub Desktop.
JAMESS' FORTRAN90 standard syntax.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ! Variable declaration: | |
| ! ========================= | |
| ! | |
| ! 1) Pythonic naming is used. See: http://legacy.python.org/dev/peps/pep-0008/#naming-conventions | |
| ! 2) In brief, this means "lowercase" or "lower_case_with_underscores" are acceptable examples. | |
| ! 3) Use descriptive naming. | |
| ! 4) Use of abbreviations is discouraged, unless they are very standard. | |
| ! - E.g. "kcal" for kilocalories is acceptable. | |
| ! - E.g "http" for hypertext transfer protocol is acceptable. | |
| ! - E.g "disp_ver" instead of, say, dispersion version is not acceptable. | |
| ! For instance, does disp. mean display or dispersion? Nobody will know | |
| ! 5) Every variable has it's own line and description | |
| ! 6) Always use implicit none | |
| ! Good: | |
| ! Identifier for the version of dispersion correction used. | |
| integer dispersion_version | |
| ! Bad: | |
| ! dispersion version | |
| integer disp_ver | |
| ! I'll rip your balls off: | |
| integer dispver | |
| ! OMG NO: | |
| integer dver | |
| ! You are killing me: | |
| INTEGER IDSPVER | |
| ! Constant values use the parameter tag. | |
| ! Constant values are in full caps in accordance with PEP8. | |
| ! In brief, this means "UPPERCASE" or "UPPER_CASE_WITH_UNDERSCORES" are acceptable examples. | |
| ! Convert eV (electron volts) to kJ (kilojoule) | |
| double precision, parameter :: EV_TO_KJ = 1.6021773d-22 | |
| ! IF-STATEMENTS: | |
| ! ========================= | |
| ! Standard | |
| if (do_gradient) then | |
| call do_scf(arg) | |
| endif | |
| ! Acceptable version, strictly for one-liners. | |
| if (do_gradient) call do_scf(arg) | |
| ! Don't do this | |
| if (do_gradient) | |
| call do_scf(arg) | |
| ! Somebody might do this: | |
| if (do_gradient) | |
| write (*,*) "Doing SCF now" | |
| call do_scf(arg) ! Now do_scf() is called even if do_gradient.eq..false. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment