Quantcast
Channel: Intel® Fortran Compiler
Viewing all 3270 articles
Browse latest View live

MALLOC

$
0
0

Elemental Intrinsic Function (Generic): Allocates a block of memory. This is a generic function that has no specific function associated with it. It must not be passed as an actual argument.

result=MALLOC(size)

size

(Input) Must be of type integer. This value is the size (in bytes) of memory to be allocated.

Results

The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is the starting address of the allocated memory. The memory allocated can be freed by using the FREE intrinsic function.

Example

  INTEGER(4) SIZE
  REAL(4) STORAGE(*)
  POINTER (ADDR, STORAGE)     ! ADDR will point to STORAGE
  SIZE = 1024                 ! Size in bytes
  ADDR = MALLOC(SIZE)         ! Allocate the memory
  CALL FREE(ADDR)             ! Free it

MAKEDIRQQ

$
0
0

Portability Function: Creates a new directory with a specified name.

Module

USE IFPORT

result=MAKEDIRQQ(dirname)

dirname

(Input) Character*(*). Name of directory to be created.

Results

The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..

MAKEDIRQQ can create only one directory at a time. You cannot create a new directory and a subdirectory below it in a single command. MAKEDIRQQ does not translate path delimiters. You can use either slash (/) or backslash (\) as valid delimiters.

If an error occurs, call GETLASTERRORQQ to retrieve the error message. Possible errors include:

  • ERR$ACCES - Permission denied. The file's (or directory's) permission setting does not allow the specified access.

  • ERR$EXIST - The directory already exists.

  • ERR$NOENT - The file or path specified was not found.

Example

USE IFPORT
LOGICAL(4) result
result = MAKEDIRQQ('mynewdir')
IF (result) THEN
   WRITE (*,*) 'New subdirectory successfully created'
ELSE
   WRITE (*,*) 'Failed to create subdirectory'
END IF
END

M to N

$
0
0

LTIME

$
0
0

Portability Subroutine: Returns the components of the local time zone time in a nine-element array.

Module

USE IFPORT

CALL LTIME(time,array)

time

(Input) INTEGER(4). An elapsed time in seconds since 00:00:00 Greenwich mean time, January 1, 1970.

array

(Output) INTEGER(4). One-dimensional array with 9 elements to contain local date and time data derived from time.

The elements of array are returned as follows:

Element

Value

array(1)

Seconds (0 - 59)

array(2)

Minutes (0 - 59)

array(3)

Hours (0 - 23)

array(4)

Day of month (1 - 31)

array(5)

Month (0 - 11)

array(6)

Years since 1900

array(7)

Day of week (0 - 6, where 0 is Sunday)

array(8)

Day of year (1 - 365)

array(9)

1 if daylight saving time is in effect; otherwise, 0.

Caution

This subroutine is not year-2000 compliant, use DATE_AND_TIME instead.

Example

USE IFPORT
INTEGER(4) input_time, time_array(9)
!   find number of seconds since 1/1/70
input_time=TIME()
!   convert number of seconds to time array
CALL LTIME (input_time, time_array)
PRINT *, time_array

LSTAT

$
0
0

Portability Function: Returns detailed information about a file.

Module

USE IFPORT

result=LSTAT(name,statb)

name

(Input) Character*(*). Name of the file to examine.

statb

(Output) INTEGER(4) or INTEGER(8). One-dimensional array of size 12; where the system information is stored. See STATfor the possible values returned in statb.

Results

The result type is INTEGER(4). The result is zero if successful; otherwise, an error code (see IERRNO).

LSTAT returns detailed information about the file named in name.

On Linux* and OS X* systems, if the file denoted by name is a link, LSTAT provides information on the link, while STAT provides information on the file at the destination of the link.

On Windows* systems, LSTAT returns exactly the same information as STAT (because there are no symbolic links on these systems). STAT is the preferred function.

INQUIRE also provides information about file properties.

Example

USE IFPORT
INTEGER(4) info_array(12), istatus
character*20 file_name
print *, "Enter name of file to examime: "
read *, file_name
ISTATUS = LSTAT (file_name, info_array)
if (.NOT. ISTATUS) then
   print *, info_array
