Ticket #704 (closed defect: fixed)

Opened 2 months ago

Last modified 2 months ago

ew_nt.cmd

Reported by: stefan Owned by: somebody
Priority: critical Milestone: Windows
Component: ALL modules Version: 7.10
Keywords: Cc:

Description

ew_nt.cmd doesn't properly set %TARGET% so Fortran environment variables can't be set.

The 'FORTRAN 32' below is my debug statement: echo FORTRAN %EW_BITS% %TARGET% You'll see that %TARGET% is blank. I don't understand why it isn't set because if I execute the previous not remmed lines, it looks like it should work

E:\earthworm\earthworm_7.10beta32\environment>   Set target=

E:\earthworm\earthworm_7.10beta32\environment>   If "%EW_BITS%" == "32" ( Set target=ia32    )

E:\earthworm\earthworm_7.10beta32\environment>   If "%EW_BITS%" == "64" ( Set target=intel64 )

E:\earthworm\earthworm_7.10beta32\environment>   echo FORTRAN %EW_BITS% %TARGET%
FORTRAN 32 ia32

but if I run the ew_nt.cmd, neither Visual Studio nor Fortran gets set; I get an error:

E:\earthworm\earthworm_7.10beta32\environment>E:\earthworm\earthworm_7.10beta32\environment\ew_nt.cmd
FORTRAN 32
Syntax:
 ifortvars.bat [-arch] <arch> [vs] [-platform <platform>]

   <arch> must be is one of the following
       ia32         : Set up for IA-32 target
       intel64      : Set up for Intel(R) 64 target
   If specified, <vs> must be one of the following
       vs2013      : Set to use Microsoft Visual Studio* 2013
       vs2013shell : Set to use Microsoft Visual Studio* Shell 2013
       vs2015      : Set to use Microsoft Visual Studio* 2015
       vs2015shell : Set to use Microsoft Visual Studio* Shell 2015
       vs2017      : Set to use Microsoft Visual Studio* 2017
   If <vs> is not specified, the version of Visual Studio* detected at install
   time is used.
   <platform> must be of the following.
       linux          : Set to Linux* target.
       android        : Set to Android* target.

INFO: Could not find files for the given pattern(s).

Attachments

ew_nt.cmd (7.0 KB) - added by stefan 2 months ago.
32bit ew_nt.cmd

Change History

comment:1 Changed 2 months ago by baker

Stefan,

Can you please tell me exactly what Windows OS, Visual Studio, and (Intel?) Fortran compiler you are using? I'll compare your results to my own try.

You are talking about an unmodified ew_nt.cmd from the SVN repository? If not, please upload what you are using. Also, what command prompt are you running? I mentioned before that on Windows 7 Enterprise, I run the command prompt window from the Intel compiler that it puts in the Start menu. It is already integrated with Visual Studio, so I don't have to Call any compilers setup scripts myself.

Thanks.

comment:2 Changed 2 months ago by stefan

The whole point of this file is so that it sets the variables for you, so you don't need to open a special shell. So if you're testing this file on your own system, you should not open a Fortran shell. If you're testing other things but not this file,sure open a Fortran shell first, whatever works for you.

comment:3 Changed 2 months ago by baker

That's fair enough. But, please answer and tell me exactly what Windows OS, Visual Studio, and (Intel?) Fortran compiler you are using so I can try to replicate exactly what you are doing so I can fix the problem. I happen to have Windows 10 on a laptop at home.

comment:4 Changed 2 months ago by baker

It is probably most important to describe how you open the Command Prompt window so I can start with the same environment when I make a test.

comment:5 Changed 2 months ago by stefan

I open the command-prompt from Windows-R key, and then the word "cmd".

Machine is Windows 10 64 bit. Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on IA-32, Version 19.0.3.203 Build 20190206

nmake Microsoft (R) Program Maintenance Utility Version 14.12.25834.0

It looks like the Intel install has set some environment variables. My fresh new cmd prompt window has all of this set:

C:\Users\slisowski>set
ADVISOR_2019_DIR=w:\Program Files (x86)\IntelSWTools\Advisor 2019\
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\slisowski\AppData\Roaming
CLIENTNAME=SEVENTEEN
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=HP
ComSpec=C:\WINDOWS\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
FPPUILang=en-US
FP_NO_HOST_CHECK=NO
GWT_HOME=L:\download\SmartGWT\gwt-2.7.0
HOMEDRIVE=C:
HOMEPATH=\Users\slisowski
ICPP_COMPILER19=W:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.3.203\windows\
IFORT_COMPILER18=W:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.1.156\windows\
IFORT_COMPILER19=W:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.3.203\windows\
INSPECTOR_2019_DIR=w:\Program Files (x86)\IntelSWTools\Inspector 2019\
INTEL_DEV_REDIST=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
INTEL_LICENSE_FILE=C:\Program Files (x86)\Common Files\\Intel\Licenses;C:\Program Files (x86)\Common Files\Intel\Licenses
IVIROOTDIR32=C:\Program Files (x86)\IVI Foundation\IVI\
IVIROOTDIR64=C:\Program Files\IVI Foundation\IVI\
I_MPI_ROOT=W:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.3.203\windows\mpi
LOCALAPPDATA=C:\Users\slisowski\AppData\Local
LOGONSERVER=\\DC01
MIC_LD_LIBRARY_PATH=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\compiler\lib\intel64_win_mic
NUMBER_OF_PROCESSORS=8
OneDrive=C:\Users\slisowski\OneDrive
OnlineServices=Online Services
OOBEUILang=en-US
OS=Windows_NT
Path=W:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.3.203\windows\mpi\intel64\bin;C:\Program Files (x86)\RSA SecurID Token Common;C:\Program Files\RSA SecurID Token Common;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\mpirt;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32_win\mpirt;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32_win\compiler;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files\Intel\DMIX;C:\Program Files (x86)\IVI Foundation\IVI\bin;C:\Program Files\IVI Foundation\IVI\bin;C:\Program Files\IVI Foundation\VISA\Win64\Bin\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Program Files (x86)\Calibre2\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;E:\Program Files\bin;C:\Program Files (x86)\Parallels\Parallels Workstation\Application;c:\program files\oracle\virtualbox;e:\python27;C:\Program Files (x86)\Common Files\Seagate\SnapAPI\;C:\Program Files (x86)\Skype\Phone\;e:\cygwin\bin;C:\Program Files\TextPad 8\;;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Bitvise SSH Client;C:\Users\slisowski\AppData\Local\Microsoft\WindowsApps;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PCBRAND=Pavilion
Platform=HPD
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 26 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=1a05
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=RDP-Tcp#12
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\SLISOW~1\AppData\Local\Temp
TMP=C:\Users\SLISOW~1\AppData\Local\Temp
USERDNSDOMAIN=ISTI.NET
USERDOMAIN=ISTI
USERDOMAIN_ROAMINGPROFILE=ISTI
USERNAME=slisowski
USERPROFILE=C:\Users\slisowski
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
VBOX_USER_HOME=C:\Users\stefan\.VirtualBox
VS140COMNTOOLS=E:\Program Files\Common7\Tools\
VS2017INSTALLDIR=w:\Program Files (x86)\Microsoft Visual Studio\2017\Community
VTUNE_AMPLIFIER_2019_DIR=w:\Program Files (x86)\IntelSWTools\VTune Amplifier 2019\
VXIPNPPATH64=C:\Program Files\IVI Foundation\VISA\
windir=C:\WINDOWS

Attached is one of my makefiles.

Changed 2 months ago by stefan

32bit ew_nt.cmd

comment:6 Changed 2 months ago by baker

  • Status changed from new to closed
  • Resolution set to fixed

Windows CMD.exe is a royal pain!

The reason the target environment variable was not defined in the Call to set up the compiler variables is that Windows CMD.exe evaluates %target% inside the ( ... ) braces before executing the IF command. The trick is to use SetLocal EnableDelayedExpansion and change the syntax of the target expansion from %target% to !target!.

Here's a couple toy scripts that demonstrate the effect of SetLocal EnableDelayedExpansion:

NoDelayedExpansion.cmd:

@Echo Off
Set EW_BITS=32
Set FC=ifort
Set target=garbage
Echo Before: target = %target%
If "%FC%" == "ifort" (
   Set target=
   If "%EW_BITS%" == "32" ( Set target=ia32    )
   If "%EW_BITS%" == "64" ( Set target=intel64 )
   Echo Inside: target = %target%
)
Echo After: target = %target%
DelayedExpansion.cmd:

@Echo Off
Set EW_BITS=32
Set FC=ifort
Set target=garbage
Echo Before: target = %target%
@SetLocal EnableDelayedExpansion
If "%FC%" == "ifort" (
   Set target=
   If "%EW_BITS%" == "32" ( Set target=ia32    )
   If "%EW_BITS%" == "64" ( Set target=intel64 )
   Echo Inside: target = !target!
)
Echo After: target = %target%
C:\Users\baker\Desktop>NoDelayedExpansion.cmd
Before: target = garbage
Inside: target = garbage
After: target = ia32

C:\Users\baker\Desktop>DelayedExpansion.cmd
Before: target = garbage
Inside: target = ia32
After: target = ia32

Unfortunately, SetLocal EnableDelayedExpansion was not sufficient to cure the problem. It seems that one-line commands inside ( ... ) braces are executed in the same CMD session, while multi-line commands are executed in a separate CMD session. So, the commands like ( Set target=ia32 ) work fine, but the Call commands do not have any lasting effect on the current CMD session, such as setting the environment variables needed for the Earthworm build.

I had to rewrite ew_nt.cmd to avoid ( ... ) clauses.

Thank you, Stefan, for your thorough testing of ew_nt.cmd.

Fixed in r7939.

Note: See TracTickets for help on using tickets.