- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have my coding setup to check and see if I am using windows or linux, but what about Mac.
THis is what I have for windows and linux tests.
[bash]$if def,msnt (for windows) ..... $endif $if -def,msnt (for linux) ..... $endif[/bash]
Link Copied
14 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, that won't work on any platform for Intel Fortran. Here's what will:
!DEC$ IF DEFINED(_WIN32)
... ! Windows
!DEC$ ELSE IF DEFINED (__linux__)
... ! Linux
!DEC$ ELSE IF DEFINED (__APPLE__)
... ! Mac OS
!DEC$ ELSE
... Error
!DEC$ END IF
See here for all the predefined symbols.
!DEC$ IF DEFINED(_WIN32)
... ! Windows
!DEC$ ELSE IF DEFINED (__linux__)
... ! Linux
!DEC$ ELSE IF DEFINED (__APPLE__)
... ! Mac OS
!DEC$ ELSE
... Error
!DEC$ END IF
See here for all the predefined symbols.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[bash]So I added the DEC DEFINE lines, but when I compile on linux, it is pulling in the options for _win32.[/bash]
[bash]If I add to the compiler lie -D_linux_, it pulls in all options for Windows, Linux, and Apple.[/bash]
[bash]
[/bash]
[bash]*mlist subroutine nlssrv ! This is the subroutine for licensing RELAP ! Created by: Brian Allison ! $if def,msnt use dflib $if def,ifortc,1 use ifport, only: system $endif ! use ufilef ! implicit none $if def,msnt !dec$ attributes dllimport :: ValidateDLL, CheckLicense !dec$ attributes dllimport :: InstallLicense, DisplayInstallationID $endif ! logical exis integer is, iargc, irc, irc2, irc3, irc4, irc5, irc6, irn, ln2 integer(4) ValidateDLL, CheckLicense, DisplayInstallationID, & InstallLicense $if -def,msnt integer(4) system $endif character id*12, lcns*22, ln1*18 character :: syscall1*35 = "nilm -l /usr/lib/libFileMgmt.so -G " ! !DEC$ IF DEFINED(_WIN32) !DEC$ ATTRIBUTES ALIAS:'_ValidateDLL' :: ValidateDLL !DEC$ ATTRIBUTES ALIAS:'_CheckLicense' :: CheckLicense !DEC$ ATTRIBUTES ALIAS:'_DisplayInstallationID' :: DisplayInstallationID !DEC$ ATTRIBUTES ALIAS:'_InstallLicense' :: InstallLicense !DEC$ ATTRIBUTES ALIAS:'_StartTheService' :: StartTheService !DEC$ ELSE IF DEFINED (__linux__) !DEC$ ATTRIBUTES ALIAS:'ValidateDLL' :: ValidateDLL !DEC$ ATTRIBUTES ALIAS:'CheckLicense' :: CheckLicense !DEC$ ATTRIBUTES ALIAS:'DisplayInstallationID' :: DisplayInstallationID !DEC$ ATTRIBUTES ALIAS:'InstallLicense' :: InstallLicense !DEC$ ELSE IF DEFINED (__APPLE__) !DEC$ ATTRIBUTES ALIAS:'_ValidateDLL' :: ValidateDLL !DEC$ ATTRIBUTES ALIAS:'_CheckLicense' :: CheckLicense !DEC$ ATTRIBUTES ALIAS:'_DisplayInstallationID' :: DisplayInstallationID !DEC$ ATTRIBUTES ALIAS:'_InstallLicense' :: InstallLicense !DEC$ END IF ! ! Check license. !DEC$ IF DEFINED(_WIN32) call StartTheService !DEC$ END IF ! Random Number irn = 12 irc3 = ValidateDLL (3009, 9445, irn) irc = CheckLicense (irn) irc2 = DisplayInstallationID (id) write (tty,"('License Status:',i10)") irc write (tty,"('Installation ID:',a13)") id !DEC$ IF DEFINED(_linux_) irc5 = system("nilm -l /usr/lib/libFileMgmt.so -I") !DEC$ END IF !DEC$ IF DEFINED(_linux_) if (irc .eq. -4) then is = 0 do write (tty,"('E-mail the Installation ID, found on this scr &een to issnet@cableone.net.'/'Please key in the 15 digit unlock co &de that you recieved in your e-mail'/'after sending in the Install &ation ID.'/)") read (5,"(a)") ln1 !15 character unlock code ln2 = len_trim(ln1) !Measure the length of the unlcok code if (ln2 .ne. 15) then write (tty,"('15 character unlock code was not entered &.')") else irc6 = system(syscall1//ln1) if (irc .lt. 0) then write (tty,"('License Status:', i10)") irc stop "Unlock code was incorrect" exit endif is = is + 1 if (is .lt. 3) cycle stop 'Unlock code was not entered properly.' enddo stop endif !DEC$ END IF !DEC$ IF DEFINED(_WIN32) inquire (file="licensedata.txt",exist=exis) if (exis) then open (unit=output,file="licensedata.txt",status='old', & form='formatted') close (output, dispose='delete') endif !DEC$ END IF lcns = " " irc4 = InstallLicense (lcns) !DEC$ IF DEFINED(_WIN32) if (irc .lt. 0) then write (tty,"('Problewm with license! Please contact Innovati &ve Systems software with error code and installation id.'/'issnet@ &cableone.net')") stop endif !DEC$ END IF if (irc .eq. 10000) then write (tty,"(' LicenseStatus: License is active')") endif if (irc .eq. -108) then write (tty,"(' RELAP5 folder must have full administrative ri &ghts')") endif if (irc.lt.365 .and. irc.gt.0) then write (tty,"(' LicenseStatus:',i10,' Days left')") irc endif ! end subroutine nlssrv[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should not add -D for the platform names - these are predefined by the compiler. Did you leave in those $if lines?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you referring to these:
- $ifdef,msnt(forwindows)
- .....
- $endif
- $if-def,msnt(forlinux)
- .....
- $endif
I took them out. Also, linux and apple are not defined. THe manual says that you have to define them at the start of compilation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should not define the linux and apple symbols (nor WIN32). The compiler supplies the appropriate definition depending on the platform you compile on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok so then why when I compile on linux does it load the win32 items?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I typed "ifort platform.f90" on my mac and got new prompt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Run the resulting program and see what it prints.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
what resulting program? It did not create any new files. all there is is platform.f90.
oh wait there is a file called a.out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK I figured it out. It says MAC OS!
SO why when I run a linux compile program it is using the options under the _win32 decloration?
Is it because I am compiling on a virtual Linux machine on my Win 7 computer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just tried platform.f90 on my virtual linux on my mac and it says LINUX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If it gave anything else, we could conclude that the VM implementation was defective or that you had lost awareness of whether you were running inside the host or the guest OS -- the latter is not plausible since the look-and-feel is quite different between the host and the guest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler is what determines the value and it is specific to the target platform of the compiler. It doesn't "detect" the OS.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page