Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Old Drain Code

JohnNichols
Valued Contributor III
2,947 Views
read (xxline,1020) probid,nstat,kexe,kecho,kkpdel,kkenr,uf,ihed
 1020 format (2x,a8,3x,i2,4x,i1,3(1x,i1),3x,a1,10x,a40)

      if (kecho .eq. 1) write (*,'(1x,a80)') xxline(1:80)

This code is perfect for a punch card system, but it is a pain for the modern text editor, counting columns is a pain.  

The sample drain.inp I have had nstat as blank in the line and so it was set to zero in the run.  

Sad about Lahey, I remember its early adds. 

0 Kudos
21 Replies
jimdempseyatthecove
Honored Contributor III
2,815 Views

I suggest you convert the input file to CSV format (be careful of blank and text fields with embedded spaces).

.OR.

verify that the 'x' fields are indeed blank

!                     format (2x,a8,    3x,i2,4x,i1,3(1x,i1),3x,a1,10x,a40)
character(len=40) :: xxlinex = "  aaaaaaaa   ii    i i i i   a          " ! ignore a40
...
do i=1,len(xxlinex)
  if(xxlinex(i:i) == " " .and. xxline(i:i) /= " ") stop xxline
end do

Jim Dempsey

0 Kudos
JohnNichols
Valued Contributor III
2,807 Views

Yes, I agree, at the moment I am just trying to get it running.  

0 Kudos
JohnNichols
Valued Contributor III
2,802 Views
c ------------------------------------------------------------INITIALIZE
      ksofar = 2

They are using a trick of incrementing a counter so they know where they are.  Debugging punch cards would not have been fun.  

In 1978 Newcastle Uni had a one day turn around time for programs.  

 

have you seen the colour coding options in VS for the tabs?  Who picked the FOR colour, must be colour blind?  

 

Screenshot_20221213_125004.png

0 Kudos
JohnNichols
Valued Contributor III
2,797 Views

The program, uses inp as an implicit integer for the main input file number, but never sets the value.  It works as zero in the first routine where inp is opened, but subsequent calls using a common tapes block cannot open the input file, says error and crashes out gently.  

If inp is assumed implicit, it should be created as 0 in the first use, but then what gets stored in the common block, is it the zero?

 

0 Kudos
mecej4
Honored Contributor III
2,770 Views

You have not shared with us the source code(s) that you are using, so you should only expect speculation about what is wrong.

I suspect that inp is in a labelled common block, and that this variable is initialized in a BLOCK DATA subprogram. If that is the case, your conclusion that inp is initialized to zero is not correct.

Please verify that the common block containing the variable in question is declared in every subprogram where the variable value is used, and that the various common block declarations are consistent.

 

P.S. Based on vague recollections, I searched this forum and found a thread from seven years ago -- you originated it. Are you using the same program, or have you modified it further?

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,745 Views

Unit 0 defaults to stderr.

OPEN with units 7 and above .AND. without filename defaults to 'fort.nn' nn=unit number (analog to tape drive unit number).

 

Jim Dempsey

0 Kudos
JohnNichols
Valued Contributor III
2,732 Views

@mecej4 , thank you for your comments.  I had actually forgotten about my last attempt at getting Drain to work, as I have been working away in the last week in some spare time, I stumbled across the old copy on an external hard drive.  We all get old.  

 

I enclose the file as I have been setting up for VS and Windows.  I would have loved to use LINUX for my work, but one cannot run an ethernet accelerometer and link to an ethernet cable at the same time, UBUNTU now switches off one of them, so I am stuck on Windows for most of my work.  If I could have solved that problem I would have and the LINUX experts tried and said, bad luck. 

I have been using another UCB program ULARC for doing some Structural Reliability analysis of old bridges, but it is 2D, now that it works and the method is sound I was looking for a 3D replacement for ULARC.  DRAIN is in the public domain and it comes from a good group of programmers, it is worth a look.  

Really it is just a quest to see if it will work, now that I am retired I have some more time.  

I found the manuals and put them onto the FORUM site.  

It is a useful program for some PhD students, having a working version in the public domain will not hurt.  

I appreciate your points, and I really appreciate all the help over the years.  

JMN

 

0 Kudos
JohnNichols
Valued Contributor III
2,729 Views

Manuals. 

 

0 Kudos
mecej4
Honored Contributor III
2,703 Views

@JohnNichols wrote: "The program, uses inp as an implicit integer for the main input file number, but never sets the value."

That statement is not applicable to the source code in Drain3DX.zip. The variable inp is the first member of /tapes/. That common block is declared in file tapes.h, and the main program contains:

 

      include 'tapes.h'

 

