[cig-commits] [commit] master: add argument to input file (d122cd4)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Oct 9 19:26:02 PDT 2013


Repository : ssh://geoshell/relax

On branch  : master
Link       : https://github.com/geodynamics/relax/compare/4ceac8680a3867cc2985789e729ef16b6ea7d032...d122cd458c418cf02ecb7db67a052dcd22798923

>---------------------------------------------------------------

commit d122cd458c418cf02ecb7db67a052dcd22798923
Author: Sylvain Barbot <sbarbot at ntu.edu.sg>
Date:   Thu Oct 10 09:30:45 2013 +0800

    add argument to input file


>---------------------------------------------------------------

d122cd458c418cf02ecb7db67a052dcd22798923
 src/input.f90 | 23 +++++++++++++----------
 src/relax.f90 |  0
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/input.f90 b/src/input.f90
index 969fc29..0726da5 100644
--- a/src/input.f90
+++ b/src/input.f90
@@ -38,13 +38,12 @@ CONTAINS
   !! OUTPUT:
   !! @param in
   !---------------------------------------------------------------------
-  SUBROUTINE init(in,unit)
+  SUBROUTINE init(in)
     USE types
     USE export
     USE getopt_m
 
     TYPE(SIMULATION_STRUC), INTENT(OUT) :: in
-    INTEGER, OPTIONAL, INTENT(INOUT) :: unit
 
     CHARACTER :: ch
     CHARACTER(256) :: dataline
@@ -53,7 +52,7 @@ CONTAINS
     CHARACTER(3) :: digit
     CHARACTER(4) :: digit4
 #endif
-    INTEGER :: iunit
+    INTEGER :: iunit,noptions
 !$  INTEGER :: omp_get_num_procs,omp_get_max_threads
     REAL*8 :: dummy,dum1,dum2
     REAL*8 :: minlength,minwidth
@@ -61,13 +60,6 @@ CONTAINS
 
     INTEGER :: k,iostatus,i,e
 
-    ! default is standard input
-    IF (.NOT. PRESENT(unit)) THEN
-       iunit=5
-    ELSE
-       iunit=unit
-    END IF
-
     ! parse the command line for options
     opts( 1)=OPTION_S("no-proj-output",.FALSE.,CHAR(20))
     opts( 2)=OPTION_S("no-relax-output",.FALSE.,CHAR(21))
@@ -83,6 +75,7 @@ CONTAINS
     opts(12)=OPTION_S("dry-run",.FALSE.,CHAR(31))
     opts(13)=OPTION_S("help",.FALSE.,'h')
 
+    noptions=0;
     DO
        ch=getopt("h",opts)
        SELECT CASE(ch)
@@ -136,6 +129,7 @@ CONTAINS
           WRITE_DEBUG_INFO
           STOP 3
        END SELECT
+       noptions=noptions+1
     END DO
 
     IF (in%isversion) THEN
@@ -235,6 +229,15 @@ CONTAINS
 #endif
     PRINT 2000
 
+    IF (noptions .LT. COMMAND_ARGUMENT_COUNT()) THEN
+       iunit=25
+       CALL GET_COMMAND_ARGUMENT(noptions+1,filename)
+       OPEN (UNIT=iunit,FILE=filename,IOSTAT=iostatus)
+    ELSE
+       ! default is standard input
+       iunit=5
+    END IF
+
     PRINT '(a)', "grid dimension (sx1,sx2,sx3)"
     CALL getdata(iunit,dataline)
     READ (dataline,*) in%sx1,in%sx2,in%sx3



More information about the CIG-COMMITS mailing list