else
   print *, 'Error ',istatus
end if

Migrate from Linux to Windows

$
0
0

I have inherited a large Fortran project, and I need to migrate it to Windows. We use Visual Studio 2008. It was developed in Linux, and the previous owners said to use Visual Fortran. So I got the proper version installed nicely. Now can I open the Linux project directly? Can I reuse the makefiles? I tried clicking around but couldn't find how.

Is there an approved method for doing this?

I am probably not the first person to have this problem, though everybody else here seems to be porting in the other direction.

Run-Time Check Failure #2

$
0
0

I am getting the following message when I leave a particular subroutine, at the end statement:

Run-Time Check Failure #2 - Stack around the variable '.T209_' was corrupted.

By trial and error I have traced it to the calling of another subroutine, "A", 4 levels below. If I comment out the call to this subroutine "A" the error goes away.  However if I still call "A" but remove all the code inside it, I get the error. So it looks like a argument list issue.  However all the arguments match fine.  Most of the arguments are structures from USE'd modules which both the caller and callee USE.

How do I debug this further?

LOG10

$
0
0

Elemental Intrinsic Function (Generic): Returns the common logarithm of the argument.

result=LOG10(x)

x

(Input) Must be of type real or complex. If x is real, its value must be greater than zero. If x is complex, its value must not be zero.

Results

The result type and kind is the same as x. The result value is approximately equal to log10x.

Specific Name

Argument Type

Result Type

ALOG10 1,2

REAL(4)

REAL(4)

DLOG10 3

REAL(8)

REAL(8)

QLOG10

REAL(16)

REAL(16)

CLOG102

COMPLEX(4)

COMPLEX(4)

CDLOG103

COMPLEX(8)

COMPLEX(8)

CQLOG10

COMPLEX(16)

COMPLEX(16)

1This function is treated like LOG10.

2The setting of compiler options specifying real size can affect ALOG10, CLOG10, and LOG10.

3The setting of compiler options specifying double size can affect DLOG10 and CDLOG10.

Example

LOG10 (8.0) has the value 0.9030900.

LOG10 (15.0) has the value 1.176091.

The following shows another example:

REAL r
r = LOG10(10.0)  ! returns 1.0

See Also


LOG_GAMMA

$
0
0

Elemental Intrinsic Function (Generic): Returns the logarithm of the absolute value of the gamma function of the argument.

result=LOG_GAMMA(x)

x

(Input) Must be of type real. It must not be zero or a negative integer.

Results

The result type and kind are the same as x.

The result has a value equal to a processor-dependent approximation to the natural logarithm of the absolute value of the gamma function of x.

Example

LOG_GAMMA (3.0) has the approximate value 0.693.

LOG

$
0
0

Elemental Intrinsic Function (Generic): Returns the natural logarithm of the argument.

result=LOG(x)

x

(Input) Must be of type real or complex. If x is real, its value must be greater than zero. If x is complex, its value must not be zero.

Results

The result type and kind is the same as x. The result value is approximately equal to logex.

If the arguments are complex, the result is the principal value with imaginary part omega in the range -pi <= omega <= pi.

If the real part of x< 0 and the imaginary part of x is a positive real zero, the imaginary part of the result is pi.

If the real part of x< 0 and the imaginary part of x is a negative real zero, the imaginary part of the result is -pi.

Specific Name

Argument Type

Result Type

ALOG 1,2

REAL(4)

REAL(4)

DLOG

REAL(8)

REAL(8)

QLOG

REAL(16)

REAL(16)

CLOG 2

COMPLEX(4)

COMPLEX(4)

CDLOG3,4

COMPLEX(8)

COMPLEX(8)

CQLOG

COMPLEX(16)

COMPLEX(16)

1This function is treated like LOG.

2The setting of compiler options specifying real size can affect ALOG, LOG, and CLOG.

3This function can also be specified as ZLOG.

4The setting of compiler options specifying double size can affect CDLOG.

Example

LOG (8.0) has the value 2.079442.

