soccer jersey forums.silverfrost.com :: View topic - Finding Variables and COMMONS.
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 

Finding Variables and COMMONS.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Plato
View previous topic :: View next topic  
Author Message
AKS



Joined: 19 Mar 2008
Posts: 29

PostPosted: Mon Jun 22, 2020 7:54 pm    Post subject: Finding Variables and COMMONS. Reply with quote

I have a large number of program modules (subroutines) with several different COMMONS. I have a few questions regarding PLATO:
1. Is there a way to use PLATO to find in which subprograms a particular variable is found?
2. Is there a way to get a memory map (location/address) of variables in a given COMMON. This would help locate variables that are incorrectly located within a COMMON or which are sized/typed incorrectly.
3. Is there a way to acquire a listing of what are the COMMON names in each subprogram?
Thank you.
EJY
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Tue Jun 23, 2020 12:19 am    Post subject: Reply with quote

Much of the information you seek can be generated, but the output may need to be run through a utility (that you write or obtain from somewhere else) to organize it the way that you want.

If you use the /xref compiler option, a cross-reference listing is generated. In that listing you will see all the variables used in each subprogram and a list of source lines where those variables are declared and used in various ways.

The command line utility FINDSTR can be used to list all the lines containing COMMON in a given source file:

Code:
 findstr /in common source1.f90


If you have COMMON declarations that have continuation lines, only the first line will be shown.

FINDSTR has other options that you may find useful. Type FINDSTR /? to see a list and brief descriptions of the options.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2585
Location: Sydney

PostPosted: Tue Jun 23, 2020 9:35 am    Post subject: Reply with quote

I have placed findstr into a file called tfs.bat which contains
Code:

echo findstr %1 > tfs.tce

findstr /i /n /s /c:%1 *.f9? *.in? >> tfs.tce

line_edit tfs.tce < tfs_fix.txt

notepad tfs.tce


my line editor (line_edit) uses the commands in file tfs_fix.txt
Code:
c/:/~/99999
t
c/:/~/99999
fil

This replaces the first 2 colons in each line with ~, for easier formatting in excel. I use this approach frequently (most days) to remind me where variables are defined/used.
/s is useful to search a whole tree where I have .f?? fortran code files and .in? include files. It can complain if no .in? file exists, where all COMMON is converted to modules !
There are many other options I haven't tried.
I am thinking of writing my own findstr with an option /ignore_comments to not search Fortran comments.
( I have forgotten where the command name "tfs" came from ? )
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1226
Location: Morrison, CO, USA

PostPosted: Fri Jun 26, 2020 12:12 am    Post subject: Reply with quote

AKS, it sounds like you have manually placed COMMON and declarations into various modules. Is that correct?

Assuming this is: I find that using an INCLUDE prevents problems with the type of the variables since all the declarations and COMMON declarations are in one file. So long as the compilation process detects that the INCLUDE'd file has changed, no problem. One thing to look for is the LINK step will tell you if a COMMON has a different size in some other compiled file.

If you use Plato, it should detect this automatically. But, to make sure, you can scan for dependencies to make all the INCLUDE'd files properly set-up to compile when an INCLUDE is changed.
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2585
Location: Sydney

PostPosted: Fri Jun 26, 2020 5:53 am    Post subject: Reply with quote

I have always been too lazy to use projects or make or any other smart build utility. I instead use a .bat file to re-compile or relink. With FTN95 Ver 8.0+ I even gave away static libraries and instead my link is
"slink64 @myplot_load.txt >> ftn95.tce" where .txt lists lots of other directory files. With the .txt you take ownership of any dependency order, which really is not that hard.

If you develop on multiple computers and merge files, date-stamps can be misleading, so it is better to just rebuild.

My build.bat starts with :
Code:
now                             >ftn95.tce
rem build
del *.obj
del *.mod
del myplot.exe
 
build_stamp

rem  menu routines

ftn95 myplot_module        /64 >>ftn95.tce
ftn95 myplot               /64 /inhibit_check 16 >>ftn95.tce
...

