arraysfortranfortran-coarrays

Fortran error, use '-fcoarray=' to enable


I'm having some troubles with an awkward error in fortran, this is the code I need in order to get simulation of materials in solid state

  PROGRAM EUCLID
    PRINT *, 'A?'
    READ *, NA
    IF (NA.LE.0) THEN
      PRINT *, 'A must be a positive integer.'
      STOP
    END IF
    PRINT *, 'B?'
    READ *, NB
    IF (NB.LE.0) THEN
      PRINT *, 'B must be a positive integer.'
      STOP
    END IF
    PRINT *, 'The GCD of', NA, ' and', NB, ' is', NGCD(NA, NB), '.'
    STOP
  END

  FUNCTION NGCD(NA, NB)
    IA = NA
    IB = NB
1   IF (IB.NE.0) THEN
      ITEMP = IA
      IA = IB
      IB = MOD(ITEMP, IB)
      GOTO 1
    END IF
    NGCD = IA
    RETURN
  END

The error says Coarrays disabled at (1), use '-fcoarray=' to enable|, but I'm not using any arrays, so what should I do?

I'm using codeblocks as my compiler, and had no issues with some previous programs I wrote


Solution

  • If you are not planning to use coarrays and don't bother with threads and images, just abandon this custom init_random_seed subroutine and substitute it with the intrinsic random_seed subroutine. From the function reference here:

    If RANDOM_SEED is called without arguments, it is seeded with random data retrieved from the operating system.

    Else, if you do plan to use coarray features and do bother with threads and images (only recommended for advanced usage) you can use the new intrinsic random_init, if it is avaliable in your compiler. If it is not, then it is advisable to use a library, like OpenCoarrays, or implement it by your own.