Geert Jan Bex

Geert Jan Bex

Since 2009 I'm an HPC consultant for the Flemish Supercomputer Center, doing support and training (also for PRACE and EuroCC). I've a PhD in physics and CS on topics in machine learning.

Location Belgium


  • @JennyMitchell This is unfortunately compiler-dependent. Intel's ifort and ifx (OneAPI) will initialize integer, real and complex values to 0, but gfortran doesn't.
    Just for the record, the values are not really random, they just represent the current contents of the computer's memory at the location the variable refers to.

  • @NielsOlie I've not tried the library yet, but you might want to have a look at:

  • Indeed, you always first declare everything before any statements.

  • @MiguelQuevedoB. That seems like a problem with your internet connection/configuration.

  • @SebastianMeyer Have a look at fibonacci/fibonacci.f90

  • @YueAnn You can make it explicitly abstract, that would be more consistent.

  • @HongPhucNguyen For scientific data HDF5 or netCDF (depending on your domain) are worth looking into. Both are platform and language-independent, and you get performance comparable to raw binary I/O with the added benefit of data organization, self-documentation and annotation.

  • @HongPhucNguyen Binding to Python is quite straightforward thank to f2py (in numpy).

    Glad you liked the course.

  • @HongPhucNguyen Not all best practices can be language-agnostic. Some are very specific to a language, either for technical reasons, or due to culture.

  • @AaronSanabria It depends a bit on the recursion depth, and the type of recursion. For low depth, it won't matter much. For tail recursion, the compiler will usually optimize.

  • @HongPhucNguyen associate is runtime, #define is compile time. Moreover, associate is a pure Fortran syntax feature, while #define requires you to run the preprocessor. The scope of the association is also clearly defined and imposed by the syntax. Although the same can be achieve using #undef, the burden would be on the developer.

  • @HongPhucNguyen Unless you do a lot of work to create a fast implementation of linked lists, remember that performance will suffer.

  • @AaronSanabria Welcome :)

  • @HongPhucNguyen Not sure what you are referring to. It seems there are only 2D examples in this section, no?

  • @HongPhucNguyen That implies they can be applied to arrays, i.e., called with an array as an argument, acting on each of the latter's elements.

  • @HongPhucNguyen I'd strongly disagree here. I'd suggest to always go with functions unless there is no alternative.

    Functions lend themselves more naturally to side-effect free programming, which is definitely best practice.

  • @HongPhucNguyen Have a look at the repository for many examples of modules. In short, it's intended for separation of concern and code reuse.

  • @HongPhucNguyen Indeed, always start by looking at the first error, don't be intimidated by a huge list. Solving that first one typically reduces the list considerably (or even completely).

  • @IanBoshoff There are a few things that can help to prevent this. Typically, the compiler will inline small procedures, i.e., it will insert the assembler instructions for the procedure at the site of the procedure call, hence avoiding the procedure call. Also, link-time optimization will consider multiple procedures and tries to find opportunities for...

  • @SebastianMeyer Indeed, that would work well, and there is nothing wrong doing it like this.

  • @ShainathKalamkar It is essentially a function that doesn't return a value, but acts on its arguments. In C/C++ that would be a function with return type void.

  • You might want to look at vTunes that is part of the OneAPI distribution. It is a GUI profiler that can also give you suggestions for and limits to optimizations and parallelizations (with threads, e.g., OpenMP).

  • @MélodieAngeletti Thanks for mentioning it, fixed.

  • @dg iso_fortran_env is a standard module (hence intrinsic, so that the compiler is to use the module supplied by the distribution, rather than a module with the same name that the developer might have created.
    It contains definitions of various constants such as INT32 and INT64, but also output_unit and error_unit.
    In this case, we care only about the INT32...

  • @MatthewRiruemkan Make sure to check the man page of ifort/ifx because the option to display warnings, for instance, differ from those of gfortran. Also note that for Intel Fortran -O2 optimization is the default, as opposed to gfortran.

  • @SophiaSimmons Have you ever used vim before, or are you new to it? In the latter case, vim has a learning curve, and I'd advise you to check out an online tutorial about it (there are many). vim is a very powerful editor and worth learning, but it takes some time to get proficient. If you prefer not to spend the effort, you'd better use anohter editor.

  • @IoannisStergiou Glad you enjoyed the training, hopefully it will be useful.

  • In Fortran arrays are first-class citizens, so many things you can do in MATLAB, you can also do in Fortran.

  • @LuzSilva Being familiar with a terminal interface such as Bash can help you in a number of ways. Data manipulation tasks are typically a lot easier to accomplish in such an environment. If you move to HPC infrastructure, you will have to have at least a nodding acquaintance with Bash or some other shell.

  • @AleksandraVisich Consider h5dcreate_f for creating a dataset (d), or h5gcreate_f for creating a group (g). The '_f' at the end of the names would be a suffix. Perhaps it would have been more clear if I'd used 'h5d'-prefix or 'h5g'-prefix?

  • @AleksandraVisich Depending on your domain, NetCDF can be the best storage format. I've some sample code in a Github repository that illustrates how to use NetCDF from Fortran.
    However, note that this code has not been updated in quite a while, so use with caution ;)

  • @MohideenAnsar As far as I know, the Fortran specification doesn't say, so it is compiler-dependent. Most compilers also allow you to specify that on the command line. For me, best practice: always specify if you want to fix the precision, otherwise, leave it to compile time settings if it doesn't matter. Assume the minimum is the default in that case.

  • @AleksandraVisich In theory, yes, but nothing interesting happens outside of that region which is clear from the iteration condition.

  • @AleksandraVisich Which message?

  • @YassirWardi Indeed, I get a segmentation fault both with ifort and ifx. The backtrace shows that it has to do with te optional argument min_val. Intel Fortran compilers represent an optional argument that is not present by a null pointer, and you can not assign to that. The solution is to define a variable that will hold the minimum to be used, either...

  • @YassirWardi It works for me. Which Fortran ocmpiler are you using?

  • @LalitSyunary The answer to the question is 0, so that is correct. What is not correct is the implementation of the subroutine fill_array. It is always a good idea to compile with -fbounds-check while developing your code. The compiler will automatically insert code to verify that array indices are within bounds, throwing a runtime error if not.
    When you...

  • @GeorginoKalengTshikwand Glad you enjoyed the course.

  • @TahaSoomro Fortran I/O is weird ;) In short, the unit number plays a role similar to that of a file handle in other programming langauges such as Python.

  • @GeorginoKalengTshikwand I'm giving such a training (Python for HPC). The next iteration is not yet scheduled though.

  • @GeorginoKalengTshikwand Absolutely, we'll deal with those in week 5 (BLAS and Lapack).

  • @VittorioDiBona It limits what you make available from a module, the advantage is that you don't pollute the namespace with procedures or variables you don't need. It is good practice to do this.