Reputation: 178
I am currently developing a software in Fortran. It has been already a couple of times I've encountered the error below. Previously I just managed to undo those changes and rewrite the code again as I was not able to understand the issue.
Obviously, the issue came back again. So I am wondering why it happens. What am I doing in the code thats triggering it.
The compiler used is gfortran-9. I also tried to compile in gfortran-10 (ubuntu 20.04) with the hope it was a compiler bug already solved :/. The error shown is the same but with different elements.
This part of the software consists in a library (modules starting with SIO_...) which is using another one (modules starting with SHR_...).
Project structure:
The file triggering the error at compilation times is soulio/tests/unit/ncSpatialFile.F90. It has the following imports:
module ncSpatialFile_test
use netcdf
use SHR_file_mod, only: removeIfExists
use SHR_testSuite_mod, only: testSuite
use SHR_datetime_mod, only: datetime, timedelta, clock
use SIO_ncSpatialFile_mod, only: ncSpatialFile_abs <- gfortran-9 complains about this line
...
Imports from soulio/src/ncSpatialFile_abs.F90
module SIO_ncSpatialFile_abs
! use netcdf
use SHR_datetime_mod, only: clock, datetime, timedelta
use SHR_strings_mod, only: string
use SHR_precision_mod, only: sp
use SHR_array_mod, only: initArrayRange
use SHR_error_mod, only: raiseError
use SIO_ncfile_mod, only: ncfile
use SIO_ncDimensions_mod, only: ncDimensions
use SIO_ncVariables_mod, only: ncVariables
use SIO_grid_mod, only: grid
use SIO_parallel_mod, only: mpiContext_type
use SIO_ncSlimSpatialDims_mod, only: ncSlimSpatialDims
use SIO_ncFullSpatialDims_mod, only: ncFullSpatialDims
use SIO_ncSpatialDims_abs, only: ncSpatialDims
use SIO_ncParams_mod, only: NC_TIME_DIM_NAME, NC_SPATIAL_DIM_NAME!, SIO_NC_GLOBAL_ATTR
use SIO_ncOtherDim_mod, only: ncOtherDim
use SIO_ncTimeDim_mod, only: ncTimeDim
use SIO_ncVar_mod, only: ncVar
use SIO_ncDim_mod, only: ncDim, ncDimHolder
use SIO_ncTime_mod, only: ncTime
use SIO_ncDimensionsRequest_mod, only: ncDimensionsRequest
use SIO_ncVariableBounds_mod, only: ncVariableBounds
use SIO_ncAttributes_mod, only: ncAttributes
... (too many imports?)
type, abstract :: ncSpatialFile_abs
! netcdf file interface
class(ncfile), allocatable :: ncfile
! time series
class(clock), allocatable :: ncClock
soulio/soulshared/src/datetime_mod.F90
module SHR_datetime_mod
use iso_fortran_env, only: real32, real64
use iso_c_binding, only: c_char, c_int, c_null_char
use SHR_error_mod, only: raiseError
implicit none
private
public :: datetime, timedelta, clock, calendar
...
Error in gfortran-10:
soulio/tests/unit/ncSpatialFile_test.F90:20:7:
20 | use SIO_ncSpatialFile_mod, only: ncSpatialFile_abs
| 1
Fatal Error: Mismatch in components of derived type ‘__vtype_shr_datetime_mod_Calendar’ from ‘shr_datetime_mod’ at (1): expecting ‘calendar_assign’, but got ‘getdaysinmonth’
compilation terminated.
make[2]: *** [tests/unit/CMakeFiles/soulio_test.dir/build.make:232: tests/unit/CMakeFiles/soulio_test.dir/ncSpatialFile_test.F90.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:260: tests/unit/CMakeFiles/soulio_test.dir/all] Error 2
Error in gfortran-9:
soulio/tests/unit/ncSpatialFile_test.F90:20:6:
20 | use SIO_ncSpatialFile_mod, only: ncSpatialFile_abs
| 1
Fatal Error: Mismatch in components of derived type ‘__vtype_shr_datetime_mod_Clock’ from ‘shr_datetime_mod’ at (1): expecting ‘currenttickintervals’, but got ‘clock_assign’
compilation terminated.
make[2]: *** [tests/unit/CMakeFiles/soulio_test.dir/build.make:232: tests/unit/CMakeFiles/soulio_test.dir/ncSpatialFile_test.F90.o] Error 1
The error came up after modifing ncSpatialFile_test but not datetime.
I find the error confusing. Any ideas about what the compiler is trying to say? Any other advice in how to dig further?
Edit:
Datetime_mod file is taken from https://github.com/wavebitscientific/datetime-fortran. There are a few modifications but its the same structure.
clock declaration:
type :: clock
type(datetime) :: startTime
type(datetime) :: stopTime
type(datetime) :: currentTime
type(datetime) :: prevTime !> currentTime - 1 timestep
type(datetime) :: nextTime !> currentTime + 1 timestep
type(timedelta) :: tickInterval
logical :: alarm = .false.
logical :: started = .false.
logical :: stopped = .false.
logical :: nullified = .false. !< it is considered not defined
contains
procedure :: getStartTime
procedure :: getStopTime
procedure :: reset
procedure :: tick
procedure :: toString => toString_clock
procedure :: isStopped
procedure :: isNull
! true when the condition is satisfied for the current time step
procedure :: isBeginYear, isEndYear
procedure :: isBeginMonth, isEndMonth
procedure :: isBeginDay, isEndDay
procedure :: isBeginClock, isEndClock
procedure :: getTickIntervals
procedure :: totalTickIntervals
procedure :: currentTickIntervals
!
procedure, private :: clock_assign
procedure, private, pass(from) :: clock_assign_tickInterval
generic :: assignment(=) => clock_assign, clock_assign_tickInterval
procedure :: findEquivalentCurrentTime
procedure :: getCalendarType => getCalendarType_clock
procedure, private :: equiv_clock
generic :: operator(==) => equiv_clock
procedure :: isInAbsoluteBounds
end type clock
Upvotes: 0
Views: 777
Reputation: 178
As suggested by @veryreverie in the comments section, it was a problem of cache.
The cmake project places its mod files into tree project/lib. Those files are not removed when I clean the build folder. Because of this, some inconsistencies were happening.
Upvotes: 1