soccer jersey forums.silverfrost.com :: View topic - What is the rationale for that ?
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 

What is the rationale for that ?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
DanRRight



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

PostPosted: Fri Jun 24, 2022 9:51 pm    Post subject: Reply with quote

Simon,
Wow, i did not know about preprocessor is already there. Never used or seen people used it in this forum at least.

As to these new Fortran features there clearly are world champions of obscurity and verbosity. Out of curiosity i compared the original code written by other people which was then rewritten into Fortran2003 code. Original was ~3 times smaller and absolutely clear. No heavy use of derived types, pointers, interfaces, model procedures, no anything fancy complicating readabilty to the state you're totally lost. For example, in Fortran2003 code IF or DO blocks look very small. But the trick is that this was because the source text was packed into subroutines. These subroutines immediately called another subroutines, which called another and another which called INCLUDE files Smile

Fun was to find that OPEN(file=..., status=...) is not just one line of Fortran code but also a subroutine 113 lines long. The WRITE(unit=..., Format=...) not one line of Fortran code but several subroutines around 2KB each which are very specific for some obscure data packing file format no one here used or knew.

One of the most confusing is that you never know the variable is array or not and what is its dimensions, types and interfaces, and how to find all that quickly. And when trying to find all that among 100s of files you totally lose the track.

Will i change my mind as times go and i will use these features? Possible but not very likely. Because even the authors of this long rewritten code now say that the code is quite large and complex Smile

Additional intrigue with this code is that the original Fortran source code was also rewritten by some other people. Fun is that it was moved to C. Will ask these folks if they are happy with that move too in which i doubt a lot. I have seen people moved from Fortran to C and then the code development almost stopped. Soon i will be able to compare several such codes performances, and we will see how much they no doubt lost here too.
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Wed Jul 13, 2022 7:24 pm    Post subject: Reply with quote

Simon,
i tried this code
Code:
#if PHOTONS==1
INTEGER, PARAMETER :: num = KIND(1.d0)
#else
INTEGER, PARAMETER :: num = KIND(1.e0)
#endif

print*, num
end


compiling it
Code:
ftn95 aaa.f90 /link /fpp /vparam PHOTONS 1 >z


and getting this error message

Code:
0001) #if PHOTONS==1
*** Invalid character '#' at start of line
*** Statement not recognised
0003) #else
*** Invalid character '#' at start of line
*** Statement not recognised
0004) INTEGER, PARAMETER :: num = KIND(1.e0)
*** NUM has already been declared with the PARAMETER attribute
WARNING - NUM has been declared more than once with the same type (see line 2)
0005) #endif
*** Invalid character '#' at start of line
*** Statement not recognised
    7 ERRORS, 1 WARNING  [<main program> FTN95 v8.83.0]
*** Compilation failed

What's wrong?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jul 13, 2022 8:38 pm    Post subject: Reply with quote

You need /CFPP.

https://silverfrost.com/ftn95-help/options/using_the_preprocessor.aspx
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Thu Jul 14, 2022 6:16 pm    Post subject: Reply with quote

Thanks, Paul
Back to top
View user's profile Send private message
DanRRight



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

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

About preprocessor: in some 3rd party code FTN95 found the error on this line
Code:
#include "../afivo/src/cpp_macros.h"


Code:
0001) #include "../afivo/src/cpp_macros.h"
*** Invalid character '#' at start of line
*** Statement not recognised


Is this incompatibility of FTN95 with this code or still a preprocessor command ? I see in other places this code uses preprocessor commands usual way like this
Code:
#if NDIM == 2
       if (GL_cylindrical) volume = af_cyl_volume_cc(box, i)
#endif


To use it i will compile with
Code:
FTN95 apic.f90 /CFPP /VPARAM NDIM 2


If this is C-style preprocessing then how i have to setup /CFPP to use this include file ? Should i do like this ?

Code:
FTN95 apic.f90 /CFPP /VPARAM INCLUDE "../afivo/src/cpp_macros.h"
repeating the line of source text in the command prompt ? But there are a lot of such preprocessor definitions in the code and all of them to add into compilation line would be probably impossible. Here is the complete their list in this mentioned above file 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


Wish this is not our usual Saturday devilry from the hell Smile
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2393
Location: Yateley, Hants, UK

PostPosted: Sat Aug 06, 2022 11:52 am    Post subject: Reply with quote

Referring to John Campbell's post on 22nd June, I also find REAL*4 of very little use. Having grown up using computers that had a sensible default REAL size (2 x 24-bit words), with INTEGERs the same size, I do find:

OPTIONS (INTL, DREAL)

suits me fine, even though the length of INTEGER is only half that of REAL. It's a shame that there is no equivalent to INTL for INTEGER*8.

I suspect that there may well be a use for short INTEGERs somewhere (for example, for grey codes where after all we only need to cope with 0 or 1), for me even the 32-bit address space is unimaginably vast, and the waste of space with all those unused bits doesn't matter.

As to some of the other innovations in this and the posts on Fortran 2003 and 2008 features, can someone please remind me of the Star Trek episode where Spock leans over to Kirk, and says "Its FORTRAN, Jim, but not as we know it"?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

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

Dan

/CFPP is required for #include etc.

#include works on its own without a VPARAM.

For #if NDIM == 2 you could use...

/CFPP /DEFINE NDIM 2

then the #if block will be compiled.
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 -> General All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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