Q Porting HP Console-Based FORTRAN Program to Win32 Console 
Author Message
 Q Porting HP Console-Based FORTRAN Program to Win32 Console

Hello All,

   I recieved a large program which was built to run on HP
Workstations and I'm interested in porting it to a Win32 console-based
program.  The program is used to take a data file calleda GRIB
(GRIdded Binary) file which is the output from the National Weather
Service forcast models which are "mapped" to the earth with a certian
"projection" (Lat/Lon, Mercator, Polar Stereographic, etc.) and
Interpolate it to another projection through Command line options.

I need help trasforming the code so it will work in a Win32 Console
environment.  I'm using Digital Visual fortran 5.*.  Here is the MAIN
Program:

      PROGRAM COPYGB
C$$$  MAIN PROGRAM DOCUMENTATION BLOCK
C
C MAIN PROGRAM: COPYGB       COMPARE GRIB FILES
C   PRGMMR: IREDELL          ORG: NP23        DATE: 97-03-05  
C
C ABSTRACT: The command copygb copies all or part of one GRIB file
C   to another GRIB file, interpolating if necessary.  Unless
C   otherwise directed (-x option), the GRIB index file is also used
C   to speed the reading. The fields are interpolated to an output
grid
C   if specified (-g option). The interpolation type defaults to
C   bilinear but may be specified directly (-i option).  The copying
C   may be limited to specific fields (-k option). It may also be
C   limited to a specified subgrid of the output grid or to a subrange
C   of the input fields (-B and -b, -A, and -K options). Fields can be
C   identified as scalars or vectors (-v option), which are
interpolated
C   differently.
C
C PROGRAM HISTORY LOG:
C   96-07-19  IREDELL
C   97-03-05  IREDELL  CORRECTED THE COPYING OF THE V-WIND FIELD
C                      WHEN NO INTERPOLATION IS DONE
C
C COMMAND LINE OPTIONS:
C   -A "<> mapthreshold"
C      Inequality and threshold used in determining
C      where on the map statistics will be computed.
C      Statistics are computed only where the given
C      map field is on the correct side of the threshold.
C      The mapthresh defaults to '>-1.e30'; in this case,
C      only the map field's bitmap will limit the domain.
C
C   -b mapindex  
C      Optional index file used to get the map field.
C
C   -B mapgrib    
C      GRIB file used to get the map field.  The map field
C      is read from the GRIB file and compared to the
C      map threshold to determine for which region on the map
C      the statistics will be computed.  mapgrib can be the
C      name of an actual GRIB file (in which case the index
C      file may be specified with the -b option) or it can
C      be '-1'.  If mapgrib is '-1', then GRIB file 1
C      (first positional argument) is used.
C      The -K option specifies which field to read from
C      the mapgrib GRIB file.  If mapgrib is an actual file,
C      then the first field is taken if -K is not specified.
C      On the other hand, if mapgrib is '-1', then if the
C      if -K is not specified, the current field is taken
C      as the map field.  A special exception is if -K '-1'
C      is specified, in which case the current field is
C      taken as the map field and it is applied before any
C      interpolation; otherwise the map field is always
C      applied after interpolation.
C
C   -g "grid [kgds]"
C      Verification grid identification.  If grid=-1
C      (the default), then the grid is taken from the first
C      GRIB field in GRIB file 1.  If grid=-4,
C      then the grid is taken from the first GRIB field
C      in the mapgrib file.
C      If 0<grid<255, then grid designates an NCEP grid.
C      If grid=255, then the grid must be specified by the
C      full set of kgds parameters determining a GRIB GDS
C      (grid description section) in the W3FI63 format.
C
C   -i "ip [ipopts]"
C      Interpolation options.  The default is bilinear
C      interpolation (ip=0).  Other interpolation options
C      are bicubic (ip=1), neighbor (ip=2), budget (ip=3),
C      and spectral (ip=4).  See the documentation for iplib
C      for further details about interpolation.
C
C   -k "kpds"
C      Full set of kpds parameters determing a GRIB PDS
C      (product definition section) in the W3FI63 format
C      determining the field(s) from GRIB file 1
C      for which statistics are computed.  Note that
C      kpds(5) is the parameter indicator (PDS octet 9).
C      A wildcard is specified by -1 (the defaults).
C      If the -k is not specified, then copygb will attempt
C      to copy every field in GRIB file 1.
C
C   -K "mapkpds"
C      Full set of kpds parameters determing a GRIB PDS
C      (product definition section) in the W3FI63 format
C      determining the map field to be used to determine
C      where on the map statistics will be computed.  
C      A wildcard is specified by -1 (the defaults).
C
C   -M "mask"
C      Mask used to fill out bitmapped areas of the map.
C      If specified, there will be no bitmap in the output.
C      The mask must be in the format '#value' where value
C      is the real number used to fill out the field.
C
C   -v "uparms"
C      Parameter indicator(s) for the u-component of vectors.
C      The parameter indicator for the v-component is assumed
C      to be one more than that of the u-component.
C      If the -v option is not specified, then the wind
C      components (parameters 33 and 34) are the only fields
C      assumed to be vector components in the GRIB file.
C
C   -x
C      Turns off the use of an index file.  The index records
C      are then extracted from the GRIB file, which
C      will increase the time taken by copygb.
C
C   -X
C      Turns on verbose printout.  This option is incompatible
C      with GRIB output to standard output (designated as '-').
C
C INPUT FILES:
C   UNIT   11    GRIB FILE 1
C   UNIT   14    MAP GRIB FILE
C   UNIT   31    GRIB INDEX FILE 1
C   UNIT   34    MAP GRIB INDEX FILE
C
C OUTPUT FILES:
C   UNIT   51    GRIB FILE 2
C
C SUBPROGRAMS CALLED:
C   FILENV
C   IARGC
C   GETARG
C   ERRMSG
C   EUSAGE
C   EXIT
C   FPARSEI
C   FPARSER
C   BAOPENR
C   BAOPEN
C   CPGB
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN
C
C$$$
      CHARACTER*256 CARG,CG1,CX1,CGB,CXB,CG2
      INTEGER KARG(100)
      INTEGER KGDSI(200),IPOPT(20),JPDS1(200),JPDSB(200),IUV(100)
      REAL RARG(100)
      INTEGER GETARG
      CHARACTER*400 GDS
      DATA IGI/-1/,KGDSI/19*0,255,180*0/
      DATA IP/0/,IPOPT/20*-1/
      DATA JPDS1/200*-1/,JPDSB/200*-1/,IUV/33,99*0/,NUV/1/
      DATA LXX/0/,LX/1/,KZ1/-1/,KZ2/-2/
      DATA JB/0/,JBK/0/,LAB/1/,AB/-1.E30/,LAM/0/,AM/0./
      DATA CGB/' '/,CXB/' '/
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
C  PARSE COMMAND LINE OPTIONS
C      CALL FILENV
      NARG=IARGC()
      IARG=1
      LSTOPT=0
      DOWHILE(IARG.LE.NARG.AND.LSTOPT.EQ.0)
        LARG=GETARG(IARG,CARG)
        IARG=IARG+1
        IF(CARG(1:1).NE.'-') THEN
          LSTOPT=1
          IARG=IARG-1
        ELSEIF(LARG.EQ.1) THEN
          CALL ERRMSG('copygb: invalid option -')
          CALL EUSAGE
          CALL EXIT(1)
        ELSE
          L=2
          DOWHILE(L.LE.LARG)
            IF(CARG(L:L).EQ.'-') THEN
              LSTOPT=1
            ELSEIF(CARG(L:L).EQ.'A') THEN
              IF(L.EQ.LARG) THEN
                L=0
                LARG=GETARG(IARG,CARG)
                 IARG=IARG+1
              ENDIF
              IF(CARG(L+1:L+1).EQ.'>') THEN
                LAB=1
                L=L+1
              ELSEIF(CARG(L+1:L+1).EQ.'<') THEN
                LAB=-1
                L=L+1
              ELSE
                CALL ERRMSG('copygb: invalid threshold '//
     &                      CARG(L+1:LARG))
                CALL EUSAGE
                CALL EXIT(1)
              ENDIF
              CALL FPARSER(CARG(L+1:LARG),1,AB)
              L=LARG
            ELSEIF(CARG(L:L).EQ.'B') THEN
              IF(L.EQ.LARG) THEN
                L=0
                LARG=GETARG(IARG,CARG)
                IARG=IARG+1
              ENDIF
              LCGB=LARG-L
              CGB=CARG(L+1:LARG)
              L=LARG
            ELSEIF(CARG(L:L).EQ.'b') THEN
              IF(L.EQ.LARG) THEN
                L=0
                LARG=GETARG(IARG,CARG)
                IARG=IARG+1
              ENDIF
              LCXB=LARG-L
              CXB=CARG(L+1:LARG)
              L=LARG
            ELSEIF(CARG(L:L).EQ.'g') THEN
              IF(L.EQ.LARG) THEN
                L=0
                LARG=GETARG(IARG,CARG)
                IARG=IARG+1
              ENDIF
              KARG(1)=IGI
              KARG(2:100)=KGDSI(1:99)
              CALL FPARSEI(CARG(L+1:LARG),100,KARG)
              IGI=KARG(1)
              IF(IGI.GT.0.AND.IGI.LT.255) THEN
                CALL MAKGDS(IGI,KGDSI,GDS,LGDS,IRET)
                IF(IRET.NE.0) IGI=-1
              ELSEIF(IGI.EQ.255) THEN
                KGDSI(1:99)=KARG(2:100)
              ENDIF
              IF(IGI.LT.-4.OR.IGI.EQ.0.OR.IGI.GT.255) THEN
                CALL ERRMSG('copygb: invalid output grid '//
     &                      CARG(L+1:LARG))
                CALL EUSAGE
                CALL EXIT(1)
              ENDIF
              MI=LENGDS(KGDSI)
              IF(MI.LE.0) THEN
                CALL ERRMSG('copygb: unsupported output grid '//
     &                      CARG(L+1:LARG))
                CALL EUSAGE
                CALL EXIT(1)
              ENDIF
              L=LARG
            ELSEIF(CARG(L:L).EQ.'i') THEN
              IF(L.EQ.LARG) THEN
                L=0
                LARG=GETARG(IARG,CARG)
                IARG=IARG+1
              ENDIF
              KARG(1)=IP
              KARG(2:21)=IPOPT
              CALL FPARSEI(CARG(L+1:LARG),21,KARG)
              IP=KARG(1)
              IPOPT=KARG(2:21)
              L=LARG
            ELSEIF(CARG(L:L).EQ.'K') THEN
              IF(L.EQ.LARG) THEN
                L=0
                LARG=GETARG(IARG,CARG)
                IARG=IARG+1
              ENDIF
              JBK=1
              CALL FPARSEI(CARG(L+1:LARG),100,JPDSB)
              IF(JPDSB(5).EQ.0) THEN
                CALL ERRMSG('copygb: invalid PDS parms '//
     &          
...

read more »



Wed, 18 Jun 1902 08:00:00 GMT  
 Q Porting HP Console-Based FORTRAN Program to Win32 Console


Quote:
>Hello All,

>   I recieved a large program which was built to run on HP
>Workstations and I'm interested in porting it to a Win32 console-based
>program.  The program is used to take a data file calleda GRIB
>(GRIdded Binary) file which is the output from the National Weather
>Service forcast models which are "mapped" to the earth with a certian
>"projection" (Lat/Lon, Mercator, Polar Stereographic, etc.) and
>Interpolate it to another projection through Command line options.

>I need help trasforming the code so it will work in a Win32 Console
>environment.  I'm using Digital Visual Fortran 5.*.  Here is the MAIN
>Program:

    <big snip>

Quote:

>I believe I need to add at the top:

>USE DFLIB
>USE DFPORT

>DVF is complaining about GETARG having "unresolved external symbol"

>Do all the: LARG=GETARG(*,*)  need to be changed to:
>CALL GETARG(*,*)?

>Any & all help would be GREATLY appreciated.  I know enough about
>FORTRAN to be dangerous and VERY little about Win32 programming.

>Jeff Krob

>PS - sorry for the long post but I thought including the source code
>would help.

Sorry I forgot to add these things.

I have to force DVF to make the executable...too many errors ;-)
However, when I run it, in the Win32 Console I get this:

"forrtl: severe (157): Program Exception - access violation"

When I try to execute copygb.exe, I get in the Digital Visual Fortran
Debug window:

Loaded 'C:\WINNT\System32\ntdll.dll', no matching symbolic information
found.
Loaded 'C:\WINNT\system32\kernel32.dll', no matching symbolic
information found.
First-chance exception in copygb.exe: 0xC0000005: Access Violation.
The thread 0xCC has exited with code -1073741667 (0xC000009D).
The program 'C:\Grib\utils\Debug\copygb.exe' has exited with code
-1073741667 (0xC000009D).

When I execute the program Copy GRIB.exe (the full program), I get
this:

Loaded 'C:\Grib\utils\Copy GRIB\Release\Copy GRIB.exe', no matching
symbolic information found.
Loaded 'C:\WINNT\System32\ntdll.dll', no matching symbolic information
found.
Loaded 'C:\WINNT\system32\kernel32.dll', no matching symbolic
information found.
The thread 0xC8 has exited with code 3 (0x3).
The program 'C:\Grib\utils\Copy GRIB\Release\Copy GRIB.exe' has exited
with code 3 (0x3).

What does all this info mean...besides the fact that it didn't run?

Thanks in advance (again)

Jeff Krob



Wed, 18 Jun 1902 08:00:00 GMT  
 Q Porting HP Console-Based FORTRAN Program to Win32 Console