and ends with :
notepad ftn95.tce

Not sure if it is too lazy, or just to be sure.
No longer enough time for a coffee.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Fri Jun 26, 2020 8:12 am    Post subject: Re: Reply with quote

wahorger wrote:
AKS, it sounds like you have manually placed COMMON and declarations into various modules. Is that correct?


It is worth noting that what AKS calls "modules" are NOT Fortran modules. There were no modules in Fortran 77 and earlier versions. There may be multiple instances of labelled common blocks with non-matching lengths and variable names, so it may not be easy to convert common block variables to module variables.

The program may work only if the /SAVE option is used.
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Fri Jun 26, 2020 11:13 am    Post subject: Reply with quote

@Mecej4,

I beg to differ as to whether there were modules prior to Fortran 90. Before the authors of Fortran 90 stole the word, a module was a separately compiled file containing source code. The original poster uses that meaning.

Traditionalists, and I regret that in my old age I am one, dislike intensely the giving of radically new meanings to words and phrases, and then insisting that the old usage is wrong. It is a completely separate matter from whether or not one likes the new features in Fortran, although you have to be a certain age to regard 30 years old as 'new*'!.

As examples from outside the programming world, we have the US usage of 'momentarily**', and as I have become aware from watching Parker Schnabel on the 'Gold Rush' TV Series on the Discovery Channel, the Americans have redefined the word 'sketchy' to mean something completely different to what I understand by it.

Eddie

*And in some parts of the world, 30 years old may be considered antique, or even 'historic' !

**And if I am in a US piloted airliner that will 'touch down momentarily', I always ask 'WTF is happening afterwards?'
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Fri Jun 26, 2020 11:33 am    Post subject: Reply with quote

I agree with you about associating special meanings in new contexts to old words, but I am not going to make my last stand on this matter.

English is now a language which everyone in the world is free to abuse, easily and without even trying. Last month's deadly PIA A320 crash in Karachi started with a "momentary landing". In the US "momentarily" means "in a moment" rather than "for a moment", but one cannot say "minutely" for either "in a minute" or "for a minute". Fortunately, in this forum we do not have to contend for variations in the spoken language, a la https://www.youtube.com/watch?v=gi_6SaqVQSw .

Fortran standardese is quite bad in this regard -- see "becomes undefined" as an example phrase.

There is no instance of the word "module" in the F77 standard: https://wg5-fortran.org/ARCHIVE/Fortran77.html .

I started out on CDCs in the late '60s. A decade later, it took me quite a bit of effort to understand the concepts of "module" and "permanent file", in IBM and Univac documentation.

The IBM 360 had "object module" and "load module". The CDC (MOMS and Kronos OS) had "source libraries".


Last edited by mecej4 on Fri Jun 26, 2020 3:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1226
Location: Morrison, CO, USA

PostPosted: Fri Jun 26, 2020 1:04 pm    Post subject: Reply with quote

Eddie, I took the use of modules as did you. I'm also one of those old FTN programmers. Using INCLUDE's (or an equivalent), though, has been available for a very long time.

To the other commenters, yes, going through the code and making the variable usage the same can be a big task. It is still worth doing so. I know there are exceptions to my statement, and I don't want to get people riled up, but even if one uses EQUIVALENCE to associate the local variable names with the COMMON variable names, the net effect will be the same - more maintainable code. You do lose the type assigned to the "local" variable, and that might be bad. On the other hand, going through the code and changing all variable names might actually be more time-consuming and/or hazardous to working code than can be justified. I've done the latter, and have been so glad for a good backup system!

For my compile, if I used a batch file to compile and link, I would consume over 5 minutes for each time I changed one file. I don't view that as an acceptable use of time, except in the morning when I am enjoying my coffee. I use GNUMAKE, and have created, by hand, a MAKE file for the 5 programs to be created from the 300+ files (873 routines) and 30+ INCLUDE's. If an INCLUDE changes, I re-compile/link everything. If a file changes, I only compile that one file and link the appropriate executables that are affected. All COMMON are in INCLUDE's. My code has no MODULE's. It dates from 35 years ago, before the current capability. That said, I call a section of the code that can be successfully compiled a "module" using the old definition.
Back to top
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Fri Jun 26, 2020 1:27 pm    Post subject: Reply with quote

