I have been writing FORTRAN code for the numerical simulation of applied physics for more than two years, and I tried to implement the conventions described in Fortran Best Practices .
In particular, I defined the parameter as
integer, parameter:: dp=kind(0.d0)
and then used it for all doubles in my code.
However, I found out (in this forum) that using the KIND options does not necessarily give you the same accuracy if you compile your code using other compilers. In this question, I read that a possible solution uses SELECTED_REAL_KIND and SELECTED_INT_KIND, which, as I understand it, comply with some conventions.
Subsequently, I found out about ISO_FORTRAN_ENV , which defines the parameters REAL32, REAL64 and REAL128 KIND.
I think they are really portable, and since they are FORTRAN 2008 standard (although supported by GNU), I assume that I should use them?
Therefore, I would be very grateful if someone with more knowledge and experience would eliminate the confusion.
Also, I have the following question about using these KINDs in HDF5. I used H5T_NATIVE_DOUBLE and it really worked fine (as far as I know). However , this document states that this is an obsolete feature and should not be used. Instead, they provide a function
INTEGER(HID_T) FUNCTION h5kind_to_type(kind, flag) RESULT(h5_type) .
When I use it and print out the exact numeric value of the integer HID_T corresponding to REAL64 gives me 50331972, while H5T_NATIVE_DOUBLE gives me 50331963, which is different.
If I try to use the value calculated by H5kind_to_type, the HDF5 library will work just as well and, using XDMF , I can output the result in VisIt or Paraview without changing the attached .xmf file.
So my second question will be (again): Is this the correct use?