Fortran intrinsics reference on fortran-lang.org

The Fortran-lang website now has a thorough intrinsics reference:

Many thanks to @urbanjost and reviewers for this big contribution!

21 Likes

Could you by any chance point me at the part of the repo that holds what I assume are the HTML files?
I would like to see if I can have fortls download the intrinsics html/JSON/any file instead of having to keep a separate JSON updated.

It’s a real pain having to keep up to date with the standards

I replied in a previous post about the exp() function for complex argument with non default kind that the description was incorrect. That discussion, and the correction, did not make it into the final document.

@gnikit, the sources are Markdown, one file per intrinsic. See Fortran Intrinsics by urbanjost · Pull Request #347 · fortran-lang/fortran-lang.org · GitHub for all the files that were introduced.

@RonShepard can you point me to that thread? Let’s fix it.

This is terrific! Very clean and modern looking.

1 Like

It was Intrinsic descriptions - #25 by RonShepard and there are a few others like RANDOM_INIT seems to be missing and some changes to RANDOM_SEED and CPU_TIME seem out of sync with what I thought was the last push; and this might just be a bug in my browser, but I cannot get to end of list of names unless I change my browser scale from 100% to 90%; but nice to see otherwise. Odd, but all the others I have looked at look OK.

1 Like

The change was for this sentence:

if cx=(re,im) then exp(cx)=exp(re)*cmplx(cos(im),sin(im))

It should read something like:

if cx=(re,im) then exp(cx)=exp(re)*cmplx(cos(im),sin(im),kind(cx))

Maybe a link to the cmplx() intrinsic could be added in order to explain why the kind argument is necessary for non default kind result.

1 Like

I personally will urge a lot of caution and a lot of review by different pairs of eyes and editing and settling on a common theme and style and brevity with the examples via a workflow that might borrow from ISO IEC standardization process before hosting this at fortran-lang.

I didn’t manage to look beyond the first description for ABS intrinsic where the first link I noticed “Standard” which is not strictly accurate: ANSI X3.9 1966 (FORTRAN 66) did support ABS as an intrinsic, albeit with a REAL argument only.

Separately it will be nice if instead of the *UX man page reference and style section numbering, a direct naming is applied:
image

image

Also, it is unclear to me how any licensing applies to description of intrinsics in an ISO IEC standard document, it might be better if the author(s) were to “donate” the effort to fortran-lang and for fortran-lang to seek approval from ISO on the nature of the content prior to hosting this:
image

2 Likes

Wonderful! Thanks for that work! :champagne:

I have just installed the man pages in Ubuntu, following the instructions in https://fortran-lang.org/learn/intrinsics. But the mand -c command did not work, it was instead mandb -c.

I have also noticed that the code frame # as a user, placing the files in ~/man: seems to be misplaced. I think it should be placed before the sentence “then anyone on that plaform can enter commands like (see man(1))”, not after.

On my machine, amongst these commands:

man sinh.3fortran     # specifically show Fortran sinh(3) documentation
man -k . -s 3fortran  # list all fortran pages
man -s 3fortran --regex '.*' |col -b # show all Fortran intrinsics

the first and last ones work, but the second one returns nothing.

Awesome, Markdown should work too. I will have a look to see if I can make this work.

Thanks to @urbanjost and the reviewers.

Looking at the allocated entry I wonder what the (3) means.

Name

allocated(3) - [ARRAY INQUIRY] Status of an allocatable entity

I think the line of code in the example

   if (allocated(x) .eqv. .false.) allocate(x(i))

should be written more concisely as

   if (.not. allocated(x)) allocate(x(i))
2 Likes

I guess the (3) is the man section. Although a total Linux fan, I am not sure these (3) should be present. Fortran is not linked to any operating system and it may be very confusing for people using only Windows. At least for the web version. It has sense of course in the man version.

2 Likes

+1.

See this comment upthread where I suggest not to use the *UX based manpages style and numbering on what is hosted at fortran-lang.org website.

2 Likes

The current format supports automatic conversion of the documents to man-pages. The filters currently used require the (3) to be present for that to work. There was discussion in the original threads about whether generation of real man-pages for Unix-like systems should continue, or whether an on-line format allowing for non-ASCII text features like math expressions, graphics, and links was preferred. Included in this release under the experimental suggestion is a tarball with actual *roff manpages, and a conversion to a slidy(1) HTML file, etc. I personally prefer having man-pages available (as well as a system-independent CLI viewer – see fman(1) in the experimental section) but there was strong support for going completely to the more expressive document format(s). The Unix convention allows for distinguishing between when a word is just representing a word, or a procedure, or a command even when just simple plain ASCII is available; whereas other conventions like a key at the beginning of a single document indicating italics or bold or a certain color means function, etc… is generally used in a single published work. If no other format other than the on-line one is going to be supported going forward, a simpe sed(1) program or other simple filter can probably change them all without undo effort s. Anyone can make a push request to change them. Is there consensus that going forward just the on-line format will be supported? The original hope was this would become a community-supported effort with a lot of individuals refining the documentation; so anyone can volunteer to make the change if there is consensus that is the way to go. I definitely hope the pages will continue to be improved by the community. So support for fman(1) and man-pages should end and the Unix-like section designations should go?