Quote:
>   I recieved a large program which was built to run on HP
>Workstations and I'm interested in porting it to a Win32 console-based
>program.  The program is used to take a data file calleda GRIB
>(GRIdded Binary) file which is the output from the National Weather
>Service forcast models which are "mapped" to the earth with a certian
>"projection" (Lat/Lon, Mercator, Polar Stereographic, etc.) and
>Interpolate it to another projection through Command line options.

>I need help trasforming the code so it will work in a Win32 Console
>environment.  I'm using Digital Visual Fortran 5.*.

[very large snip]

You have a couple of issues you need to resolve...  You say you forced
linking - that's because there are a number of unresolved routine
references.  Forcing linking when this happens simply delays the problem -
you get an access violation when you run the program.

First: GETARG.  The reference to GETARG can be resolved by adding USE DFLIB
at the top of the program, but that's not sufficient, as your use of GETARG
is different than what DVF expects (as you seem to realize).  Apparently, on
the HP system, GETARG is a function returning a value, whereas in DVF, it's
a subroutine you CALL.  So some minor code changes may be needed here.  See
the online documentation for details on GETARG.

Next... there are unresolved references to routines ERRMSG, EUSAGE, FPARSER,
FPARSEI, MAKGDS, LENGDS, BAOPENR, BAOPEN and CPGB.  Perhaps these are in a
library of other code you supply?

