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

Program using IMSL LIN_SOL_GEN crashing on runtime machine

$
0
0

Hello all,

This has to be a silly problem but I can't seem to find the source of it.

I have created a Fortran module which I compile and link to work with Python. This module makes use of several routines of the IMSL library, including LIN_SOL_GEN. Compilation seems to work fine( I'm using static linking) and the whole thing runs fine on my machine. However, when I give the compiled file to a colleague to run on his machine (he has installed the Intel Fortran redistributables library), everything works fine except for the LIN_SOL_GEN routine. On his machine, when that particular routine is called, the program stops without any error message. Absolutely no clue whatsoever.

I have modified the terminal error flags so that IMSL routines won't stop the program, to no avail.

I have tried to use an alternate routine to perform the linear solve, LIN_SOL_SVD (basically, just changed the name of the routine called!), and the whole thing works fine on the runtime machine, albeit LIN_SOL_SVD is a lot slower than LIN_SOL_GEN for my particular problem.

I suspect this has to do with "High performance"/SMP behaviour of LIN_SOL_GEN but can't find exactly what makes it fail on the runtime machine but not on mine. Is there something special to do to make SMP routines work on runtime-only machines?

Many thanks.

 

Cédric

 


Debug impossible with Visual Studio 2013

$
0
0

Dear all,

up to a week ago I was perfectly able to compile and debug a Fortran code with Visual Studio 2013, paralleziled with openMP, but now, when debugging, I get the error message:

Debug assertion failed!

Program:*\mycode.exe

File:f:\dd\vctools\crt\crtw32\misc\winsig.c

Line:418

Expression: invalid signal or error.

This happens only when debugging because the executable is actually working nicely. Moreover I have no error message on the command window. I haven't change any settings in VS.

Could you please help me to figure out what can cause the problem?

Thanks

 

error #5082: Syntax error, found

$
0
0

Hi Steve

could you help me please?

Thanks

David

I have following error:

Error    1     error #5082: Syntax error, found '(' when expecting one of: <END-OF-STATEMENT> ; <LABEL> BLOCK BLOCKDATA PROGRAM MODULE TYPE COMPLEX BYTE ...    c:\Source\neu29.05.15\src\traeger12\traeger12\traeger12\h_anstell.f90    13    

here my cods:

 subroutine h_anstell (kontur, anstmass)

 use modmpc, only: profil 
 record / profil/      kontur
 real(kind=8)     ::   anstmass
 integer          ::   i

 do i=1,kontur.anz_punkte

       if (kontur.pkt(i).y < 0 ) then
       
             (kontur.pkt(i).y = kontur.pkt(i).y - anstmass/2_8)
              
                elseif (kontur.pkt(i).y > 0) then 
                
             (kontur.pkt(i).y = kontur.pkt(i).y + anstmass/2_8)
             
       endif
 enddo

 end subroutine   

Visual Studio 2005 and Composer XE 2013

$
0
0

I have Visual Studio 2005 installed and am trying to upgrade my FORTRAN projects from Composer XE 2011 to Composer XE 2013.  Composer XE 2013 seemed to install properly but it does not appear under Options -> Intel Visual Fortran -> Compilers in Visual Studio.  How can I get Visual Studio to compile with Composer XE 2013?

Having Trouble recompiling model on a new machine

$
0
0

Hi There,

I recently migrated a model written in fortran to a new machine, from OSX to CentOS.  With this migration came a new version of ifort and icc and also a switch from using mpich2 to openmpi for the parallel compilation.  The problem is, with no changes to the code, the model won't compile on the new machine.  I have already compiled another model written in fortran in both serial and parallel, so I know the compilers are working properly.

I was hoping someone could help me figure out some possible compiler options, or point out some differences in the ifort versions that could lead to this difference.

Here is the version of Ifort on the Mac that was used previously that works for both serial and parallel (with mpich2)

Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.3.166 Build 20140415

and the new version on the CentOS server

Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.3.187 Build 20150407

and the error message from the new machine (this is in parallel with openmpi)

ifort: command line remark #10010: option '-vec-report0' is deprecated and will be removed in a future release. See '-help deprecated'

wqm_inputs.o: In function `inputs_':

wqm_inputs.f90:(.text+0x0): multiple definition of `inputs_'

wqm_inputs.o:wqm_inputs.f90:(.text+0x0): first defined here

wqm_inputs.o: In function `error_check_':

wqm_inputs.f90:(.text+0x2c890): multiple definition of `error_check_'

wqm_inputs.o:wqm_inputs.f90:(.text+0x2c890): first defined here

make: *** [wqm_dom2] Error 1

 

When I comment out subroutine ERROR_CHECK the error_check error doesn't occur, but I can't figure out the other one.

 

It also doesn't compile in serial... but the error is different.

 

Any help would be greatly appreciated, bare in mind I am an oceanographer not an engineer, so my knowledge of coding and compiling is very limited.

 

 

 

 

 

 

 

Switch from GNU to Ifort both under Linux

$
0
0

Hi there,

I actually run simulations with ABAQUS Standard 6.14-1.
Thereby I use some subroutines written in a combination of Fortran 77 and free-format (unlimited length of lines). In general Subroutines should be written in Fortran 77, but on the actual machine it works good.
Because of performance limit I’d like to change the machine.

The actual machine is a Debian Version 4.6.3-14 – Compiling with GNU Version 4.7.2-5.
The new one is called RedHat5 – Compiling with Intel Fortran 64 XE Version 12.0.
Both use Linux as operating system.

The “simple” task is now to switch the environment in that way, that it works the same way using the Intel Fortran Compiler instead of GNU Fortran.

Details of the actual/old system

excerpt of the environment-file

compile_fortran = [fortCmd,

'-c', '-fPIC', '-extend_source', '-O2', '-I%I', '-ffixed-line-length-none', '-fno-align-commons',
'-std=f2008', '-frecursive']

 

excerpt of one Subroutine (subroutine.f)
(this is the third one of 9, but the first that makes trouble) --> Uploaded 1 & 2:

Excerpt1-Subr.f.PNG

Excerpt2-Subr.f.PNG

Line 140 is the first one that makes troube on the “new machine” using the environment-file below.
I tried a word-wrap by using & at the end or beginning of a line (column 5 and further), $ or 1 but it doesn’t work at all. Further I tried to shift the whole subroutine in that way, that the first word starts at column 6 as prescribed in Fortran 77… but that works less.

 

Details of the new system

excerpt of the environment-file

compile_fortran = [fortCmd,
                  '-V',
                  '-c', '-fPIC', '-auto', '-mP2OPT_hpo_vec_divbyzero=F', '-extend_source',
                   '-WB', '-I%I']

Via trial and error I migth exclude “-free” , “-frecursive” (isn’t supported), “assume cc_omp”,

 

Typical error-massages:

/tmp/2198878.1.abax18/U_Data_Calculate.f(140): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...

          IF ( NR .EQ. PHASE_FERRITE)     Data_Density_Jablonka   = (rhoF0  +  rhoF1*TEMP +  rhoF2*TEMP*TEMP) *

---------------------------------------------------------------------------------------------------------------^

/tmp/2198878.1.abax18/U_Data_Calculate.f(141): error #5082: Syntax error, found '(' when expecting one of: BLOCK BLOCKDATA PROGRAM MODULE TYPE BYTE CHARACTER CLASS DOUBLE DOUBLECOMPLEX ...

    1     (1.0 - rhoFC*cC)

----------^

/tmp/2198878.1.abax18/U_Data_Calculate.f(142): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...

          IF ( NR .EQ. PHASE_CARBIDE)     Data_Density_Jablonka   = (rhoK0  +  rhoK1*TEMP +  rhoK2*TEMP*TEMP) *

----------------------------------------------------------------------------------------------------------------^

/tmp/2198878.1.abax18/U_Data_Calculate.f(143): error #5082: Syntax error, found '(' when expecting one of: BLOCK BLOCKDATA PROGRAM MODULE TYPE BYTE CHARACTER CLASS DOUBLE DOUBLECOMPLEX ...

    1      (1.0 - rhoKC*cC - rhoKCr*cCr - rhoKMn*cMn)

 

Furthermore a colleaguewho works with Damask gave me an environment that might help

compile_fortran = (fortCmd + " -c -fPIC -auto " +

                   "-I%I -free -O1 -fpp -openmp " +

                   "-ftz -diag-disable 5268 " +

                   "-implicitnone -assume byterecl " +

                   "-real-size 64 -integer-size 32 -DFLOAT=8 -DINT=4")

 

…  but I can’t transfer it because he uses another Fortran style… excerpt of his routine:

!*** input/output variables

type(p_vec), dimension(1,mesh_maxNips,mesh_NcpElems), intent(inout) :: &

                               state                           !

microstructural state

 

!*** local variables
integer(pInt)            ipc, &
                               el, &
                               ip, &
                               e, &
                               i, &
                               ns, &                          
! short notation for total number of active slip systems
                               f, &  
! index of lattice family

 

Up to the present or a few weeks ago – I work on it since 3 weeks - I never mind about details in the environment and the compiling process.  Thus or nevertheless I’m no specialist in this kind of stuff. 
Since I work on it for a certain time, but without having achieving the switch, I hope someone might help me.
 

Kind regards

Sandra

 

 

 

 

 

 

 

 

File is opened. But giving an error

$
0
0

Hi,

I open a file using this.

open(100,FILE ='temp.txt',STATUS='OLD',ERR=63) 

But it goes to error line.

Then,I check the error using this(when the error is happen) .

INQUIRE (100, OPENED=I_OPENED, NAME=I_NAME, ACTION=I_ACTION)

But it says file is opened.

I_OPENED = T and other variable are fine.

Please help me.

Stack Error Passing a string from VB.NET to a Fortran DLL

$
0
0

Hi,

I am rewriting a large application moving from VB6 using FORTRAN executables, to VB.NET using FORTRAN DLL's.

I am able to move single values and arrays both to and from the DLL, but now have gotten stuck trying to push strings. 

Here is the relevant VB.NET code:

In the declarations section:

    <UnmanagedFunctionPointer(CallingConvention.StdCall)>
Private Delegate Sub pushString(ByRef varIndex As Short, ByVal MsgString As StringBuilder)

        Dim EntryPointer As IntPtr = NativeMethods.LoadLibrary(EXE_DLL_filename)
        FunctionPointer = NativeMethods.GetProcAddress(EntryPointer, "pushString")
        Dim pushString As pushString = CType(Marshal.GetDelegateForFunctionPointer(FunctionPointer, GetType(pushString)), pushString)

Executable code:

            Dim index As Short = 501
            Dim filePath As String = "C:\Users\mark.ARROWTECH\AppData\Local\Temp\tmpD33F.tmp"
            Dim strMessage As StringBuilder = New StringBuilder(filePath, 120)
            pushString(index, strMessage)

The DLL that I link to is only known at runtime.

Relevant FORTRAN code:

!dec$ attributes dllexport, CVF,  alias : 'pushString' :: pushString
SUBROUTINE pushString(varIndex, InputString )
use, intrinsic :: ISO_C_BINDING
USE Traj20006D_Global_Export
integer(2), intent(in) :: varIndex
CHARACTER(KIND=C_CHAR,LEN=1), INTENT(in) :: InputString(*)
INTEGER :: StringLen
INTEGER :: I
 !.. Determine input string length; check for null-termination
 StringLen = 0
 Loop_SizeVec: DO !
  IF (InputString(StringLen+1) == C_NULL_CHAR) THEN
   EXIT Loop_SizeVec
  End If
  StringLen = StringLen + 1
  IF (StringLen == 2048) THEN !.. Replace: arbitrary large length
   EXIT Loop_SizeVec
  END IF
 END DO Loop_SizeVec
 IF (StringLen == 0) RETURN
 select case(varIndex)
  Case (501)
   FORALL (I = 1:StringLen)     !.. Copy string
    TEXTFILE1(I:I) = InputString(I)(1:1)
   END FORALL
  Case (502)
   FORALL (I = 1:StringLen)     !.. Copy string
    TEXTFILE2(I:I) = InputString(I)(1:1)
   END FORALL
  End Select
 Return
END SUBROUTINE pushString

So what happens is the string is transferred fine, but on leaving the routine I get this error:

"Additional information: A call to PInvoke function 'PRODASV4!PRODASV4.prodasTask+pushString::Invoke' has unbalanced the stack. "

I am just not sure what to try next.

Thanks,
Mark

 


Matrix Determinant

$
0
0

Hi all,

I am just trying to get a determinant of a matrix ( could be from 4x4 to 10x10 , so not huge matrices). I was wondering what is the most efficient way?

Using MKL or....

also the matrix would not be always a sparse matrix.

 

Thanks,

Arman 

Optional Arguments and Their Uses.

$
0
0

Dear All,

I was wondering: is it worth considering to code using optional arguments or should they be avoided at any cost? Is there a loss in performance if optional arguments are used?

I have read the FORTRAN Newsletter Articles posted by Dr.Fortran.

Looking forward to your thoughts,

Daniel.

std_minus0_rounding

$
0
0

I have Visual Studio 2013 with the Intel(R) Visual Fortran Compiler XE 14.0.5.239 which is supposed to support the std_minus0_rounding compiler option but I cannot figure out how to set that option using the Visual Studio IDE.  Can anyone help?  Thanks.

debugging sample project VB-Calls-Fortran.sln

$
0
0

I have built this sample project, and it runs fine, but I'm having limited success with the debugger. The instructions say...

To enable debugging of Fortran code called from Visual Basic, right click on project "VBCallsFortran" and then select Properties. In the left column, select Configuration Properties > Debugging. Check the box labeled "Enable unmanaged code debugging"

VS 2012 doesn't have that option, but there is Enable Native Code Debugging. Checking that gets the debugger to step into and through the fortran code, but the values of arguments cannot be examined, although local variables can. Is there something else I need to do to enable this?

intel fortran compatibility with xcode 6.4 and osx 10.10

$
0
0

I just upgraded to osx 10.10, and xcode 6.4 was automatically installed. i need to renew my intel fortran license, but before i pay for it i noticed that this combination is not listed here: https://software.intel.com/en-us/articles/performance-tools-for-software...

so my question is: will the latest update of intel fortran work with this system? if not, what are my options.

(no idea if i am asking this in the right place, but i could not find a way to live chat or talk to a sales rep)

 

 

Intel® Fortran Compiler 16.0 Release Notes

$
0
0

This page provides links to the current Release Notes for the Intel® Fortran Compiler 16.0 component of Intel® Parallel Studio XE 2016 for Windows*, Linux* and OS X*. 

To get product updates, log in to the Intel® Software Development Products Registration Center.

For questions or technical support, visit Intel® Software Products Support.

For Release Notes for other versions, visit Intel® Compiler Release Notes.

 

Intel® Fortran Compiler 16.0 for
Windows*

Intel® Fortran Compiler 16.0 for
Linux*

Intel® Fortran Compiler 16.0 for
OS X*

Initial Release Notes
English

Initial Release Notes
English

Initial Release Notes
English

  • Developers
  • Apple OS X*
  • Linux*
  • Microsoft Windows* (XP, Vista, 7)
  • Microsoft Windows* 10
  • Microsoft Windows* 8.x
  • Fortran
  • Intel® Parallel Studio XE Composer Edition
  • Intel® Fortran Compiler
  • Intel® Visual Fortran Composer XE
  • URL
  • Overriding the READ function in Fortran

    $
    0
    0

    All,

    I have inherited a legacy Fortran system which contains several different modules which read ASCII text files from various logical units.  Examples:

    100 read (userin,1,iostas=ios) line

    READ(I3,805) ACTYCO,

    etc.

    The Fortran system is distributed with the necessary ASCII text files.  I have been given the task to only delivered the system with binary files instead of ASCII files for proprietary data security.  An easy solution would be to add a converter of the binary files to ASCII in a temporary file at the beginning of the system and then delete the temporary ASCII files after all the reads are complete.  This solution has been removed due to the possible of temporary file remaining on the user's machine after an unexpected crash of the Fortran.

    So, my question is:  Can I override the "READ" function in Fortran ( similar to C capability ) to insert my own READ which would handle either ASCII or binary?  This would allow me to not change the hundred or so READ statements in the legacy code.  Also, if there is a more elegant solution this the problem stated, I am all ears.

    Thanks,

    Bryan


    Calling C in dynamically loaded DLL from Fortran

    $
    0
    0
    I have always been using this method to call functions in a dynamically loaded DLL:
    
          INTERFACE
            logical function Check_Security_DLL(itype) BIND(C, NAME="Check_Security_DLL")
              integer(4) :: itype [value]
            end function Check_Security_DLL
          END INTERFACE
    
          pointer (p_CheckSecurity, Check_Security_DLL)
    
          if(.not. LibLoaded) then
            dll_handle = LoadLibrary('Tec1.dll'//char(0))
            if (dll_Handle /= 0) then
              i_CheckSecurity = GetProcAddress(dll_handle, "Check_Security_DLL"C)
              if (i_CheckSecurity /= 0) then
                p_CheckSecurity = i_CheckSecurity
                LibLoaded = .true.
              endif
            endif
          endif
    
          if (LibLoaded) then
            result = Check_Security_DLL(type)
          endif
    

     

    However I get these warnings if I switch on F2008 checking:

    D:\ToolsetIncs\Check_SecF.F90(23): warning #7028: Integer pointer non-standard
    D:\ToolsetIncs\Check_SecF.F90(17): warning #7372: Procedures as pointees is not supported in Fortran 2008 standard.   [CHECK_SECURITY_DLL]

    So I guess there is a new method, however the Samples do not have an example for dynamically loading the DLL and how to call a function in the DLL.

    Program Exception - access violation

    $
    0
    0

    I am running some simulation software written in Fortran while using Matlab to automate the simulations. The simulations run through, but I keep getting this error very frequently while the program is running: 

     forrtl: severe (157): Program Exception - access violation  
     Image                              PC                       Routine                  Line          Source              
     Simulate.exe       000000013F473F2B     Unknown               Unknown    Unknown 
     Simulate.exe       000000013F473BDC    Unknown               Unknown    Unknown 
     Simulate.exe       000000013F4DF4BC    Unknown               Unknown    Unknown 
     Simulate.exe       000000013F4C80F6     Unknown               Unknown    Unknown 
     kernel32.dll         00000000773559CD     Unknown               Unknown    Unknown 
     ntdll.dll                000000007758B981      Unknown               Unknown    Unknown 

     

    From what I found online, this error apparently means that I am using memory that I am not supposed to. However, I am puzzled by how it's reporting "unknown" for the Routine, Line, and Source. Any suggestions on how to deal with this?

    dynamic character array of deferred length in subroutine

    $
    0
    0

    I have found that that dynamic character array of deferred length in subroutine could not be allocated.

    Here is the sample code. One array is declared in the main program (var name is array_main) and is being passed to subroutine. In subroutine this array is being declared as array_sub1. Also subroutine contains another array - array_sub2.

    And here is the problem. First array (array_sub1) has no problems with allocation in the subroutine. The allocation of array_sub2 is not seen in debugger ("Undefined pointer/array") when program is being run the next after allocation statements. At the same time there are no error signs such as non zero error stat.

    Where is the problem? How to allocate array of this kind in subroutine?

    Intel Visual Fortran Composer XE 2013 + Microsoft Visual Studio 2012

     program TEST_PROG
        implicit none
        CHARACTER*(:), ALLOCATABLE :: array_main(:)
        INTERFACE
            SUBROUTINE TEST_SUB (array_sub1)
                IMPLICIT NONE
                INTEGER nword, wordlen, statv
                CHARACTER*(7) errv
                CHARACTER*(:), ALLOCATABLE :: array_sub1(:)
                CHARACTER*(:), ALLOCATABLE :: array_sub2(:)
            END SUBROUTINE
        END INTERFACE
    
        CALL TEST_SUB(array_main)
        end program TEST_PROG
    
        SUBROUTINE TEST_SUB (array_sub1)
        IMPLICIT NONE
        INTEGER nword, wordlen, statv
        CHARACTER*(7) errv
        CHARACTER*(:), ALLOCATABLE :: array_sub1(:)
        CHARACTER*(:), ALLOCATABLE :: array_sub2(:)
    
        nword = 3; wordlen = 4
        ALLOCATE (CHARACTER(wordlen)::array_sub2(nword), STAT=statv, ERRMSG=errv)
        WRITE (*,*) statv, errv
        ALLOCATE (CHARACTER(wordlen)::array_sub1(nword), STAT=statv, ERRMSG=errv)
        WRITE (*,*) statv, errv
        array_sub2(1) = 'abab'
        array_sub2(2) = 'cdcd'
        array_sub2(3) = 'efef'
        END SUBROUTINE

     

    Allocatable Array of Inherited Derived Types Issues in Fortran

    $
    0
    0

    I'm attempting to create global-ish-ly available allocatable array of a set of derived types that share inheritance with a single object. Fortran does not seem to make this very easy. The below is what I have so far.

    First the derived types and module with the allocatable array.

        Module Environment
    
            use Entity_M
            type(Entity_C), dimenion(:), allocatable :: objects
        End Module Environment
    
        Module Entity_M
            type Entity_T
                integer :: id
                real*8 :: time
                real*8, dimension(3) :: currPos
    
                type(TrajectoryDatum), dimension(:), allocatable :: trajTable
    
            end type Entity_T
    
            type Entity_C
                class(Entity_T), pointer :: e
            end type Entity_C
    
            type, extends(Entity_T) :: Aircraft_T
                real*8 :: altitude
            end type Aircraft_T
    
            type, extends(Entity_T) :: Missile_T
                integer :: targetID
            end type Missile_T
    
        End Module Entity_M

    Now the main program

       

     Program Main
    
            use Initialization
            use Environment
            use Entity_M
    
            call simInit(3)
            write(*,*) objects%trajTable !<---- this does not persist
    
            call runSim()
    
        End Program Main

    The code with the issue

        

    Module Initialization
    
            use Entity_M
    
            contains
    
            subroutine simInit(numOfObjects)
    
                integer, intent(in) :: numOfObjects
    
                call objectsInit(numOfObjects)
                call launchersInit()
    
            end subroutine simInit
    
    
            subroutine objectsInit(numOfObjects)
    
                use Environment
    
                integer, intent(in) :: numOfObjects
    
                !local
                type(Aircraft_T) :: aircraft
                integer :: i
    
                allocate(objects(numOfObjects)
    
                do i = 1, numOfObjects
    
                    aircraft%trajTable = getTrajectoryData()
    
                    call allocatePointer(objects(i)%e, aircraft)
    
                end do
    
            end subroutine objectsInit
    
            subroutine allocatePointer(c, t)
    
                class(Entity), pointer, intent(out) :: c
                type(Aircraft), target, intent(in) :: t
    
                c => t
    
            end subroutine allocatePointer
    
        End Module Initialization

    This above just example code written on a computer that doesn't have a compiler. I did my best and hopefully if there are typos they are few. I did my best to mirror the structure of the original code.

    The problem is that the field "objects%trajTable" goes back to a undefined pointer after it leaves the "objectsInit" subroutine. The other values like time, id, and currPos are still correct. How can I correct this?

    I am using Visual Studio 2012 and Intel Visual Fortran 2015.

    Here is a link to the stack overflow question which has slightly better formatting. http://stackoverflow.com/questions/31439117/allocatable-array-of-inherit...

    Fortran pointer error inside subroutine

    $
    0
    0

    Dear all,

    The following minimal code will yield to many issues with ifort 14.0.2.176 and visual studio 2013 12.0.31101.00 update 4, but I couldn't figure out what is wrong with it. It produces three issues when a structure has a member which has pointers as sub-structure. I also don't understand why it reports error when I pass the pointer inside a subroutine and declare it as pointer  (toBeCalled2). In fact, another piece of my code seems to be doing the same thing but ran into no issue. Any comment is appreciated
     

    Please see inline where these occur
    ! issue 1: we cannot examine run_input2%test%dat1 values in visual studio
    ! issue 2: upon leaving the subroutine, run_input2%test%dat1 points to some junk
    ! issue 3: it will die inside immediately    

        ================================
              module testMod
              type test
                  real*8,pointer,dimension(:):: dat1
                  real*8,pointer,dimension(:,:):: dat2
              end type
              TYPE :: containsMixed
                  type(test):: test
              END TYPE containsMixed
              TYPE(containsMixed) :: run_input2
              end module
        
              program main
              use testMod, Only: run_input2
              implicit none
              real*8, dimension(100),target::x
              real*8, dimension(:),pointer::p2=>null()
              x=100D0
              run_input2%test%dat1 =>  x  ! issue 1: we cannot examine run_input2%test%dat1 values in visual studio. 
              
              print*, run_input2%test%dat1(1)
              call toBeCalled(run_input2%test%dat1)
              print*, run_input2%test%dat1(1:2) ! it will produce 2, 100 which is correct
              call toBeCalled2(run_input2%test%dat1)  ! issue 2: upon leaving the subroutine, run_input2%test%dat1 points to some junk
              print*, run_input2%test%dat1(1:2) ! see junk  
               if(associated(p2)) deallocate(p2)
              call toBeCalled2(p2)  ! issue 3: it will die inside immediately
              print*, run_input2%test%dat1(1:2) ! it will produce 2, 100 which is correct
        end program
              
        subroutine toBeCalled(dat)
        real*8, dimension(*) ::dat
        dat(1)=2;
        end subroutine
              
        subroutine toBeCalled2(dat)
        ! issue 2: it will die inside
        real*8, dimension(:),pointer ::dat
        real*8, dimension(:),pointer::x2
        allocate(x2(200))
        x2 = 200
        dat=> x2;
        print*, dat(1:10)
        end subroutine

    Viewing all 3270 articles
    Browse latest View live


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