The variable inp is initialized to 5 in the BLOCK DATA subprogram, in file block.f.

 

main/block.f:67:      DATA inp,iou,inpx,nfbeg,nfcur,nfupd,nfscrt/5,15,3,1,2,3,2/

 

I do not see how the unit number inp can be anything but 5 throughout the program, unless you built the program using a select subset of the source files or with modified sources.

Is there a set of data files that can be used to verify that the program, when built, is functional and produces correct results (at least for the test case)?

0 Kudos
JohnNichols
Valued Contributor III
2,684 Views

Thank you, yes you are correct, and yes I have been slowly building a subset of the program, and as you show block.for is critical and I missed it.  Thank you for your time and patience. 

There are no known correct input file. I asked the UCB who has the program on their library website, but none exists, and the library does not know where the people who created the 2010 version come from.  Neither the librarian nor I could find reference to them that was plausible.  I have said if I can get a working model, I will give them a correct sample input, so this problem is solved for others.  

I am slowly making a standard input file and checking that it is input correctly and is a standard problem with a known answer.  I think I made this sample problem in 2015, but I could be wrong, I just do not remember.  

A drain.inp is included in the main directory for the program.  I enclose a copy, it is zipped as Intel does not allow inp file types.    

Why:

Structural reliability needs Monte Carlo analysis of a model with say 200,000 repeats to cover the field of data, a standard structural analysis program like Strand7 on a concrete arch bridge takes minutes for each run, a program like ULARC takes a minute for about 20,000 runs, so it is useful. I have the code for ULARC and DRAIN.  

 

 

0 Kudos
mecej4
Honored Contributor III
2,682 Views

@JohnNichols wrote, "as you show block.for is critical and I missed it".

There is a way to avoid this mishap, which I learned from "LitusSaxonicum" on the Silverfrost forum.

  1. Add a name to the Block Data subprogram. For example, in Block.for change the first line to
          BLOCK DATA DRAINBLK​
  2. In the main program, add an EXTERNAL declaration for that subprogram:
          external DRAINBLK​
    If you now try to (recompile and ) link without including Block.obj, the linker will tell you that DRAINBLK is an unsatisfied external symbol.
JohnNichols
Valued Contributor III
2,654 Views

Interesting name, 'The Saxon Shore', 

Thanks that worked a  treat. 

0 Kudos
JohnNichols
Valued Contributor III
2,611 Views

I am slowly working through the code, but one thing that has always intrigued me,  is why the external calls when they pop up as an unfound error, have an _incode  an underscore as the leading letter.  

I realize it has to do with the compiler, but why? 

0 Kudos
JohnNichols
Valued Contributor III
2,588 Views

Jim:

I have gone as far as I can without getting out the manual and working through the code to get rid of the l array.   The output from the input file looks strange.  

It is at least inputting some data.

Here is a copy so far. 

John

0 Kudos
JohnNichols
Valued Contributor III
2,573 Views

Note in manual from grad student.   Challenging to them as well.  

 

Screenshot_20221216_014253.png

0 Kudos
Steve_Lionel
Honored Contributor III
2,126 Views

@JohnNichols wrote:

I am slowly working through the code, but one thing that has always intrigued me,  is why the external calls when they pop up as an unfound error, have an _incode  an underscore as the leading letter.  

I realize it has to do with the compiler, but why? 


This is "name decoration" and is platform-specific. On 32-bit Windows, compiled global symbols have a leading underscore, whereas on 64-bit Windows they do not. The 32-bit STDCALL convention adds @n to procedure names as a suffix, where the n indicates the number of stack bytes to pop on return.

0 Kudos
JohnNichols
Valued Contributor III
2,109 Views

Thank you, I always wondered, you know we accept things because that is the way they are, and then someone decides, I do not like Fortran, let us invent C and let us count from zero instead of one.  Let us take the worst of LISP as well and then reward people with weird language names, grek and grok and other useless word naming groups, and let us call it C, because A and B were already used.  

I switched to some C programming yesterday, stored stuff in a 2 element array, just pottering along after having fun on Fortran, and error, exception on array, took 20 minutes to work out my mistake.  Count 0 and 1 not 1 and 2. 

I hate C. 

Merry xmas and a happy new year.  

Dr. Hill:

Intel confirmed with some tests, that a corei3 running Windows 10 is faster than a Dell core i7 precision running Windows 11 preview for single thread program running FFT's.  Intel has a great program to test for things on your computer and their service is really good.  

The guy was even polite and did not laugh. One is 400 USD and the other is 2000. 

 

JMN

 

0 Kudos
AlHill
Super User
2,106 Views