You'll need to fix the reference to GETARG and supply the other missing
routines.  Once you do so, assuming that all else is ok, it should link
without having to "force" an executable.  If you still get unresolved symbol
references, check to make sure that the number and types of routine
arguments all match.

If you need further assistance, please let us know at

BUGREPRT.TXT, a problem reporting template you'll find in the DF directory.
Also, check our web site to be sure you have the 5.0D update.

Lastly, I'll comment that some of the newsgroups you cross-posted to don't
seem to be relevant (...nt.kernel-mode???)  I've set the follow-up to just
comp.lang.fortran.



DIGITAL Fortran Development     http://www.digital.com/info/slionel.html
Compaq Computer Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698           "Free advice is worth every cent"

DIGITAL Fortran web site: http://www.digital.com/fortran



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Porting FORTRAN DOS Console Application to Win32

2. Q: Porting a UNIX Command-Line Parser to Win32 Console

3. Spawning console programs with I/O redirection and (preferably no) visible console

4. Seeking Examples of Win32 Console Programming, Any Compiler

5. Win32 Console app -> Win32 app: help wanted

6. Hiding the DOS console on a console application on Windows

7. console mp3->wav decoder for $indows or GUI one which supports console

8. Porting a tk-based program with cygnus to win32

9. WIN32 Console

10. Win32 Console in ISE.

11. Minforth in Win32 console

12. Q: Clear screen in Win32 console?

 

 
Powered by phpBB® Forum Software