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

Activity

  • @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 ;)
    https://github.com/gjbex/training-material/tree/master/DataStorage/NetCDF

  • @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.

  • @MatthewRiruemkan C++ is certainly useful. I actually run a training titled "Scientific C++" that focuses on C++ features that are useful for programming in the context of science and engineering.

  • @MatthewRiruemkan Relearning C++ might also make sense, but be aware that C++ has evolved considerably over the last 10 years. We moved from C++11 (in the best case, C++03 or C++98 in the worst) to C++20.
    Although you'd have to start from scratch in Python, I think that the investment is worthwhile anyway. There are quite a number of things I'd hesitate to...

  • @MatthewRiruemkan You could consider a basic programming course for Python. This is a nice language to complement Fortran anyway since it is more convenient for data processing/analytics and prototyping.

  • @MatthewRiruemkan That is of course fine. What happens exactly is likely to depend on the Fortran runtime, hence the compiler and its version. So your mileage may vary ;)

  • @MatthewRiruemkan This seems rather fishy: "iomsg-msg", you probably mean "iomsg=msg"?

  • @MatthewRiruemkan The problem is rather technical, and implementation (of the runtime, hence the compiler if you will). In the program unit, you have a print statement. This will be using the standard output unit, i.e., it will write the result to the screen. One of the values the print statement will write is the return value of the procedure you call,...

  • @MatthewRiruemkan A print in a function that is called in a print statement is a problem with some Fortran runtimes. In main, assign the value of the function to a variable, and print its value.

  • @MatthewRiruemkan At the time when this was recorded, WSL wasn't as mature and not widely available. For production, I worked with VMWare, but for about a year now I simply use WSL2 + containers for most things.

    So no, there is no need for a VM.

  • @GeorginoKalengTshikwand There are quite a number of excellent courses organized by PRACE, have a look at their training portal.

  • @MatthewRiruemkan If you like, but you don't need it (I don't use it).

  • I was using the default terminal of my Linux distribution (installed in a VM). As such you can use whatever you want, see the step on requirements.

  • @AnnEnnen Good point, in Fortran the situation is a little convoluted due to the distinction between subroutines and functions. A subroutine is considered to be pure in Fortran if it only modifies its arguments (or none at all). This would not be considered "pure" in the sense of the functional programming paradigm, hence the ambiguity.

  • @AnnEnnen The runtime will handle deallocation for you in many circumstances. However, sometimes it is better to do it yourself. In general, I deallocate myself, rather than rely on the runtime.

    The visibility modifiers will be discussed in one of the steps.

  • @GeorginoKalengTshikwand Exactly, a sloppy class hierarchy is counter-productive, and you will end up with code that is less flexible and harder to maintain while using object-orientation properly facilitates that.

    Of course, this is not specific to Fortran, that goes for any object-oriented programming language.

  • @GeorginoKalengTshikwand Many opinions you will hear or read on Fortran are based on Fortran 90, or Fortran 95 at best. Many people are ignorant that Fortran has evolved considerably since that time.

    It is one of the few programming languages that let you code high-level distributed programs without using external libraries (co-arrays, see week 5). This...

  • @AnnEnnen Since you refer to C and C++, I'll map the Fortran concepts to C++.

    A user-defined type is a struct in C++. As in C++, you can associate procedures with it, sort of like methods. You can also do dynamic memory allocation of arrays or user-defined types.

    Derived types can be compared to a C++ class that inherits from a parent class. It is a...

  • @GeorginoKalengTshikwand And with the added advantage that is was designed to do science, and to be easy to optimize.

  • @GeorginoKalengTshikwand Yes, that is possible, I didn't mention it for simplicity and clarity.

  • @IagoGiné You can set breakpoints in arbitrary files in GDB, e.g.,,
    b my_module.f90:my_procudure
    Of course, you need to build with -g to add debugging information to the executable.

  • @IagoGiné Interesting, I didn't notice this. However, it seems to be a problem with the GNU Fortran compiler (unless I'm missing something in the Fortran specification). The Intel compiler generates an application that runs without issues.
    The problem is in the allocate statement. Using the source argument with the "constructor" should ensure that the...

  • @GeorginoKalengTshikwand Don't forget that 2D arrays in Fortran are stored in column-major layout, as opposed to C where they are stored row-major.

  • @GeorginoKalengTshikwand Intel OneAPI can be used free of charge nowadays, and you can even have a docker container with the whole suite installed.

  • @GeorginoKalengTshikwand Unless I'm terminally confused here, 2 and 3 are printed, so I don't quite get what you mean.

  • @GeorginoKalengTshikwand How are you running the application? This will read from standard input, so if you don't feed standard input, the application will sit and wait forever, so call it with, e.g.,
    $ ./read_messy_data.exe < messy_data.txt

  • @IagoGiné-Vázquez You can create matrices for x0 and r as a meshgrid (see MATLAB or Python numpy), so that the result is a matrix of function values, so that the rows represent x0 values, and the columns r values.

  • @GeorginoKalengTshikwand The function is_leap_year is being called as an argument in the print statement. If you print from such a function, you create a deadlock. The print statement in the main program will lock the I/O stream, so the write statement in the is_leap_year function can not execute until the lock is released, which will never happen.
    This is...

  • @NinibethGibelliSarmientoHerrera Not unless you want to fork the repository to host your own copy of it on Github. To clone a repository (just get a local copy) you don't need an account (I think ;)

  • @IagoGiné-Vázquez The mask expression is optional, so you can, but don't have to specify a logical expression on the indices.

  • @AtulJadhav Sure, feel free to use any environment you feel comfortable with.

  • Geert Jan Bex replied to [Learner left FutureLearn]

    @varshafelsy You'd have to install WSL, it's not part of a default Windows installation. Google for installing WSL2 on your Windows version (10 or 11) and follow the instructions.

  • @IagoGiné-Vázquez If memory serves, that is 'vim-syntastic/syntastic'