@JohnNichols et al, Happy Holidays to all of you and your families.

 

Doc (not an Intel employee or contractor)
[Maybe Windows 12 will be better]

0 Kudos
JohnNichols
Valued Contributor III
1,327 Views

Back to Drain on a holiday 

c **********************************************************************
      PROGRAM MAIN
c **********************************************************************
c     DRAIN-3DX main program
c ----------------------------------------------------------------------
c     SUBR. CALLS : contrl
c ----------------------------------------------------------------------
c     DOUBLE PRECISION / LARGE

      include 'double.h'
c ----------------------------------------------------------------------
c     BLANK COMMON
      
      PARAMETER (NTSTP=1000000)
      common l(NTSTP)

c ----------------------------------------------------------------------

 


c --- check for separator
      if (chksep('*MASSES         ')) then
         call INMASS1(nnods,l(kndid),l(kcoord))

 

!-------------------------------------------------------------------------------------------------------------
c **********************************************************************
      SUBROUTINE INMASS1 (nnods,ndid,coord)
c **********************************************************************
c     PURPOSE : *MASSES : Nodal Masses.
c ----------------------------------------------------------------------
c     DOUBLE PRECISION / LARGE
      include 'double.h'
c ----------------------------------------------------------------------
c     CALLED FROM : ingeom
c     SUBR. CALLS : getlin, dzero, izero
c ----------------------------------------------------------------------
c     ARGUMENT TYPES
c       INPUT
c         ndid(3,nnods) = 1:node ID, 2:node type, 3:location in ID.
c         coord(3,nnods) = X, Y & Z coordinates.
c         id(6,ntnds) = degree of freedom array.
c         nnods = no. of nodes.
c         ntnds = total no. of nodes and subnodes.
c         neqq = no. of degrees of freedom + 1.
c       OUTPUT
c         fmnod(6,nnods) = nodal masses.
c         fmdof(neqq) = mass matrix.
c         alpham(neqq) = mass proportional damping matrix.
c       MODIFY
c         kdata = data error counter.
c ----------------------------------------------------------------------
c     LABELLED COMMON BLOCKS
      include 'cline.h'
      include 'dampg.h'
      include 'ptop.h'
      include 'tapes.h'
c ----------------------------------------------------------------------
c     EXTERNAL PROCEDURE
      external chksep
      logical chksep
c ----------------------------------------------------------------------
c     ARGUMENT DECLARATIONS
      dimension ndid(3,nnods), coord(3,nnods)
c ----------------------------------------------------------------------

      Write(*,*)"Inside inmass1 :: Number of nodes :: ",nnods
      
      return 
      end subroutine inmass1
      
      

l is defined as a large common, it is clearly integer.  If I take the inmass subroutine and reduce it to the basics, I have the routine above inmass1. 

It worked and now it does not.  I get

Severity Code Description Project File Line Suppression State
Error error #6633: The type of the actual argument differs from the type of the dummy argument. [L] B:\Users\macne\Documents\Visual Studio 2017\Projects\Program124 - Drain\Drain3DX\Drain3DX\SOURCE\INPUT\INGEOM.FOR 208

error which is the inmass1 and the compiler does not like the third argument.  In inmass1 the third argument is clearly a real argument, but it worked and I could output the coords, and then I added another argument and it stopped working, took out the added argument and it still did not work.  

I understand what it is doing, when it was working coords was real*8, why would it just stop.  

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,317 Views

In INMASS1 ndid is implicitly declared as an integer array with dimensions (3,nnods)

*** a scalar is being passed ***

PROGRAM is making a call to INMASS1 with the 2nd argument of l(kdnid), which is a scalar element of l and where l is implicitly declared as an integer array l(NTSTP).

*** a scalar is being passed ***

 

The interfaces do not match. The error message is a result of interface checking. You could turn interface checking off, or use one of the methods to change the shape of the argument without copying the data.

 

 

program Console13
    implicit none

    integer, PARAMETER :: NTSTP=1000000
    integer :: l(NTSTP)
    integer :: nnods, kndid, kcoord
    
    nnods = 123
    kndid = 456
    kcoord = 789
    
    call INMASS1(nnods, RESHAPE(l(kndid:kndid+nnods*3-1),(/3,nnods/)), RESHAPE(l(kcoord:kcoord+nnods*3-1),(/3,nnods/)))
    
end program Console13

SUBROUTINE INMASS1 (nnods,ndid,coord)
      integer :: ndid(3,nnods), coord(3,nnods)
      Write(*,*)"Inside inmass1 :: Number of nodes :: ",nnods
      
      return 
end subroutine inmass1

 

Jim Dempsey

0 Kudos
Reply