10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2025-01-05 02:48:38 +01:00

Fix writer

This commit is contained in:
Thomas Applencourt 2017-03-17 13:01:12 -05:00
parent 5379700a3d
commit ea5fa02b26
4 changed files with 25 additions and 24 deletions

View File

@ -1,5 +1,5 @@
IRPF90= irpf90 IRPF90= ../bin/irpf90
IRPF90FLAGS= -I ./ -I input/ IRPF90FLAGS=
BUILD_SYSTEM= make BUILD_SYSTEM= make
.EXPORT_ALL_VARIABLES: .EXPORT_ALL_VARIABLES:
@ -50,7 +50,7 @@ define run_and_touch
$(BUILD_SYSTEM) -C $(dir $(1) ) -f $(notdir $(1) ) $(addprefix $(CURDIR)/, $(2)) && touch $(2) $(BUILD_SYSTEM) -C $(dir $(1) ) -f $(notdir $(1) ) $(addprefix $(CURDIR)/, $(2)) && touch $(2)
endef endef
EXE := $(shell egrep -r '^\s*program' *.irp.f | awk '{print $$2}') EXE := $(shell egrep -ri '^\s*program' *.irp.f | cut -d'.' -f1)
.PHONY: all .PHONY: all

View File

@ -178,17 +178,19 @@ class Entity(object):
'group_entity': [{ 'group_entity': [{
'name': n, 'name': n,
'dim': build_dim( 'dim': build_dim(
self.cm_d_variable[n].dim, colons=True) self.d_entity[n].dim, colons=True)
} for n in self.l_name] } for n in self.l_name]
} }
return ashes_env('io.f90', d_template).split('\n') return ashes_env.render('ioer.f90', d_template).split('!TOKEN_SPLIT')
@irpy.lazy_property
def reader(self): def reader(self):
return io.er.split('TOKEN_SPLIT')[0] return self.io_er[1].split('\n')
@irpy.lazy_property
def writer(self): def writer(self):
return io.er.split('TOKEN_SPLIT')[1] return self.io_er[0].split('\n')
@irpy.lazy_property_mutable @irpy.lazy_property_mutable
def is_read(self): def is_read(self):

View File

@ -114,7 +114,6 @@ class Fmodule(object):
result += var.reader result += var.reader
if var.is_written: if var.is_written:
result += var.writer result += var.writer
return result return result
@irpy.lazy_property @irpy.lazy_property

View File

@ -1,4 +1,4 @@
SUBROUTINE write_{name}(irp_num) SUBROUTINE writer_{name}(irp_num)
USE {fmodule} USE {fmodule}
IMPLICIT NONE IMPLICIT NONE
@ -17,28 +17,28 @@ SUBROUTINE write_{name}(irp_num)
CALL provide_{same_as} CALL provide_{same_as}
ENDIF ENDIF
{children} {#children}
CALL write_{.}(irp_num) CALL writer_{.}(irp_num)
{/children} {/children}
DO WHILE (irp_is_open) DO WHILE (irp_is_open)
irp_iunit = irp_inuit + 1 irp_iunit = irp_iunit + 1
INQUIRE(UNIT=irp_inuit, OPENED=irp_is_open) INQUIRE(UNIT=irp_iunit, OPENED=irp_is_open)
END DO END DO
{#group_entity} {#group_entity}
OPEN(UNIT=irp_inuit,file='irpf90_{name}_'//trim(irp_num),FROM='FORMATTED',STATUS='UNKNOWN',ACTION='WRITE') OPEN(UNIT=irp_iunit,file='irpf90_{name}_'//trim(irp_num),FORM='FORMATTED',STATUS='UNKNOWN',ACTION='WRITE')
WRITE(irp_inuit,*) {.}{dim} WRITE(irp_iunit,*) {name}{dim}
CLOSE(irp_inuit) CLOSE(irp_iunit)
{/group_entity} {/group_entity}
{?do_debug} CALL irp_leave(irp_here) {/do_debug} {?do_debug} CALL irp_leave(irp_here) {/do_debug}
END SUBROUTINE write_{name} END SUBROUTINE writer_{name}
!TOKEN_SPLIT !TOKEN_SPLIT
SUBROUTINE read_{name}(irp_num) SUBROUTINE reader_{name}(irp_num)
USE {fmodule} USE {fmodule}
IMPLICIT NONE IMPLICIT NONE
@ -54,18 +54,18 @@ SUBROUTINE read_{name}(irp_num)
{?do_debug} CALL irp_enter(irp_here) {/do_debug} {?do_debug} CALL irp_enter(irp_here) {/do_debug}
DO WHILE (irp_is_open) DO WHILE (irp_is_open)
irp_iunit = irp_inuit + 1 irp_iunit = irp_iunit + 1
INQUIRE(UNIT=irp_inuit, OPENED=irp_is_open) INQUIRE(UNIT=irp_iunit, OPENED=irp_is_open)
END DO END DO
{#group_entity} {#group_entity}
OPEN(UNIT=irp_inuit,file='irpf90_{name}_'//trim(irp_num),FROM='FORMATTED',STATUS='UNKNOWN',ACTION='WRITE') OPEN(UNIT=irp_iunit,file='irpf90_{name}_'//trim(irp_num),FORM='FORMATTED',STATUS='UNKNOWN',ACTION='WRITE')
READ(irp_inuit,*) {name}{dim} READ(irp_iunit,*) {name}{dim}
CLOSE(irp_inuit) CLOSE(irp_iunit)
{/group_entity} {/group_entity}
CALL touch_{name} CALL touch_{name}
{?do_debug} CALL irp_leave(irp_here) {/do_debug} {?do_debug} CALL irp_leave(irp_here) {/do_debug}
END SUBROUTINE read_{name} END SUBROUTINE reader_{name}