forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fortran 2003 and 2008 features
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Aug 06, 2022 8:01 am    Post subject: Reply with quote

Dan

I will add NORM2 to the list of missing features from the 2008 standard.

Regarding afivo-pic, please provide a short working program that illustrates the what is missing from FTN95.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Sat Aug 06, 2022 10:03 am    Post subject: Reply with quote

I am not familiar with the history of NORM2, but I do use a similar RMS function, which I thought was more often used ?
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 697
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sat Aug 06, 2022 10:21 am    Post subject: Reply with quote

If adding NORM2 to FTN95, then perhaps also consider HYPOT?

hypot(x,y) = sqrt(x*x + y*y) = abs(complex(x,y))
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Aug 06, 2022 1:26 pm    Post subject: Reply with quote

I have added HYPOT to the list.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Aug 07, 2022 10:29 am    Post subject: Re: Reply with quote

PaulLaidler wrote:
Regarding afivo-pic, please provide a short working program that illustrates the what is missing from FTN95.


Paul,
OK, here is an example of module m_af_types which has no other modules to USE but it has #include "cpp_macros.h". I further simplified both by shortening of them and removing mentioning GFortran there

m_af_types.f90:
Code:
#include "cpp_macros.h"
module m_af_types

  use iso_c_binding, only: c_ptr
  implicit none
  public
  integer, parameter :: dp = kind(0.0d0)

end module m_af_types


cpp_macros.h:
Code:
!#ifdef __GFORTRAN__
!#define PASTE(a) a
!#define CONCAT(a,b) PASTE(a)b
!#else
#define PASTE(a) a ## b
#define CONCAT(a,b) PASTE(a,b)
!#endif

#if NDIM == 1
#define DTIMES(TXT) TXT
#define DINDEX(TXT) TXT(1)
#define DSLICE(lo,hi) lo(1):hi(1)
#define KJI_DO(lo,hi) i = lo, hi
#define CLOSE_DO
#define IJK i
#define IJK_(s) CONCAT(i_,s)
#define DIMNAME "1d"
#elif NDIM == 2
#define DTIMES(TXT) TXT, TXT
#define DINDEX(TXT) TXT(1), TXT(2)
#define DSLICE(lo,hi) lo(1):hi(1), lo(2):hi(2)
#define KJI_DO(lo,hi) j = lo, hi; do i = lo, hi
#define CLOSE_DO end do
#define IJK i, j
#define IJK_(s) CONCAT(i_,s), CONCAT(j_,s)
#define DIMNAME "2d"
#elif NDIM == 3
#define DTIMES(TXT) TXT, TXT, TXT
#define DINDEX(TXT) TXT(1), TXT(2), TXT(3)
#define DSLICE(lo,hi) lo(1):hi(1), lo(2):hi(2), lo(3):hi(3)
#define KJI_DO(lo,hi) k = lo, hi; do j = lo, hi; do i = lo, hi
#define CLOSE_DO end do; end do
#define IJK i, j, k
#define IJK_(s) CONCAT(i_,s), CONCAT(j_,s), CONCAT(k_,s)
#define DIMNAME "3d"
#endif


The compilation (i gather result of compilation in the file Z ):

Code:
 FTN95 m_af_types.f90 /CFPP NDIM 2 >Z


The file Z:
Code:
*** More than one source file specified with names m_af_types.f90 and NDIM

    1 ERROR [m_af_types.f90] - Compilation failed.


Additionally this piece also looks very unusual
Code:
#define PASTE(a) a ## b
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun Aug 07, 2022 4:13 pm    Post subject: Reply with quote

Dan

Some of the #define's illustrated here are not currently supported by FTN95.

Preprocessing instructions, such as these that are common to the language C, are not Fortran standard conforming.

Our first priority is to add useful features from the 200x Fortran standards that are not currently supported.
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Mon Aug 08, 2022 1:12 am    Post subject: Reply with quote

Dan, if he bothered to perform the RTFM ritual at least once a year, would have typed the compilation command as

