#
#     Copyright (c) 2017-2018, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#

# Compiler Configurations specific to Fortran (77, 90)
#

set TRACEBACK=ON;	# ON for Fortran

set ISFTN=1;

variable FTNALT is
	help(Name of alternate startup object module with -Munixlogicals);

variable FTNUNIXALT is
	help(Name of alternate startup object module with -Munixlogicals)
	default(pgfalt.$HOSTOBJSUFFIX);

variable FTNMAIN is
	help(Name of Fortran MAIN program object module)
	default($lookup($COMPLIBOBJ,pgfmain.$HOSTOBJSUFFIX));

variable DEFFTNRTL is
	help(Name of f77 runtime library)
	default($replace($PGF77LIB,$LIBSW,$LIBSSW));

variable SIGNEX is hide
	default(1);

variable INTEGER64BIT is
    default(NO);

switch -byteswapio is
	help(Swap byte-order for unformatted input/output)
	helpgroup(language)
	append(F901ARGS=-x 125 2);

switch -C is
	help(Generate code to check array bounds)
	helpgroup(debug)
	set(BOUNDSCHECK=1)
	append(F901ARGS=$ifn($NOBOUNDSCHECK,-x 70 2));

switch -F is
	help(Stop after preprocessing, save output in .f file)
	helpgroup(prepro)
	set(PREPROCONLY=YES)
	set(KEEPPREPRO=YES)
	set(HANDLEOTHER=$OTHERPREPROCESS)
	set(NOILM=YES)
	set(NOASM=YES)
	stopafter(Compile)
	set(COMPILEONLY=YES);

switch -i8 is
	help(Treat INTEGER and LOGICAL as INTEGER*8 and LOGICAL*8)
	helpgroup(language)
    set(INTEGER64BIT=YES)
	append(CARGS=-x 124 0x10)
	append(FLANG1ARGS=-i8)
	append(F901ARGS=-x 124 0x10);

switch -i8storage is
	help(INTEGER and LOGICAL occupy 8 bytes)
	helpgroup(language)
	set(I8STORAGE=YES)
	append(F901ARGS=-x 124 0x10 )
	append(F901ARGS=-x 124 0x10 );

switch -Mbackslash is
	help(Treat backslash like any other character in character strings)
	helpgroup(language)
	helpname(-M[no]backslash)
	append(CGARGS=-x 124 0x40)
	append(FLANG1ARGS=-backslash)
	append(F901ARGS=-x 124 0x40);

switch -Mnobackslash is
	hide
	help(Treat backslash like a C escape character in character strings)
	helpgroup(language)
	append(CGARGS=-y 124 0x40)
	append(FLANG1ARGS=-nobackslash)
	append(F901ARGS=-y 124 0x40);

switch -Mbyteswapio is
	help(Swap byte-order for unformatted input/output)
	helpgroup(language)
	append(FLANG1ARGS=-Mbyteswapio)
	append(F901ARGS=-x 125 2);

switch -Mcray is
	help(Set Cray pointer semantics)
	helpgroup(language)
	keyword(
	    pointer(append(CGARGS=-x 125 0x40))
#	    nopointer(append(CGARGS=-y 125 0x40))
	);

switch -Mdclchk is
	help(Check that all variables are declared)
	helpgroup(language)
	helpname(-M[no]dclchk)
	append(F901ARGS=-dclchk)
  append(FLANG1ARGS=-Mdclchk);

switch -Mnodclchk is
	hide
	help(Do not check that all variables are declared)
	helpgroup(language)
	append(F901ARGS=-nodclchk)
  append(FLANG1ARGS=-Mdclchk=0);

switch -Mdefaultunit is
	help(Treat '*' unit as standard input/output)
	helpgroup(language)
	helpname(-M[no]defaultunit)
	append(F901ARGS=-x 124 4);

switch -Mnodefaultunit is hide
	help(Treat '*' unit as 5 for input and 6 for output)
	helpgroup(language)
	append(F901ARGS=-y 124 4);

switch -Mdlines is
	help(Compile lines beginning with the letter D)
	helpgroup(language)
	helpname(-M[no]dlines)
	append(FARGS=-dlines);

switch -Mnodlines is hide
	help(Treat lines beginning with the letter D as comments)
	helpgroup(language)
	append(FARGS=-nodlines);

replace switch -Mdollar=char is
	help(Map dollar sign in identifiers to this character)
	helpgroup(language)
	append(CGARGS=-dollar $char);

switch -Mextend is
	help(Allow source lines up to 132 characters)
	helpgroup(language)
	append(FARGS=-extend);

switch -Miomutex is
	help(Generate critical sections around Fortran input/output)
	helpgroup(language)
	helpname(-M[no]iomutex)
	append(F901ARGS=-x 125 1);

