2

I am trying to figure out a way to do calculations with ridiculous numbers, just as Python would, such as 2**1000 for example. There isn't really a good reason why I want to do this, however I have seen code for this using the fmzm library, I think. I don't know how to do this as I am using code blocks Ide and it just comes up with the error of no such file or directory "fmzm.mod". How would I go about installing this/being able to do use FMZM in Fortran 95 code.

Already tried using the integer(kind=64) and then kind=128... and so on to see if that was allowed. This is some code from another StackOverflow example, but I run into the error of code blocks not being able to open fmzm.mod

program cycle
    use FMZM           !<----- a module for handling big numbers
    implicit none
    character(200) :: str
    integer :: n
    type(IM) :: x1, result, x2, x3     !<----- IM = BigInt, FM = BigFloat

    do n = 40, 500, 40
        x1 = n
        result = 1
        x2 = 0
        x3 = 1
        do
            if (x1 > 1) then
                x2 = result
                result = result + x3
                x3 = x2
                x1 = x1 - 1
            else
                exit
            end if
        end do
        str = IM_format( 'i200', result )   !<----- convert BigInt to string
        print *, n, trim( adjustl(str) )    !<----- print huge integers
    end do
end program cycle
||=== Build: Debug in test1 (compiler: GNU Fortran Compiler) ===|
C:\Users\hh\Desktop\Fortran\test1\main.f95|5|Fatal Error: Can't open module file 'fmzm.mod' for reading at (1): No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
  • Welcome, please take the [tour]. Pay attention to the formatting of the code in your questions and to proper tags. What is FMZM? Do you have this module at all? What is it supposed to do? It is certainly not something included in standard Fortran, you have to get that module somewhere first. – Vladimir F Героям слава Sep 15 '19 at 12:29
  • ...okay, i'm new here so im just trying to include anything relevant to the question as I'm no expert at fortran95 so its more likely to be answered correctly with more variety of tags, and yes, thank you for pointing out that i need to get the module from somewhere else first, if you had read the question you would have seen I had already known that was the first step about being able to use the module. My question is HOW to install it for code blocks or any other solutions/ways of solving my problem if FMZM is not a good way faward –  Sep 15 '19 at 12:49
  • Well, I DID read the question, notice that I have edited it. We can give you an advice how ti install it, but you have to tell as what it even is and where did you find it. I have never heard about it before. – Vladimir F Героям слава Sep 15 '19 at 13:01
  • This is the link where I got it from: https://stackoverflow.com/questions/38801846/how-do-i-do-big-integers-in-fortran/38807728#38807728 What i want to do is be able to have an unrestricted integer limit, like with python. say fmzm isn't the way to go, is there other methods to allow fortran to do say, 2**1000000 or something absolutely ridiculous. If fmzm is the way to go thought, how do i install it for use on codeblocks ide for fortran gnu compiler –  Sep 15 '19 at 13:05
  • Did you do the points 1) and 2) in your link? If not we can only tell you to do so. – Vladimir F Героям слава Sep 15 '19 at 13:18
  • Well yes, i tried, otherwise i wouldnt be here. The links that are included do not work for me, they have an error page not found –  Sep 15 '19 at 14:50
  • So, what *exactly* did you do? Did you download anything? This site is not here for finding a library for you. You must do that yourself. See [ask]. – Vladimir F Героям слава Sep 15 '19 at 15:03
  • I tried to download all of the links that the page suggests to download, none of them work, and the ones that do just open up a pdf file on chrome –  Sep 17 '19 at 10:28
  • Unfortunately, finding this file for you is off-topic and recommending a different library is as well. If knew such a library, I would at least mention it in a comment and other peoole would probably do the same, but I do not know it. I suggest learning some established C library, like GMP, and link it from Fortran. – Vladimir F Героям слава Sep 17 '19 at 10:36
  • I actually just got the zip file with all the libraries included, on their original post, I don't quite understand these bits: "(the file names should be changed by dropping ".txt"). 2) Make a library file as gfortran -c -O2 FMSAVE.f95 FMZM90.f95 FM.f95 ar rv fmlib.a FM*.o" If you could help me with following these steps properly I would much appreciate it, thanks –  Sep 17 '19 at 10:38

0 Answers0