Code:
FTN95 m_af_types.f90 /CFPP /DEFINE NDIM 2 >Z


That aside, note that none of the macros defined in the included file is invoked in the .f90 source file that includes the .h file, so we have nothing to give us a hint as to how those macros are supposed to function. Depending on how a compiler is implemented, the syntax of macros that are not invoked may be subjected to no checking at all.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Aug 08, 2022 10:13 am    Post subject: Reply with quote

Mecej4
Adding content to the file still gives the error
Code:
*** Unexpected character found after #define
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Mon Aug 08, 2022 10:24 am    Post subject: Reply with quote

Dan, I already noted that FTN95 is attempting to parse #define lines that are not needed in the Fortran file that includes the .h file, even when the macro being parsed is not invoked. Paul has pointed out that FTN95's preprocessing repertoire is not the same as that of typical C compilers.

FTN95 is in many ways not suitable as a replacement for GNU compilers when you are building a large Linux/Unix codebase on Windows. Its command line capabilities are not as extensive as those of other compilers -- you cannot issue a command similar to

Code:
gfortran a.f90 b.f90 -Lmydir -llib1 -llib2 -o myprog


Partly as a result of this difference, you cannot use makefiles from elsewhere (such as Linux) without making substantial adaptations.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Aug 08, 2022 6:37 pm    Post subject: Reply with quote

It is one story when one compiler can do some things while the other can do the other things first one can't. Its up to developers to chose at what degree to support C-style or graphics integration or NET or Wininet etcetcetc in their compiler. Some compilers even can do some things absolutely no any other compilers do.

But it is different story when all 5 or 6 other existing Fortran compilers can do some things practically forming the de-facto standard even it is not in the written Fortran Standard while your own compiler is the only which can't do them. Specifically if the trends are pointing into specific directions like better C/C++ integration or multiprocessing, then for the lagging compiler there simply is no other way but to catch and start to support things where others already aligned. Not catching the cohort will marginalize the users base.

As to MAKE utility I have two Linux large codes and one for Windows which use MAKE for compilation. Make typically support whole bunch of compilers. The only compiler which did not work in all cases with MAKE was FTN95. Anyone wants to try? That are not my own codes
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Aug 09, 2022 7:44 am    Post subject: Reply with quote

NORM2 and the "cast" to REAL in an array constructor have now been implemented for the next release of FTN95 and the DLLs.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Thu Aug 11, 2022 10:45 pm    Post subject: Reply with quote

Thanks, Paul.

Here is more work for you extracted from the codes of crazy Fortran youngsters who surprisingly embraced so many modern Fortran latest tricks that the codes look unreadable as if this is not a Fortran. I lost last 4-5 months deciphering them. And unfortunately they are not in our forums but in the forums for the other compilers. This time it is a demo for "associate" :

Code:
program associateTest

  implicit none
  integer :: a=1,b=1
  associate( x => a*b )
    print *, x                ! yields: 1
    a=10
    print *, x                ! yields: 1
  end associate

  associate( x => a )
    print *, x                ! yields: 10
    a=100
    print *, x                ! yields: 100
  end associate

end program associateTest
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Aug 12, 2022 7:19 am    Post subject: Reply with quote

Thanks. I will add ASSOCIATE to the list.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 697
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Aug 12, 2022 12:22 pm    Post subject: Reply with quote

I have seen Dan's example for the use of ASSOCIATE before, and find it very confusing. Why does the second print*, x statement return 1 and not 10 since the value of a is updated in the proceeding line?
The final print*, x statement does appear to recognize that a has been updated within the second associate block. What is the difference here - that I cannot see?
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Aug 12, 2022 1:35 pm    Post subject: Reply with quote

Ken

I appears that expressions are stored as the constant that they evaluate to (at the point of association), whilst simple variables are treated as targets to the identifier on the LHS which is effectively a pointer.

In the latter case you effectively get a pointer to a variable target with the pointer having a limited scope.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 6 of 10

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group