LOG (25.0) has the value 3.218876.

The following shows another example:

REAL r
r = LOG(10.0)  ! returns 2.302585

See Also

LOCK and UNLOCK

$
0
0

Statements: A LOCK statement causes a lock variable to become locked by an image. An UNLOCK statement causes the lock variable to become unlocked. They take the following forms:

LOCK(lock-var[,ACQUIRED_LOCK=log-var][,STAT=stat-var][,ERRMSG=err-var])

UNLOCK(lock-var[,STAT=stat-var][,ERRMSG=err-var])

lock-var

Is a scalar variable of type LOCK_TYPE. For more information, see intrinsic module ISO_FORTRAN_ENV.

log-var

Is a scalar logical variable.

stat-var

Is a scalar integer variable in which the status of the synchronization is stored.

err-var

Is a scalar default character variable in which explanatory text is stored if an error occurs.

ACQUIRED_LOCK=, STAT=, and ERRMSG= can appear in any order, but only once in a LOCK statement.

STAT= and ERRMSG= can appear in either order, but only once in an UNLOCK statement.

Description

A lock variable is unlocked if its value is equal to that of the structure constructor LOCK_TYPE ( ). If it has any other value, it is locked.

A lock variable is locked by an image if it was locked by execution of a LOCK statement on that image and has not been subsequently unlocked by execution of an UNLOCK statement on the same image.

When a LOCK statement is specified without an ACQUIRED_LOCK= specifier, it causes the lock variable to become locked by that image. If the lock variable is already locked by another image, that LOCK statement causes the lock variable to become defined after the other image causes the lock variable to become unlocked.

If the lock variable is unlocked, successful execution of a LOCK statement with an ACQUIRED LOCK= specifier causes the lock variable to become locked by that image and the log-var to become defined with the value TRUE. If the lock variable is already locked by a different image, successful execution of a LOCK statement with an ACQUIRED LOCK= specifier leaves the lock variable unchanged and causes the log-var to become defined with the value FALSE.

During the execution of the program, the value of a lock variable changes through a sequence of locked and unlocked states when LOCK and UNLOCK statements are executed. If a lock variable becomes unlocked by execution of an UNLOCK statement on image M and next becomes locked by execution of a LOCK statement on image T, the segments preceding the UNLOCK statement on image M precede the segments following the LOCK statement on image T. Execution of a LOCK statement that does not cause the lock variable to become locked does not affect segment ordering.

An error condition occurs in the following cases:

  • If the lock variable in a LOCK statement is already locked by the executing image

  • If the lock variable in an UNLOCK statement is not already locked by the executing image

If an error condition occurs during execution of a LOCK or UNLOCK statement, the value of the lock variable is not changed and the value of the ACQUIRED_LOCK variable, if any, is not changed.

Example

The following example shows the use of LOCK and UNLOCK statements to manage a work queue:

USE, INTRINSIC :: ISO_FORTRAN_ENV

TYPE(Task) :: work_queue(50)[*]          ! List of tasks on queue to perform
INTEGER :: work_queue_size[*]
TYPE(LOCK_TYPE) :: work_queue_lock[*]    ! Lock to manage the work queue

TYPE(Task) :: current_task
INTEGER :: my_image

my_image = THIS_IMAGE()
DO
   ! Process the next task in the work queue
   LOCK (work_queue_lock)              ! Start of new segment A
   ! Segment A is ordered with respect to segment B
   ! executed by image my_image-1 below because of lock exclusion
   IF (work_queue_size>0) THEN
       ! Get the next job from the queue
       current_task = work_queue(work_queue_size)
       work_queue_size = work_queue_size-1
   END IF
   UNLOCK (work_queue_lock) ! Segment ends
...
   ! Process the task

   ! Add a new task on the neighboring queue:
   LOCK(work_queue_lock[my_image+1])      ! Starts segment B
   ! Segment B is ordered with respect to segment A
   ! executed by image my_image+1 above because of lock exclusion
   IF (work_queue_size[my_image+1]<SIZE(work_queue)) THEN
       work_queue_size[my_image+1] = work_queue_size[ti+1]+1
       work_queue(work_queue_size[my_image+1])[my_image+1] = current_task
   END IF
   UNLOCK (work_queue_lock[my_image+1]) ! Ends segment B