I am a long time user of make, and tools such as makemake that can read a directory containing scores of source files, build up an index of module dependencies and use these to generate a makefile. It took some effort to learn to use make and to acquire these tools, but they save a lot of time.

There is a relatively newer thing called Cmake. When you have a cmakelists.txt that works, Cmake is great and easier to use than Make. Unfortunately, the instances of cmakelists.txt that I have encountered have often failed, and when that happens I have given up. The Cmake manual is now 187 pages long, see https://cmake.org/cmake/help/v3.18/genindex.html , and that size makes it easy to decide to go back to Make.

The Submodule feature in Fortran 2008 can help with reducing unnecessary recompilations, but of course it is not available in FTN95.
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Fri Jun 26, 2020 2:45 pm    Post subject: Reply with quote

Thank you Bill and Mecej4 for your comments.
It�s not the change in terminology that bothers me anywhere near enough as the insistence that the new usage is the only possible one, trampling roughshod over what may be lengthy traditional and common usage � there is no other in language. Fortran Standards are usually honoured in the breach than the observance, I find.
For me, the additions in Fortran 90 et seq. made the ting into a different language, and it might have been called a different name, even though it encapsulated the whole of Fortran 77. We know that it was poorly thought through because its deficiencies showed through rather quickly. Those additions and alternatives showed to me that the committee at the time � and for all I know, right up to the present � didn�t like Fortran and its foibles at all. They seem to have wanted it to be Algol, which I suppose ought to have pleased me, because I cut my teeth on Algol, and consider it to be a far superior framework for programming. However, I soon discovered that Algol was implemented rather differently � if at all � on different computers, and Fortran had the benefit of near-ubiquity. That hasn�t stopped it being a bizarre, cobbled-together, ill thought-out programming language. A bit like English, I suppose.
To return to the intent of the current thread, my approach to all this has been for many years to have my source code in different files. In the early days of the PC most of those files contained only one subprogram, but now they are much larger as up to a point, a couple of thousand lines is not challenging to any editor. I always have a block of comments at the start of each such source code module, listing its subprogram contents and giving their start line number. I update the list once or twice perhaps each year, as the line number only needs to be approximate to find the routine easily, then I copy the whole block and paste it into another file called WHEREIS.FOR. That is then where I search for a particular routine if I have forgotten where it is.
I also add the source code file name to any subprogram call, like this:

Code:
      CALL NEW_FILE ( � )                                 ! SS_9


Where in this case SS_9.FOR is the source code file where SUBROUTINE NEW_FILE resides.
As for COMMON blocks, which I use for preference and from habit, they are listed in a related file called WHATIS.FOR (why they are .FOR files I don�t know, probably because I�m looking at .FOR files when I consult them) along with descriptions of what the variables are. I also list the meanings of all arrays, even though I tend to add comments of explanation in the source code.
I find that the linker messages about the lengths of named COMMON blocks to be invaluable in finding problems in other peoples� code. I don�t seem to get on with INCLUDE, because I treat each subprogram on its own and I like to see how things are declared. For that reason, I don�t think I should ever get on with USE as a substitute.
A reason why COMMON blocks are different lengths in different routines relates to the size of the individual variables. Back in the late 60s and early 70s when one could easilly find oneself programming on a British made computer, INTEGERs had the same two 24-bit words as REALs. One doesn�t get 48-bit INTEGERs these days, and one was far less likely to get a bad round off effect with 48 bit single precision REALs than with 32-bit REALs, and if DOUBLE PRECISION was there at all, it would have been 96 bit rather than 64 bit, not that it was useful in a computer that might have 32k of those 24 bit words. I found that this variable length issue occurred far more commonly (pun intended) than programmers declaring the arrays to be of different length (although one case I looked at recently in another post the chap had altered the order of the variable names in one routine � I�d never seen that before).
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Fri Jun 26, 2020 8:51 pm    Post subject: Reply with quote