1 Like

I have successfully installed it on a second Ubuntu machine and all commands are now working.
Maybe on the first machine I forgot to use sudo on the tar command? I remember the mandb process was much shorter than on the second machine. I will retry on the first machine on Monday.
Thanks.

Just an update on the
M_intrinsics project
for providing Fortran intrinsics descriptions (and ultimately a refresh
of the fortran-lang intrinsics pages).

About 1/2 way through a phase-II rewrite of the descriptions of the
Fortran intrinsics, reviewing each page against the 2018 standard,
trying a newer format that uses pseudo-Fortran in the SYNOPSIS section
to describe the procedure characteristic, and continuing development of
the example programs.

The goal is to provide an update to the fortran-lang pages as well as
generating new man-pages and an improved fman/fpm-man program (same
program, when you rename it to “fpm-man” it becomes an fpm(1) plugin).

  • slides are the easiest view mode.
    With the caveat that these are a WIP (Work In Progress) please feel free to leave comments and feedback
    in the “Issues” section of the M_intrinsics project site.

  • manpages.zip for anyone who wants to try the man-pages

  • standalone file fman.f90
    is a single-file build of the terminal-based viewer, which can also easily extract the example programs

    • builds with gfortran fman.f90
    • builds with ifort -O1 fman.f90
    • feedback on other processors would be appreciated
1 Like

@urbanjost , I have only now looked at your “slides” link and in particular your coding example of SYSTEM_CLOCK.
It has some very interisting characteristics, especially,

" do i=-huge(0)-1, huge(0)-1, 10 "
( I am surprised the loop count is calculated ! This loop has not terminated for the compiler I am using, although it does for do i=-huge(0)-1, huge(0)-2, 10 )

" COUNT RATE FOR INT64: 1000000000 "
( reported as 1,000,000,000 format would be useful in this case )

This is an impressive clock rate. The example should also utilise compile_version (), compiler_options () and in this case an additional useful intrinsic : processor_description () to provide some background to the results. My 64-bit Gfortran on windows provides COUNT RATE FOR INT64: 10000000

An important additional characteristic is the resolution of “clock”, ie
What is the minimum (non-zero) difference between two successive calls to SYSTEM_CLOCK ?
and also
Can SYSTEM_CLOCK return the same value of “clock” ?

Your description implies that the “clock” value is initialised from midnight, but this would be an implementation dependant outcome I have not previously noticed.

Thanks for your code example as it is very interesting !

The loop is of course just a placeholder for the code to be timed; the way the standard defines the processing for a DO loop, although non-intuitive and a bit disappointing would allow the processor to not be able to handle the entire range of processor-supported integer values. Since the DO counter increments one greater than the upper bound of the loop at the end -1 has to be removed; but the lower bound should have probably been just -huge(…) instead of adding the -1.
That can turn into an entire discussion on it’s own so I should probably put something else in there as the substitute for some calculation as well. I really meant to do a second pass by now of the intrinsic descriptions; and have been updating the M_intrinsics module with that in mind so feel free to push a PR to M_intrinsics/SYSTEM_CLOCK.md at master · urbanjost/M_intrinsics · GitHub or directly to the fortran.lang pages as well. The system_clock procedure by its very nature is so processor dependent the standard leaves a lot of latitude in how it works so more than almost all the other routines the clock-related routine description should probably suggest to read the processor-specific vendor documentation for details. If you would rather not make the changes I have taken note of all the suggestions; but some are probably more suited to an actual topic in a short wiki-book on fortran-lang or the Fortran Wiki, as the details are rather more complicated that the procedure looks at first.

Question/suggestion for the intrinsics website.

When you go into a subcategory e.g. Bit-level inquiry and manipulation, there is a list to the right with On this page. Since all intrinsics are listed there, it is possible to search for one of them with Ctrl + F.

In the main page, however, the list of all intrinsics is not shown at first; you need to click the down arrow in the purple rectangle of Intrinsics, and then you can Ctrl + F.

My question/suggestion, wouldn’t it be better to have a list to the right, with all the intrinsics listed (named List of intrinsics or something, in place of On this page)? That way you can search directly for something, no need to open the list. I know. Also this way the list-to-the-right style is kept for all pages.


@urbanjost Minor typo in the Readme under Basic VIM usage:

Because their are name collisions

their should be there