END DO

Any problem for Fortran under Windows to read files produced by Fortran under Linux

$
0
0

Hi,

I will run the Cluster Studio and Fortran both under Windows and Linux. I want run code under Linux to produce result files. I then want to read the result files using Fortran code under Windows with nice Quickwin graphics to inspect the results. Later on I will add a Xeon Phi card and has found out that there a lot of hands on documentation of running the Phi under Linux but virtually zero information on running the Phi card under Windows.

Best regards

Anders S

-heap_arrays option, thread safety and performance

$
0
0

I'm updating old .f90 code to f2003 and in order to make thread-safe libraries.  I've come across this old topic:

https://software.intel.com/en-us/forums/topic/270572

in listing a few guidelines for writing thread-safe code.  One of the libraries I've updated uses very large arrays, which I've been able to get working when using the -heap_arrays compiler option. Otherwise I get a stack overflow error in the MAXVAL intrinsic function.  But the above topic states to not use the -heap_arrays option for thread-safe code. 

Is this true?  I'm using Intel® Parallel Studio XE 2015 Update 4 Composer Edition for Fortran Windows* Integration for Microsoft Visual Studio* 2013, Version 15.0.0122.12

I know previous versions of IVF had memory leak problems with this option but have since been fixed. 

Also, this particular library is being executed across multiple threads (2-8) 1000s of times and I do see a noticeable slow down when I get to the 1000+ run/thread.  Is this due to the -heap arrays option for creating the library? or would this be attributable to a memory leak problem? 

Installer says another instance of the installer is running

$
0
0

Hello,

This is my first time posting to this forum, not sure if this is the right forum for this question. Apologies if that is not the case.

