Silverfrost Forums

Welcome to our forums

Converting a F95 program to Clearwin+

27 Jul 2013 12:38 #12695

Hello,

I have a program that compiles and runs as needed via a terminal window (or double-click) but was wondering how tricky it is to convert it to a menu-driven style?

Basically it reads a parameters file which has these elements: OPEN(10, file='parameters.dat', status='OLD')

!//////////////////INPUT///////////////////////////// ! Program inputs in parameters.dat: ! Perform a detailed topography calculation on the land areas ! present in the file topo_cart_det.xyz: ! det=1-->yes ! det=0-->no ! del_xd-->grid step Distant zone (km) ! del_xi-->grid step Intermediate zone (km) ! del_xBg-->grid step Bouguer output grid (km) ! rho_c-->crust reduction density (kg/m³) ! rho_w-->water reduction density (kg/m³) ! N-->number of nodes of elevation an FA input grids in x ! M-->number of nodes of elevation an FA input grids in y ! R_i-->Limit of the intermediate zone (km) ! R_d-->Limit of the distant zone (km) ! land='on'-->calculates Bouguer anomaly at land and sea points ! land='off'->calculates Bouguer anomaly only at sea points ! slab_Boug=1-->INPUT GRAVITY ANOMALY IS SLAB-CORRECTED BOUGUER ! slab_Boug=0-->INPUT GRAVITY ANOMALY IS FREE AIR !If det=1, then, the input file must contain the following additional !information: ! N_det-->number of nodes of topo_cart_det.xyz input grid in x ! M_det-->number of nodes of topo_cart_det.xyz input grid in y ! del_xdet-->grid step of the Detailed Intermediate zone (km)

opens up two existing files for data input (gravity and topography) open(4,file='topo_cart.xyz', status='OLD') open(5,file='gravi_cart.xyz',status='OLD')

Processes the data to write two output files (Bouguer anomaly and slab_correction) open(15,file='bouguer.xyz',status='UNKNOWN') open(17,file='bouguer_slab.xyz',status='UNKNOWN') .......... OPEN(10, file='lat_ex.dat', status='UNKNOWN') WRITE(10,) L_x,L_y,rtiodel_xi CLOSE(10) write(,)'' write(,)'BOUGUER ANOMALY CALCULATED' write(,)'' DEALLOCATE (E,FA,FA_strg) IF (det==1) DEALLOCATE (E_det) CLOSE(15) CLOSE(17)

I am trying to simplify the usage of the program since at present if one needs to change a variable in the parameters file, that is done externally.

At the moment, input file names have to be standard and changed after computation.

I have not used Clearwin+ yet so kind of shooting in the dark a bit here!

Cheers Lester

29 Jul 2013 2:47 #12707

Incomplete, and far from elegant:

      WINAPP
      OPTIONS(INTL)
      PROGRAM PARAMS

      INCLUDE <WINDOWS.INS>
      INTEGER DET, LAND, slab_Boug, N_det, M_det
      real*8 del_xd,       del_xi
      DET = 0
      LAND = 0
      slab_Boug = 0
      del_xd = 1.0
      del_xi = 1.0
      N_det = 0
      M_det = 0

      IA=WINIO@('%ca[Parameters]&')
      IA=WINIO@('%`rb[detailed topo calc]&', DET)
      IA=WINIO@('%2nl%`rb[use land as well as sea points]&', LAND)
      IA=WINIO@('%2nl%`rb[Slab corrected?]&', slab_Boug)
      IA=WINIO@('%2nl%rf[initially_blank] grid step Distant zone (km)&',
     &  del_xd)
      IA=WINIO@('%2nl%rf[initially_blank] grid step Intermediate'//
     & ' zone (km)&',
     &  del_xi)
      IA=WINIO@('%2nl%rd[initially_blank] number of nodes in x&',
     &  N_det)
      IA=WINIO@('%2nl%rd[initially_blank] number of nodes in y&',
     &  M_det)
      IA=WINIO@('%ff%nl%6bt[Run] %6bt[Cancel]')
      IF (IA .EQ. 0 .OR. IA .EQ. 2) STOP
! now check that no value is impermissible and proceed 
      END

      RESOURCES
      1  24 default.manifest

learning Clearwin will enable you to introduce elegance, and to catch errors. For example, you could allow te user to press Run anytime, and catch errors after, or you could keep the Run button greyed-out until the set of parameters is cmplete and valid.

Please login to reply.