# MAIN, has not been explicitly declared

**URL:** <https://forums.developer.nvidia.com/t/main-has-not-been-explicitly-declared/136052>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [March 25, 2019, 4:27pm UTC](https://forums.developer.nvidia.com/t/main-has-not-been-explicitly-declared/136052 "2019-03-25T16:27:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodrigo.nemmen](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rodrigo.nemmen/32/23164_2.png) [@rodrigo.nemmen](https://forums.developer.nvidia.com/u/rodrigo.nemmen)\
**Post date:** [March 25, 2019, 4:27pm UTC](https://forums.developer.nvidia.com/t/main-has-not-been-explicitly-declared/136052/1 "2019-03-25T16:27:38Z")

</div>

I am having a strange issue with pgfortran, 18.4-0 64-bit on x86-64 Linux. When trying to compile a fortran 90 code, I get the following error message:

```nohighlight
pgfortran -O -acc -Minfo=accel spectrum.f90 -o spectrum
PGF90-S-0038-Symbol, MAIN, has not been explicitly declared (spectrum.f90)
  0 inform, 0 warnings, 1 severes, 0 fatal for fct
Makefile:21: recipe for target 'spectrum' failed
make: *** [spectrum] Error 2

```

Any idea of what is going on?

More info about the code: this is a astrophysical code with 1700 lines, which I am porting from openmp to openacc (GPU). It contains a couple of parallel loops which call subroutines.

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [March 25, 2019, 4:55pm UTC](https://forums.developer.nvidia.com/t/main-has-not-been-explicitly-declared/136052/2 "2019-03-25T16:55:18Z")

</div>

Hi nemmen,

This is a link error meaning that the source doesn’t contain a main program.

Is the main program in a different source? If so, then you’ll want to add the “-c” flag to tell the compiler to stop after compilation and not link.

Hope this helps,  
Mat

---

<div class="post-metadata">

**Author:** ![rodrigo.nemmen](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rodrigo.nemmen/32/23164_2.png) [@rodrigo.nemmen](https://forums.developer.nvidia.com/u/rodrigo.nemmen)\
**Post date:** [March 26, 2019, 5:11pm UTC](https://forums.developer.nvidia.com/t/main-has-not-been-explicitly-declared/136052/3 "2019-03-26T17:11:17Z")

</div>

Thanks for the help, Mat. I found out that the origin of the error is because I did not include the CONTAINS statement to include the subroutines in the source file. After I’ve done that, the code proceeds compilation.

Thanks!