No, John, that's the file for other peoples' code!
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Sat Jun 27, 2020 9:51 am    Post subject: Reply with quote

Well, we need a file system with the property that part of the file name depends on the identity of the user, so that when our Count Eddie (*) uploads WHATISIT.FOR to Dropbox and John S. downloads the same, on John's PC the file is named WHATTFISTHAT.FOR, both of them are happy, and everyone else is as confused as normal Fortran users often are.

---------
*Does "Litus Saxonicum" mean "a shore attacked by Saxons", or a" shore infested with Saxons"? When did the now landlocked German state of Sachsen lose its coast?
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Sat Jun 27, 2020 5:09 pm    Post subject: Reply with quote

The question you ask is one that has puzzled many good folk. The Saxon Shore is mentioned only once in ancient literature, in the Notitia Dignitatum, and all we have is a copy of the original list preserved in a monastic library in Ravenna, and which is known to contain errors. The Comes (count) is recorded as being in command of a number of forts along the coast of SE England with various companies of soldiery under his command. The date at which this applied is not known, but is likely to be the status quo of the late 4th or early 5th century and preserved after Honorius moved his seat to Ravenna, or perhaps even a plan for reconquest dating to Bellisarius' reconquest of Italy by the eastern Roman Empire under Justinian, which for strategic reasons was based also in Ravenna.
Eutropius is the source for the quote about Franks and Saxons swarming (or thereby infesting) the coasts of the English Channel, and again, it is the only source. That it could mean either of your options is due to the observation that Saxons were resettled in Britannia following the defeat of a particular uprising in central Europe, and that some were invited as mercenaries. S. Ireland�s �Roman Britain: A Sourcebook� contains an interesting set of these snippets.
A third alternative is rarely considered, and that is that �Saxonicum� is itself a mistake in copying. Beram Saklatvalata in �Arthur: Roman Britain�s last champion� points out that the famous drawing of the sword from the stone by the Once and Future King could easily be a transcription error in taking the sword from the Saxon. Applying the reverse logic, the coast of SE England could well be the �Stony Shore� as most of the beaches here are marine gravels, whereas on the opposite Channel coast they are sandy. Who knows?
If the Saxons were transported from the Rhine, it is possible that Saxony never had a coast.
An interesting factoid is that �litoral� (from litus) became the modern spelling with 2 Ts, because the Duke of Wellington spelled it that way in a despatch!
Perhaps another conundrum is why I chose LitusSaxonicum and not RorkesDrift.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Sun Jun 28, 2020 2:40 am    Post subject: Reply with quote

Off Topic: "What is Silverfrost?":

John, since you are so insistent, one possible answer to "what is Silverfrost?":

http://www.perennials.com/plants/artemisia-silver-frost.html

Another:

https://www.meisterdrucke.com/kunstdrucke/Ivan-Fedorovich-Choultse/594177/Silberfrost,-Engadin,-1910.html

Verbal description of the natural phenomenon of silverfrost from a book published in 1918:

https://babel.hathitrust.org/cgi/ssd?id=nyp.33433090741723;seq=147

Even older (1851), in German (Fraktur type, even) describes the dangers of silverfrost falling on the heads of in-the-forest-walking-unsuspecting-outdoors-persons (page 182, left column, middle of page):

https://books.google.com/books?id=mUdEAAAAcAAJ&pg=PA182&lpg=PA182&dq=Silberfrost&source=bl&ots=gNbxG9nDHK&sig=ACfU3U2uqzS82KWjMxDYCMT2mrobVj_jyQ&hl=en&sa=X&ved=2ahUKEwjN_s-rrqPqAhVHYs0KHTucCPw4FBDoATAFegQIChAB#v=onepage&q&f=false
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Plato All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 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