switch -Mnoiomutex is hide
	help(Don't generate critical sections around Fortran input/output)
	helpgroup(language)
	append(F901ARGS=-y 125 1);

switch -Ml3f is hide	# really a no op
	help(Vestigial)
	helpgroup(language);

switch -Mnomain is
	help(Don't include Fortran main program object module)
	helpgroup(language)
	set(FTNMAIN=);

switch -Monetrip is
	help(Force DO loops to execute at least once)
	helpgroup(language)
	helpname(-M[no]onetrip)
	append(CGARGS=-onetrip);

switch -Mnoonetrip is hide
	help(Don't force DO loops to execute at least once)
	helpgroup(language)
	append(CGARGS=-noonetrip);

switch -Mr8 is
	help(Promote REAL variables and constants to DOUBLE PRECISION)
	helpgroup(language)
	helpname(-M[no]r8)
	append(FLANG1ARGS=-r8)
	append(F901ARGS=-x 124 8);

switch -Mnor8 is hide
	help(Don't promote REAL variables and constants to DOUBLE PRECISION)
	helpgroup(language)
	append(CGARGS=-y 124 8)
	append(FLANG1ARGS=-r4)
	append(F901ARGS=-y 124 8 -y 124 0x80000);

switch -Mr8intrinsics is
	help(Treat REAL,CMPLX intrinsics as DBLE,DCMPLX)
	helpgroup(language)
	helpname(-M[no]r8intrinsics)
	append(CGARGS=-x 124 0x20)
	keyword(
	    float(
		append(CGARGS=-x 124 0x80000)
		append(F901ARGS=-x 124 0x80000)
		help(Treat FLOAT intrinsic as DBLE as well)
	    )
	)
	nokeyword();

switch -Mnor8intrinsics is hide
	help(Don't treat REAL,CMPLX intrinsics as DBLE,DCMPLX)
	helpgroup(language)
	append(CGARGS=-y 124 0x20)
	keyword(
	    float(
		append(CGARGS=-y 124 0x80000)
		append(F901ARGS=-y 124 0x80000)
		help(Don't treat FLOAT intrinsic as DBLE)
	    )
	)
	nokeyword();

switch -Mrecursive is
	help(Generate code to allow recursive subprograms)
	helpgroup(language)
	helpname(-M[no]recursive)
	append(CGARGS=-recursive)
	append(F901ARGS=-recursive);

switch -Mnorecursive is hide
	help(Don't generate code to allow recursive subprograms)
	helpgroup(language)
	append(CGARGS=-norecursive)
	append(FLANG1ARGS=-save)
	append(F901ARGS=-norecursive);

switch -Mref_externals is
	help(Force references to any EXTERNAL subprograms)
	helpgroup(language)
	helpname(-M[no]ref_externals)
	append(F901ARGS=-x 124 0x1000)
	append(FCGARGS=-x 124 0x1000);

switch -Mnoref_externals is hide
	help(Don't force references to EXTERNAL subprograms)
	helpgroup(language)
	append(F901ARGS=-y 124 0x1000)
	append(FCGARGS=-y 124 0x1000);

switch -Msave is
	help(Assume all variables have SAVE attribute)
	helpgroup(language)
	helpname(-M[no]save)
	append(FCGARGS=-save)
	append(FLANG1ARGS=-save)
	append(F901ARGS=-save);

switch -Mnosave is hide
	help(Assume no variables have SAVE attribute)
	helpgroup(language)
	append(FCGARGS=-nosave)
	append(F901ARGS=-nosave);

switch -Mstandard is
	help(Check standard conformance)
	helpgroup(language)
	append(FARGS=-standard);

switch -Munixlogical is
	help(Treat any nonzero logical value as .TRUE.)
	helpgroup(language)
	helpname(-M[no]unixlogical)
	append(F901ARGS=-x 125 8)
	append(CGARGS=-x 125 8)
	set(FTNALT=$lookup($COMPLIBOBJ,$FTNUNIXALT));

switch -Mnounixlogical is hide
	help(Use only the least significant bit of a logical value)
	helpgroup(language)
	append(CGARGS=-y 125 8);

switch -Mupcase is
	help(Preserve upper and lower case in identifiers; Fortran keywords must be lower case)
	helpgroup(language)
	helpname(-M[no]upcase)
	append(CGARGS=-upcase)
	append(F901ARGS=-upcase);

switch -Mnoupcase is hide
	help(Convert all names to lower case)
	helpgroup(language)
	append(CGARGS=-noupcase)
	append(F901ARGS=-noupcase);

switch -r4 is
	help(Treat REAL as REAL*4)
	helpgroup(language)
	append(CGARGS=-y 124 0x8)
	append(FLANG1ARGS=-r4)
	append(F901ARGS=-y 124 0x8);

switch -Msafe_forall is hide
	help(Assume array assignments and FORALL statements can be safely converted to sequential loops)
	helpgroup(opt)
	append(F901ARGS=-x 4 0x100000);

append CGARGS=$if($SIGNEX,-x 124 1,-y 124 1);
append F901ARGS=$if($SIGNEX,-x 124 1,-y 124 1);

set PREPROSUFFIX=f;
set LRTLIB=$LRTLIBNAME;	# need -lrt for linux
# Enable function specialization to optimize exchange2 benchmark
set LLVM_FUNCSPEC=$if($expr($LLVMVERINT >= 160),1,0); 
