Dear all
A quick question. I am writing a Fortran subroutine which contains some large elements in p array as below,
subroutine expmvtay1()
use iso_fortran_env
implicit none
integer(int32), parameter, dimension(3) :: p=[ &
8320987112741391580056396102959641077457945541076708813599085350531187384917164032 &
, 507580213877224835833540161373088490724281389843871724559898414118829028410677788672 &
, 31469973260387939390320343330721249710233204778005956144519390914718240063804258910208]
end subroutine expmvtay1
However, it compile with error messages below (Intel Fortran):
error #6901: The decimal constant was too large when converting to an integer, and overflow occurred. [8320987112741391580056396102959641077457945]
Change int32 to int64 or int128 does not seem to work.
So how do I make the above Fortran subroutine compile and work correctly?
Many thanks in advance!
PS1.
I can think of just make this array p as real type instead of integer. Then the below code can compile without problem
subroutine expmvtay1()
use iso_fortran_env
implicit none
real(real64), parameter, dimension(3) :: p=[ &
8320987112741391580056396102959641077457945541076708813599085350531187384917164032.0_real64 &
, 507580213877224835833540161373088490724281389843871724559898414118829028410677788672.0_real64 &
, 31469973260387939390320343330721249710233204778005956144519390914718240063804258910208.0_real64]
end subroutine expmvtay1
PS2.
The problem arise from that I am translating a matrix exponential solver in this paper
written in matlab as below
https://personales.upv.es/joalab/software/expmvtay1.m
into Fortran.
The Matlab code is very simple, less than 60 line, however, in the Matlab code, there is a 63-element integer (or real) array p with some very big elements, like below
p=[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000, 51090942171709440000, 1124000727777607680000, 25852016738884978212864, 620448401733239409999872, 15511210043330986055303168, 403291461126605650322784256, 10888869450418351940239884288, 304888344611713836734530715648, 8841761993739700772720181510144, 265252859812191032188804700045312, 8222838654177922430198509928972288, 263130836933693517766352317727113216, 8683317618811885938715673895318323200, 295232799039604119555149671006000381952, 10333147966386144222209170348167175077888, 371993326789901177492420297158468206329856, 13763753091226343102992036262845720547033088, 523022617466601037913697377988137380787257344, 20397882081197441587828472941238084160318341120, 815915283247897683795548521301193790359984930816, 33452526613163802763987613764361857922667238129664, 1405006117752879788779635797590784832178972610527232, 60415263063373834074440829285578945930237590418489344, 2658271574788448529134213028096241889243150262529425408, 119622220865480188574992723157469373503186265858579103744, 5502622159812088456668950435842974564586819473162983440384, 258623241511168177673491006652997026552325199826237836492800, 12413915592536072528327568319343857274511609591659416151654400, 608281864034267522488601608116731623168777542102418391010639872, 30414093201713375576366966406747986832057064836514787179557289984, 1551118753287382189470754582685817365323346291853046617899802820608, 80658175170943876845634591553351679477960544579306048386139594686464, 4274883284060025484791254765342395718256495012315011061486797910441984, 230843697339241379243718839060267085502544784965628964557765331531071488, 12696403353658276446882823840816011312245221598828319560272916152712167424, 710998587804863481025438135085696633485732409534385895375283304551881375744, 40526919504877220527556156789809444757511993541235911846782577699372834750464, 2350561331282878906297796280456247634956966273955390268712005058924708557225984, 138683118545689864933221185143853352853533809868133429504739525869642019130834944, 8320987112741391580056396102959641077457945541076708813599085350531187384917164032, 507580213877224835833540161373088490724281389843871724559898414118829028410677788672, 31469973260387939390320343330721249710233204778005956144519390914718240063804258910208];
That Fortran subroutine example is a minimal example which try to contain this p array.