Thursday, September 20, 2012

Compiling map65 for LInux, Ubuntu 12.04

Joe says...

First, compile the library libm65.a

$ cd libm65
$ make 


Which results in an error on my Ubuntu 12.04 machine...

m65a.F90:45.9:

  p_m65=>address_m65()
         1
Error: The pointer object 'address_m65' at (1) must have an explicit function interface or be declared as array


Ok...I've been stumped at this point before.  At the top of the m65a.F90 file, there's hint.

! NB: this interface block is required by g95, but must be omitted
!     for gfortran.  (????)

#ifndef UNIX
  interface
     function address_m65()
     end function address_m65
  end interface
#endif


Switching the state of the #ifndef produces a different result...
 
gfortran -c -fno-second-underscore -DUNIX m65a.F90
m65a.F90:45.9:

  p_m65=>address_m65()
         1
Error: Target expression in pointer assignment at (1) must deliver a pointer result


This site had a useful definition of pointers and functions returning pointers
     http://w3.pppl.gov/~hammett/comp/f90tut/f90.tut6.html

Well, after some fooling around, it complies.  First, define the return parameters for address_m65 with the interface block function definition.  Then remove the other reference defining address_m65  as a pointer.  Lastly, define the p_m65 points as an array.

===================================================================
--- m65a.F90    (revision 2591)
+++ m65a.F90    (working copy)
@@ -3,16 +3,17 @@
 ! NB: this interface block is required by g95, but must be omitted
 !     for gfortran.  (????)

-#ifndef UNIX
+#ifdef UNIX
   interface
      function address_m65()
+     integer*1, pointer :: address_m65(:)
      end function address_m65
   end interface
 #endif
  
   integer*1 attach_m65,lock_m65,unlock_m65
   integer size_m65
-  integer*1, pointer :: address_m65,p_m65
+  integer*1, pointer :: p_m65(:)
   character*80 cwd
   logical fileExists

   common/tracer/limtrace,lu


Wednesday, September 19, 2012

Fix for map65iq for latest gfortran

Posted to the WSJT and linrad mail lists...
 
According to
     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52860,
gfortran revisions later than v4.4 handles writes to files at EndOfFile more strictly.

ftn_init.f90 reads to the end of ALL65.TXT file and leaves the file position just _after_ the EOF mark.  On my Ubuntu 12.04 system, Map65iq quits with the error...

    At line 56 of file decode1.f90 (unit = 21, file = 
'/home/jeff/ham/wsjt/branches/map65iq/ALL65.TXT')
    Fortran runtime error: Sequential READ or WRITE not allowed after EOF marker, possibly use REWIND or BACKSPACE

I fixed this by adding a backspace command to just before the decode1.f90 subroutine writes out the ALL65.TXT date line.  This positions the file pointer to just before the EOF mark.  See the patch below...

jeff, wa1hco

===================================================================
--- decode1.f90    (revision 2591)
+++ decode1.f90    (working copy)
@@ -50,6 +50,10 @@
       rewind 21
       ns0=999999
    endif
+
+! wa1hco: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52860
+  backspace(21)
+
    if(n.lt.ns0 .and. utcdate(1:1).eq.'2') then

       call cs_lock('decode1a')