473,320 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

A question of Fortran 2003

Here is an example of Fortran ,but I can't run it in ivf 11.
Expand|Select|Wrap|Line Numbers
  1.  MODULE m
  2.  TYPE t(k)
  3.  INTEGER, KIND :: k
  4.  REAL(k),POINTER :: vector(:) => NULL()
  5.  CONTAINS
  6.  FINAL :: finalize_t1s, finalize_t1v, finalize_t2e
  7.  END TYPE
  8.  CONTAINS
  9.  SUBROUTINE finalize_t1s(x)
  10.  TYPE(t(KIND(0.0))) x
  11.  IF (ASSOCIATED(x%vector)) DEALLOCATE(x%vector)
  12.  END SUBROUTINE
  13.  SUBROUTINE finalize_t1v(x)
  14.  TYPE(t(KIND(0.0))) x(:)
  15.  DO i=LBOUND(x,1),UBOUND(x,1)
  16.  IF (ASSOCIATED(x(i)%vector)) DEALLOCATE(x(i)%vector)
  17.  END DO
  18.  END SUBROUTINE
  19.  ELEMENTAL SUBROUTINE finalize_t2e(x)
  20.  TYPE(t(KIND(0.0d0))),INTENT(INOUT) :: x
  21.  IF (ASSOCIATED(x%vector)) DEALLOCATE(x%vector)
  22.  END SUBROUTINE
  23.   END MODULE
  24.  
  25. SUBROUTINE example(n)
  26. USE m
  27. TYPE(t(KIND(0.0))) a,b(10),c(n,2)
  28. TYPE(t(KIND(0.0d0))) d(n,n)
  29.  
  30. ! Returning from this subroutine will effectively do
  31. ! CALL finalize_t1s(a)
  32. ! CALL finalize_t1v(b)
  33. ! CALL finalize_t2e(d)
  34. ! No final subroutine will be called for variable C because the user
  35. ! omitted to define a suitable specific procedure for it.
  36.  END SUBROUTINE
ivf 11 says there's something wrong at
Expand|Select|Wrap|Line Numbers
  1. TYPE t(k)
and
Expand|Select|Wrap|Line Numbers
  1. FINAL :: finalize_t1s, finalize_t1v, finalize_t2
I want to know how to use a parameterized derived type with final subroutines.
Aug 26 '10 #1
0 1108

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Markus Faust | last post by:
Hi, I'm trying to link Fortran files generated with “Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update B)” under “Enthought Edition build 1028, Python 2.3 (#46, Aug 11 2003,...
5
by: NM | last post by:
Hi all I am trying to link C++ and Fortran.I am not very familiar with Fortran. I have been successful in linking C++ and fortran using g++ and ifc for simple program. So adding _ to at the end of...
4
by: NM | last post by:
Hello All I am writing some progam that involves both C++ and Fortran. Some of the existing code is in Fortran. The main program will be in C++ and it will call some Fortran subroutine. All the...
5
by: foo | last post by:
I've been looking on the web to see if I could find a link that would describe the difference between the 14882:1998 and the 14882:2003 C++ standard. I found the following link:...
7
by: To Forum | last post by:
hi, how can i use existing library in Fortran for my C++ program. I have try f2c but it is rather cubersome... Can I compile the Fortran code into Object file and then link to C++ code? My thanks...
11
by: John Smith | last post by:
Ok, I know this is a common topic, but I didn't find any post that solves my current problem. I'm using Microsoft Visual C++ 6.0 (SP5), and Intel Fortran 7.1 Compiler for Windows. I'm trying to...
12
by: Bigdakine | last post by:
I don't know if this is the right forum for this, and if not please suggest one which fits. I have to call a fortran sub routine from a C main program. The fortran subroutine statement is ...
10
by: Julian | last post by:
I get the following error when i try to link a fortran library to a c++ code in .NET 2005. LINK : fatal error LNK1104: cannot open file 'libc.lib' the code was working fine when built using...
111
by: Tonio Cartonio | last post by:
I have to read characters from stdin and save them in a string. The problem is that I don't know how much characters will be read. Francesco -- ------------------------------------- ...
8
by: Luna Moon | last post by:
Hi all, As a C/C++ programmer, there are a few reasons to use Fortran: (1) Fortran is very similar to Matlab and easy to port; (2) Fortran has support of complex numbers and vectorized numbers...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.