ecmwf / fckit

A Fortran toolkit for interoperating Fortran with C/C++
https://confluence.ecmwf.int/display/fckit
Apache License 2.0
29 stars 15 forks source link

Fixes for NAG compiler #43

Closed DJDavies2 closed 3 months ago

DJDavies2 commented 3 months ago

These fixes seem to enable fckit to build with NAG and run most of the ctests. The changes fall into 3 categories:

1) Addition of target attribute to some variables

This affects fckit_mpi.fypp, fckit_tensor.F90 and test_tensor.F90. The issue here is that there are variables being passed to array_view1d, a function that returns a point to that same variable. However this only works if the variable is declared with the target in the calling routine. I think NAG is correct here; in Fortran pointers can only point to variables with the target attribute; without the target attribute these pointers are in an undefined state.

2) Turn fckit_external and fckit_owned into subroutines

NAG doesn't compile these as functions and I think it is a compiler bug. However turning them into subroutines works and doesn't seem to cause any knock-on problems.

3) Changes to cmake code to enable compiler options to be passed to downstream* ctests

These tests require building Fortran code but compile flags are needed for this to work. These changes do that.

What do you think? I don't think this has any downstream affects. The only possibility is if something outside of fckit is calling fckit_owned or fckit_external directly; I don't know of anything but maybe there is.

FussyDuck commented 3 months ago

CLA assistant check
All committers have signed the CLA.