Some time back I had installed Intel Parallel Studio XE on my 64-bit Ubuntu 12.04 machine, at which time I had only installed a few selected components. Recently, I realized that I needed to install Vtune amplifier to profile my code. So I downloaded a file called "parallel_studio_xe_2015_update3.tgz", un-tar-gzed it, ran the installer and chose to modify my installation. At this point, I got a message saying that there was another instance of the installer running (there wasn't). The full screen looks as follows:

This product is already installed
--------------------------------------------------------------------------------
Installation program has detected that at least one component of the product is
already installed. Select one of the following options to continue:
--------------------------------------------------------------------------------
1. Modify the installation [default]
2. Repair the installation
3. Uninstall the product

h. Help
q. Quit
--------------------------------------------------------------------------------
Please type a selection or press "Enter" to accept default choice [1]: 1
Another instance of the installation program has been detected. Please quit the
other instance and try again.
--------------------------------------------------------------------------------
Press "Enter" key to quit:

I've even tried rebooting the machine, to kill off any processes which might be causing this. But this is a perfectly reproducible problem. Has anyone seen something like this before? How do I get the installer to run?

Thanks,

Sourish

ifort 15 compile time error with adj3.f90


Access Fortran module exported in dll from Fortran executable

$
0
0

I am trying to export a module (including a derived type and procedures) to a dll that can be used, in principle, by a fortran executable...

With Visual Studio, I was able to do it in a solution with two projects, one to build the dll (with the DLLEXPORT directives for the exported procedures), the other project with the code for building the executable file USEing the module derived type and procedures, by setting as a depencency the dll project (without any DLLIMPORT directives in the code, and without including the .lib within the project files). It worked. Indeed making some changes in the dll project, recompiling only the dll project and replacing the dll file copied at the executable file folder, it still works.

Nevertheless, I have understood  from other posts that it is possible to build the that executable accesing the module types and procedures, only with the .dll and the .mod files available. Is that right? Only from command line? Also with Visual Studio?

Thanks in advance for any advice!

Gustavo 

Compilation of Multi-fortran files in one visual studio project 2

$
0
0

Hi  Everyone,

I m using  Developer studio with visual fortran 6.  I have a code with many  fortran projetcs:     one main project and the others are

Modules containing subroutine. This code run perfectly  when using  linux.

The problem occurs when i try to compile it using VF (Windows).

I think  the problem comes to  the  fact there is no link between my file or  the compilation order is not respect at all.

May be  i m wrong, and i need i least to dismiss  this possibility. 

Can anybody tells me  how can i link these differents files and how can i compile this code? 

How can i adapt the makefile  file in my case.

 

Thank you 

Will purchasing IVF 15 now allow for upgrade to IVF 16 in a few weeks?

$
0
0

If I remember well, free upgrades are possible within a year of purchase of a compiler - it this correct?

Thanks,
Olivier

are include statements in subroutines safe for mutithreading?

$
0
0

HI 

This may the the first of many questions about running or rewriting an application with

ThreadModel Free  ( the application works fine in ThreadModel Apartment)

I upgraded to visual fortran compiler XE 15.04.221 , but still using IA-32 build. 

 

I have read that COMMON blocks are a problem for multithreading because they can

lead to racing , is that correct??

So when now passing arrays between subroutines on the subroutine argument list

instead of in common blocks, does the use of include statements in subroutines

to dimension arrays on the subroutine argument list, or to dimension arrays

local to the subroutine cause racing, or is it threadsafe??  

Example

apple is an include with two parameter statements 

INTEGER, PARAMETER ::NPCOUNT =405

INTEGER,PARAMETER :: KREAL = 355

 

So then are these ok to do, the first subroutine dimensions an array on the calling list with the include parameter value,

the second subroutine dimensions a local array in the subroutine with the include parameter value....

SUBROUTINE Fort01(MAIN1)

INCLUDE 'apple'

DIMENSION MAIN1(NPCOUNT)

RETURN

END

 

and

SUBROUTINE Fort02(MAIN1,IMAIN1)

INCLUDE 'apple'

DIMENSION MAIN1(IMAIN1)

DIMENSION LOCAL1(KREAL)

RETURN

END 

Thanks

BIll

How do I properly create a dll?

$
0
0

Hello,

I am attempting to create dll files in Fortran.  If I am not mistaken, I am supposed to export a .dll file from my project, which is a .f90 file as opposed to a .dll file, in order for another program (written in Basic) to link to it.  To get things started, I have made a simple program in Fortran that goes as follows:
 

! TestDLL.f90 

!
!  FUNCTIONS/SUBROUTINES exported from TestDLL.dll:
!  TestDLL - subroutine
!
subroutine TestDLL

  ! Expose subroutine TestDLL to users of this DLL
  !
  !DEC$ ATTRIBUTES DLLEXPORT::TestDLL

  ! Variables
    Integer K

 ! Body of TestDLL
    K = 1

    Return

end subroutine TestDLL

 

However, when I create the .dll file by running this program, I see the following when I open the .dll file in a text editor:

 

This program cannot be run in DOS mode.

Stack around the variable '' was corrupted. The variable '' is being used without being initialized.  The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

A cast to a smaller data type has caused a loss of data.  If this was intentional, you should mask the source of the cast with the appropriate bitmask.

Changing the code in this way will not affect the quality of the resulting optimized code.

    Stack memory was corrupted

    A local variable was used before it was initialized

   Stack memory around _alloca was corrupted

 Unknown Runtime Check Error

   Runtime Check Error .

Unable to display RTC Message.   Run-Time Check Failure  Unknown Filename   Unknown Module Name Run-Time Check Failure  Stack corrupted near unknown variable   user32.dll   wsprintfA   Stack area around _alloca memory reserved by this function is corrupted

Stack area around _alloca memory reserved by this function is corrupted A variable is being used without being initialized.

Stack pointer corruption
Cast to smaller type causing loss of data
Stack memory corruption Local variable used before initialization
Stack around _alloca corrupted

                                                                                                                        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel></requestedPrivileges></security></trustInfo></assembly>

Where could I going wrong here?

Thanks,

Jamal
 

 

 

                                                                                                                                                                                                                         

 

 

Viewing all 3270 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>